Revert "优化接口、订单最大功率统计"

This reverts commit 34b663e774ff9a16addc871ed8cfe355acf377fd.
This commit is contained in:
yjh_yyds 2024-08-14 09:24:13 +08:00
parent 2ea195bf66
commit c5f219ee11
89 changed files with 597 additions and 3686 deletions

View File

@ -34,5 +34,3 @@ public interface AuthSecretTokenRepository extends JpaRepository<AuthSecretToken
}

View File

@ -118,7 +118,7 @@ public class CoreDispatcher {
commonRequest.setData(originalData);
tData = JSONUtil.toJSONString(commonRequest);
System.out.println("=========加密前data=============="+tData);
// log.debug("to [{}] {} out plain data:\n{}", authSecretTokenOut.getOperatorId3irdpty(), url, tData);
log.debug("to [{}] {} out plain data:\n{}", authSecretTokenOut.getOperatorId3irdpty(), url, tData);
if (authSecretTokenOut.isEncrypt()) {
tData = encryptReqOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(),
authSecretTokenOut.getSigSecret(), commonRequest);
@ -126,7 +126,7 @@ public class CoreDispatcher {
System.out.println("=========加密data=============="+tData);
}
body = okhttp3.RequestBody.create(JSON, tData);
// logger.info("==============流量方平台推送值================="+tData);
// logger.info("==============平台推送值================="+tData);
}
} catch (JsonProcessingException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {

View File

@ -31,7 +31,7 @@ public class NotificationCancelOrderTask extends CoreDispatcher {
//private Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
//推送不开放(evcs 放开)
//@Scheduled(fixedRate = 1000 * 15)
@Scheduled(fixedRate = 1000 * 15)
public void run() throws JsonProcessingException {
//Getting the orders, which need to be notified.

View File

@ -39,7 +39,7 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher {
private final Logger logger = LoggerFactory.getLogger(NotificationChargeOrderInfoTask.class);
//推送不开放(evcs 放开)
//@Scheduled(fixedRate = 1000 * 15)
@Scheduled(fixedRate = 1000 * 15)
public void run() throws JsonProcessingException {
Collection<String> orderKeys = REDIS.keys("order:*");
@ -103,8 +103,6 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher {
CommonRequest<ChargeOrderInfo> commonRequest = new CommonRequest<>();
commonRequest.setData(data);
String responseBody = ok(commonRequest, "/notification_charge_order_info", authSecretTokenOut);
return DTOJsonHelper.parseResponseData(responseBody,
ChargeOrderInfoResponse.class, authSecretTokenOut);
}

View File

@ -34,7 +34,7 @@ public class NotificationStartChargeResultTask extends CoreDispatcher {
* Judging the 3rd whether it has got the start charging task.
*/
//推送不开放(evcs 放开)
//@Scheduled(fixedRate = 1000 * 30)
@Scheduled(fixedRate = 1000 * 30)
public void run() throws IOException {
//Getting the charge orders which from 3rd.

View File

@ -96,11 +96,6 @@ public class XhpcClearingHistoryOrderDomain implements Serializable {
*/
private BigDecimal actServicePrice;
/**
* 实收-运营商总费用
*/
private BigDecimal actTotalPrice;
/**
* 流量方总金额抽成
*/

View File

@ -141,12 +141,10 @@ public class XhpcClearingHistoryOrderServiceImpl extends BaseService implements
writer.addHeaderAlias("operationSvcCommission", "运维服务费抽成(元)");
writer.addHeaderAlias("actPowerPrice", "运营商实收电费(元)");
writer.addHeaderAlias("actServicePrice", "运营商实收服务费(元)");
writer.addHeaderAlias("actTotalPrice", "运营商实收总费用(元)");
writer.addHeaderAlias("startSoc", "启动SOC");
writer.addHeaderAlias("endSoc", "结算SOC");
writer.addHeaderAlias("startTime", "开始充电时间");
writer.addHeaderAlias("endTime", "结束充电时间");
writer.addHeaderAlias("totalPower", "电量");
// 默认的未添加alias的属性也会写出如果想只写出加了别名的字段可以调用此方法排除之
writer.setOnlyAlias(true);
// 一次性写出内容使用默认样式强制输出标题

View File

@ -19,10 +19,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: mse-e2a05960-nacos-ans.mse.aliyuncs.com:8848
server-addr: 127.0.0.1:8858
config:
# 配置中心地址
server-addr: mse-e2a05960-nacos-ans.mse.aliyuncs.com:8848
server-addr: 127.0.0.1:8858
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -76,7 +76,6 @@
ifnull(ho.act_price, 0) as 'act_price',
ifnull(ho.act_power_price, 0) as 'act_power_price',
ifnull(ho.act_service_price, 0) as 'act_service_price',
ifnull(ho.act_service_price+ho.act_power_price, 0) as 'actTotalPrice',
ifnull(ho.internet_commission, 0) as 'internet_commission',
ifnull( ho.internet_svc_commission, 0) as 'internet_svc_commission',
ifnull(ho.platform_commission, 0) as 'platform_commission',
@ -87,7 +86,7 @@
ho.create_time, ho.create_by, ho.update_time, ho.update_by, ho.remark, ho.`state`, ho.vin_normal, ho.search_value,
ho.operator_id_evcs, ho.charge_model_evcs, ho.connector_power_evcs, ho.meter_value_end_evcs,
ho.meter_value_start_evcs, ho.operator_id3rdpty_evcs, ho.start_time, ho.end_time, ho.stop_reason_evcs,
ho.total_power as totalPower, ho.user_name_evcs, ho.phone, ho.evcs_order_no, ho.confirm_Result, ho.rate_model_id,
ho.total_power, ho.user_name_evcs, ho.phone, ho.evcs_order_no, ho.confirm_Result, ho.rate_model_id,
ho.charging_mode,
ifnull(ho.internet_degree_commission, 0) as 'internet_degree_commission',
ho.`source`, ho.tenant_id, ho.operator_id, ho.operator_name,
@ -162,9 +161,7 @@
when ho.charging_mode="4" then '小桔'
when ho.charging_mode="微信" then '微信'
when ho.charging_mode="支付宝" then '支付宝'
when ho.charging_mode="App" then 'App'
when ho.charging_mode="刷卡" then '刷卡'
else 'vin码'
else '刷卡'
end as 'chargingModeName'
from xhpc_clearing_history_order ho
left join xhpc_charging_station ct on ct.charging_station_id = ho.charging_station_id
@ -250,8 +247,6 @@
when ho.charging_mode="4" then "小桔"
else "--"
end as 'charging_mode_name'
from xhpc_clearing_history_order as ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
@ -590,9 +585,7 @@
when ho.charging_mode="4" then "小桔"
when ho.charging_mode="微信" then "微信"
when ho.charging_mode="支付宝" then "支付宝"
when ho.charging_mode="App" then "App"
when ho.charging_mode="刷卡" then "刷卡"
else "vin码"
else "刷卡"
end chargingModeName
from xhpc_clearing_history_order as ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id

View File

@ -1,10 +1,7 @@
package com.xhpc.charging.station.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.charging.station.service.IXhpcChargingStationService;
import com.xhpc.charging.station.service.IXhpcTerminalService;
import com.xhpc.common.core.utils.HttpUtils;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
@ -14,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -92,4 +88,9 @@ public class XhpcChargingStationApiController extends BaseController {
}
}

View File

@ -244,7 +244,7 @@ public class XhpcChargingPileController extends BaseController {
if(powerNumber<1 || powerNumber>100){
return AjaxResult.error("充电桩最大允许输出功率1~100之内");
}
redisService.setCacheObject("pile:"+serialNumber+":powerNumber",powerNumber);
REDIS.setCacheObject(serialNumber+":powerNumber",powerNumber);
R r = powerPileService.pileConfigSettings(serialNumber,powerNumber.toString());
if(r.getCode() !=200){
return AjaxResult.error(r.getMsg());

View File

@ -2,7 +2,8 @@ package com.xhpc.charging.station.service;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.charging.station.dto.XhpcActivityDiscountDto;
import com.xhpc.charging.station.mapper.XhpcChargingStationMapper;
import com.xhpc.charging.station.mapper.XhpcChargingStationPushStatusMapper;
@ -22,6 +23,7 @@ import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.LogUserUtils;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.common.util.Utilitys;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import org.slf4j.Logger;
@ -35,6 +37,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

View File

@ -163,20 +163,6 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I
xhpcTimingChargingModel.setCreateTime(new Date());
xhpcTimingChargingModel.setChargingStationId(chargingStationId);
xhpcTimingChargingModel.setPhone(xhpcTimingChargingModelDto.getPhone());
Integer[] chargingPileIds = xhpcTimingChargingModelDto.getChargingPileIds();
String PileIds ="";
for (int i = 0; i <chargingPileIds.length ; i++) {
if(i==0 && chargingPileIds.length>1){
PileIds =PileIds+chargingPileIds[i];
}else if(chargingPileIds.length==1){
PileIds =chargingPileIds[i]+"";
}else{
PileIds =PileIds+","+chargingPileIds[i];
}
}
xhpcTimingChargingModel.setPileIds(PileIds);
if(xhpcTimingChargingModelDto.getTimingChargingModelId() !=null){
xhpcTimingChargingModel.setTimingChargingModelId(xhpcTimingChargingModelDto.getTimingChargingModelId());
xhpcTimingChargingModelMapper.updateXhpcTimingChargingModel(xhpcTimingChargingModel);
@ -429,16 +415,6 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I
}
//查询是否是未执行状态
map = xhpcTimingChargingModelMapper.getXhpcTimingChargingModelMapById(timingChargingModelId,loginUser.getTenantId());
if(map.get("pileIds")!=null){
String[] split = map.get("pileIds").toString().split(",");
Integer [] piles =new Integer [split.length];
for (int i = 0; i <split.length ; i++) {
String s = split[i];
piles[i] = Integer.parseInt(s);
}
map.put("chargingPileIds",piles);
}
//费率
List<Map<String, Object>> xhpcRateList = xhpcTimingChargingModelMapper.getXhpcTimingChargingRateList(timingChargingModelId);

View File

@ -88,7 +88,7 @@ public class XhpcTimingChargingPowerServiceImpl implements IXhpcTimingChargingPo
String st ="";
for (int i = 0; i <chargingPileIds.length ; i++) {
if(i==0 && chargingPileIds.length>1){
st =st+chargingPileIds[i];
st =st+chargingPileIds[i]+",";
}else if(chargingPileIds.length==1){
st =chargingPileIds[i]+"";
}else{

View File

@ -24,9 +24,9 @@ spring:
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
#logging:
# level:
# com.xhpc.charging.station.mapper: debug
logging:
level:
com.xhpc.charging.station.mapper: debug
#二维码Logo图片获取位置
#imgPath: "D:\\Enterprise_Resources\\XiaoHuaMaterialImgs\\xhcd_logo.png"

View File

@ -217,7 +217,6 @@
update xhpc_charging_station
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="chengduName != null">chengdu_name = #{chengduName},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="type != null">type = #{type},</if>
<if test="constructionSite != null">construction_site = #{constructionSite},</if>
@ -256,9 +255,6 @@
<if test="null != equipmentOwnerId and '' != equipmentOwnerId">
equipment_owner_id=#{equipmentOwnerId},
</if>
<if test="null != internetEquipmentOwnerId and '' != internetEquipmentOwnerId">
internet_equipment_owner_id=#{internetEquipmentOwnerId},
</if>
<if test="null != isAloneApply ">
is_alone_apply=#{isAloneApply},
</if>
@ -419,11 +415,9 @@
<select id="getXhpcChargingStationMessage" resultType="java.util.Map">
select ct.charging_station_id as chargingStationId,
ct.name as name,
ct.chengdu_name as chengduName,
ct.operator_id as operatorId,
ct.operator_id_evcs as operatorIdEvcs,
ct.equipment_owner_id as equipmentOwnerId,
ct.internet_equipment_owner_id as internetEquipmentOwnerId,
ct.is_alone_apply as isAloneApply,
ct.account_number as accountNumber,
ct.capacity as capacity,
@ -699,9 +693,6 @@
<if test="null != name and '' != name">
name,
</if>
<if test="null != chengduName and '' != chengduName">
chengdu_name,
</if>
<if test="null != operatorId ">
operator_id,
</if>
@ -794,9 +785,6 @@
<if test="null != equipmentOwnerId and '' != equipmentOwnerId">
equipment_owner_id,
</if>
<if test="null != internetEquipmentOwnerId and '' != internetEquipmentOwnerId">
internet_equipment_owner_id,
</if>
<if test="null != isAloneApply ">
is_alone_apply,
</if>
@ -922,9 +910,6 @@
<if test="null != name and '' != name">
#{name},
</if>
<if test="null != chengduName and '' != chengduName">
#{chengduName},
</if>
<if test="null != operatorId ">
#{operatorId},
</if>
@ -1017,9 +1002,6 @@
<if test="null != equipmentOwnerId and '' != equipmentOwnerId">
#{equipmentOwnerId},
</if>
<if test="null != internetEquipmentOwnerId and '' != internetEquipmentOwnerId">
#{internetEquipmentOwnerId},
</if>
<if test="null != isAloneApply ">
#{isAloneApply},
</if>

View File

@ -599,8 +599,7 @@
tcm.timing_time as timingTime,
tcm.status as status,
tcm.create_time as createTime,
tcm.phone as phone,
tcm.pile_ids as pileIds
tcm.phone as phone
from xhpc_timing_charging_model as tcm
left join xhpc_charging_station as cs on cs.charging_station_id = tcm.charging_station_id
where tcm.timing_charging_model_id =#{timingChargingModelId}

View File

@ -159,13 +159,9 @@
</insert>
<select id="getXhpcTimingChargingPowerModelById" resultMap="BaseResultMap">
select xtcp.*,xcs.name as chargingStationName
from xhpc_timing_charging_power xtcp
left join xhpc_charging_station xcs on xtcp.charging_station_id = xcs.charging_station_id
where xtcp.timing_charging_power_id =#{timingChargingPowerId}
and xtcp.del_flag=0
select * from xhpc_timing_charging_power where timing_charging_power_id =#{timingChargingPowerId} and del_flag=0
<if test="tenantId !=null and ''!=tenantId">
and xtcp.tenant_id=#{tenantId}
and tenant_id=#{tenantId}
</if>
</select>

View File

@ -20,6 +20,4 @@ public class XhpcTimingChargingModelDto extends XhpcTimingChargingModel {
//默认时段费率
String defaultPeriodId;
}

View File

@ -21,10 +21,6 @@ public class XhpcChargingStation extends BaseEntity {
@Excel(name = "名称")
private String name;
/** 成都监管平台推送场站名称 */
@Excel(name = "成都监管平台推送场站名称")
private String chengduName;
/** 运营商id */
@Excel(name = "运营商id")
private Long operatorId;
@ -127,10 +123,7 @@ public class XhpcChargingStation extends BaseEntity {
* 产权所属单位ID
*/
private String equipmentOwnerId;
/**
* 成都市推送产权所属单位ID
*/
private String internetEquipmentOwnerId;
/**
* 是否独立报桩
*/
@ -888,20 +881,4 @@ public class XhpcChargingStation extends BaseEntity {
public void setChargingMethod(String chargingMethod) {
this.chargingMethod = chargingMethod;
}
public String getChengduName() {
return chengduName;
}
public void setChengduName(String chengduName) {
this.chengduName = chengduName;
}
public String getInternetEquipmentOwnerId() {
return internetEquipmentOwnerId;
}
public void setInternetEquipmentOwnerId(String internetEquipmentOwnerId) {
this.internetEquipmentOwnerId = internetEquipmentOwnerId;
}
}

View File

@ -56,8 +56,4 @@ public class XhpcTimingChargingModel extends BaseEntity {
private String tenantId;
private String phone;
private String pileIds;
private Integer [] chargingPileIds;
}

View File

@ -61,7 +61,5 @@ public class XhpcTimingChargingPowerModel extends BaseEntity {
private String pileIds;
private String chargingStationName;
private Integer [] chargingPileIds;
}

View File

@ -119,13 +119,4 @@ public class UserTypeUtil {
* 未登录状态
*/
public static final String NO_LOGIN = "0";
/**
* 登录语言中文英文阿拉伯语
*/
public static final String LANGUAGE_ZH ="1";
public static final String LANGUAGE_EN ="2";
public static final String LANGUAGE_ARA ="3";
}

View File

@ -1,6 +1,5 @@
package com.xhpc.order.api;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.common.api.WebSocketService;
@ -15,7 +14,6 @@ import com.xhpc.order.service.IXhpcChargeOrderService;
import com.xhpc.order.service.IXhpcHistoryOrderService;
import com.xhpc.system.api.model.LoginUser;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,7 +24,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author yuyang
@ -59,7 +60,7 @@ public class XhpcChargeOrderController extends BaseController {
}
/**
* 启动充电检查(微信)
* 实时订单(微信)
*/
@GetMapping("/getHistotyChargeOrderMessage")
public AjaxResult getHistotyChargeOrderMessage(HttpServletRequest request)
@ -67,17 +68,6 @@ public class XhpcChargeOrderController extends BaseController {
return iXhpcChargeOrderService.getHistotyChargeOrderMessage(request);
}
/**
* 我的实时订单(微信)
*/
@GetMapping("/getUserHistotyChargeOrderMessage")
public AjaxResult getUserHistotyChargeOrderMessage(HttpServletRequest request)
{
return iXhpcChargeOrderService.getUserHistotyChargeOrderMessage(request);
}
/**
* 异常订单(微信)
*/
@ -93,7 +83,7 @@ public class XhpcChargeOrderController extends BaseController {
* 启动充电
* @param userId
* @param serialNumber 终端编码
* @param type 1 微信 2支付宝 3 APP 4.刷卡 5vin
* @param type 1 微信 2支付宝 3 APP
* @return
*/
@GetMapping("/startUp")
@ -231,6 +221,7 @@ public class XhpcChargeOrderController extends BaseController {
* @param userId
* @param serialNumber 终端编码
* @param type 1 微信
* @param type 1 微信
* @return
*/
@GetMapping("/cycStartUp")
@ -259,11 +250,4 @@ public class XhpcChargeOrderController extends BaseController {
return iXhpcChargeOrderService.chargingCapacityStartUp(request,userId, serialNumber, type,chargingCapacity);
}
@GetMapping("/ceshi")
public AjaxResult ceshi(String phone,String vin, String plateNnum,Long chargingStationId,String time){
String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
int blacklistUser = iXhpcChargeOrderService.getBlacklistUser(phone, vin, plateNnum, chargingStationId, format);
return AjaxResult.success(blacklistUser);
}
}

View File

@ -335,7 +335,7 @@ public class XhpcPileOrderController extends BaseController {
//停止充电
xhpcChargeOrder.setRemark("充电桩校验故障");
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
powerPileService.stopCharging(orderNo, substring,orderNo.substring(0, 16), "0C");
powerPileService.stopCharging(orderNo, substring,orderNo.substring(0, 16), "0A");
System.out.println("=====================p平台下发停止充电=============================="+xhpcChargeOrder.getSerialNumber());
return R.fail(500,"充电桩校验故障");
}
@ -497,17 +497,12 @@ public class XhpcPileOrderController extends BaseController {
logger.info("*********************订单号>>>>>orderNo" + orderNo);
return R.ok();
}
CacheOrderData cacheOrderData = (CacheOrderData)cacheMap.get("orderData");
//停止原因
try{
if(cacheOrderData.getStopReason() !=null && !"".equals(cacheOrderData.getStopReason())){
xhpcChargeOrder.setType(cacheOrderData.getStopReason());
}else{
if(cacheMap.get("stopReasonHex")!=null){
xhpcChargeOrder.setType(cacheMap.get("stopReasonHex").toString());
}else{
xhpcChargeOrder.setType("199");
}
}
}catch (Exception e){}
if(xhpcChargeOrder == null ){
@ -525,46 +520,11 @@ public class XhpcPileOrderController extends BaseController {
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
return R.fail(500,"无效订单号:"+orderNo);
}
//1.订单结束时上报的开始时间小于订单创建时间3分钟 2.订单结束时上报的开始时间大于订单创建时间5分钟
long createTimeLong = xhpcChargeOrder.getCreateTime().getTime();
if(cacheOrderData.getStartTime() !=null || "".equals(cacheOrderData.getStartTime())){
long startTimeLong = DateUtil.parse(cacheOrderData.getStartTime()).getTime();
if(createTimeLong-startTimeLong>60000){
// xhpcChargeOrder.setStatus(2);
// xhpcChargeOrder.setChargingDegree(totalPowerQuantity);
// xhpcChargeOrder.setUpdateTime(new Date());
// xhpcChargeOrder.setErroRemark("结算订单开始充电时间小于订单创建时间1分钟");
// xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
// return R.fail(500,"无效订单号:"+orderNo);
xhpcChargeOrder.setStartTime(xhpcChargeOrder.getCreateTime());
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
}
if(startTimeLong-createTimeLong>180000){
// xhpcChargeOrder.setStatus(2);
// xhpcChargeOrder.setChargingDegree(totalPowerQuantity);
// xhpcChargeOrder.setUpdateTime(new Date());
// xhpcChargeOrder.setErroRemark("结算订单开始充电时间大于订单创建时间3分钟");
// xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
// return R.fail(500,"无效订单号:"+orderNo);
xhpcChargeOrder.setStartTime(xhpcChargeOrder.getCreateTime());
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
}
}else{
xhpcChargeOrder.setStatus(2);
xhpcChargeOrder.setChargingDegree(totalPowerQuantity);
xhpcChargeOrder.setUpdateTime(new Date());
xhpcChargeOrder.setErroRemark("结算订单开始充电时间为空");
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
return R.fail(500,"无效订单号:"+orderNo);
}
BigDecimal money = new BigDecimal(cacheOrderData.getCost()).divide(bigDecimal,2,BigDecimal.ROUND_HALF_UP);
if(cacheOrderData.getTotalPowerQuantity()==0 || totalPowerQuantity.compareTo(new BigDecimal(0.1))<1 || money.compareTo(new BigDecimal(0.1))<1){
xhpcChargeOrder.setStatus(3);
xhpcChargeOrder.setUpdateTime(new Date());
int startSoc1 = cacheOrderData.getStartSoc();
@ -578,13 +538,13 @@ public class XhpcPileOrderController extends BaseController {
xhpcChargeOrder.setEndTime(date);
xhpcChargeOrder.setChargingTime("0分");
xhpcChargeOrder.setChargingDegree(bigDecimal1);
xhpcChargeOrder.setType("199");
xhpcChargeOrder.setAmountCharged(bigDecimal1);
xhpcChargeOrder.setChargingTimeNumber(0L);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
//xhpcRealTimeOrderService.addZeroHistoryOrder(xhpcChargeOrder);
logger.info("*********************电量为0订单号>>>>>orderNo" + orderNo);
logger.info("*********************电量为0订单号>>>>>orderNo" + orderNo);
//生成一条历史订单
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
xhpcHistoryOrder.setStartTime(date);
@ -597,9 +557,7 @@ public class XhpcPileOrderController extends BaseController {
xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue());
xhpcHistoryOrder.setVinNormal(xhpcChargeOrder.getVinNormal());
xhpcHistoryOrder.setType(1);
xhpcHistoryOrder.setUserNameEvcs(xhpcChargeOrder.getDriverId());
xhpcHistoryOrder.setPhone(xhpcChargeOrder.getDriverId());
xhpcHistoryOrder.setUserNameEvcs(xhpcChargeOrder.getDriverId());
Map<String, Object> userMessage =new HashMap<>();
if(!UserTypeUtil.INTERNET_TYPE.equals(source)||(UserTypeUtil.INTERNET_TYPE.equals(source) && userId>1000)){
@ -853,8 +811,6 @@ public class XhpcPileOrderController extends BaseController {
}
}
xhpcHistoryOrder.setType(1);
xhpcHistoryOrder.setPhone(xhpcChargeOrder.getDriverId());
xhpcHistoryOrder.setUserNameEvcs(xhpcChargeOrder.getDriverId());
//结算
R r = xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder);
if(r.getCode()==200){
@ -950,23 +906,6 @@ public class XhpcPileOrderController extends BaseController {
// }else{
// xhpcHistoryOrderService.addXhpcChargeOrder(null,orderNo,1);
// }
//双枪修改逻辑查询是否是双枪
if(xhpcChargeOrder.getSunchaStatus()!=0){
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.CUSTOMERS;
}
Map<String, Object> map = new HashMap<>();
if(xhpcChargeOrder.getSunchaStatus()==1){
map.put("aBalanceStatus",2);
}else{
map.put("bBalanceStatus",2);
}
String key = "user:" + xhpcChargeOrder.getUserId() + userType + ".order";
redisService.setCacheMap(key,map);
}
Date date = new Date();
xhpcChargeOrder.setStatus(2);
xhpcChargeOrder.setEndTime(date);
@ -1008,24 +947,6 @@ public class XhpcPileOrderController extends BaseController {
if(status==0){
xhpcChargeOrder.setStatus(0);
xhpcChargeOrder.setStartTime(date);
//查询是否是双枪
if(xhpcChargeOrder.getSunchaStatus()!=0){
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.CUSTOMERS;
}
Map<String, Object> map = new HashMap<>();
if(xhpcChargeOrder.getSunchaStatus()==1){
map.put("aBalanceStatus",0);
}else{
map.put("bBalanceStatus",0);
}
String key = "user:" + xhpcChargeOrder.getUserId() + userType + ".order";
redisService.setCacheMap(key,map);
}
} else{
xhpcChargeOrder.setStatus(-1);
xhpcChargeOrder.setDelFlag(1);
@ -1043,19 +964,35 @@ public class XhpcPileOrderController extends BaseController {
return userId;
}
// private void rabbimt(String message) {
// //发送消息队列
// try {
// // 1获取到连接
// Connection connection = ConnectionRabbitMQUtil.getConnection();
// // 2从连接中创建通道使用通道才能完成消息相关的操作
// Channel channel = connection.createChannel();
// // 3声明创建队列
// channel.queueDeclare("webSocket", false, false, false, null);
// // 4消息内容
// channel.basicPublish("", "webSocket", null, message.getBytes());
// channel.close();
// connection.close();
// } catch (Exception e) {
//
// }
// }
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber,
@RequestParam(value = "driverId", required = false) String driverId,
@RequestParam(value = "chargingAmt", required = false, defaultValue = "500") Integer chargingAmt,
@RequestParam(value = "plateNum", required = false) String plateNum,
@RequestParam(value = "status") Integer status,
@RequestParam(value = "connectorId") String connectorId) {
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber,
@RequestParam(value = "driverId", required = false) String driverId,
@RequestParam(value = "chargingAmt", required = false, defaultValue = "500") Integer chargingAmt,
@RequestParam(value = "plateNum", required = false) String plateNum,
@RequestParam(value = "status") Integer status,
@RequestParam(value = "connectorId") String connectorId) {
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方启动>>>>>>>>>>>>>>>>>"+internetSerialNumber);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方启动>>>>>>>>>>>>>>>>>"+internetSerialNumber);
return xhpcChargeOrderService.startUpBy3rd(internetSerialNumber, driverId, chargingAmt, plateNum, status, connectorId);
}
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方启动>>>>>>>>>>>>>>>>>"+internetSerialNumber);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方启动>>>>>>>>>>>>>>>>>"+internetSerialNumber);
return xhpcChargeOrderService.startUpBy3rd(internetSerialNumber, driverId, chargingAmt, plateNum, status, connectorId);
}

View File

@ -4,13 +4,8 @@ import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.order.domain.XhpcOrderOutputMax;
import com.xhpc.order.domain.XhpcRealTimeOrderBms;
import com.xhpc.order.service.IXhpcChargingStationPowerService;
import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
@ -20,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -36,9 +30,6 @@ public class XhpcChargingStationPowerController extends BaseController {
@Resource
private IXhpcChargingStationPowerService xhpcChargingStationPowerService;
@Autowired
private RedisService redisService;
@GetMapping("/test1")
@Scheduled(cron = "0 0/3 0/1 * * ? ")
@ -76,53 +67,9 @@ public class XhpcChargingStationPowerController extends BaseController {
return R.ok(xhpcChargingStationPowerService.getChargingStationList());
}
//择线图时间为准
//获取订单最大功率统计列表
@GetMapping("/getMaxPowerList")
public TableDataInfo getMaxPowerList(
@RequestParam(required = false)String tenantId,
@RequestParam(required = false)String startTime,
@RequestParam(required = false)String endTime,
@RequestParam(required = false)Long chargingStationId,
@RequestParam(required = false)Long chargingPileId,
@RequestParam(required = false)Long terminalId,
@RequestParam(required = false)Long operatorId,
@RequestParam String pileStart,
@RequestParam String pileEnd,
@RequestParam String bmsStart,
@RequestParam String bmsEnd,
@RequestParam String pileVoltageStart,
@RequestParam String pileVoltageEnd,
@RequestParam String bmsVoltageStart,
@RequestParam String bmsVoltageEnd,
@RequestParam String pileCurrentStart,
@RequestParam String pileCurrentEnd,
@RequestParam String bmsCurrentStart,
@RequestParam String bmsCurrentEnd
) {
Map<String, Object> params = new HashMap<>();
params.put("tenantId",tenantId);
params.put("startTime",startTime);
params.put("endTime",endTime);
params.put("chargingStationId",chargingStationId);
params.put("chargingPileId",chargingPileId);
params.put("terminalId",terminalId);
params.put("operatorId",operatorId);
params.put("pileStart",pileStart);
params.put("pileEnd",pileEnd);
params.put("bmsStart",bmsStart);
params.put("bmsEnd",bmsEnd);
params.put("pileVoltageStart",pileVoltageStart);
params.put("pileVoltageEnd",pileVoltageEnd);
params.put("bmsVoltageStart",bmsVoltageStart);
params.put("bmsVoltageEnd",bmsVoltageEnd);
params.put("pileCurrentStart",pileCurrentStart);
params.put("pileCurrentEnd",pileCurrentEnd);
params.put("bmsCurrentStart",bmsCurrentStart);
params.put("bmsCurrentEnd",bmsCurrentEnd);
List<Map<String, Object>> listPage = xhpcChargingStationPowerService.getMaxPowerList(params);
return getDataTable(listPage);
}
}

View File

@ -52,7 +52,7 @@ public class XhpcPileRegularInspectController extends BaseController {
//费率定时任务
@GetMapping("/getRateTime")
//@Scheduled(cron = "0 0/4 * * * ?")
@Scheduled(cron = "0 0/4 * * * ?")
public void getRateTime()
{
xhpcPileRegularInspectService.getRateTime();

View File

@ -377,7 +377,7 @@ public class XhpcStatisticsController extends BaseController {
//-------------------------------------------------首页------------------------------------------------------------
/**
* 今日订单量
* 今日订单量今日订电量今日营收今日充电枪状态
*/
@GetMapping("/getToday")
public AjaxResult getToday(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type)
@ -385,19 +385,6 @@ public class XhpcStatisticsController extends BaseController {
return AjaxResult.success(xhpcStatisticsService.getToday(operatorId,chargingStationId,chargingPileId,type));
}
@GetMapping("/getOrderElectricityQuantity")
public AjaxResult getOrderElectricityQuantity(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type)
{
return AjaxResult.success(xhpcStatisticsService.getOrderElectricityQuantity(operatorId,chargingStationId,chargingPileId,type));
}
@GetMapping("/getTodayRrevenue")
public AjaxResult getTodayRrevenue(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type)
{
return AjaxResult.success(xhpcStatisticsService.getTodayRrevenue(operatorId,chargingStationId,chargingPileId,type));
}
/**
* 今日电枪实时状态
*/

View File

@ -64,6 +64,10 @@ public class XhpcStopChargingOrderController extends BaseController {
if(cacheMap.get("version") !=null){
version =cacheMap.get("version").toString();
}
System.out.println("=================111========停止充电命令已下发==================停止 充电=================="+serialNumberOrderMap);
System.out.println("=================111========停止充电命令已下发==================停止 充电=================="+serialNumberOrderMap);
System.out.println("=================111========停止充电命令已下发==================停止 充电=================="+serialNumberOrderMap);
R r = powerPileService.stopCharging(serialNumberOrderMap, serialNumberOrderMap.substring(0,14), serialNumberOrderMap.substring(0,16), version);
if(r.getCode()==200){

View File

@ -157,9 +157,6 @@ public class XhpcChargeOrder extends BaseEntity {
private String vinNormal;
private Integer chargingCapacity;
private Integer sunchaStatus;
public Integer getStopReasonEvcs() {
return stopReasonEvcs;
@ -497,12 +494,4 @@ public class XhpcChargeOrder extends BaseEntity {
public void setChargingCapacity(Integer chargingCapacity) {
this.chargingCapacity = chargingCapacity;
}
public Integer getSunchaStatus() {
return sunchaStatus;
}
public void setSunchaStatus(Integer sunchaStatus) {
this.sunchaStatus = sunchaStatus;
}
}

View File

@ -1,39 +0,0 @@
package com.xhpc.order.domain;
import com.xhpc.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* @author yuyang
* @date 2022/8/31 17:32
*/
@Data
public class XhpcOrderOutputMax extends BaseEntity {
private Long orderOutputMaxId;
private String orderNo; //交易流水号
private String pileNo; //桩号
private String gunId; //枪号
private Double bmsVoltageRequest; //BMS 电压需求
private Double bmsCurrentRequest; //BMS 电流需求
private Double countBmsRequest; //BMS 电流需求功率
private Integer bmsChargingMod; //BMS 充电模式
private Double bmsChargingVolt; //BMS 充电电压测量值
private Double bmsChargingCurrent; //BMS 充电电流测量值
private Double monoBatteryVolt; //BMS 最高单体动力蓄电池电压
private Integer soc; //BMS 当前荷电状态 SOC %
private String bmsEstRemainingTime; //BMS 估算剩余充电时间
private Double pileVoltageOutput; //电桩电压输出值
private Double pileCurrentOutput; //电桩电流输出值
private Double countPileOutput;//电桩输出功率
private String chargingTimeSummary; //累计充电时间
private Integer monoBatteryVoltGroupId; // BMS 最高单体动力蓄电池电压所在组号ID
private Long chargeOrderId;
private Long chargingStationId;
private Long terminalId;
private Date createTime;
}

View File

@ -28,11 +28,7 @@ public interface XhpcChargeOrderMapper {
*/
Map<String,Object> getHistotyChargeOrderMessageMap(@Param("userId") Long userId,@Param("tenantId") String tenantId,@Param("userType") Integer userType,@Param("thirdCode")String thirdCode);
int getHistotyChargeOrderMessage(@Param("userId") Long userId,@Param("tenantId") String tenantIde,@Param("userType") Integer userTyp,@Param("sunchaStatus") Integer sunchaStatus);
int getUserTypeSunchaSwitch(@Param("userId") Long userId,@Param("tenantId") String tenantId,@Param("userType") Integer userType);
int getHistotyChargeOrderMessage(@Param("userId") Long userId,@Param("tenantId") String tenantId,@Param("userType") Integer userType);
Map<String,Object> getMessage(@Param("userId") Long userId);
/**
@ -56,15 +52,6 @@ public interface XhpcChargeOrderMapper {
*/
int updateUserBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/**
* 双枪修改金额
* @param userId
* @param balance
* @param sunchaStatus
* @return
*/
int updateUserSunchaBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance, @Param("sunchaStatus")Integer sunchaStatus);
/**
* 社区用户修改余额
* @param userId
@ -73,14 +60,7 @@ public interface XhpcChargeOrderMapper {
*/
int updateCommunityBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/**
* 双枪修改金额
* @param userId
* @param balance
* @param sunchaStatus
* @return
*/
int updateCommunitySunchaBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance, @Param("sunchaStatus")Integer sunchaStatus);
/**
* B端用户修改余额
* @param userId
@ -88,15 +68,6 @@ public interface XhpcChargeOrderMapper {
* @return
*/
int updateCustomersBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/**
* 双枪修改金额
* @param userId
* @param balance
* @param sunchaStatus
* @return
*/
int updateCustomersSunchaBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance, @Param("sunchaStatus")Integer sunchaStatus);
/**
* 更新川逸充用户余额
@ -277,17 +248,5 @@ public interface XhpcChargeOrderMapper {
//获取充电站信息
Map<String,Object> getChargingStationById(@Param("chargingStationId")Long chargingStationId);
//修改账户金额C端
int updateXhpcAppUser(@Param("userId")Long userId,@Param("aBalance")BigDecimal aBalance,@Param("bBalance")BigDecimal bBalance);
//修改账户金额社区用户
int updateXhpcCommunityPersonnel(@Param("userId")Long userId,@Param("aBalance")BigDecimal aBalance,@Param("bBalance")BigDecimal bBalance);
//修改账户金额B端用户
int updateXhpcCustomersPersonnel(@Param("userId")Long userId,@Param("aBalance")BigDecimal aBalance,@Param("bBalance")BigDecimal bBalance);
//查询是否可以充电
int getBlacklistUser(@Param("phone")String phone,@Param("vin")String vin,@Param("plateNnum")String plateNnum,@Param("chargingStationId")Long chargingStationId,@Param("time")String time);
}

View File

@ -27,11 +27,4 @@ public interface XhpcChargingStationPowerMapper {
void addXhpcChargingStationPower(XhpcChargingStationPower xhpcChargingStationPower);
List<Map<String,Object>> getListPage(@Param("params") Map<String, Object> params);
/**
* 获取登陆用户信息
*/
Map<String, Object> getLandUser(@Param("userId")Long userId);
List<Map<String,Object>> getMaxPowerList(@Param("params") Map<String, Object> params);
}

View File

@ -32,10 +32,6 @@ public interface XhpcRealTimeOrderMapper {
* @return
*/
int insertRealTimeOrderBms(XhpcRealTimeOrderBms xhpcRealTimeOrderBms);
int insertOrderOutputMax(XhpcOrderOutputMax xhpcOrderOutputMax);
/**
* 添加订单实时SOC
* @param xhpcChargeOrderSoc

View File

@ -5,7 +5,6 @@ import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcRate;
import com.xhpc.order.domain.XhpcChargeOrder;
import com.xhpc.order.domain.XhpcOrderRedisRecord;
import org.apache.ibatis.annotations.Param;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
@ -37,14 +36,6 @@ public interface IXhpcChargeOrderService {
*/
AjaxResult getHistotyChargeOrderMessage(HttpServletRequest request);
/**
* 判断实时订单
*
* @param
* @return
*/
AjaxResult getUserHistotyChargeOrderMessage(HttpServletRequest request);
/**
* 实时订单
@ -123,11 +114,6 @@ public interface IXhpcChargeOrderService {
*/
int updateUserBalance(Long userId, BigDecimal balance,Integer source,String tenantId);
/**
* 修改双枪余额
*/
int updateUserSunchaBalance(Long userId, BigDecimal balance,Integer source,String tenantId,Integer sunchaStatus);
/**
* 获取运营商信息
* @param chargingStationId
@ -230,11 +216,4 @@ public interface IXhpcChargeOrderService {
*/
AjaxResult chargingCapacityStartUp(HttpServletRequest request, Long userId, String serialNumber, Integer type,Integer chargingCapacity);
/**
* 判断用户是否在充电中
*/
String countXhpcRealTimeOrder(Long userId,Integer source,String tenantId);
int getBlacklistUser(String phone,String vin,String plateNnum,Long chargingStationId,String time);
}

View File

@ -19,7 +19,4 @@ public interface IXhpcChargingStationPowerService {
List<Map<String,Object>> getChargingStationList();
List<Map<String,Object>> getMaxPowerList(Map<String, Object> params);
}

View File

@ -286,17 +286,9 @@ public interface IXhpcStatisticsService {
void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) throws IOException ;
/**
* 今日订单量
* 今日订单量今日订电量今日营收今日充电枪状态
*/
Map<String, Object> getToday(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);
/**
* 今日订电量
*/
Map<String, Object> getOrderElectricityQuantity(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);
/**
* 今日营收
*/
Map<String, Object> getTodayRrevenue(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);
/**
* 今日电枪实时状态

View File

@ -116,41 +116,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
public AjaxResult getHistotyChargeOrderMessage(HttpServletRequest request) {
try{
LoginUser loginUser = tokenService.getLoginUser(request);
Integer type = loginUser.getUserType();
if(UserTypeUtil.USER_TYPE.equals(type) || UserTypeUtil.COMMUNIT_TYPE.equals(type)|| UserTypeUtil.INTERNET_TYPE.equals(type)){
int sunchaSwitch = xhpcChargeOrderMapper.getUserTypeSunchaSwitch(loginUser.getUserid(), loginUser.getTenantId(), loginUser.getUserType());
if(sunchaSwitch==1){
int count = xhpcChargeOrderMapper.getHistotyChargeOrderMessage(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType(),1);
if(count>1){
return AjaxResult.success();
}
return AjaxResult.error(1201,"无实时数据");
}else{
int count = xhpcChargeOrderMapper.getHistotyChargeOrderMessage(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType(),0);
if(count>0){
return AjaxResult.success();
}
return AjaxResult.error(1201,"无实时数据");
}
}else{
int count = xhpcChargeOrderMapper.getHistotyChargeOrderMessage(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType(),0);
if(count>0){
return AjaxResult.success();
}
return AjaxResult.error(1201,"无实时数据");
}
}catch (Exception e){
return AjaxResult.error("数据异常,请联系客服或拨打桩上电话");
}
//return AjaxResult.success(xhpcChargeOrderMapper.getMessage(userId));
}
@Override
public AjaxResult getUserHistotyChargeOrderMessage(HttpServletRequest request) {
try{
LoginUser loginUser = tokenService.getLoginUser(request);
int count = xhpcChargeOrderMapper.getHistotyChargeOrderMessage(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType(),0);
int count = xhpcChargeOrderMapper.getHistotyChargeOrderMessage(loginUser.getUserid(),loginUser.getTenantId(),loginUser.getUserType());
if(count>0){
return AjaxResult.success();
}
@ -158,6 +125,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}catch (Exception e){
return AjaxResult.error("数据异常,请联系客服或拨打桩上电话");
}
//return AjaxResult.success(xhpcChargeOrderMapper.getMessage(userId));
}
@Override
@ -223,7 +191,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return AjaxResult.error(UserTypeUtil.LOGIN_TYPE, "此账号不能在该场站充电,请使用手机号登录");
}
}
xhpcChargeOrder.setDriverId(userMessage.get("phone").toString());
String pattern = "^([0-9]{16})";
Pattern compile = Pattern.compile(pattern);
@ -259,17 +226,11 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
return AjaxResult.error(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
}
//充电用户是否在充电中
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
if (!"".equals(i) && i!=null) {
return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息");
}
// if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) ==0){
// //充电用户是否在充电中
// String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
// if (!"".equals(i) && i!=null) {
// return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息");
// }
// }
//终端状态是否空闲
//是否插枪
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + terminalSerialNumber);
@ -312,15 +273,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
}
//判断是否可以充电(黑名单)
// int blacklistUser = xhpcChargeOrderMapper.getBlacklistUser(userMessage.get("phone").toString(), userMessage.get("vinSpecCode").toString(), userMessage.get("vehicleName").toString(), xhpcTerminal.getChargingStationId(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
// if(blacklistUser>0){
// return AjaxResult.error(1104, "该车辆暂停充电,请联系客服");
// }
// if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) !=0){
// return startUpSuncha(userMessage,xhpcChargeOrder,xhpcTerminal,tenantId,userType,terminalSerialNumber,type);
// }
//余额
String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
//获取桩信息
@ -347,35 +299,41 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
int number =0;
if(!"".equals(userMessage.get("socUser")) && userMessage.get("socUser") !=null && userMessage.get("socProtect") !=null && !"0".equals(userMessage.get("socProtect").toString())){
number =Integer.parseInt(userMessage.get("socUser").toString());
logger.info("=========用户、桩、平台(最小的)===number==="+number);
}
logger.info("<<<<<<<<<<<<11<<<<<<<<<<<<number>>>>>>>>>>>>11>>>>>:"+number);
//平台
String soc = redisService.getCacheObject("global:"+tenantId+":SOC");
logger.info("=========用户、桩、平台(最小的)===soc==="+soc);
if(!"".equals(soc) && soc!=null){
if(number!=0){
if(Integer.parseInt(soc)-number<0){
number=Integer.parseInt(soc);
logger.info("=========用户、桩、平台最小的1===number==="+number);
}
}else{
number=Integer.parseInt(soc);
logger.info("=========用户、桩、平台最小的2===number==="+number);
}
}
logger.info("<<<<<<<<<<<<222<<<<<<<<<<<<number>>>>>>>>>>>>222>>>>>:"+number);
Map<String, Object> operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId());
if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){
if(number!=0){
if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){
number=Integer.parseInt(operatorMessage.get("soc").toString());
logger.info("=========用户、桩、平台最小的3===number==="+number);
}
}else{
number=Integer.parseInt(operatorMessage.get("soc").toString());
logger.info("=========用户、桩、平台最小的4===number==="+number);
}
}
if(number !=0){
startChargingData.setSoc(number);
}
logger.info("<<<<<<<<<<<333<<<<<<<<<<<<<number>>>>>>333>>>>>>>>>>>:"+number);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<number>>>>>>>>>>>>>>>>>:"+number);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<Soc>>>>>>>>>>>>>>>>>:"+startChargingData.getSoc());
//创建充电订单(充电启动soc初始值结束是获取,并修改状态)
xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId());
xhpcChargeOrder.setUserId(userId);
xhpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId());
@ -538,19 +496,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return 0;
}
@Override
public int updateUserSunchaBalance(Long userId, BigDecimal balance, Integer source, String tenantId,Integer sunchaStatus) {
//修改用户余额
if(UserTypeUtil.USER_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateUserSunchaBalance(userId, balance,sunchaStatus);
}else if (UserTypeUtil.COMMUNIT_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateCommunitySunchaBalance(userId, balance,sunchaStatus);
}else if(UserTypeUtil.CUSTOMERS_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateCustomersSunchaBalance(userId, balance,sunchaStatus);
}
return 0;
}
@Override
public Map<String, Object> getOperatorMessage(Long chargingStationId) {
@ -617,9 +562,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
r.setMsg("场站不支持该流量方充电");
return r;
}
StartChargingData startChargingData = new StartChargingData();
//500000 equals 500 yuan
startChargingData.setBalance(chargingAmt * 100);
@ -697,13 +639,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
}
//判断是否可以充电(黑名单)
int blacklistUser = xhpcChargeOrderMapper.getBlacklistUser(driverId, null, plateNum, xhpcTerminal.getChargingStationId(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
if(blacklistUser>0){
r.setCode(500);
r.setMsg("该车辆暂停充电,请联系客服");
return r;
}
//启动充电
//订单流水号 终端号+年月日时分秒+自增4位 共32位
@ -732,7 +668,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
number=Integer.parseInt(soc);
}
}
logger.info("<<<<<<<<<<11<<<<<<<<<<<<<<number>>>>>>>>11>>>>>>>>>:" + number);
Map<String, Object> operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId());
if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){
if(number!=0){
@ -745,7 +680,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
}
startChargingData.setSoc(number);
logger.info("<<<<<<<<<22<<<<<<<<<<<<<<<number>>>>>>>>>22>>>>>>>>:" + number);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<number>>>>>>>>>>>>>>>>>:" + number);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<Soc>>>>>>>>>>>>>>>>>:" + startChargingData.getSoc());
String startTime = DateUtil.format(date, "yyyy-MM-dd HH: mm: ss");
Map<String, Object> extraData1 = xhpcChargeOrderMapper.selectDate3rdNeedBy(connectorId).get(0);
Long terminalId = (Long) extraData1.get("terminalId");
@ -921,11 +857,9 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return R.fail(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
}
//充电用户是否在充电中
if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) ==0) {
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId, userType, tenantId);
if (!"".equals(i) && i != null) {
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
}
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
if (!"".equals(i) && i!=null) {
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
}
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + serialNumber);
if(cacheMap==null){
@ -965,11 +899,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return R.fail(1104, "该充电场站不支持扫描充电");
}
}
//判断是否可以充电(黑名单)
int blacklistUser = xhpcChargeOrderMapper.getBlacklistUser(userMessage.get("phone").toString(), userMessage.get("vinSpecCode").toString(), userMessage.get("vehicleName").toString(), xhpcTerminal.getChargingStationId(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
if(blacklistUser>0){
return R.fail(1104, "该车辆暂停充电,请联系客服");
}
//创建订单
//订单流水号 终端号+年月日时分秒+自增4位 共32位
String orderNo = genOrder(serialNumber);
@ -990,11 +919,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime());
xhpcChargeOrder.setType("91");
if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) !=0){
startUpSuncha(userMessage, xhpcChargeOrder, xhpcTerminal, tenantId, userType, serialNumber, 4);
return R.ok();
}
xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder);
//插一帧实时数据
@ -1102,12 +1026,10 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
return R.fail(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
}
if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) ==0) {
//充电用户是否在充电中
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId, userType, tenantId);
if (!"".equals(i) && i != null) {
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
}
//充电用户是否在充电中
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
if (!"".equals(i) && i!=null) {
return R.fail(1102, "车辆正在充电,请查询车辆充电信息");
}
//终端状态是否空闲
//是否插枪
@ -1155,12 +1077,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return R.fail(1104, "该充电场站不支持扫描充电");
}
}
//判断是否可以充电(黑名单)
int blacklistUser = xhpcChargeOrderMapper.getBlacklistUser(userMessage.get("phone").toString(), userMessage.get("vinSpecCode").toString(), userMessage.get("vehicleName").toString(), xhpcTerminal.getChargingStationId(), DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
if(blacklistUser>0){
return R.fail(1104, "该车辆暂停充电,请联系客服");
}
//余额
String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
//获取桩信息
Map<String, Object> xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(),tenantId);
@ -1230,12 +1148,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime());
xhpcChargeOrder.setType("91");
xhpcChargeOrder.setVinNormal(vinNumber);
if(Integer.valueOf(userMessage.get("sunchaSwitch").toString()) !=0){
startUpSuncha(userMessage,xhpcChargeOrder,xhpcTerminal,tenantId,userType,serialNumber,5);
return R.ok();
}
xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder);
executorService.execute(new Runnable() {
@ -1905,229 +1817,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
return AjaxResult.error(UserTypeUtil.LOGIN_TYPE, "请确认设备网络状况正常和枪正确插好后重新尝试");
}
@Override
public String countXhpcRealTimeOrder(Long userId, Integer source, String tenantId) {
return xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,source,tenantId);
}
@Override
public int getBlacklistUser(String phone, String vin, String plateNnum, Long chargingStationId, String time) {
return xhpcChargeOrderMapper.getBlacklistUser(phone, vin, plateNnum, chargingStationId, time);
}
//判断双枪启规则
private AjaxResult startUpSuncha(Map<String, Object> userMessage,XhpcChargeOrder xhpcChargeOrder,XhpcTerminal xhpcTerminal,String tenantId,Integer source,String terminalSerialNumber,Integer type){
//余额
String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
Long appUserId = Long.valueOf(userMessage.get("appUserId").toString());
//获取桩信息
Map<String, Object> xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(),tenantId);
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==source){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==source){
userType =UserTypeUtil.CUSTOMERS;
}
//判断是否有车充电
Map<String, Object> cacheMap = redisService.getCacheMap("user:" + appUserId + userType + ".order");
if(cacheMap!=null){
boolean a =true; //A账户未启动
boolean b =true; //b账户未启动
//查看AB账户启动情况
if(cacheMap.get("aBalanceStatus")!=null){
Integer status = Integer.valueOf(cacheMap.get("aBalanceStatus").toString());
if(status==0 || status==2){
a =false;
}
}
if(cacheMap.get("bBalanceStatus")!=null){
Integer status = Integer.valueOf(cacheMap.get("bBalanceStatus").toString());
if(status==0 || status==2){
b =false;
}
}
if(a && b){
//账号金额平分修改账号金额
BigDecimal aBigDecimal = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(2)).setScale(0, BigDecimal.ROUND_UP);
BigDecimal bBigDecimal =new BigDecimal(userMessage.get("balance").toString()).subtract(aBigDecimal);
if(UserTypeUtil.USER_TYPE==source){
xhpcChargeOrderMapper.updateXhpcAppUser(appUserId,aBigDecimal,bBigDecimal);
}else if(UserTypeUtil.COMMUNIT_TYPE==source){
xhpcChargeOrderMapper.updateXhpcCommunityPersonnel(appUserId,aBigDecimal,bBigDecimal);
}else if(UserTypeUtil.CUSTOMERS_TYPE==source){
xhpcChargeOrderMapper.updateXhpcCustomersPersonnel(appUserId,aBigDecimal,bBigDecimal);
}
String key = "user:" + appUserId + userType + ".order";
redisService.deleteObject(key);
return getAjaxResult(userMessage, xhpcChargeOrder, xhpcTerminal, tenantId, source, terminalSerialNumber, type, xhpcChargingPileById, appUserId, userType, aBigDecimal.multiply(new BigDecimal(100)).toString(),1);
}else if(a){
BigDecimal bigDecimal = new BigDecimal(userMessage.get("aBalance").toString());
return getAjaxResult(userMessage, xhpcChargeOrder, xhpcTerminal, tenantId, source, terminalSerialNumber, type, xhpcChargingPileById, appUserId, userType, bigDecimal.multiply(new BigDecimal(100)).toString(),1);
}else{
BigDecimal bigDecimal = new BigDecimal(userMessage.get("bBalance").toString());
return getAjaxResult(userMessage, xhpcChargeOrder, xhpcTerminal, tenantId, source, terminalSerialNumber, type, xhpcChargingPileById, appUserId, userType, bigDecimal.multiply(new BigDecimal(100)).toString(),2);
}
}else{
//账号金额平分修改账号金额
BigDecimal aBigDecimal = new BigDecimal(balance).divide(new BigDecimal(2)).setScale(0, BigDecimal.ROUND_UP);
BigDecimal bBigDecimal =new BigDecimal(balance).subtract(aBigDecimal);
if(UserTypeUtil.USER_TYPE==source){
xhpcChargeOrderMapper.updateXhpcAppUser(appUserId,aBigDecimal,bBigDecimal);
}else if(UserTypeUtil.COMMUNIT_TYPE==source){
xhpcChargeOrderMapper.updateXhpcCommunityPersonnel(appUserId,aBigDecimal,bBigDecimal);
}else if(UserTypeUtil.CUSTOMERS_TYPE==source){
xhpcChargeOrderMapper.updateXhpcCustomersPersonnel(appUserId,aBigDecimal,bBigDecimal);
}
return getAjaxResult(userMessage, xhpcChargeOrder, xhpcTerminal, tenantId, source, terminalSerialNumber, type, xhpcChargingPileById, appUserId, userType, aBigDecimal.toString(),1);
}
}
private AjaxResult getAjaxResult(Map<String, Object> userMessage, XhpcChargeOrder xhpcChargeOrder, XhpcTerminal xhpcTerminal, String tenantId, Integer source, String terminalSerialNumber, Integer type, Map<String, Object> xhpcChargingPileById, Long appUserId, String userType, String bigDecimal,Integer sunchaStatus) {
//启动充电
StartChargingData startChargingData = new StartChargingData();
//订单流水号 终端号+年月日时分秒+自增4位 共32位
String orderNo = genOrder(terminalSerialNumber);
startChargingData.setOrderNo(orderNo);
if(userMessage.get("phone") !=null){
startChargingData.setTel(userMessage.get("phone").toString());
xhpcChargeOrder.setDriverId(userMessage.get("phone").toString());
}
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14));
startChargingData.setBalance(Double.valueOf(bigDecimal).intValue());
if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){
startChargingData.setVersion(xhpcChargingPileById.get("communicationProtocolVersion").toString());
}else{
startChargingData.setVersion("0A");
}
//用户平台最小的
int number =0;
if(!"".equals(userMessage.get("socUser")) && userMessage.get("socUser") !=null && userMessage.get("socProtect") !=null && !"0".equals(userMessage.get("socProtect").toString())){
number =Integer.parseInt(userMessage.get("socUser").toString());
logger.info("=========用户、桩、平台(最小的)===number==="+number);
}
//平台
String soc = redisService.getCacheObject("global:"+ tenantId +":SOC");
logger.info("=========用户、桩、平台(最小的)===soc==="+soc);
if(!"".equals(soc) && soc!=null){
if(number!=0){
if(Integer.parseInt(soc)-number<0){
number=Integer.parseInt(soc);
logger.info("=========用户、桩、平台最小的1===number==="+number);
}
}else{
number=Integer.parseInt(soc);
logger.info("=========用户、桩、平台最小的2===number==="+number);
}
}
Map<String, Object> operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId());
if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){
if(number!=0){
if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){
number=Integer.parseInt(operatorMessage.get("soc").toString());
logger.info("=========用户、桩、平台最小的3===number==="+number);
}
}else{
number=Integer.parseInt(operatorMessage.get("soc").toString());
logger.info("=========用户、桩、平台最小的4===number==="+number);
}
}
if(number !=0){
startChargingData.setSoc(number);
}
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<number>>>>>>>>>>>>>>>>>:"+number);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<Soc>>>>>>>>>>>>>>>>>:"+startChargingData.getSoc());
//创建充电订单(充电启动soc初始值结束是获取,并修改状态)
xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId());
xhpcChargeOrder.setUserId(appUserId);
xhpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId());
xhpcChargeOrder.setGunId(xhpcTerminal.getSerialNumber());
xhpcChargeOrder.setSerialNumber(orderNo);
xhpcChargeOrder.setSource(source);
xhpcChargeOrder.setStatus(-1);
xhpcChargeOrder.setTenantId(tenantId);
if (xhpcChargingPileById != null && xhpcChargingPileById.get("power") != null) {
xhpcChargeOrder.setPower(xhpcChargingPileById.get("power").toString());
}
if (type == 1) {
xhpcChargeOrder.setChargingMode("微信");
} else if (type == 2){
xhpcChargeOrder.setChargingMode("支付宝");
}else if (type == 3){
xhpcChargeOrder.setChargingMode("App");
}else if (type == 4){
xhpcChargeOrder.setChargingMode("刷卡");
}else{
xhpcChargeOrder.setChargingMode("vin码");
}
xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime());
xhpcChargeOrder.setType("91");
if(sunchaStatus==1){
xhpcChargeOrder.setSunchaStatus(1);
}else{
xhpcChargeOrder.setSunchaStatus(2);
}
//获取车牌
Map<String, Object> xhpcUserVehicleMessage = xhpcChargeOrderMapper.getXhpcUserVehicleMessage(xhpcChargeOrder.getUserId(), xhpcChargeOrder.getSource());
if(xhpcUserVehicleMessage !=null && xhpcUserVehicleMessage.get("vehicleName") !=null){
xhpcChargeOrder.setPlateNum(xhpcUserVehicleMessage.get("vehicleName").toString());
}
xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder);
String finalUserType = userType;
executorService.execute(new Runnable() {
@Override
public void run() {
R r1 = powerPileService.startCharging(startChargingData);
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<双枪充电返回>>>>>>>>>>>>>>>>>");
//添加缓存数据
String key = "user:" + appUserId + finalUserType + ".order";
Map<String, Object> map = new HashMap<>();
if(sunchaStatus==1){
map.put("aBalance", bigDecimal);
map.put("aBalanceStatus",-1);
}else{
map.put("bBalance", bigDecimal);
map.put("bBalanceStatus",-1);
}
redisService.setCacheMap(key,map);
if(r1.getCode() == 200){
try{
xhpcChargeOrder.setRateModelId(Long.valueOf(r1.getData().toString()));
xhpcChargeOrderMapper.updateXhpcChargeOrder(xhpcChargeOrder);
//插一帧实时数据
extracted(xhpcChargeOrder);
//修改双枪缓存状态
if(sunchaStatus==1){
map.put("aBalanceStatus",0);
}else{
map.put("bBalanceStatus",0);
}
redisService.setCacheMap(key,map);
}catch (Exception e){
e.printStackTrace();
logger.error("update order[{}] failed.", orderNo);
}
}
}
});
logger.info("<<<<<<<<<1111<<<<<<<<<<双枪启动<<<<<C端订单号>>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+ appUserId);
return AjaxResult.success();
}
public static void main(String[] args) {
try{
// //String alipayPublicKey1 = getAlipayPublicKey("C:\\Users\\Administrator\\Downloads\\alipayCertPublicKey_RSA2.crt");

View File

@ -112,6 +112,7 @@ public class XhpcChargingStationPowerServiceImpl extends BaseService implements
@Override
public List<Map<String, Object>> getListPage(Map<String, Object> params) {
//桩的统计该时段金额
List<Map<String, Object>> list = new ArrayList<>();
//!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())
@ -174,42 +175,6 @@ public class XhpcChargingStationPowerServiceImpl extends BaseService implements
return xhpcChargingStationPowerMapper.getChargingStationId();
}
@Override
public List<Map<String, Object>> getMaxPowerList(Map<String, Object> params) {
Long logUserId = SecurityUtils.getUserId();
LoginUser loginUser = tokenService.getLoginUser();
//桩的统计该时段金额
List<Map<String, Object>> list = new ArrayList<>();
if (loginUser.getUserid() != UserTypeUtil.USER_ID) {
Map<String, Object> landUser = xhpcChargingStationPowerMapper.getLandUser(logUserId);
if (landUser != null) {
if (landUser.get("userType") != null) {
startPage();
if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(landUser.get("userType").toString())) {
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
params.put("status",1);
params.put("userId",logOperatorId);
startPage();
//运营商看自己的场站
list = xhpcChargingStationPowerMapper.getMaxPowerList(params);
} else {
params.put("status",2);
params.put("userId",logUserId);
startPage();
//查询赋值的场站
list = xhpcChargingStationPowerMapper.getMaxPowerList(params);
}
}
}
} else {
params.put("status",0);
startPage();
list = xhpcChargingStationPowerMapper.getMaxPowerList(params);
}
return list;
}
private void addXhpcChargingStationPower(Map<String, Object> map){
XhpcChargingStationPower xhpcChargingStationPower =new XhpcChargingStationPower();
if(map.get("chargeOrderId")!=null){

View File

@ -60,29 +60,29 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
return AjaxResult.error(500, "请重新登录");
}
// if(xhpcPileRegularInspect.getVersionNumberTime()==null || "".equals(xhpcPileRegularInspect.getVersionNumberTime())){
// return AjaxResult.error(500, "版本号检查时间必填");
// }
if(xhpcPileRegularInspect.getVersionNumberTime()==null || "".equals(xhpcPileRegularInspect.getVersionNumberTime())){
return AjaxResult.error(500, "版本号检查时间必填");
}
if(xhpcPileRegularInspect.getTimingPriceTime()==null || "".equals(xhpcPileRegularInspect.getTimingPriceTime())){
return AjaxResult.error(500, "校时校价时间必填");
}
// if(xhpcPileRegularInspect.getRateTime()==null || "".equals(xhpcPileRegularInspect.getRateTime())){
// return AjaxResult.error(500, "费率时间必填");
// }
// if(xhpcPileRegularInspect.getCopyingAdministratorTime()==null || "".equals(xhpcPileRegularInspect.getCopyingAdministratorTime())){
// return AjaxResult.error(500, "定期抄发给管理员时间必填");
// }
// try{
// String[] split = xhpcPileRegularInspect.getVersionNumberTime().split(",");
// for (int i = 0; i <split.length ; i++) {
// int s = Integer.parseInt(split[i]);
// if(s<0 ||s>24){
// return AjaxResult.error(500, "版本号检查时间格式不对");
// }
// }
// }catch (Exception e){
// return AjaxResult.error(500, "版本号检查时间格式不对");
// }
if(xhpcPileRegularInspect.getRateTime()==null || "".equals(xhpcPileRegularInspect.getRateTime())){
return AjaxResult.error(500, "费率时间必填");
}
if(xhpcPileRegularInspect.getCopyingAdministratorTime()==null || "".equals(xhpcPileRegularInspect.getCopyingAdministratorTime())){
return AjaxResult.error(500, "定期抄发给管理员时间必填");
}
try{
String[] split = xhpcPileRegularInspect.getVersionNumberTime().split(",");
for (int i = 0; i <split.length ; i++) {
int s = Integer.parseInt(split[i]);
if(s<0 ||s>24){
return AjaxResult.error(500, "版本号检查时间格式不对");
}
}
}catch (Exception e){
return AjaxResult.error(500, "版本号检查时间格式不对");
}
try{
String[] split = xhpcPileRegularInspect.getTimingPriceTime().split(",");
for (int i = 0; i <split.length ; i++) {
@ -95,26 +95,26 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
return AjaxResult.error(500, "校时校价时格式不对");
}
// try{
// String[] split = xhpcPileRegularInspect.getRateTime().split(",");
// for (int i = 0; i <split.length ; i++) {
// int s = Integer.parseInt(split[i]);
// if(s<0 ||s>24){
// return AjaxResult.error(500, "定期抄发给管理员时间格式不对");
// }
// }
// }catch (Exception e){
// return AjaxResult.error(500, "定期抄发给管理员时间格式不对");
// }
try{
String[] split = xhpcPileRegularInspect.getRateTime().split(",");
for (int i = 0; i <split.length ; i++) {
int s = Integer.parseInt(split[i]);
if(s<0 ||s>24){
return AjaxResult.error(500, "定期抄发给管理员时间格式不对");
}
}
}catch (Exception e){
return AjaxResult.error(500, "定期抄发给管理员时间格式不对");
}
try{
// String[] split = xhpcPileRegularInspect.getCopyingAdministratorTime().split(",");
// for (int i = 0; i <split.length ; i++) {
// int s = Integer.parseInt(split[i]);
// if(s<0 ||s>24){
// return AjaxResult.error(500, "费率式不对");
// }
// }
String[] split = xhpcPileRegularInspect.getCopyingAdministratorTime().split(",");
for (int i = 0; i <split.length ; i++) {
int s = Integer.parseInt(split[i]);
if(s<0 ||s>24){
return AjaxResult.error(500, "费率式不对");
}
}
if(xhpcPileRegularInspect.getPileRegularInspectId()==null){
Map<String, Object> map = xhpcPileRegularInspectMapper.getPileRegularInspectTenantId(tenantId);
if(map !=null){
@ -253,12 +253,6 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX
}
public static void main(String[] args) {
String times = DateUtil.formatTime(new Date());
String [] time =times.split(":");
for (int i = 0; i <time.length ; i++) {
System.out.println("=====:"+time[i]);
}
}
}

View File

@ -1,6 +1,5 @@
package com.xhpc.order.service.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@ -205,19 +204,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo);
xhpcRealTimeOrderBms.setChargingOrderId(xhpcChargeOrder.getChargeOrderId());
xhpcRealTimeOrderBms.setCreateTime(new Date());
String key ="orderOutpu:"+orderNo;
XhpcRealTimeOrderBms bms = redisService.getCacheObject(key);
if(bms==null){
redisService.setCacheObject(key,xhpcRealTimeOrderBms);
}else{
BigDecimal bigDecimal1 = new BigDecimal(bms.getPileVoltageOutput()).multiply(BigDecimal.valueOf(bms.getPileCurrentOutput())).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal bigDecimal2 = new BigDecimal(xhpcRealTimeOrderBms.getPileVoltageOutput()).multiply(BigDecimal.valueOf(xhpcRealTimeOrderBms.getPileCurrentOutput())).setScale(2, BigDecimal.ROUND_CEILING);
if(bigDecimal1.compareTo(bigDecimal2)<0){
redisService.setCacheObject(key,xhpcRealTimeOrderBms);
}
}
xhpcRealTimeOrderMapper.insertRealTimeOrderBms(xhpcRealTimeOrderBms);
}
@ -243,13 +229,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
public Map<String, Object> getExamineMessage(Long realTimeOrderId,Long chargeOrderId) {
if(realTimeOrderId==null){
Map<String, Object> message = xhpcRealTimeOrderMapper.getMessageChargeOrderId(chargeOrderId);
if(message.get("createTime") !=null && message.get("startTime")==null && message.get("endTime")==null){
message.put("startTime",message.get("createTime").toString());
DateTime parse = DateUtil.parse(message.get("createTime").toString(), "yyyy-MM-dd HH:mm:ss");
DateTime dateTime = DateUtil.offset(parse, DateField.MILLISECOND,10000);
message.put("endTime",DateUtil.format(dateTime, "yyyy-MM-dd HH:mm:ss"));
}
message.put("powerPriceTotal",0);
message.put("servicePriceTotal",0);
message.put("chargingDegree",0);
@ -635,33 +614,23 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
}
//生成一条历史订单
if("微信".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("微信");
}
if("支付宝".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("支付宝");
}
if("刷卡".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("刷卡");
}
if("VIN码".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("VIN码");
}
if("川逸充".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("川逸充");
}
if("快电".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("1");
}
if("恒大".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("2");
}
if("新电途".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("3");
}
if("小桔".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("4");
if(UserTypeUtil.INTERNET_TYPE ==xhpcChargeOrder.getSource()){
xhpcHistoryOrder.setChargingMode(xhpcChargeOrder.getUserId()+"");
}else{
if("微信".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("微信");
}
if("支付宝".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("支付宝");
}
if("刷卡".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("刷卡");
}
}
xhpcHistoryOrder.setStartTime(xhpcChargeOrder.getStartTime());
if(xhpcChargeOrder.getEndTime()==null ){
xhpcHistoryOrder.setEndTime(xhpcChargeOrder.getStartTime());
@ -702,33 +671,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
public R addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map<String, Object> userMessage, Integer type, String vinNormal, XhpcHistoryOrder xhpcHistoryOrder) {
logger.info("<<<<<<<<<<<<<<<进入结算>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
try{
if("微信".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("微信");
}
if("支付宝".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("支付宝");
}
if("刷卡".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("刷卡");
}
if("VIN码".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("VIN码");
}
if("川逸充".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("川逸充");
}
if("快电".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("1");
}
if("恒大".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("2");
}
if("新电途".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("3");
}
if("小桔".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("4");
}
xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setTotalPrice(money.setScale(2, BigDecimal.ROUND_HALF_UP));
@ -780,6 +722,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
logger.info("<<<<<<<<<<<<<<<判断是否有活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
boolean judge =false;
if(source==UserTypeUtil.INTERNET_TYPE && internetSerialNumber!=null && xhpcChargeOrder.getStartTime()!=null && xhpcChargeOrder.getEndTime()!=null && money.compareTo(new BigDecimal(0))>=1){
xhpcHistoryOrder.setChargingMode(xhpcChargeOrder.getUserId()+"");
xhpcHistoryOrder.setInternetSerialNumber(xhpcChargeOrder.getInternetSerialNumber());
Double totalPower = xhpcHistoryOrder.getTotalPower();
boolean activityInternet =false;
@ -945,6 +888,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
if(operatorIdEvcs.get("operatorIdEvcs")!=null && operatorIdEvcs.get("commissionType")!=null && operatorIdEvcs.get("commissionRate")!=null){
BigDecimal commissionRate = new BigDecimal(operatorIdEvcs.get("commissionRate").toString()).divide(new BigDecimal(100));
String commissionType = operatorIdEvcs.get("commissionType").toString();
if(operatorIdEvcs.get("internetUserId") !=null){
xhpcHistoryOrder.setChargingMode(operatorIdEvcs.get("internetUserId").toString());
}
//0总金额提成 1服务费提成
if(new BigDecimal(0).compareTo(commissionRate)==-1){
if("0".equals(commissionType) || "1".equals(commissionType)|| "2".equals(commissionType)){
@ -1200,6 +1146,21 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
surplusServicePrice = surplusServicePrice.subtract(multiply2);
}
}
if("微信".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("微信");
}
if("支付宝".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("支付宝");
}
if("刷卡".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("刷卡");
}
if("VIN码".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("VIN码");
}
if("川逸充".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("川逸充");
}
}else{
//订单异常
xhpcChargeOrder.setStatus(2);
@ -1345,7 +1306,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
map.put("remark","充电结算自动申请退款");
}
}
xhpcHistoryOrder.setUserNameEvcs(xhpcChargeOrder.getDriverId());
xhpcHistoryOrder.setPhone(xhpcChargeOrder.getDriverId());
logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>getUserNameEvcs>>>>>>>>>>>>"+xhpcHistoryOrder.getUserNameEvcs());
logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>getPhone>>>>>>>>>>>>"+xhpcHistoryOrder.getPhone());
@ -1361,7 +1323,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
final String refundTypes =refundType;
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
// 另起线程处理业务上传redis数据
BigDecimal finalActPrice = actPrice;
executorService.execute(new Runnable() {
@Override
public void run() {
@ -1430,85 +1391,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
try{
//双枪修改逻辑查询是否是双枪
if(xhpcChargeOrder.getSunchaStatus()!=0){
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==xhpcChargeOrder.getSource()){
userType =UserTypeUtil.CUSTOMERS;
}
Map<String, Object> map = new HashMap<>();
String key = "user:" + xhpcChargeOrder.getUserId() + userType + ".order";
Map<String, Object> cacheMap = redisService.getCacheMap(key);
if(xhpcChargeOrder.getSunchaStatus()==1){
map.put("aBalanceStatus",1);
BigDecimal aBalance = new BigDecimal(cacheMap.get("aBalance").toString()).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_CEILING);
BigDecimal subtract = aBalance.subtract(finalActPrice);
map.put("aBalance",subtract.multiply(new BigDecimal(100)).toString());
xhpcChargeOrderService.updateUserSunchaBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId(),1);
}else{
map.put("bBalanceStatus",1);
BigDecimal bBalance = new BigDecimal(cacheMap.get("bBalance").toString()).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_CEILING);
BigDecimal subtract = bBalance.subtract(finalActPrice);
map.put("bBalance",subtract.multiply(new BigDecimal(100)).toString());
xhpcChargeOrderService.updateUserSunchaBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId(),2);
}
redisService.setCacheMap(key,map);
boolean a =true; //A账户未有充电中异常订单
boolean b =true; //b账户未有充电中异常订单
//查询所有状态
if(cacheMap.get("aBalanceStatus")!=null){
Integer status = Integer.valueOf(cacheMap.get("aBalanceStatus").toString());
if(status==0 || status==2){
a =false;
}
}
if(cacheMap.get("bBalanceStatus")!=null){
Integer status = Integer.valueOf(cacheMap.get("bBalanceStatus").toString());
if(status==0 || status==2){
b =false;
}
}
if(a && b){
String i = xhpcChargeOrderService.countXhpcRealTimeOrder(xhpcChargeOrder.getUserId(),xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId());
if (!"".equals(i) && i!=null) {
//"车辆正在充电,请查询车辆充电信息"
}else{
//退款判断A+B账号金额 = 总金额
R user = userTypeService.getUser(null, userId, source, null, tenantId);
if(user !=null && user.getData() !=null ){
Map<String, Object> userMap = (Map<String, Object>)user.getData();
if (userMap == null || userMap.get("balance") == null) {
//获取用户信息失败
}else{
BigDecimal balance = new BigDecimal(userMap.get("balance").toString());
BigDecimal aBalance = new BigDecimal(userMap.get("aBalance").toString());
BigDecimal bBbalance = new BigDecimal(userMap.get("bBbalance").toString());
if(balance.compareTo(aBalance.add(bBbalance))==0){
//退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
redisService.deleteObject(key);
}
}
}
}
}
}
}
}
}else{
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
}
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
}
}
}
@ -1534,8 +1421,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
evcsService.getCYCNotificationConnectorChargeStatus(orderMap);
logger.info("<<<<<<<<<22<<<<<<<川逸充,调用订单结束推送>>>>>>>>>>>>>orderMap>>>>"+orderMap.toString());
}
}
});
//小华充电二台子社区充电站 道闸
@ -1678,22 +1563,6 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcHistoryOrderService.insertXhpcWorkHistoryOrderDto(xhpcWorkHistoryOrderDto);
logger.info("<<<<<<<<<<<<<<<<入库成功>>>>>>>>>订单号:>>>");
}
//存储订单最大功率数据
String key ="orderOutpu:"+orderNo;
XhpcRealTimeOrderBms bms = redisService.getCacheObject(key);
if(bms!=null){
XhpcOrderOutputMax max=new XhpcOrderOutputMax();
BeanUtils.copyProperties(bms,max);
max.setCountPileOutput(new BigDecimal(max.getPileVoltageOutput()).multiply(new BigDecimal(max.getPileCurrentOutput())).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_CEILING).doubleValue());
max.setCountBmsRequest(new BigDecimal(max.getBmsVoltageRequest()).multiply(new BigDecimal(max.getBmsCurrentRequest())).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_CEILING).doubleValue());
max.setChargeOrderId(xhpcChargeOrder.getChargeOrderId());
max.setChargingStationId(xhpcChargeOrder.getChargingStationId());
max.setTerminalId(xhpcChargeOrder.getTerminalId());
max.setBmsChargingVolt(bms.getBmsChargingVolt());
max.setBmsChargingCurrent(bms.getBmsChargingCurrent());
xhpcRealTimeOrderMapper.insertOrderOutputMax(max);
}
}catch (Exception e){
}
@ -1867,37 +1736,12 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcHistoryOrder.setEndSoc(xhpcChargeOrder.getEndSoc());
Date date = new Date();
xhpcHistoryOrder.setCreateTime(date);
if("微信".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("微信");
}
if("支付宝".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("支付宝");
}
if("刷卡".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("刷卡");
}
if("VIN码".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("VIN码");
}
if("川逸充".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("川逸充");
}
if("快电".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("1");
}
if("恒大".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("2");
}
if("新电途".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("3");
}
if("小桔".equals(xhpcChargeOrder.getChargingMode())){
xhpcHistoryOrder.setChargingMode("4");
}
Map<String, Object> pushOrder = redisService.getCacheMap("pushOrder:"+xhpcChargeOrder.getSerialNumber());
if(pushOrder !=null){
if(pushOrder.get("internetSerialNumber") !=null){
xhpcHistoryOrder.setInternetSerialNumber(pushOrder.get("internetSerialNumber").toString());
xhpcHistoryOrder.setChargingMode(xhpcChargeOrder.getUserId()+"");
}
if(pushOrder.get("operatorId3rdpty") !=null){
xhpcHistoryOrder.setOperatorId3rdptyEvcs((String) pushOrder.get("operatorId3rdpty"));
}
@ -2231,15 +2075,10 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
public static void main(String[] args) {
// WxMessageSend("ot6ul4nlSC5ZZOC4rTLS5hedFTGk","69_G2hFrelhCsfOPuFB6OPP5I8j_DKdP-N6QF-shvpUFT2mQ-KjonSxbS_mrP5P9nYyat9OsJLZAcbYA4g5rWdn0i6whxueiU3hWfguoeqSnick1zAGvu7SKa50_VkKPAcAGABGR","黄金东二路","80","76.6");
// String st ="小华充电润茂酒店用品城汽车充电站1";
// String str = st.replace("小华充电", "").substring(0,13);
// System.out.println(str);
String st ="小华充电润茂酒店用品城汽车充电站1";
String str = st.replace("小华充电", "").substring(0,13);
System.out.println(str);
String createTime="2024-07-03 22:57:12";
DateTime parse = DateUtil.parse(createTime, "yyyy-MM-dd HH:mm:ss");
DateTime dateTime = DateUtil.offset(parse, DateField.MILLISECOND,10000);
String format = DateUtil.format(dateTime, "yyyy-MM-dd HH:mm:ss");
System.out.println("format====:"+format);
}

View File

@ -1048,7 +1048,7 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
}
/**
* 今日订单量
* 今日订单量今日订电量今日营收今日充电枪状态
*
* @param operatorId
* @param chargingStationId
@ -1077,76 +1077,26 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
Long logOperatorId = sysUser.getOperatorId();
//今日订单量
extracted(1,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, lastBeginOfDay, lastEndOfDay, weekBeginOfDay, weekEndOfDay, map, logOperatorId);
}else{
//今日订单量
extracted(2,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, lastBeginOfDay, lastEndOfDay, weekBeginOfDay, weekEndOfDay, map, logUserId);
}
}else{
//今日订单量
extracted(0,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, lastBeginOfDay, lastEndOfDay, weekBeginOfDay, weekEndOfDay, map, null);
}
}
return map;
}
@Override
public Map<String, Object> getOrderElectricityQuantity(Long operatorId, Long chargingStationId, Long chargingPileId, Integer type) {
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
Long logUserId = SecurityUtils.getUserId();
SysUser sysUser = loginUser.getSysUser();
//今日订单量
//今天时间格式 yyyy-mm-dd
String beginOfDay= DateUtil.formatDateTime(DateUtil.beginOfDay(new Date()));
String endOfDay= DateUtil.formatDateTime(DateUtil.endOfDay(new Date()));
Map<String ,Object> map =new HashMap<>();
if(tenantId !=null && !"".equals(tenantId)){
if(sysUser.getUserId() !=UserTypeUtil.USER_ID){
if ("01".equals(sysUser.getUserType())) {
Long logOperatorId = sysUser.getOperatorId();
//今日电量
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(1, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
map.put("todayDegree",todayDegreeNUmber);
}else{
//今日电量
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(2, logUserId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
map.put("todayDegree",todayDegreeNUmber);
}
}else{
//今日电量
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(0, null, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
map.put("todayDegree",todayDegreeNUmber);
}
}
return map;
}
@Override
public Map<String, Object> getTodayRrevenue(Long operatorId, Long chargingStationId, Long chargingPileId, Integer type) {
//* 今日订单量今日订电量今日营收今日充电枪状态
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
Long logUserId = SecurityUtils.getUserId();
SysUser sysUser = loginUser.getSysUser();
//今日订单量
//今天时间格式 yyyy-mm-dd
String beginOfDay= DateUtil.formatDateTime(DateUtil.beginOfDay(new Date()));
String endOfDay= DateUtil.formatDateTime(DateUtil.endOfDay(new Date()));
Map<String ,Object> map =new HashMap<>();
if(tenantId !=null && !"".equals(tenantId)){
if(sysUser.getUserId() !=UserTypeUtil.USER_ID){
if ("01".equals(sysUser.getUserType())) {
Long logOperatorId = sysUser.getOperatorId();
//今日营收
extracted(1,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logOperatorId);
}else{
//今日订单量
extracted(2,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, lastBeginOfDay, lastEndOfDay, weekBeginOfDay, weekEndOfDay, map, logUserId);
//今日电量
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(2, logUserId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
map.put("todayDegree",todayDegreeNUmber);
//今日营收
extracted(2,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, logUserId);
}
}else{
//今日订单量
extracted(0,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, lastBeginOfDay, lastEndOfDay, weekBeginOfDay, weekEndOfDay, map, null);
//今日电量
int todayDegreeNUmber = xhpcStatisticsServiceMapper.getTodayDegreeNUmber(0, null, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
map.put("todayDegree",todayDegreeNUmber);
//今日营收
extracted(0,operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay, map, null);
}
@ -1773,27 +1723,27 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
private void extracted(Integer status, Long operatorId, Long chargingStationId, Long chargingPileId, String tenantId, String beginOfDay, String endOfDay, String lastBeginOfDay, String lastEndOfDay, String weekBeginOfDay, String weekEndOfDay, Map<String, Object> map, Long logOperatorId) {
List<Map<String,Object>> list = xhpcStatisticsServiceMapper.getTodayStatusNumber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
//int todayOrderCount = xhpcStatisticsServiceMapper.getTodayOrderNumber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
// int t1 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, lastBeginOfDay, lastEndOfDay);
// int t2 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, weekBeginOfDay, weekEndOfDay);
// Map<String,Object> todayStatusNUmber = new HashMap<>();
//
// if(t1==0.0 && t2==0.0){
// todayStatusNUmber.put("weekNumber",0);
// todayStatusNUmber.put("type",true);
// }else if (t1==0.0){
// BigDecimal divide2 = new BigDecimal(t2).multiply(new BigDecimal(100));
// todayStatusNUmber.put("weekNumber",divide2);
// todayStatusNUmber.put("type",false);
// }else if(t2==0.0){
// todayStatusNUmber.put("weekNumber",100);
// todayStatusNUmber.put("type",true);
// }else{
// BigDecimal divide1 = new BigDecimal(t1 - t2).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
// BigDecimal divide2 = new BigDecimal(t2 - t1).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
// todayStatusNUmber.put("weekNumber",t1-t2>0?divide1:divide2);
// todayStatusNUmber.put("type",t1-t2>0?true:false);
// }
int todayOrderCount = xhpcStatisticsServiceMapper.getTodayOrderNumber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, beginOfDay, endOfDay);
int t1 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, lastBeginOfDay, lastEndOfDay);
int t2 = xhpcStatisticsServiceMapper.getTodayNUmber(status, logOperatorId, operatorId, chargingStationId, chargingPileId, tenantId, weekBeginOfDay, weekEndOfDay);
Map<String,Object> todayStatusNUmber = new HashMap<>();
if(t1==0.0 && t2==0.0){
todayStatusNUmber.put("weekNumber",0);
todayStatusNUmber.put("type",true);
}else if (t1==0.0){
BigDecimal divide2 = new BigDecimal(t2).multiply(new BigDecimal(100));
todayStatusNUmber.put("weekNumber",divide2);
todayStatusNUmber.put("type",false);
}else if(t2==0.0){
todayStatusNUmber.put("weekNumber",100);
todayStatusNUmber.put("type",true);
}else{
BigDecimal divide1 = new BigDecimal(t1 - t2).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
BigDecimal divide2 = new BigDecimal(t2 - t1).divide(new BigDecimal(t1),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
todayStatusNUmber.put("weekNumber",t1-t2>0?divide1:divide2);
todayStatusNUmber.put("type",t1-t2>0?true:false);
}
if(list ==null || list.size()==0){
List<Map<String,Object>> mapList =new ArrayList<>();
Map<String,Object> objectMap =new HashMap<>();
@ -1839,8 +1789,8 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
}else{
map.put("todayOrder",list);
}
// map.put("todayOrderCount",todayOrderCount);
// map.put("todayOrderWeek",todayStatusNUmber);
map.put("todayOrderCount",todayOrderCount);
map.put("todayOrderWeek",todayStatusNUmber);
}
/**

View File

@ -34,7 +34,6 @@
<result column="charging_time_number" property="chargingTimeNumber"/>
<result column="tenant_id" property="tenantId"/>
<result column="charging_capacity" property="chargingCapacity"/>
<result column="suncha_status" property="sunchaStatus"/>
</resultMap>
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcTerminal">
@ -97,26 +96,9 @@
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
</if>
<if test="sunchaStatus ==1">
and suncha_status !=0
</if>
and source =#{userType}
</select>
<select id="getUserTypeSunchaSwitch" resultType="int">
<if test="userType==0">
select suncha_switch from xhpc_app_user where app_user_id=#{userId} and del_flag =0
</if>
<if test="userType==2">
select suncha_switch from xhpc_community_personnel where community_personnel_id=#{userId} and del_flag =0
</if>
<if test="userType==3">
select suncha_switch from xhpc_customers_personnel where customers_personnel_id=#{userId} and del_flag =0
</if>
</select>
<select id="getMessage" resultType="map">
select
rto.real_time_order_id as realTimeOrderId,
@ -162,42 +144,13 @@
<update id="updateUserBalance">
update xhpc_app_user set balance=#{balance} where app_user_id=#{userId}
</update>
<update id="updateUserSunchaBalance">
update xhpc_app_user
<set>
<if test="sunchaStatus==1">a_balance = #{balance}</if>
<if test="sunchaStatus==2">b_balance = #{balance}</if>
</set>
where app_user_id=#{userId}
</update>
<update id="updateCommunityBalance">
update xhpc_community_personnel set surplus_money=#{balance} where community_personnel_id=#{userId}
</update>
<update id="updateCommunitySunchaBalance">
update xhpc_community_personnel
<set>
<if test="sunchaStatus==1">a_balance = #{balance}</if>
<if test="sunchaStatus==2">b_balance = #{balance}</if>
</set>
where community_personnel_id=#{userId}
</update>
<update id="updateCustomersBalance">
update xhpc_customers_personnel set surplus_money=#{balance} where customers_personnel_id=#{userId}
</update>
<update id="updateCustomersSunchaBalance">
update xhpc_customers_personnel
<set>
<if test="sunchaStatus==1">a_balance = #{balance}</if>
<if test="sunchaStatus==2">b_balance = #{balance}</if>
</set>
where customers_personnel_id=#{userId}
</update>
<update id="updateAppInternetUserBalance">
update xhpc_app_internet_user set balance=#{balance} where app_internet_user_id=#{userId}
</update>
@ -326,9 +279,6 @@
<if test="null != chargingCapacity">
charging_capacity,
</if>
<if test="null != sunchaStatus">
suncha_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargingStationId ">
@ -415,9 +365,6 @@
<if test="null != chargingCapacity">
#{chargingCapacity},
</if>
<if test="null != sunchaStatus">
#{sunchaStatus},
</if>
</trim>
</insert>
@ -781,6 +728,7 @@
</insert>
<select id="selectDate3rdNeedBy" resultType="map">
select xt.charging_station_id as chargingStationId,
xt.terminal_id as terminalId,
cs.rate_model_id as rateModelId,
@ -873,49 +821,4 @@
from xhpc_charging_station xcs
where xcs.charging_station_id =#{chargingStationId}
</select>
<update id="updateXhpcAppUser">
update xhpc_app_user set a_balance=#{aBalance}, b_balance =#{bBalance} where app_user_id=#{userId}
</update>
<update id="updateXhpcCommunityPersonnel">
update xhpc_community_personnel set a_balance=#{aBalance}, b_balance =#{bBalance} where community_personnel_id=#{userId}
</update>
<update id="updateXhpcCustomersPersonnel">
update xhpc_customers_personnel set a_balance=#{aBalance}, b_balance =#{bBalance} where customers_personnel_id=#{userId}
</update>
<select id="getBlacklistUser" resultType="int">
select count(blacklist_id)
from xhpc_blacklist
where distinguish =1
and (
<choose>
<when test="phone !=null and phone !='' and vin !=null and vin !='' and plateNnum !=null and plateNnum !=''">
phone=#{phone} or vin =#{vin} or plate_num=#{plateNnum}
</when>
<when test="phone !=null and phone !='' and vin !=null and vin !=''">
phone=#{phone} or vin =#{vin}
</when>
<when test="vin !=null and vin !='' and plateNnum !=null and plateNnum !=''">
vin =#{vin} or plate_num=#{plateNnum}
</when>
<when test="phone !=null and phone !='' and plateNnum !=null and plateNnum !=''">
phone=#{phone} or plate_num=#{plateNnum}
</when>
<when test="phone !=null and phone !=''">
phone=#{phone}
</when>
<when test="vin !=null and vin !=''">
vin =#{vin}
</when>
<otherwise>
plate_num=#{plateNnum}
</otherwise>
</choose>
)
and blacklist_id in (select mechanism_id from xhpc_mechanism where source =2 and del_flag =0 and charging_station_id =#{chargingStationId} )
and start_time &lt;= #{time} and end_time &gt;= #{time}
</select>
</mapper>

View File

@ -157,7 +157,6 @@
</if>
</trim>
</insert>
<select id="getListPage" resultType="map">
select
xcs.name as chargingStationName,
@ -197,89 +196,95 @@
ORDER BY DATE_FORMAT(xcsp.create_time,'%Y-%m-%d'),xcsp.charging_station_id
</select>
<select id="getLandUser" resultType="map">
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<select id="getMaxPowerList" resultType="map">
select
xcs.name as chargingStationName,
concat(xcp.name ,"号桩")as chargingPileName,
xt.name as terminalName,
DATE_FORMAT(xoom.create_time,'%Y-%m-%d') time,
xoom.count_pile_output as countPileOutput,
xoom.pile_voltage_output as pileVoltageOutput,
xoom.pile_current_output as pileCurrentOutput,
xoom.count_bms_request as countBmsRequest,
xoom.bms_voltage_request as bmsVoltageRequest,
xoom.bms_current_request as bmsCurrentRequest
from xhpc_order_output_max xoom
left join xhpc_charging_station as xcs on xcs.charging_station_id = xoom.charging_station_id
left join xhpc_terminal as xt on xt.terminal_id = xoom.terminal_id
left join xhpc_charging_pile as xcp on xcp.charging_pile_id = xt.charging_pile_id
where xoom.del_flag = 0
<if test="params.status==1">
and xoom.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{params.userId})
</if>
<if test="params.status==2">
and xoom.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{params.userId})
</if>
<if test="params.chargingStationId !=null">
and xoom.charging_station_id =#{params.chargingStationId}
</if>
<if test="params.chargingPileId !=null">
and xcp.charging_pile_id =#{params.chargingPileId}
</if>
<if test="params.terminalId !=null">
and xoom.terminal_id =#{params.terminalId}
</if>
<if test="params.operatorId !=null">
and xoom.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{params.operatorId})
</if>
<if test="params.startTime !=null and params.startTime !=''">
and DATE_FORMAT(xoom.create_time,'%Y-%m-%d') &gt;=#{params.startTime}
</if>
<if test="params.endTime !=null and params.endTime !=''">
and DATE_FORMAT(xoom.create_time,'%Y-%m-%d') &lt;= #{params.endTime}
</if>
<if test="params.pileStart !=null and params.pileStart !=''">
and xoom.count_pile_output &gt;=#{params.pileStart}
</if>
<if test="params.pileEnd !=null and params.pileEnd !=''">
and xoom.count_pile_output &lt;=#{params.pileEnd}
</if>
<if test="params.bmsStart !=null and params.bmsStart !=''">
and xoom.count_bms_request &gt;=#{params.bmsStart}
</if>
<if test="params.bmsEnd !=null and params.bmsEnd !=''">
and xoom.count_bms_request &lt;=#{params.bmsEnd}
</if>
<if test="params.pileVoltageStart !=null and params.pileVoltageStart !=''">
and xoom.pile_voltage_output &gt;=#{params.pileVoltageStart}
</if>
<if test="params.pileVoltageEnd !=null and params.pileVoltageEnd !=''">
and xoom.pile_voltage_output &lt;=#{params.pileVoltageEnd}
</if>
<if test="params.pileCurrentStart !=null and params.pileCurrentStart !=''">
and xoom.pile_current_output &gt;=#{params.pileCurrentStart}
</if>
<if test="params.pileCurrentEnd !=null and params.pileCurrentEnd !=''">
and xoom.pile_current_output &lt;=#{params.pileCurrentEnd}
</if>
<if test="params.bmsVoltageStart !=null and params.bmsVoltageStart !=''">
and xoom.bms_voltage_request &gt;=#{params.bmsVoltageStart}
</if>
<if test="params.bmsVoltageEnd !=null and params.bmsVoltageEnd !=''">
and xoom.bms_voltage_request &lt;=#{params.bmsVoltageEnd}
</if>
<if test="params.bmsCurrentStart !=null and params.bmsCurrentStart !=''">
and xoom.bms_charging_current &gt;=#{params.bmsCurrentStart}
</if>
<if test="params.bmsCurrentEnd !=null and params.bmsCurrentEnd !=''">
and xoom.bms_charging_current &lt;=#{params.bmsCurrentEnd}
</if>
ORDER BY DATE_FORMAT(xoom.create_time,'%Y-%m-%d') desc
</select>
<!-- <select id="getListPage" resultType="map">-->
<!-- select-->
<!-- xcs.name as chargingStationName,-->
<!-- xcsp.status as status,-->
<!-- xcsp.voltage as voltage,-->
<!-- xcsp.current as current,-->
<!-- format(ifnull((xcsp.voltage*xcsp.current),0),2) as power,-->
<!-- case when xcsp.status=0 then "00:00"-->
<!-- when xcsp.status=1 then "00:30"-->
<!-- when xcsp.status=2 then "01:00"-->
<!-- when xcsp.status=3 then "01:30"-->
<!-- when xcsp.status=4 then "02:00"-->
<!-- when xcsp.status=5 then "02:30"-->
<!-- when xcsp.status=6 then "03:00"-->
<!-- when xcsp.status=7 then "03:30"-->
<!-- when xcsp.status=8 then "04:00"-->
<!-- when xcsp.status=9 then "04:30"-->
<!-- when xcsp.status=10 then "05:00"-->
<!-- when xcsp.status=11 then "05:30"-->
<!-- when xcsp.status=12 then "06:00"-->
<!-- when xcsp.status=13 then "06:30"-->
<!-- when xcsp.status=14 then "07:00"-->
<!-- when xcsp.status=15 then "07:30"-->
<!-- when xcsp.status=16 then "08:00"-->
<!-- when xcsp.status=17 then "08:30"-->
<!-- when xcsp.status=18 then "09:00"-->
<!-- when xcsp.status=19 then "09:30"-->
<!-- when xcsp.status=20 then "10:00"-->
<!-- when xcsp.status=21 then "10:30"-->
<!-- when xcsp.status=22 then "11:00"-->
<!-- when xcsp.status=23 then "11:30"-->
<!-- when xcsp.status=24 then "12:00"-->
<!-- when xcsp.status=25 then "12:30"-->
<!-- when xcsp.status=26 then "13:00"-->
<!-- when xcsp.status=27 then "13:30"-->
<!-- when xcsp.status=28 then "14:30"-->
<!-- when xcsp.status=29 then "15:00"-->
<!-- when xcsp.status=30 then "15:00"-->
<!-- when xcsp.status=31 then "15:30"-->
<!-- when xcsp.status=32 then "16:00"-->
<!-- when xcsp.status=33 then "16:30"-->
<!-- when xcsp.status=34 then "17:00"-->
<!-- when xcsp.status=35 then "17:30"-->
<!-- when xcsp.status=36 then "18:00"-->
<!-- when xcsp.status=37 then "18:30"-->
<!-- when xcsp.status=38 then "19:00"-->
<!-- when xcsp.status=39 then "19:30"-->
<!-- when xcsp.status=40 then "20:00"-->
<!-- when xcsp.status=41 then "20:30"-->
<!-- when xcsp.status=42 then "21:00"-->
<!-- when xcsp.status=43 then "21:30"-->
<!-- when xcsp.status=44 then "22:00"-->
<!-- when xcsp.status=45 then "22:30"-->
<!-- when xcsp.status=46 then "23:00"-->
<!-- when xcsp.status=47 then "23:30"-->
<!-- end time-->
<!-- from xhpc_charging_station_power as xcsp-->
<!-- left join xhpc_charging_station as xcs on xcs.charging_station_id = xcsp.charging_station_id-->
<!-- left join xhpc_charging_pile as xcp on xcp.charging_pile_id = xcsp.charging_pile_id-->
<!-- left join xhpc_terminal as xt on xt.terminal_id = xcsp.terminal_id-->
<!-- where xcsp.del_flag = 0-->
<!-- <if test="params.chargingStationId !=null">-->
<!-- and xcsp.charging_station_id =#{params.chargingStationId}-->
<!-- </if>-->
<!-- <if test="params.chargingPileId !=null">-->
<!-- and xcsp.charging_pile_id =#{params.chargingPileId}-->
<!-- </if>-->
<!-- <if test="params.terminalId !=null">-->
<!-- and xcsp.terminal_id =#{params.terminalId}-->
<!-- </if>-->
<!-- <if test="params.operatorId !=null">-->
<!-- and xcsp.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{params.operatorId})-->
<!-- </if>-->
<!-- <if test="params.startTime !=null and params.startTime !=''">-->
<!-- and xcsp.terminal_id =#{params.startTime}-->
<!-- </if>-->
<!-- <if test="params.endTime !=null and params.endTime !=''">-->
<!-- and xcsp.terminal_id =#{params.endTime}-->
<!-- </if>-->
<!-- <if test="params.number==1">-->
<!-- and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})-->
<!-- </if>-->
<!-- <if test="params.number==2">-->
<!-- and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})-->
<!-- </if>-->
<!-- GROUP BY xcsp.status-->
<!-- </select>-->
</mapper>

View File

@ -1050,13 +1050,12 @@
when ho.charging_mode="4" then "小桔"
when ho.charging_mode="微信" then "微信"
when ho.charging_mode="支付宝" then "支付宝"
when ho.charging_mode="App" then "App"
when ho.charging_mode="刷卡" then "刷卡"
else "vin码"
else "刷卡"
end chargingModeName
from xhpc_history_order as ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
@ -1064,7 +1063,6 @@
left join xhpc_app_user as apu on apu.app_user_id = ho.user_id and ho.internet_serial_number is null and ho.source=0
left join xhpc_community_personnel as cop on cop.community_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=2
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = ho.user_id and ho.internet_serial_number is null and ho.source=3
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
<if test="number==1">
inner join (
select hio.history_order_id as history_order_id from xhpc_history_order as hio INNER JOIN xhpc_app_user as xau on xau.app_user_id = hio.user_id where xau.phone LIKE concat('%',#{phone}, '%')
@ -1300,10 +1298,10 @@
ho.activity_total_price as activityTotalPrice,
ho.create_time as createTime
from xhpc_history_order ho
left join xhpc_charging_station cs on cs.charging_station_id = ho.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
where ho.state = #{state} and ho.total_price is not null
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.state = #{state} and ho.total_price is not null
limit 0,#{number}
</select>
@ -1343,9 +1341,9 @@
ho.activity_total_price as activityTotalPrice,
ho.create_time as createTime
from xhpc_history_order ho
left join xhpc_charging_station cs on cs.charging_station_id = ho.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.history_order_id not in (select history_order_id from xhpc_statistics_time_interval where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= create_time)
and ho.total_price is not null and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= ho.end_time and now() &gt;DATE_ADD(ho.end_time,interval 6 hour)
limit 0,#{number}
@ -1387,9 +1385,9 @@
ho.activity_total_price as activityTotalPrice,
ho.create_time as createTime
from xhpc_history_order ho
left join xhpc_charging_station cs on cs.charging_station_id = ho.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.history_order_id not in (select history_order_id from xhpc_statistics_station where type =2 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= create_time)
and ho.total_price is not null and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= ho.end_time and now() &gt;DATE_ADD(ho.end_time,interval 6 hour)
limit 0,#{number}
@ -1431,9 +1429,9 @@
ho.activity_total_price as activityTotalPrice,
ho.create_time as createTime
from xhpc_history_order ho
left join xhpc_charging_station cs on cs.charging_station_id = ho.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.history_order_id not in (select history_order_id from xhpc_statistics_station and type =2 )
and ho.total_price is not null and now() >DATE_ADD(ho.end_time,interval 6 hour)
limit 0,#{number}
@ -1461,6 +1459,7 @@
co. STATUS AS STATUS,
co.type AS type,
cs. NAME AS chargingStationName,
te. NAME AS terminalName,
co.type as typeName
from xhpc_charge_order co
LEFT JOIN xhpc_terminal AS te ON te.terminal_id = co.terminal_id
@ -1686,9 +1685,7 @@
when xho.charging_mode="4" then "小桔"
when xho.charging_mode="微信" then "微信"
when xho.charging_mode="支付宝" then "支付宝"
when xho.charging_mode="App" then "App"
when xho.charging_mode="刷卡" then "刷卡"
else "vin码"
else "刷卡"
end chargingModeName
FROM xhpc_history_order xho
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id = xho.charging_station_id

View File

@ -300,8 +300,8 @@
<if test="null != bmsChargingMod ">
#{bmsChargingMod},
</if>
<if test="null != bmsChargingVolt ">
#{bmsChargingVolt},
<if test="null != monoBatteryVolt ">
#{monoBatteryVolt},
</if>
<if test="null != bmsChargingCurrent ">
#{bmsChargingCurrent},
@ -336,139 +336,6 @@
</trim>
</insert>
<insert id="insertOrderOutputMax" >
insert into xhpc_order_output_max
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != orderNo and orderNo !=''">
order_no,
</if>
<if test="null != pileNo and pileNo!=''">
pile_no,
</if>
<if test="null != gunId and gunId!='' ">
gun_id,
</if>
<if test="null != bmsVoltageRequest ">
bms_voltage_request,
</if>
<if test="null != bmsCurrentRequest ">
bms_current_request,
</if>
<if test="null != bmsChargingMod ">
bms_charging_mod,
</if>
<if test="null != bmsChargingVolt ">
bms_charging_volt,
</if>
<if test="null != bmsChargingCurrent ">
bms_charging_current,
</if>
<if test="null != monoBatteryVolt ">
mono_battery_volt,
</if>
<if test="null != soc ">
soc,
</if>
<if test="null != bmsEstRemainingTime and bmsEstRemainingTime !=''">
bms_est_remaining_time,
</if>
<if test="null != pileVoltageOutput ">
pile_voltage_output,
</if>
<if test="null != pileCurrentOutput ">
pile_current_output,
</if>
<if test="null != chargingTimeSummary and chargingTimeSummary !=''">
charging_time_summary,
</if>
<if test="null != monoBatteryVoltGroupId ">
mono_battery_volt_groupId,
</if>
<if test="null != chargeOrderId ">
charge_order_id,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != countPileOutput ">
count_pile_output,
</if>
<if test="null != countBmsRequest ">
count_bms_request,
</if>
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != terminalId ">
terminal_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != orderNo and orderNo !=''">
#{orderNo},
</if>
<if test="null != pileNo and pileNo!=''">
#{pileNo},
</if>
<if test="null != gunId and gunId!='' ">
#{gunId},
</if>
<if test="null != bmsVoltageRequest ">
#{bmsVoltageRequest},
</if>
<if test="null != bmsCurrentRequest ">
#{bmsCurrentRequest},
</if>
<if test="null != bmsChargingMod ">
#{bmsChargingMod},
</if>
<if test="null != bmsChargingVolt ">
#{bmsChargingVolt},
</if>
<if test="null != bmsChargingCurrent ">
#{bmsChargingCurrent},
</if>
<if test="null != monoBatteryVolt ">
#{monoBatteryVolt},
</if>
<if test="null != soc ">
#{soc},
</if>
<if test="null != bmsEstRemainingTime and bmsEstRemainingTime!=''">
#{bmsEstRemainingTime},
</if>
<if test="null != pileVoltageOutput ">
#{pileVoltageOutput},
</if>
<if test="null != pileCurrentOutput ">
#{pileCurrentOutput},
</if>
<if test="null != chargingTimeSummary and chargingTimeSummary!=''">
#{chargingTimeSummary},
</if>
<if test="null != monoBatteryVoltGroupId ">
#{monoBatteryVoltGroupId},
</if>
<if test="null != chargeOrderId ">
#{chargeOrderId},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != countPileOutput ">
#{countPileOutput},
</if>
<if test="null != countBmsRequest ">
#{countBmsRequest},
</if>
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != terminalId ">
#{terminalId},
</if>
</trim>
</insert>
<insert id="insertSOC" parameterType="com.xhpc.order.domain.XhpcChargeOrderSoc" useGeneratedKeys="true"
keyProperty="chargeOrderSocId">

View File

@ -22,7 +22,6 @@ import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.common.domain.XhpcRechargeOrder;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.payment.domain.AlipayNotifyParam;
@ -75,10 +74,6 @@ public class AlipayPaymentController {
private IXhpcCommonPayment xhpcCommonPayment;
@Autowired
private UserTypeService userTypeService;
@Autowired
private RedisService redisService;
private ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
@ -158,8 +153,6 @@ public class AlipayPaymentController {
String encode = URLEncoder.encode(attach);
request.setBizContent("{" + "\"out_trade_no\":\""+orderNumber+"\"," +
"\"product_code\":\"JSAPI_PAY\"," +
"\"op_app_id\":\"2021002156615717\"," +
"\"total_amount\":"+amount+"," +
"\"subject\":\"小华充电\"," +
"\"timeout_express\":\"30m\"," +
@ -310,92 +303,34 @@ public class AlipayPaymentController {
R user = userTypeService.getUser(null,userId, source, null, tenantId);
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
Integer sunchaSwitch = Integer.valueOf(map.get("sunchaSwitch").toString());
if(sunchaSwitch==0){
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
//判断用户是否在充电中
String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId);
logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber"+serialMumber);
if(!"".equals(serialMumber) && serialMumber !=null){
//充电中
postRefreshBalance(money, serialMumber);
}
if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("支付宝充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
}else{
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal aBigDecimal = xhpcRechargeOrder.getAmount().divide(new BigDecimal(2)).setScale(0, BigDecimal.ROUND_UP);
BigDecimal bBigDecimal =xhpcRechargeOrder.getAmount().subtract(aBigDecimal);
BigDecimal aBalance = new BigDecimal(map.get("aBalance").toString()).add(aBigDecimal);
BigDecimal bBalance = new BigDecimal(map.get("bBalance").toString()).add(bBigDecimal);
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==xhpcRechargeOrder.getSource()){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==xhpcRechargeOrder.getSource()){
userType =UserTypeUtil.CUSTOMERS;
}
String key = "user:" + xhpcRechargeOrder.getUserId() + userType + ".order";
//判断用户是否在充电中
String serialMumberA = xhpcUserAccountStatementMapper.getUserHistotyChargeOrderSuncha(xhpcRechargeOrder.getUserId(),source,tenantId,1);
if(!"".equals(serialMumberA) && serialMumberA !=null){
//充电中
postRefreshBalance(aBalance, serialMumberA);
Map<String, Object> mapA = new HashMap<>();
map.put("aBalance", aBalance);
redisService.setCacheMap(key,mapA);
}
String serialMumberB = xhpcUserAccountStatementMapper.getUserHistotyChargeOrderSuncha(xhpcRechargeOrder.getUserId(),source,tenantId,2);
if(!"".equals(serialMumberB) && serialMumberB !=null){
//充电中
postRefreshBalance(bBalance, serialMumberB);
Map<String, Object> mapA = new HashMap<>();
map.put("bBalance", bBalance);
redisService.setCacheMap(key,mapA);
}
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("支付宝充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
//判断用户是否在充电中
String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId);
logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber"+serialMumber);
if(!"".equals(serialMumber) && serialMumber !=null){
//充电中
postRefreshBalance(money, serialMumber);
}
if(UserTypeUtil.USER_TYPE.equals(xhpcRechargeOrder.getSource())){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("支付宝充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId,UserTypeUtil.RECHARGE_ZHB,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
}
}
@ -412,7 +347,7 @@ public class AlipayPaymentController {
String s1 =money.multiply(new BigDecimal(100)).toString();
startChargingData.setBalance(Double.valueOf(s1).intValue());
R r = powerPileService.refreshBalance(startChargingData);
logger.info("<<<<<<<<<<<<余额下发>>>>>>>>>"+s1);
logger.info("<<<<<<<<<<<<余额下发>>>>>>>>>");
logger.info("<<<<<<<<<<<<"+r.getCode()+">>>>>>>>>");
logger.info("<<<<<<<<<<<<"+r.getMsg()+">>>>>>>>>");

View File

@ -13,7 +13,6 @@ import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.payment.domain.XhpcAppInternetUser;
@ -81,9 +80,6 @@ public class WxPaymentController {
private UserTypeService userTypeService;
@Autowired
private IXhpcCommonPayment xhpcCommonPayment;
@Autowired
private RedisService redisService;
private static final Logger logger = LoggerFactory.getLogger(WxPaymentController.class);
private ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
@ -449,89 +445,33 @@ public class WxPaymentController {
R user = userTypeService.getUser(null,userId, source, null, tenantId);
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
Integer sunchaSwitch = Integer.valueOf(map.get("sunchaSwitch").toString());
if(sunchaSwitch==0){
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
//判断用户是否在充电中
String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId);
logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber"+serialMumber);
if(!"".equals(serialMumber) && serialMumber !=null){
//充电中
postRefreshBalance(money, serialMumber);
}
if(UserTypeUtil.USER_TYPE.equals(source)){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("微信充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
//判断用户是否在充电中
String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId(),source,tenantId);
logger.info("<<<<<<<<<<<<充电终端>>>>>>>>>serialMumber"+serialMumber);
if(!"".equals(serialMumber) && serialMumber !=null){
//充电中
postRefreshBalance(money, serialMumber);
}
if(UserTypeUtil.USER_TYPE.equals(source)){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("微信充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
String balance = StringUtils.valueOf(map.get("balance"));
BigDecimal aBigDecimal = xhpcRechargeOrder.getAmount().divide(new BigDecimal(2)).setScale(0, BigDecimal.ROUND_UP);
BigDecimal bBigDecimal =xhpcRechargeOrder.getAmount().subtract(aBigDecimal);
BigDecimal aBalance = new BigDecimal(map.get("aBalance").toString()).add(aBigDecimal);
BigDecimal bBalance = new BigDecimal(map.get("bBalance").toString()).add(bBigDecimal);
String userType =UserTypeUtil.USER;
if(UserTypeUtil.COMMUNIT_TYPE==xhpcRechargeOrder.getSource()){
userType =UserTypeUtil.COMMUNIT;
}else if(UserTypeUtil.CUSTOMERS_TYPE==xhpcRechargeOrder.getSource()){
userType =UserTypeUtil.CUSTOMERS;
}
String key = "user:" + xhpcRechargeOrder.getUserId() + userType + ".order";
//判断用户是否在充电中
String serialMumberA = xhpcUserAccountStatementMapper.getUserHistotyChargeOrderSuncha(xhpcRechargeOrder.getUserId(),source,tenantId,1);
if(!"".equals(serialMumberA) && serialMumberA !=null){
//充电中
Map<String, Object> mapA = new HashMap<>();
map.put("aBalance", aBalance);
redisService.setCacheMap(key,mapA);
postRefreshBalance(aBalance, serialMumberA);
}
String serialMumberB = xhpcUserAccountStatementMapper.getUserHistotyChargeOrderSuncha(xhpcRechargeOrder.getUserId(),source,tenantId,2);
if(!"".equals(serialMumberB) && serialMumberB !=null){
//充电中
Map<String, Object> mapA = new HashMap<>();
map.put("bBalance", bBalance);
redisService.setCacheMap(key,mapA);
postRefreshBalance(bBalance, serialMumberB);
}
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
if(UserTypeUtil.USER_TYPE.equals(source)){
//增加用户余额
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
xhpcAppUser.setBalance(money);
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
xhpcUserAccountStatement.setRechargeOrderId(xhpcRechargeOrder.getRechargeOrderId());
xhpcUserAccountStatement.setUserId(xhpcRechargeOrder.getUserId());
xhpcUserAccountStatement.setAmount(xhpcRechargeOrder.getAmount());
xhpcUserAccountStatement.setRemainingSum(xhpcAppUser.getBalance());
xhpcUserAccountStatement.setCreateTime(new Date());
xhpcUserAccountStatement.setRemark("微信充值订单!");
xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement);
}else{
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
//增加用户余额
userTypeService.insertUserBalance(xhpcRechargeOrder.getAmount(),userId,source,tenantId, UserTypeUtil.RECHARGE_WX,UserTypeUtil.INSERT_BALANCE,null,xhpcRechargeOrder.getRechargeOrderId());
}
}
}
@ -550,7 +490,7 @@ public class WxPaymentController {
String s1 =money.multiply(new BigDecimal(100)).toString();
startChargingData.setBalance(Double.valueOf(s1).intValue());
R r = powerPileService.refreshBalance(startChargingData);
logger.info("<<<<<<<<<<<<余额下发>>>>>>>>>"+s1);
logger.info("<<<<<<<<<<<<余额下发>>>>>>>>>");
logger.info("<<<<<<<<<<<<"+r.getCode()+">>>>>>>>>");
logger.info("<<<<<<<<<<<<"+r.getMsg()+">>>>>>>>>");
if(r.getCode() !=200){

View File

@ -184,17 +184,7 @@ public class XhpcRefundOriginalOrderController extends BaseController {
}
Integer source = xhpcRefundOrder.getSource();
Long userId = xhpcRefundOrder.getUserId();
String tenantId = xhpcRefundOrder.getTenantId();
//是否有实时数据
int k = iXhpcRefundOrderService.countXhpcRealTimeOrder(userId, source, tenantId);
if (k > 0) {
return R.fail(1103, "车辆正在充电,不能退款");
}
// 是否有异常订单
int j = iXhpcRefundOrderService.countXhpcChargeOrder(userId, source, tenantId);
if (j > 0) {
return R.fail(1103, "你有异常订单未解决,请拨打客服电话进行解决");
}
if(UserTypeUtil.USER_TYPE.equals(source)){
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setAppUserId(userId);
@ -421,7 +411,7 @@ public class XhpcRefundOriginalOrderController extends BaseController {
//川逸充自动退款 每5分钟一次
//@Scheduled(cron = "0 0/5 * * * ? ")
@Scheduled(cron = "0 0/5 * * * ? ")
@GetMapping("/cycMoneyPage")
public void cycMoneyPage(){
logger.info("++++++++++++川逸充没有充电订单自动退款 每5分钟一次++++++++++++++++");

View File

@ -80,5 +80,4 @@ public interface XhpcUserAccountStatementMapper {
*/
String getUserHistotyChargeOrder(@Param("userId") Long userId,@Param("source") Integer source,@Param("tenantId")String tenantId);
String getUserHistotyChargeOrderSuncha(@Param("userId") Long userId,@Param("source") Integer source,@Param("tenantId")String tenantId,@Param("sunchaStatus")Integer sunchaStatus);
}

View File

@ -244,11 +244,4 @@
from xhpc_terminal
where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and source=#{source} and tenant_id=#{tenantId} and status=0 and del_flag =0 limit 1)
</select>
<select id="getUserHistotyChargeOrderSuncha" resultType="String">
select
serial_number as serialMumber
from xhpc_terminal
where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and source=#{source} and tenant_id=#{tenantId} and status=0 and del_flag =0 and suncha_status=#{sunchaStatus} limit 1)
</select>
</mapper>

View File

@ -418,7 +418,7 @@ public class ChargingController {
String pileNo = startChargingData.getPileNo();
String pkey = "pile:".concat(pileNo);
//log.info("==================pkey======================"+pkey);
log.info("==================pkey======================"+pkey);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
R<Object> r = checkPile(cachePile);
if (r.getCode() == 200) {
@ -539,19 +539,14 @@ public class ChargingController {
public static void main(String[] args) {
Integer FFFF1 = HexUtils.reverseHexInt("330F");
System.out.println("51 转化成="+FFFF1);
Integer FFFF = HexUtils.reverseHexInt("AD09");
System.out.println("51 转化成="+FFFF);
// Integer FFFF = HexUtils.reverseHexInt("0452");
// System.out.println("51 转化成="+FFFF);
Integer F402 = HexUtils.reverseHexInt("EE0E");
Integer F402 = HexUtils.reverseHexInt("4C");
System.out.println("F402 转化成="+F402);
//
Integer D007 = HexUtils.reverseHexInt("BB09");
System.out.println("D007 转化成="+D007);
// Integer D007 = HexUtils.reverseHexInt("D007");
// System.out.println("D007 转化成="+D007);
//
// Integer F620 = HexUtils.reverseHexInt("F620");
// System.out.println("F620 转化成="+F620);
@ -596,18 +591,16 @@ public class ChargingController {
// System.out.println(df.format(v));
// String s = CP56Time2a.p56toDateStr("C05D2011200318");
//
// System.out.println("-111-变为--:" + s);
//
// String s1 = cp56toDateStr("88903507220418");
//
// System.out.println("-111-变为--:" + s1);
// String ascii = HexUtils.toAscii("4C465A3733464C34374E44303032343535");
//
// System.out.println("ascii :"+ascii);
String ascii = HexUtils.toAscii("4C465A3733464C34374E44303032343535");
System.out.println("ascii :"+ascii);
}
}

View File

@ -433,7 +433,6 @@ public class PileController {
@PostMapping("pile/{pileNo}/{powerNumber}/configSettings")
public R pileConfigSettings(@PathVariable("pileNo") String pileNo,@PathVariable("powerNumber") String powerNumber) {
String pkey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
R<Object> r = checkPileConfig(cachePile);

View File

@ -40,6 +40,7 @@ public class StationController {
public void addNotificationStationInfo(@RequestParam("stationId")Long stationId){
CDStationInfo xhpcChargingStation = deviceMessageMapper.getXhpcChargingStation(stationId);
if(xhpcChargingStation !=null){
System.out.println("=================生成场站推送数据信息===================");
//场站信息入缓存
String skey = "cdjgpc:station:".concat(stationId.toString())+".notification";
REDIS.deleteObject(skey);
@ -49,6 +50,11 @@ public class StationController {
xhpcChargingStation.setSwapMatchCars(split);
}
xhpcChargingStation.setEquipmentInfos(new ArrayList<>());
if("3".equals(stationId)){
xhpcChargingStation.setStationName("小华充电新繁长德新世贸食品城充电站");
}else if("2".equals(stationId)){
xhpcChargingStation.setStationName("小华充电温江学府杏林充电站");
}
REDIS.setCacheObject(skey, xhpcChargingStation);
}

View File

@ -18,7 +18,6 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.Map;
@ -43,91 +42,10 @@ public class BmsReqChargerOutputDataLogic implements ServiceLogic {
ObjectMapper objectMapper = new ObjectMapper();
BmsReqChargerOutputData orderData = objectMapper.convertValue(req, BmsReqChargerOutputData.class);
String hex = (String) req.get("hex");
int idxStart = 60;
int bmsVoltageRequest = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 电压需求
idxStart = 4 + idxStart;
int bmsCurrentRequest = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 电流需求
idxStart = 6 + idxStart;
int bmsChargingVolt = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 充电电压测量值
idxStart = 4 + idxStart;
int bmsChargingCurrent = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 充电电流测量值
idxStart = 88;
int pileVoltageOutput = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//电桩电压输出值
idxStart = 4 + idxStart;
int pileCurrentOutput = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//电桩电流输出值
String orderNo = (String) req.get("orderNo");
String orderKey = "order:".concat(orderNo).concat(".bms");
orderData.setBmsVoltageRequest(bmsVoltageRequest+"");
orderData.setBmsCurrentRequest(bmsCurrentRequest+"");
orderData.setBmsChargingVolt(bmsChargingVolt+"");
orderData.setBmsChargingCurrent(bmsChargingCurrent+"");
orderData.setPileVoltageOutput(pileVoltageOutput+"");
orderData.setPileCurrentOutput(pileCurrentOutput+"");
//CacheBmsReqChargerOutputData cacheBmsReqChargerOutputData = translate(orderData);
CacheBmsReqChargerOutputData cacheBmsReqChargerOutputData = new CacheBmsReqChargerOutputData();
cacheBmsReqChargerOutputData.setOrderNo(orderData.getOrderNo());
cacheBmsReqChargerOutputData.setPileNo(orderData.getPileNo());
cacheBmsReqChargerOutputData.setGunId(orderData.getGunId());
cacheBmsReqChargerOutputData.setBmsVoltageRequest(new BigDecimal(bmsVoltageRequest).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract1 = new BigDecimal(bmsCurrentRequest).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract1.compareTo(new BigDecimal(0))<0){
subtract1 =subtract1.abs();
}
cacheBmsReqChargerOutputData.setBmsCurrentRequest(subtract1.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setBmsChargingMod(HexUtils.reverseHexInt(orderData.getBmsChargingMod()));
cacheBmsReqChargerOutputData.setBmsChargingVolt(new BigDecimal(bmsChargingVolt).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract2 = new BigDecimal(bmsChargingCurrent).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract2.compareTo(new BigDecimal(0))<0){
subtract2 =subtract2.abs();
}
cacheBmsReqChargerOutputData.setBmsChargingCurrent(subtract2.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setMonoBatteryVolt(convertDouble(Integer.parseInt(orderData.getMonoBatteryVoltGroupId().substring(0, 3), 16) * 0.01));
cacheBmsReqChargerOutputData.setSoc(HexUtils.reverseHexInt(orderData.getSoc()));
cacheBmsReqChargerOutputData.setBmsEstRemainingTime(HexUtils.reverseHexInt(orderData.getBmsEstRemainingTime()));
cacheBmsReqChargerOutputData.setPileVoltageOutput(new BigDecimal(pileVoltageOutput).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract = new BigDecimal(pileCurrentOutput).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract.compareTo(new BigDecimal(0))<0){
subtract =subtract.abs();
}
cacheBmsReqChargerOutputData.setPileCurrentOutput(subtract.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setChargingTimeSummary(HexUtils.reverseHexInt(orderData.getChargingTimeSummary()));
cacheBmsReqChargerOutputData.setMonoBatteryVoltGroupId(Integer.parseInt(orderData.getMonoBatteryVoltGroupId().substring(3), 16));
cacheBmsReqChargerOutputData.setHex(orderData.getHex());
cacheBmsReqChargerOutputData.setCreateTime(DateUtil.now());
CacheBmsReqChargerOutputData cacheBmsReqChargerOutputData = translate(orderData);
REDIS.setCacheObject(orderKey, cacheBmsReqChargerOutputData);
pileOrderService.pileRimeOrderBms(orderNo);
@ -149,44 +67,16 @@ public class BmsReqChargerOutputDataLogic implements ServiceLogic {
cacheBmsReqChargerOutputData.setOrderNo(orderData.getOrderNo());
cacheBmsReqChargerOutputData.setPileNo(orderData.getPileNo());
cacheBmsReqChargerOutputData.setGunId(orderData.getGunId());
cacheBmsReqChargerOutputData.setBmsVoltageRequest(new BigDecimal(orderData.getBmsVoltageRequest()).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract1 = new BigDecimal(orderData.getBmsCurrentRequest()).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract1.compareTo(new BigDecimal(0))<0){
subtract1 =subtract1.abs();
}
cacheBmsReqChargerOutputData.setBmsCurrentRequest(subtract1.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setBmsVoltageRequest(convertDouble(HexUtils.reverseHexInt(orderData.getBmsVoltageRequest()) * 0.1));
cacheBmsReqChargerOutputData.setBmsCurrentRequest(convertDouble(HexUtils.reverseHexInt(orderData.getBmsCurrentRequest()) * 0.1));
cacheBmsReqChargerOutputData.setBmsChargingMod(HexUtils.reverseHexInt(orderData.getBmsChargingMod()));
cacheBmsReqChargerOutputData.setBmsChargingVolt(new BigDecimal(orderData.getBmsChargingVolt()).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract2 = new BigDecimal(orderData.getBmsChargingCurrent()).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract2.compareTo(new BigDecimal(0))<0){
subtract2 =subtract2.abs();
}
cacheBmsReqChargerOutputData.setBmsChargingCurrent(subtract2.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setBmsChargingVolt(convertDouble(HexUtils.reverseHexInt(orderData.getBmsChargingVolt()) * 0.1));
cacheBmsReqChargerOutputData.setBmsChargingCurrent(convertDouble(HexUtils.reverseHexInt(orderData.getBmsChargingCurrent()) * 0.1));
cacheBmsReqChargerOutputData.setMonoBatteryVolt(convertDouble(Integer.parseInt(orderData.getMonoBatteryVoltGroupId().substring(0, 3), 16) * 0.01));
cacheBmsReqChargerOutputData.setSoc(HexUtils.reverseHexInt(orderData.getSoc()));
cacheBmsReqChargerOutputData.setBmsEstRemainingTime(HexUtils.reverseHexInt(orderData.getBmsEstRemainingTime()));
cacheBmsReqChargerOutputData.setPileVoltageOutput(new BigDecimal(orderData.getPileVoltageOutput()).divide(new BigDecimal(10),BigDecimal.ROUND_DOWN).doubleValue());
try{
BigDecimal subtract = new BigDecimal(orderData.getPileCurrentOutput()).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract.compareTo(new BigDecimal(0))<0){
subtract =subtract.abs();
}
cacheBmsReqChargerOutputData.setPileCurrentOutput(subtract.doubleValue());
}catch (Exception e){
}
cacheBmsReqChargerOutputData.setPileVoltageOutput(convertDouble(HexUtils.reverseHexInt(orderData.getPileVoltageOutput()) * 0.1));
cacheBmsReqChargerOutputData.setPileCurrentOutput(convertDouble(HexUtils.reverseHexInt(orderData.getPileVoltageOutput()) * 0.1));
cacheBmsReqChargerOutputData.setChargingTimeSummary(HexUtils.reverseHexInt(orderData.getChargingTimeSummary()));
cacheBmsReqChargerOutputData.setMonoBatteryVoltGroupId(Integer.parseInt(orderData.getMonoBatteryVoltGroupId().substring(3), 16));
cacheBmsReqChargerOutputData.setHex(orderData.getHex());
@ -204,37 +94,4 @@ public class BmsReqChargerOutputDataLogic implements ServiceLogic {
return Double.parseDouble(nf.format(oldVar));
}
public static void main(String[] args) {
String hex = "6830EA070023808360001500010224080715153706848083600015000102D80EAC0D028E0D150E5001334B00A50D1A0E2D0081DD";
int idxStart = 60;
int bmsVoltageRequest = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 电压需求
System.out.println("===================bmsVoltageRequest========================="+bmsVoltageRequest);
idxStart =idxStart+4;
int bmsCurrentRequest = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//BMS 电流需求
System.out.println("===================bmsCurrentRequest========================="+bmsCurrentRequest);
idxStart = 88;
int pileVoltageOutput = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//电桩电压输出值
System.out.println("===================pileVoltageOutput========================="+pileVoltageOutput);
idxStart = 4 + idxStart;
int pileCurrentOutput = HexUtils.reverseHexInt(hex.substring(idxStart, 4 + idxStart));//电桩电流输出值
System.out.println("===================pileCurrentOutput========================="+pileCurrentOutput);
BigDecimal subtract1 = new BigDecimal(bmsCurrentRequest).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract1.compareTo(new BigDecimal(0))<0){
subtract1 =subtract1.abs();
}
System.out.println("===================subtract1========================="+subtract1);
BigDecimal subtract = new BigDecimal(2905).divide(new BigDecimal(10), BigDecimal.ROUND_DOWN).subtract(new BigDecimal(400));
if(subtract.compareTo(new BigDecimal(0))<0){
subtract =subtract.abs();
}
System.out.println("===================subtract========================="+subtract);
}
}

View File

@ -57,6 +57,9 @@ public class OrderDataLogic implements ServiceLogic {
public ServiceResult service(ServiceParameter sp) throws Exception {
Map<String, Object> req = sp.getParameters();
log.info("================订单结束报文==============================");
log.info("================订单结束报文================req=============="+req.toString());
log.info("================订单结束报文==============================");
ObjectMapper objectMapper = new ObjectMapper();
OrderData orderData = objectMapper.convertValue(req, OrderData.class);
String orderNo = orderData.getOrderNo();
@ -152,6 +155,6 @@ public class OrderDataLogic implements ServiceLogic {
Integer stopReasonInt = Integer.valueOf("72", 16);
System.out.println(stopReasonInt);
String st ="充电完成(0X".concat("72").concat(")");
//System.out.println("==========st==========="+st);
System.out.println("==========st==========="+st);
}
}

View File

@ -38,9 +38,7 @@ public class PileConfigReplyDataLogic implements ServiceLogic {
int hibsn = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16);
try{
if(hibsn==1){
log.error("进入入库步骤");
System.out.println();
String nacosServer = REDIS.getCacheObject("pile:"+serialNumber+":powerNumber").toString();
String nacosServer = REDIS.getCacheObject(serialNumber+":powerNumber").toString();
deviceMessageMapper.updateXhpcChargingPile(serialNumber,Integer.valueOf(nacosServer));
}
}catch (Exception e){

View File

@ -53,8 +53,10 @@ public class PileStartChargingDataLogic implements ServiceLogic {
@Override
public ServiceResult service(ServiceParameter sp) throws Exception {
log.info("=============================刷卡启动=======sp================================"+sp.toString());
String resultStr = "00";
String result = ServiceResult.HEX_00;
log.info("=============================刷卡启动=======sp.getParameters================================"+sp.getParameters());
Map<String, Object> req = sp.getParameters();
ObjectMapper objectMapper = new ObjectMapper();
PileStartChargingData pileStartChargingData = objectMapper.convertValue(req, PileStartChargingData.class);
@ -76,20 +78,30 @@ public class PileStartChargingDataLogic implements ServiceLogic {
} else {
physicCardNo = accountOrCardNo;
}
log.info("=============================刷卡启动=======启动================================"+physicCardNo);
criteria.andCardidEqualTo(physicCardNo);//.andCorpnoEqualTo(corpNo); // todo remove corpNo alrity
List<IccardInfo> iccardInfos = iccardInfoMapper.selectByExample(example);
log.info("=============================刷卡启动=======返回================================"+iccardInfos.size());
log.info("=============================刷卡启动=======iccardInfos================================"+iccardInfos.toString());
log.info("=============================刷卡启动=======返回================================");
if (iccardInfos.size() == 1) {
IccardInfo iccardInfo = iccardInfos.get(0);
if (iccardInfo.getCardtype() == 0) {
resultStr = INVALID_OPERATOR;
} else {
log.info("=============================刷卡启动=======调用订单接口================================");
// 调用订单接口
cardNo = iccardInfo.getCardno();
Integer rateModelId = pileStartChargingData.getRateModelId(); // todo not very strict.
if (rateModelId == null)
rateModelId = ((Long) REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)),
"rateModelId")).intValue();
log.info("=============================刷卡启动=======调用订单接口================================"+cardNo.toString());
log.info("=============================刷卡启动=======调用订单接口================================"+connectorId.toString());
log.info("=============================刷卡启动=======调用订单接口================================"+rateModelId.toString());
R r = cardService.cardStartup(cardNo, connectorId, rateModelId.toString());
log.info("=============================刷卡启动=======r================================"+r.getCode());
log.info("=============================刷卡启动=======r================================"+r.getMsg());
int code = r.getCode();
if (code == 200) {
result = ServiceResult.HEX_01;
@ -150,6 +162,10 @@ public class PileStartChargingDataLogic implements ServiceLogic {
R r = pileOrderService.pileVin(connectorId, vinCode);
int code = r.getCode();
log.info("=============================VIN码充电=======返回================================");
log.info("=============================VIN码充电=======返回================================"+code);
log.info("=============================VIN码充电=======返回================================");
if (code == 200) {
if(r.getData() == null){
return new ServiceResult(ServiceResult.FAIL);
@ -203,9 +219,15 @@ public class PileStartChargingDataLogic implements ServiceLogic {
Integer startFlag = result.equals(ServiceResult.HEX_01) ? 2: 4;
log.info("======================ServiceResult.HEX_01========================="+ServiceResult.HEX_01);
log.info("======================result========================="+result);
log.info("======================startFlag========================="+startFlag);
String pushOrderKey = "pushOrder:".concat(orderNo);
Map<String, Object> pushOrder = REDIS.getCacheMap(pushOrderKey);
if (pushOrder != null) {
log.info("======================startChargeSeqStat========================="+startFlag);
REDIS.setCacheMapValue(pushOrderKey, "startChargeSeqStat", startFlag);
} else {
Map map = new HashMap<>();
@ -222,6 +244,8 @@ public class PileStartChargingDataLogic implements ServiceLogic {
deviceMessage.setContent((String) req.get("hex"));
deviceMessageMapper.insertByDomain(deviceMessage);
log.info("===========PileStartChargingDataLogic===========发送报文=========================");
return new ServiceResult(HexUtils.toBytes(hex), result);
}

View File

@ -1,6 +1,7 @@
package com.xhpc.pp.logic;
import com.xhpc.common.api.dto.ChargingStationDto;
import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.common.enums.StationDeviceEnum;
import com.xhpc.pp.domain.XhpcDeviceMessage;
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
@ -37,6 +38,7 @@ public class RateModelValidateLogic implements ServiceLogic {
Map<String, Object> req = sp.getParameters();
String pileNo = (String) req.get("pileNo");
String rateModelIdStr = req.get("rateModelId").toString();
System.out.println("=================rateModelIdStr==================="+rateModelIdStr);
Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
Integer gunNum = (Integer) cachePile.get("gunNum");
@ -68,11 +70,13 @@ public class RateModelValidateLogic implements ServiceLogic {
String skey = "pile:".concat(pileNo).concat(".seqhex");
String seq = seqHex(skey);
String resultStr;
if (!"0C".equals(version)){
System.out.println("=======111==========version==================="+version);
resultStr = "680E".concat(seq).concat("0006").concat(pileNo).concat(String.format("%04X", csRateModelId)).concat(hexCode);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
}else{
System.out.println("=======2222==========version==================="+version);
System.out.println("=======2222==========version==================="+HexUtils.toHexInt(csRateModelId));
resultStr = "6810".concat(seq).concat("0006").concat(pileNo).concat(HexUtils.toHexInt(csRateModelId)).concat(hexCode);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
}

View File

@ -165,11 +165,17 @@ public class RealtimeDataLogic implements ServiceLogic {
cacheOrder.put("lastOrderTime", DateUtil.now());
R r1 = pileOrderService.pileRimeOrder(orderNo);
if (r1 == null || (r1.getMsg()!=null && r1.getMsg().contains("无效订单")) || (r1.getCode() >=500 && r1.getCode() != 3886)) {
System.out.println("==========================无效订单============");
System.out.println("==========================r1.getCode()=================="+r1.getCode());
chargingController.stopInvalidOrder(orderNo);
} else {
Integer vul = (Integer) cachePile.get("voltageUpperLimits");
Integer cul = (Integer) cachePile.get("currentLimit");
if(vul != null && cul != null && (wc > cul || wv > vul)) {
System.out.println("==========================wc=========停止 充电======充电传电流============"+wc);
System.out.println("==========================cul=========停止 充电=================="+cul);
System.out.println("==========================wv=========停止 充电=================="+wv);
System.out.println("==========================vul=========停止 充电=================="+vul);
System.out.println("==========================wc > cul || wv > vul==================停止 充电=================="+pileNo);
R r = chargingController.stopCharging(pileNo, gunId, default_version);
if (r.getCode() == 200) {
@ -180,6 +186,8 @@ public class RealtimeDataLogic implements ServiceLogic {
} else {
Integer stopSoc = (Integer) cacheOrder.get("stopSoc");
if (stopSoc != null && socInt >= stopSoc) {
System.out.println("==========================stopSoc===="+stopSoc+"==============停止 充电=================="+pileNo);
System.out.println("==========================socInt====="+socInt+"=============停止 充电=================="+pileNo);
R r = chargingController.stopCharging(pileNo, gunId, default_version);
String alerted = (String) cacheOrder.get("socalerted");
String tel = (String) cacheOrder.get("tel");
@ -203,6 +211,9 @@ public class RealtimeDataLogic implements ServiceLogic {
Integer amountCharged =cacheRealtimeData.getAmountCharged();
if(chargingDegree < 10000 && amountCharged > 200000){
// 充电度数小于1并且充电金额大于10
System.out.println("==========================chargingDegree < 10000==================停止 充电=================="+pileNo);
System.out.println("==========================chargingDegree < 10000==================停止 充电=================="+pileNo);
System.out.println("==========================chargingDegree < 10000==================停止 充电=================="+pileNo);
R r = chargingController.stopCharging(pileNo, gunId, default_version);
}
@ -230,6 +241,9 @@ public class RealtimeDataLogic implements ServiceLogic {
cacheRealtimeData.getAmountCharged(),
cacheRealtimeData.getOrderNo());
chargingController.stopCharging(pileNo, gunId, default_version);
System.out.println("==========================实时数据充电度数:{}, 实时充电金==================停止 充电=================="+pileNo);
System.out.println("==========================实时数据充电度数:{}, 实时充电金==================停止 充电=================="+pileNo);
System.out.println("==========================实时数据充电度数:{}, 实时充电金==================停止 充电=================="+pileNo);
}
}
}
@ -256,6 +270,9 @@ public class RealtimeDataLogic implements ServiceLogic {
cacheOrder.put("abnormal", "1.2 lord as orderData");
log.error("abnormal.1.2 order[{}]", orderNo);
}
System.out.println("==========================abnormal.1.2 orde==================停止 充电=================="+pileNo);
System.out.println("==========================abnormal.1.2 orde==================停止 充电=================="+pileNo);
System.out.println("==========================abnormal.1.2 orde==================停止 充电=================="+pileNo);
chargingController.stopCharging(pileNo, gunId, default_version);
cacheOrder.put("status", "空闲>2下发中止");
if (r == null || r.getCode() != 200) {
@ -268,6 +285,9 @@ public class RealtimeDataLogic implements ServiceLogic {
REDIS.setCacheMap(orderkey, cacheOrder);
} else {
if (statusInt == 3) {
System.out.println("==========================statusInt == 3==================停止 充电=================="+pileNo);
System.out.println("==========================statusInt == 3==================停止 充电=================="+pileNo);
System.out.println("==========================statusInt == 3==================停止 充电=================="+pileNo);
chargingController.stopCharging(pileNo, gunId, default_version);
Integer bpcnt = (Integer) cacheGun.get("pleek.bp.cnt");
cacheGun.put("pleek.bp.cnt", bpcnt==null?1:bpcnt++);

View File

@ -63,7 +63,10 @@ public class RemoteStartReplyDataLogic implements ServiceLogic {
REDIS.setCacheMap(gunkey, cacheGun);
String pushOrderKey = orderkey.replace("order:", "pushOrder:");
Map<String, Object> pushOrder = REDIS.getCacheMap(pushOrderKey);
log.info("===================11===启动成功或失败===11==RemoteStartReplyDataLogic===================="+remoteStartReplyData.toString());
log.info("===================222===启动成功或失败===33==RemoteStartReplyDataLogic===================="+remoteStartReplyData.getStartResult());
if (HEX_01.equals(remoteStartReplyData.getStartResult())) {
log.info("======================启动充电成功=====RemoteStartReplyDataLogic====================");
final String orderstarttime = DateUtil.format(Calendar.getInstance().getTime(), NORM_DATETIME_FORMAT);
cacheGun.put("pileStartTime", orderstarttime);
cacheGun.put("orderstoptime", null);
@ -75,19 +78,24 @@ public class RemoteStartReplyDataLogic implements ServiceLogic {
REDIS.setCacheMap(orderkey, cacheOrder);
pileOrderService.pileStartup(orderNo, 1, "启动充电成功");
if (pushOrder != null) {
log.info("==========11========RemoteStartReplyDataLogic======11==============");
REDIS.setCacheMapValue(pushOrderKey, "startChargeSeqStat", 2);
} else {
log.info("==========22========RemoteStartReplyDataLogic======22==============");
Map map = new HashMap<>();
map.put("startChargeSeqStat", Integer.valueOf(2));
REDIS.setCacheMap(pushOrderKey, map);
}
} else {
log.info("======================启动成功或失败=====RemoteStartReplyDataLogic====================");
final String remark = frs.get(remoteStartReplyData.getFailReason());
pileOrderService.pileStartup(orderNo, 2, remark == null ? "未知错误" : remark);
if (pushOrder != null) {
log.info("==========33========RemoteStartReplyDataLogic======33==============");
REDIS.setCacheMapValue(pushOrderKey, "startChargeSeqStat", 4);
} else {
log.info("=========44========RemoteStartReplyDataLogic======44==============");
Map map = new HashMap<>();
map.put("startChargeSeqStat", Integer.valueOf(4));
REDIS.setCacheMap(pushOrderKey, map);

View File

@ -21,6 +21,10 @@ public class ServiceMainLogic {
private Map<String, ServiceLogic> serviceLogics;
public ServiceResult process(ServiceParameter sp) {
log.error("==========getServiceName================"+sp.getServiceName());
log.error("==========getPileNo================"+sp.getPileNo());
log.error("==========getParameters================"+sp.getParameters());
log.error("==========getVersion================"+sp.getVersion());
ServiceResult result;
try {
ServiceLogic logic = getServiceLogic(sp.getServiceName());

View File

@ -37,6 +37,8 @@ public class HBCheckTask {
hbtime = hbtime == null ? 0 : hbtime;
if ((now - hbtime) > 75000) {
String pileId = StrUtil.sub(gunkey.substring(gunkey.lastIndexOf(":") + 1), 0, -2);
System.out.println("================充电桩心跳掉线==========pileId========"+pileId);
System.out.println("================充电桩心跳掉线==========pileId========"+pileId);
// if (!DISCONNECTED.equals(cacheGun.get("status"))) {
// cacheGun.put("statusInt", OFF_LINE);
// cacheGun.put("status", DISCONNECTED);

View File

@ -219,8 +219,8 @@ public class CP56Time2a {
// String hex = toCp56Hex(time);
// System.out.println("--编码1--:" + hex);
// System.out.println(HexUtils.toBinaryString("90E223133D0416"));
// System.out.println("--下达1--:" + DateUtil.format(cp56toDate("E880380D170518"), NORM_DATETIME_FORMATTER));
// System.out.println("--下达2--:" + DateUtil.format(cp56toDate("A50F3A0D170518"), NORM_DATETIME_FORMATTER));
System.out.println("--下达1--:" + DateUtil.format(cp56toDate("E880380D170518"), NORM_DATETIME_FORMATTER));
System.out.println("--下达2--:" + DateUtil.format(cp56toDate("A50F3A0D170518"), NORM_DATETIME_FORMATTER));
// System.out.println("toCp56Hex = " + toCp56Hex(cp56toDate("C05D0D171F0116")));
//// System.out.println("--下达2--:" + DateUtil.format(cp56toDate(""), NORM_DATETIME_FORMAT));
// String dateStr = "2017-03-01 22:33:23";
@ -234,13 +234,13 @@ public class CP56Time2a {
// System.out.println(String.format("--编码2--:%s", encode));
// System.out.println("--解码2--:" + decode(HexUtils.toBytes(encode)));
String s = cp56toDateStr("282314090A0718");
String s = cp56toDateStr("1804080B0E22");
System.out.println("-时间解析--:" + s);
System.out.println("-111-变为--:" + s);
// String s1 = cp56toDateStr("E02E340DC80718");
//
// System.out.println("-时间解析--:" + s1);
String s1 = cp56toDateStr("88903507220418");
System.out.println("-111-变为--:" + s1);
}
}

View File

@ -141,9 +141,9 @@
<select id="getXhpcChargingStation" parameterType="com.xhpc.evcs.cdjgpc.dto.CDStationInfo"
resultType="com.xhpc.evcs.cdjgpc.dto.CDStationInfo">
select CAST(ct.charging_station_id AS CHAR(10)) as stationId,
ct.chengdu_name as stationName,
ct.name as stationName,
ct.operator_id_evcs as operatorId,
ct.internet_equipment_owner_id as equipmentOwnerId,
ct.equipment_owner_id as equipmentOwnerId,
ct.is_alone_apply as isAloneApply,
ct.account_number as accountNumber,
ct.capacity as capacity,
@ -401,6 +401,6 @@
</select>
<update id="updateXhpcChargingPile">
update xhpc_charging_pile set power_number=#{powerNumber} where serial_number =#{serialNumber}
update from xhpc_charging_pile set power_number=#{powerNumber} where serial_number =#{serialNumber}
</update>
</mapper>

File diff suppressed because one or more lines are too long

View File

@ -1,62 +0,0 @@
package com.xhpc.user.controller;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.user.domain.XhpcBlacklist;
import com.xhpc.user.domain.XhpcCustomers;
import com.xhpc.user.service.IXhpcBlacklistService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/blacklist")
public class XhpcBlacklistController extends BaseController {
@Resource
private IXhpcBlacklistService xhpcBlacklistService;
@GetMapping("/getList")
public TableDataInfo getList(String phone, String plateNum, String vin, String startTime, String endTime,Integer distinguish){
Map<String, Object> params = new HashMap<>();
params.put("phone", phone);
params.put("plateNum", plateNum);
params.put("vin", vin);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("distinguish", distinguish);
List<Map<String, Object>> list = xhpcBlacklistService.getList(params);
return getDataTable(list);
}
@PostMapping(value = "/addBlacklist")
public AjaxResult addBlacklist(HttpServletRequest request, @RequestBody XhpcBlacklist xhpcBlacklist) {
return xhpcBlacklistService.addBlacklist(request,xhpcBlacklist);
}
@GetMapping(value = "/getBlacklistById")
public AjaxResult getBlacklistById(Long blacklistId) {
return AjaxResult.success(xhpcBlacklistService.getBlacklistById(blacklistId));
}
@GetMapping(value = "/deleteBlacklistById")
public AjaxResult deleteBlacklistById(Long blacklistId) {
xhpcBlacklistService.deleteBlacklistById(blacklistId);
return AjaxResult.success();
}
}

View File

@ -85,8 +85,6 @@ public class XhpcAppUser extends BaseEntity {
private String tenantId;
private String email;
public Long getAppUserId() {
return appUserId;
}
@ -218,12 +216,4 @@ public class XhpcAppUser extends BaseEntity {
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -1,74 +0,0 @@
package com.xhpc.user.domain;
import com.xhpc.common.core.web.domain.BaseEntity;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.Date;
@Data
public class XhpcBlacklist extends BaseEntity {
private Long blacklistId;
/**
* 数据维度 0 地区 1.运营商 2. 运营商地区
*/
@NotEmpty(message = "数据维度不能为空")
private String dimension;
/**
* 是否有不参与合作的场站 0 没有 1有
*/
private Integer status;
/**
* 删除标志0代表存在 2代表删除
*/
private Integer delFlag;
/**
* 电站id
*/
private String chargingStationIds;
/**
* 制造厂商
*/
private String manufacturers;
/**
* 车辆类型
*/
private String vehicleType;
/**
* 发送机型式
*/
private String vehicleEngine;
/**
* 企业车型代码
*/
private String vehicleCode;
/**
* 电话
*/
private String phone;
/**
* 电话
*/
private String plateNum;
/**
* 车牌
*/
private String vin;
/**
* 限制开始时间
*/
private Date startTime;
/**
* 限制开始时间
*/
private Date endTime;
/**
* 1 个人 2 车型
*/
private Integer distinguish;
}

View File

@ -95,13 +95,8 @@ public interface XhpcAppUserMapper {
int updateUserIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund);
int updateUserSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch);
int updateCommunityIsRefund(@Param("userId")Long userId, @Param("isRefund")Integer isRefund, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
int updateCommunityPersonnelSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
int updateCustomersPersonnelSunchaSwitch(@Param("userId")Long userId, @Param("sunchaSwitch")Integer sunchaSwitch, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
int updateCustomersSocProtect(@Param("userId")Long userId, @Param("socProtect")Integer socProtect, @Param("soc")Integer soc);
/**
* 记录登录用户的最后一次数据

View File

@ -1,27 +0,0 @@
package com.xhpc.user.mapper;
import com.xhpc.user.domain.XhpcBlacklist;
import com.xhpc.user.domain.XhpcCustomers;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface XhpcBlacklistMapper {
List<Map<String,Object>> getList(@Param("params")Map<String, Object> params);
//判断手机号或者车牌是否重复
int getPhoneOrVin(@Param("phone")String phone,@Param("plateNum")String plateNum,@Param("blacklistId")Long blacklistId,@Param("distinguish")Integer distinguish);
int getManufacturersOrVehicletype(@Param("manufacturers")String manufacturers,@Param("vehicleType")String vehicleType,@Param("vehicleEngine")String vehicleEngine,@Param("vehicleCode")String vehicleCode,@Param("blacklistId")Long blacklistId,@Param("distinguish")Integer distinguish);
int insertBlacklist(XhpcBlacklist xhpcBlacklist);
Map<String, Object> getBlacklistById(@Param("blacklistId")Long blacklistId);
int updateBlacklist(XhpcBlacklist xhpcBlacklist);
int deleteBlacklistById(@Param("blacklistId")Long blacklistId);
}

View File

@ -72,7 +72,7 @@ public interface IXhpcAppUserUserService {
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
public R<?> appUserLogin(HttpServletRequest request,Map<String, Object> map);
public R<?> appUserLogin(Map<String, Object> map);
/**
* APP用户注册
@ -80,7 +80,7 @@ public interface IXhpcAppUserUserService {
* @param map C端用户 phone 手机号 code 验证码 type 登录方式1微信2小程序
* @return 结果
*/
public R<?> apprRegister(HttpServletRequest request,Map<String, Object> map);
public R<?> apprRegister(Map<String, Object> map);
public R<?> loginPhone(Map<String, Object> map);
@ -115,7 +115,7 @@ public interface IXhpcAppUserUserService {
* @param map
* @return
*/
public R<?> appVoluntaryLogin(HttpServletRequest request,Map<String, Object> map);
public R<?> appVoluntaryLogin(Map<String, Object> map);
/**
* 小程序用户详情
*
@ -138,12 +138,6 @@ public interface IXhpcAppUserUserService {
*/
public R<?> updateIsRefund(Long userId, Integer userType,Integer isRefund);
/**
* 设置小程序用户自动退款功能
* @return
*/
public R<?> doubleGunCharging(Long userId, Integer userType,Integer sunchaSwitch);
/**
* 设置小程序用户电池保护
* @return

View File

@ -1,21 +0,0 @@
package com.xhpc.user.service;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.user.domain.XhpcBlacklist;
import com.xhpc.user.domain.XhpcCustomers;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
public interface IXhpcBlacklistService {
List<Map<String, Object>> getList(Map<String, Object> params);
AjaxResult addBlacklist(HttpServletRequest request, XhpcBlacklist xhpcBlacklist);
Map<String, Object> getBlacklistById(Long blacklistId);
void deleteBlacklistById(Long blacklistId);
}

View File

@ -236,92 +236,39 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
}
@Override
public R<?> appUserLogin(HttpServletRequest request,Map<String, Object> map) {
String language = request.getHeader("language");
public R<?> appUserLogin(Map<String, Object> map) {
String phone = StringUtils.valueOf(map.get("phone"));
String password = StringUtils.valueOf(map.get("password"));
String tenantId = StringUtils.valueOf(map.get("tenantId"));
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
if (phone.length() < UserConstants.USERNAME_MIN_LENGTH
|| phone.length() > UserConstants.USERNAME_MAX_LENGTH) {
return R.fail(HttpStatus.ERROR_STATUS, "用户名不在指定范围");
}
XhpcAppUser user =new XhpcAppUser();
if("18123374652".equals(phone) && "123456".equals(password)){
phone ="18123374652";
password="123456";
}
if(language.equals(UserTypeUtil.LANGUAGE_ARA)){
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء الحساب");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء كلمة المرور");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "يجب على المستأجر ملء");
}
user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "خطأ في الحساب وكلمة المرور يرجى تسجيل الدخول مرة أخرى");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.DATA_ERROR, "خطأ في الحساب وكلمة المرور يرجى تسجيل الدخول مرة أخرى");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, ":رقم حسابك" + phone + " تم حذف ");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, ":رقم حسابك" + phone + " تعطيل ");
}
}else if(language.equals(UserTypeUtil.LANGUAGE_EN)){
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "Account must be filled in");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "Password must be filled in");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "Tenants must fill in");
}
user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "Account and password errors, please log in again");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.DATA_ERROR, "Account and password errors, please log in again");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "Your account" + phone + " have been deleted");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "Your account" + phone + " deactivated");
}
user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "账号和密码错误请重新登录");
}else{
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (StringUtils.isNull(user)) {
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.DATA_ERROR, "账号和密码错误请重新登录");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.DATA_ERROR, "账号和密码错误请重新登录");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "您的账号:" + phone + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "您的账号:" + phone + " 已停用");
}
}
LoginUser userInfo = new LoginUser();
@ -334,6 +281,12 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
userInfo.setUserid(user.getAppUserId());
userInfo.setTenantId(tenantId);
userInfo.setUserTypeUtil(UserTypeUtil.USER);
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + phone + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + phone + " 已停用");
}
redisService.deleteObject("pvToken:" + user.getPhone());
//去退出账号之前登录的信息
xhpcAppUserMapper.updateUserLoginTime(phone);
@ -343,124 +296,46 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
Map<String, Object> token = tokenService.createToken(userInfo);
token.put("phone",phone);
return R.ok(token);
}
@Override
public R<?> apprRegister(HttpServletRequest request,Map<String, Object> map) {
String language = request.getHeader("language");
String email = StringUtils.valueOf(map.get("email"));
String code = StringUtils.valueOf(map.get("code"));
public R<?> apprRegister(Map<String, Object> map) {
String phone = StringUtils.valueOf(map.get("phone"));
String password = StringUtils.valueOf(map.get("password"));
String confirmPassword = StringUtils.valueOf(map.get("confirmPassword"));
String tenantId = StringUtils.valueOf(map.get("tenantId"));
String captcha = redisService.getCacheObject("emailCode:" + email);
if(language.equals(UserTypeUtil.LANGUAGE_ARA)){
if (StringUtils.isAnyBlank(email)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء صندوق البريد");
}
if (StringUtils.isAnyBlank(code)) {
return R.fail(HttpStatus.NOT_NULL, "صندوق البريد رمز التحقق يجب أن تملأ");
}
if(null ==captcha || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "رمز التحقق فارغة");
}
if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "رمز التحقق من الخطأ");
}
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء الحساب");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء كلمة المرور");
}
if (StringUtils.isAnyBlank(confirmPassword)) {
return R.fail(HttpStatus.NOT_NULL, "تأكيد كلمة السر يجب أن تكتمل");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "يجب على المستأجر ملء");
}
if(!password.equals(confirmPassword)){
return R.fail(HttpStatus.NOT_NULL, "كلمة السر ليست متسقة ، يرجى إعادة إدخال");
}
XhpcAppUser user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (!StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "هذا الحساب موجود بالفعل الرجاء تسجيل الدخول");
}
}else if(language.equals(UserTypeUtil.LANGUAGE_EN)){
if(null ==captcha || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "The verification code is empty");
}
if (StringUtils.isAnyBlank(email)) {
return R.fail(HttpStatus.NOT_NULL, "Email must be filled in");
}
if (StringUtils.isAnyBlank(code)) {
return R.fail(HttpStatus.NOT_NULL, "Email verification code must be filled in");
}
if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "Verification code error");
}
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "Account must be filled in");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "Password must be filled in");
}
if (StringUtils.isAnyBlank(confirmPassword)) {
return R.fail(HttpStatus.NOT_NULL, "Confirmation password must be filled in");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "Tenants must fill in");
}
if(!password.equals(confirmPassword)){
return R.fail(HttpStatus.NOT_NULL, "Password inconsistency, please re-enter");
}
XhpcAppUser user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (!StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "The account already exists. Please log in");
}
}else{
if(null ==captcha || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "验证码为空");
}
if (StringUtils.isAnyBlank(email)) {
return R.fail(HttpStatus.NOT_NULL, "邮箱必须填写");
}
if (StringUtils.isAnyBlank(code)) {
return R.fail(HttpStatus.NOT_NULL, "邮箱验证码必须填写");
}
if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(confirmPassword)) {
return R.fail(HttpStatus.NOT_NULL, "确认密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
if(!password.equals(confirmPassword)){
return R.fail(HttpStatus.NOT_NULL, "密码和确认密码不一致,请重新输入");
}
XhpcAppUser user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (!StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "该账号已存在请登录");
}
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(confirmPassword)) {
return R.fail(HttpStatus.NOT_NULL, "确认密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
if (phone.length() < UserConstants.USERNAME_MIN_LENGTH
|| phone.length() > UserConstants.USERNAME_MAX_LENGTH) {
return R.fail(HttpStatus.ERROR_STATUS, "用户名不在指定范围");
}
if (password.length() < UserConstants.USERNAME_MIN_LENGTH
|| password.length() > UserConstants.USERNAME_MAX_LENGTH) {
return R.fail(HttpStatus.ERROR_STATUS, "密码不在指定范围");
}
if(!password.equals(confirmPassword)){
return R.fail(HttpStatus.NOT_NULL, "密码和确认密码不一致,请重新输入");
}
XhpcAppUser user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if (!StringUtils.isNull(user)) {
return R.fail(HttpStatus.DATA_ERROR, "该账号已存在请登录");
}
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setPhone(phone);
xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password));
xhpcAppUser.setEmail(email);
xhpcAppUser.setCreateTime(new Date());
xhpcAppUser.setTenantId(tenantId);
xhpcAppUserMapper.insert(xhpcAppUser);
@ -476,7 +351,6 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
userInfo.setUserTypeUtil(UserTypeUtil.USER);
redisService.deleteObject("pvToken:" + xhpcAppUser.getPhone());
redisService.deleteObject("emailCode:"+email);
//去退出账号之前登录的信息
xhpcAppUserMapper.updateUserLoginTime(phone);
//添加最后一次登录数据
@ -687,7 +561,6 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
@Override
public R<?> appLoginOut(HttpServletRequest request) {
String language = request.getHeader("language");
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser)) {
String phone = loginUser.getUsername();
@ -700,12 +573,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
// 删除用户缓存记录
tokenService.delLoginUser(loginUser.getToken());
}
if(language.equals(UserTypeUtil.LANGUAGE_ARA)){
return R.ok(null,"خروج ناجح");
}else if(language.equals(UserTypeUtil.LANGUAGE_EN)){
return R.ok(null,"Exit successful");
}
return R.ok(null,"退出成功");
return R.ok();
}
/**
@ -746,116 +614,37 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
}
@Override
public R<?> appVoluntaryLogin(HttpServletRequest request,Map<String, Object> map) {
String language = request.getHeader("language");
public R<?> appVoluntaryLogin(Map<String, Object> map) {
String phone = StringUtils.valueOf(map.get("phone"));
String password = StringUtils.valueOf(map.get("password"));
String tenantId = StringUtils.valueOf(map.get("tenantId"));
if(UserTypeUtil.LANGUAGE_ARA.equals(language)){
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء الحساب");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "يجب ملء كلمة المرور");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "يجب على المستأجر ملء");
}
}else if(UserTypeUtil.LANGUAGE_EN.equals(language)){
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "Account must be filled in");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "Password must be filled in");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "Tenants must fill in");
}
}else{
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
if (StringUtils.isAnyBlank(phone)) {
return R.fail(HttpStatus.NOT_NULL, "账号必须填写");
}
if (StringUtils.isAnyBlank(password)) {
return R.fail(HttpStatus.NOT_NULL, "密码必须填写");
}
if (StringUtils.isAnyBlank(tenantId)) {
return R.fail(HttpStatus.NOT_NULL, "租户必须填写");
}
XhpcAppUser user = xhpcAppUserMapper.getAppUserPhoneByPassword(phone,null,tenantId);
if(UserTypeUtil.LANGUAGE_ARA.equals(language)){
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.NOT_NULL, "يرجى تسجيل الدخول مرة أخرى");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.NOT_NULL, "يرجى تسجيل الدخول مرة أخرى");
}
}
Map<String, Object> userLoginTime = xhpcAppUserMapper.getAppUserLoginTime(3,user.getAppUserId(), phone,tenantId);
if(userLoginTime ==null){
return R.fail(HttpStatus.USER_LOGIN, "يرجى تسجيل الدخول مرة أخرى");
}else{
if("0".equals(userLoginTime.get("status").toString())){
return R.fail(HttpStatus.USER_LOGIN, "يرجى تسجيل الدخول مرة أخرى");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, ":رقم حسابك" + phone + " تم حذف ");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, ":رقم حسابك" + phone + " تعطيل ");
}
}else if(UserTypeUtil.LANGUAGE_EN.equals(language)){
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.NOT_NULL, "Please log in again");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.NOT_NULL, "Please log in again");
}
}
Map<String, Object> userLoginTime = xhpcAppUserMapper.getAppUserLoginTime(3,user.getAppUserId(), phone,tenantId);
if(userLoginTime ==null){
return R.fail(HttpStatus.USER_LOGIN, "Please log in again");
}else{
if("0".equals(userLoginTime.get("status").toString())){
return R.fail(HttpStatus.USER_LOGIN, "Please log in again");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "Your account" + phone + " have been deleted");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "Your account" + phone + " deactivated");
}
if (StringUtils.isNull(user)) {
return R.fail(HttpStatus.NOT_NULL, "请重新登录");
}else{
if (StringUtils.isNull(user)) {
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.NOT_NULL, "请重新登录");
}else{
boolean b = SecurityUtils.matchesPassword(password, user.getPassword());
if(!b){
return R.fail(HttpStatus.NOT_NULL, "请重新登录");
}
}
Map<String, Object> userLoginTime = xhpcAppUserMapper.getAppUserLoginTime(3,user.getAppUserId(), phone,tenantId);
if(userLoginTime ==null){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
}else{
if("0".equals(userLoginTime.get("status").toString())){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
}
}
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "您的账号:" + phone + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "您的账号:" + phone + " 已停用");
}
}
Map<String, Object> userLoginTime = xhpcAppUserMapper.getAppUserLoginTime(3,user.getAppUserId(), phone,tenantId);
if(userLoginTime ==null){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
}else{
if("0".equals(userLoginTime.get("status").toString())){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
}
}
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setPhone(phone);
xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password));
@ -872,7 +661,12 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
userInfo.setUserid(user.getAppUserId());
userInfo.setTenantId(tenantId);
userInfo.setUserTypeUtil(UserTypeUtil.USER);
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + phone + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + phone + " 已停用");
}
redisService.deleteObject("pvToken:" + user.getPhone());
//去退出账号之前登录的信息
xhpcAppUserMapper.updateUserLoginTime(phone);
@ -891,7 +685,6 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
*/
@Override
public AjaxResult appInfo(HttpServletRequest request) {
String language = request.getHeader("language");
try{
LoginUser loginUser = tokenService.getLoginUser();
String tenantId = loginUser.getTenantId();
@ -961,24 +754,12 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
map.put("socSize",redisService.getCacheObject("global:"+tenantId+":SOC"));
return AjaxResult.success(map);
}else{
if(UserTypeUtil.LANGUAGE_ARA.equals(language)){
return AjaxResult.error("يرجى تسجيل الدخول مرة أخرى",HttpStatus.USER_LOGIN);
}else if(UserTypeUtil.LANGUAGE_EN.equals(language)){
return AjaxResult.error("Please log in again",HttpStatus.USER_LOGIN);
}else{
return AjaxResult.error("请重新登录",HttpStatus.USER_LOGIN);
}
return AjaxResult.error("请重新登录",HttpStatus.USER_LOGIN);
}
}catch (Exception e){
e.printStackTrace();
logger.info("-------appInfo----请重新登录---");
if(UserTypeUtil.LANGUAGE_ARA.equals(language)){
return AjaxResult.error("يرجى تسجيل الدخول مرة أخرى",HttpStatus.USER_LOGIN);
}else if(UserTypeUtil.LANGUAGE_EN.equals(language)){
return AjaxResult.error("Please log in again",HttpStatus.USER_LOGIN);
}else{
return AjaxResult.error("请重新登录",HttpStatus.USER_LOGIN);
}
return AjaxResult.error("请重新登录",HttpStatus.USER_LOGIN);
}
}
@ -1047,36 +828,6 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
return R.fail(HttpStatus.ERROR_STATUS, "参数错误");
}
@Override
public R<?> doubleGunCharging(Long userId, Integer userType, Integer sunchaSwitch) {
if(sunchaSwitch>2 || sunchaSwitch<0){
return R.fail(HttpStatus.ERROR_STATUS, "参数错误");
}
if(userType==0){
int i = xhpcAppUserMapper.updateUserSunchaSwitch(userId, sunchaSwitch);
if(i>0){
return R.ok();
}else{
return R.fail(HttpStatus.ERROR_STATUS, "修改失败");
}
}else if(userType==1){
int i = xhpcAppUserMapper.updateCommunityPersonnelSunchaSwitch(userId, sunchaSwitch,null,null);
if(i>0){
return R.ok();
}else{
return R.fail(HttpStatus.ERROR_STATUS, "修改失败");
}
}else if(userType==2){
int i = xhpcAppUserMapper.updateCustomersPersonnelSunchaSwitch(userId, sunchaSwitch,null,null);
if(i>0){
return R.ok();
}else{
return R.fail(HttpStatus.ERROR_STATUS, "修改失败");
}
}
return R.fail(HttpStatus.ERROR_STATUS, "参数错误");
}
@Override
public R<?> batteryProtect(HttpServletRequest request, Integer soc,Integer socProtect,Integer userType) {
LoginUser loginUser = logUserUtils.getLogUser(request);

View File

@ -1,120 +0,0 @@
package com.xhpc.user.service.impl;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.security.service.TokenService;
import com.xhpc.user.domain.XhpcBlacklist;
import com.xhpc.user.mapper.XhpcBlacklistMapper;
import com.xhpc.user.service.IMechanismService;
import com.xhpc.user.service.IXhpcBlacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
public class XhpcBlacklistServiceImpl extends BaseService implements IXhpcBlacklistService {
@Resource
private XhpcBlacklistMapper xhpcBlacklistMapper;
@Resource
private TokenService tokenService;
@Autowired
private IMechanismService mechanismService;
@Override
public List<Map<String, Object>> getList(Map<String, Object> params) {
startPage();
return xhpcBlacklistMapper.getList(params);
}
@Override
public AjaxResult addBlacklist(HttpServletRequest request, XhpcBlacklist xhpcBlacklist) {
R r = judgeXhpcCustomers(xhpcBlacklist);
if(r.getCode()!=200){
return AjaxResult.error(r.getMsg());
}
//名称重复不能入库
Integer distinguish = xhpcBlacklist.getDistinguish();
if(distinguish==1){
int phoneOrVin = xhpcBlacklistMapper.getPhoneOrVin(xhpcBlacklist.getPhone(), xhpcBlacklist.getPlateNum(),xhpcBlacklist.getBlacklistId(),distinguish);
if(phoneOrVin >0 ){
return AjaxResult.error("手机号或者车牌号重复");
}
}else{
// int i = xhpcBlacklistMapper.getManufacturersOrVehicletype(xhpcBlacklist.getManufacturers(),null,null,null,xhpcBlacklist.getBlacklistId(),distinguish);
// if(i >0 ){
// return AjaxResult.error("制造厂商重复");
// }
// int i1 = xhpcBlacklistMapper.getManufacturersOrVehicletype(null,xhpcBlacklist.getVehicleType(),null,null,xhpcBlacklist.getBlacklistId(),distinguish);
// if(i1 >0 ){
// return AjaxResult.error("车辆类型重复");
// }
// int i2 = xhpcBlacklistMapper.getManufacturersOrVehicletype(null,null,xhpcBlacklist.getVehicleEngine(),null,xhpcBlacklist.getBlacklistId(),distinguish);
// if(i2 >0 ){
// return AjaxResult.error("发动机型式重复");
// }
// int i3 = xhpcBlacklistMapper.getManufacturersOrVehicletype(null,null,null,xhpcBlacklist.getVehicleCode(),xhpcBlacklist.getBlacklistId(),distinguish);
// if(i3 >0 ){
// return AjaxResult.error("企业车型代码重复");
// }
}
String chargingStationIds = xhpcBlacklist.getChargingStationIds();
if("".equals(chargingStationIds) || chargingStationIds ==null){
xhpcBlacklist.setStatus(0);
}else{
xhpcBlacklist.setStatus(1);
}
if(xhpcBlacklist.getBlacklistId() ==null){
xhpcBlacklistMapper.insertBlacklist(xhpcBlacklist);
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcBlacklist.getBlacklistId(),2);
}
}else{
xhpcBlacklistMapper.updateBlacklist(xhpcBlacklist);
mechanismService.updateMechanism(xhpcBlacklist.getBlacklistId(),2);
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
mechanismService.addMechanism(Arrays.asList(chargingStationIds.split(",")),xhpcBlacklist.getBlacklistId(),2);
}
}
return AjaxResult.success();
}
@Override
public Map<String, Object> getBlacklistById(Long blacklistId) {
return xhpcBlacklistMapper.getBlacklistById(blacklistId);
}
@Override
public void deleteBlacklistById(Long blacklistId) {
xhpcBlacklistMapper.deleteBlacklistById(blacklistId);
}
public R judgeXhpcCustomers(XhpcBlacklist xhpcBlacklist){
if(xhpcBlacklist.getDistinguish()==1){
if(xhpcBlacklist.getPhone()==null || "".equals(xhpcBlacklist.getPhone())){
return R.fail("电话必填");
}
if(xhpcBlacklist.getPlateNum()==null || "".equals(xhpcBlacklist.getPlateNum())){
return R.fail("车牌必填");
}
}
if(xhpcBlacklist.getStartTime().getTime()>xhpcBlacklist.getEndTime().getTime()){
return R.fail("限制充电开始时间大于结束时间");
}
return R.ok();
}
}

View File

@ -834,14 +834,6 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
redisService.setCacheObject(invoice,notRead);
}
public static void main(String[] args) {
try {
MailUtil.send("2265829957@qq.com", "【小华充电】验证码", "您可以使用此验证码来验证修改密码457896", false, null);
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
}
}
}

View File

@ -264,10 +264,6 @@
update xhpc_app_user set is_refund=#{isRefund} where app_user_id=#{userId}
</update>
<update id="updateUserSunchaSwitch">
update xhpc_app_user set suncha_switch=#{sunchaSwitch} where app_user_id=#{userId}
</update>
<update id="updateCommunityIsRefund">
UPDATE xhpc_community_personnel
<set>
@ -278,26 +274,6 @@
WHERE community_personnel_id = #{userId}
</update>
<update id="updateCommunityPersonnelSunchaSwitch">
UPDATE xhpc_community_personnel
<set>
<if test="null != suncha_switch">suncha_switch = #{sunchaSwitch},</if>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE community_personnel_id = #{userId}
</update>
<update id="updateCustomersPersonnelSunchaSwitch">
UPDATE xhpc_customers_personnel
<set>
<if test="null != suncha_switch">suncha_switch = #{sunchaSwitch},</if>
<if test="null != socProtect">soc_protect = #{socProtect},</if>
<if test="null != soc ">soc = #{soc},</if>
</set>
WHERE customers_personnel_id = #{userId}
</update>
<update id="updateCustomersSocProtect">
UPDATE xhpc_customers_personnel
<set>

View File

@ -1,303 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.user.mapper.XhpcBlacklistMapper">
<resultMap type="com.xhpc.user.domain.XhpcBlacklist" id="XhpcBlacklistResult">
<result column="blacklist_id" property="blacklistId"/>
<result column="vehicle_type" property="vehicleType"/>
<result column="dimension" property="dimension"/>
<result column="status" property="status"/>
<result column="del_flag" property="delFlag"/>
<result column="create_by" property="createBy"/>
<result column="create_time" property="createTime"/>
<result column="update_by" property="updateBy"/>
<result column="update_time" property="updateTime"/>
<result column="remark" property="remark"/>
<result column="manufacturers" property="manufacturers"/>
<result column="vehicle_engine" property="vehicleEngine"/>
<result column="vehicle_code" property="vehicleCode"/>
<result column="phone" property="phone"/>
<result column="plate_num" property="plateNum"/>
<result column="vin" property="vin"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="distinguish" property="distinguish"/>
</resultMap>
<select id="getList" resultType="map">
select
blacklist_id as blacklistId,
manufacturers as manufacturers,
vehicle_type as vehicleType,
vehicle_engine as vehicleEngine,
vehicle_code as vehicleCode,
phone as phone,
vin as vin,
plate_num as plateNum,
(select group_concat(name) from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_mechanism where mechanism_id = blacklist_id and source =2 and del_flag =0)) as chargingStationName,
concat(start_time," 至 ",end_time) as limitTime
from xhpc_blacklist
where del_flag =0
<if test="params.phone !=null and params.phone !=''">
and phone like CONCAT('%',#{params.phone},'%')
</if>
<if test="params.plateNum !=null and params.plateNum !=''">
and plate_num like CONCAT('%',#{params.plateNum},'%')
</if>
<if test="params.vin !=null and params.vin !=''">
and vin like CONCAT('%',#{params.vin},'%')
</if>
<if test="params.startTime !=null">
and start_time &gt;= #{params.startTime}
</if>
<if test="params.endTime !=null">
and end_time &lt;= #{params.endTime}
</if>
<if test="params.distinguish !=null">
and distinguish = #{params.distinguish}
</if>
order by create_time desc
</select>
<select id="getPhoneOrVin" resultType="int">
select count(blacklist_id)
from xhpc_blacklist
where del_flag=0 and (phone=#{phone} or plate_num=#{plateNum})
<if test="blacklistId !=null">
and blacklist_id !=#{blacklistId}
</if>
<if test="distinguish !=null">
and distinguish =#{distinguish}
</if>
</select>
<select id="getManufacturersOrVehicletype" resultType="int">
select count(blacklist_id)
from xhpc_blacklist
where del_flag=0 and (phone=#{phone} or plate_num=#{plateNum})
<if test="blacklistId !=null">
and blacklist_id !=#{blacklistId}
</if>
<if test="distinguish !=null">
and distinguish =#{distinguish}
</if>
<if test="manufacturers !=null and manufacturers !=''">
and manufacturers =#{manufacturers}
</if>
<if test="vehicleType !=null and vehicleType !=''">
and vehicle_type =#{vehicleType}
</if>
<if test="vehicleEngine !=null and vehicleEngine !=''">
and vehicle_engine =#{vehicleEngine}
</if>
<if test="vehicleCode !=null and vehicleCode !=''">
and vehicle_code =#{vehicleCode}
</if>
</select>
<insert id="insertBlacklist" parameterType="com.xhpc.user.domain.XhpcBlacklist" useGeneratedKeys="true" keyProperty="blacklistId">
insert into xhpc_blacklist
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != dimension and dimension !=''">
dimension,
</if>
<if test="null != status ">
status,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != manufacturers and '' != manufacturers">
manufacturers,
</if>
<if test="null != vehicleType and ''!=vehicleType">
vehicle_type,
</if>
<if test="null != vehicleEngine and ''!=vehicleEngine">
vehicle_engine,
</if>
<if test="null != vehicleCode and vehicleCode!=''">
vehicle_code,
</if>
<if test="null != vin and vin!=''">
vin,
</if>
<if test="null != plateNum and plateNum!=''">
plate_num,
</if>
<if test="null != startTime">
start_time,
</if>
<if test="null != endTime">
end_time,
</if>
<if test="null != phone and phone !=''">
phone,
</if>
<if test="null != distinguish">
distinguish,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != dimension and dimension !=''">
#{dimension},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != manufacturers and '' != manufacturers">
#{manufacturers},
</if>
<if test="null != vehicleType and vehicleType!=''">
#{vehicleType},
</if>
<if test="null != vehicleEngine and vehicleEngine!=''">
#{vehicleEngine},
</if>
<if test="null != vehicleCode and vehicleCode!=''">
#{vehicleCode},
</if>
<if test="null != vin and vin!=''">
#{vin},
</if>
<if test="null != plateNum and plateNum!=''">
#{plateNum},
</if>
<if test="null != startTime">
#{startTime},
</if>
<if test="null != endTime">
#{endTime},
</if>
<if test="null != phone and phone !=''">
#{phone},
</if>
<if test="null != distinguish">
#{distinguish},
</if>
</trim>
</insert>
<update id="updateBlacklist" parameterType="com.xhpc.user.domain.XhpcBlacklist" useGeneratedKeys="true" keyProperty="blacklistId">
update xhpc_blacklist
<trim prefix="SET" suffixOverrides=",">
<if test="null != dimension and dimension !=''">
dimension=#{dimension},
</if>
<if test="null != status ">
status=#{status},
</if>
<if test="null != delFlag ">
del_flag=#{delFlag},
</if>
<if test="null != createTime ">
create_time=#{createTime},
</if>
<if test="null != createBy and '' != createBy">
create_by=#{createBy},
</if>
<if test="null != updateTime ">
update_time=#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
update_by=#{updateBy},
</if>
<if test="null != remark and '' != remark">
remark=#{remark},
</if>
<if test="null != manufacturers and '' != manufacturers">
manufacturers=#{manufacturers},
</if>
<if test="null != vehicleType and vehicleType!=''">
vehicle_type=#{vehicleType},
</if>
<if test="null != vehicleEngine and vehicleEngine!=''">
vehicle_engine=#{vehicleEngine},
</if>
<if test="null != vehicleCode and vehicleCode!=''">
vehicle_code=#{vehicleCode},
</if>
<if test="null != vin and vin!=''">
vin=#{vin},
</if>
<if test="null != plateNum and plateNum!=''">
plate_num= #{plateNum},
</if>
<if test="null != startTime">
start_time= #{startTime},
</if>
<if test="null != endTime">
end_time=#{endTime},
</if>
<if test="null != phone and phone !=''">
phone= #{phone},
</if>
<if test="null != distinguish">
distinguish=#{distinguish},
</if>
</trim>
where blacklist_id=#{blacklistId}
</update>
<update id="deleteBlacklistById">
update xhpc_blacklist set del_flag =1 where blacklist_id=#{blacklistId}
</update>
<select id="getBlacklistById" resultType="map">
select
xb.blacklist_id as blacklistId,
xb.manufacturers as manufacturers,
xb.vehicle_type as vehicleType,
xb.vehicle_engine as vehicleEngine,
xb.vehicle_code as vehicleCode,
xb.phone as phone,
xb.vin as vin,
xb.plate_num as plateNum,
xb.start_time as startTime,
xb.end_time as endTime,
xb.distinguish as distinguish,
group_concat(me.charging_station_id) chargingStationIds
from xhpc_blacklist xb
left join xhpc_mechanism me on me.mechanism_id = xb.blacklist_id and me.source = 2 and me.del_flag =0
where xb.blacklist_id=#{blacklistId}
limit 1
</select>
</mapper>

View File

@ -28,10 +28,6 @@
xau.tenant_id tenantId,
xau.soc_protect socProtect,
ten.status tenantStatus,
xau.suncha_switch as sunchaSwitch,
xau.a_balance as aBalance,
xau.b_balance as bBalance,
(select vin_spec_code as vinSpecCode from xhpc_user_vehicle where app_user_id = xau.app_user_id and source=0 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vinSpecCode,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xau.app_user_id and source=0 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
xau.create_time as createTime
from xhpc_app_user xau
@ -70,10 +66,6 @@
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("ST") as userTypeName,
xcp.suncha_switch as sunchaSwitch,
xcp.a_balance as aBalance,
xcp.b_balance as bBalance,
(select vin_spec_code as vinSpecCode from xhpc_user_vehicle where app_user_id = xcp.community_personnel_id and source=2 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vinSpecCode,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xcp.community_personnel_id and source=2 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
@ -114,10 +106,6 @@
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("BE") as userTypeName,
xcp.suncha_switch as sunchaSwitch,
xcp.a_balance as aBalance,
xcp.b_balance as bBalance,
(select vin_spec_code as vinSpecCode from xhpc_user_vehicle where app_user_id = xcp.customers_personnel_id and source=3 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vinSpecCode,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xcp.customers_personnel_id and source=3 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,

View File

@ -18,11 +18,6 @@
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>

View File

@ -1,61 +0,0 @@
package com.xhpc.wxma.serialPort;
import java.nio.charset.StandardCharsets;
public class ConvertHexStrAndStrUtils {
private static final char[] HEXES = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public static String bytesToHexStr(byte[] bytes) {
if (bytes == null || bytes.length == 0) {
return null;
}
StringBuilder hex = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
hex.append(HEXES[(b >> 4) & 0x0F]);
hex.append(HEXES[b & 0x0F]);
}
return hex.toString().toUpperCase();
}
public static byte[] hexStrToBytes(String hex) {
if (hex == null || hex.length() == 0) {
return null;
}
char[] hexChars = hex.toCharArray();
byte[] bytes = new byte[hexChars.length / 2]; // 如果 hex 中的字符不是偶数个, 则忽略最后一个
for (int i = 0; i < bytes.length; i++) {
bytes[i] = (byte) Integer.parseInt("" + hexChars[i * 2] + hexChars[i * 2 + 1], 16);
}
return bytes;
}
public static String strToHexStr(String str) {
StringBuilder sb = new StringBuilder();
byte[] bs = str.getBytes();
int bit;
for (int i = 0; i < bs.length; i++) {
bit = (bs[i] & 0x0f0) >> 4;
sb.append(HEXES[bit]);
bit = bs[i] & 0x0f;
sb.append(HEXES[bit]);
}
return sb.toString().trim();
}
public static String hexStrToStr(String hexStr) {
//能被16整除,肯定可以被2整除
byte[] array = new byte[hexStr.length() / 2];
try {
for (int i = 0; i < array.length; i++) {
array[i] = (byte) (0xff & Integer.parseInt(hexStr.substring(i * 2, i * 2 + 2), 16));
}
hexStr = new String(array, StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
return "";
}
return hexStr;
}
}

View File

@ -1,114 +0,0 @@
package com.xhpc.wxma.serialPort;
import com.fazecast.jSerialComm.SerialPort;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.redis.service.RedisService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@RestController
@AllArgsConstructor
@RequestMapping("/serialPort")
public class OperationController {
@Autowired
SerialPortManager serialPortManager;
@Autowired
private RedisService redisService;
private final ConcurrentHashMap<String, SerialPort> serialPortMap = new ConcurrentHashMap<>();
/**
* 获取所有串口
*/
@GetMapping("/serialPortList")
public R getSerialPortList() {
List<String> systemPorts = new ArrayList<>();
SerialPort[] commPorts = SerialPort.getCommPorts();
for (SerialPort port : commPorts) {
System.out.println("Port:"+port.getSystemPortName());//打印串口名称如COM4
System.out.println("PortDesc:"+port.getPortDescription());//打印串口类型如USB Serial
System.out.println("PortDesc:"+port.getDescriptivePortName());//打印串口的完整类型如USB-SERIAL CH340(COM4)
systemPorts.add(port.getSystemPortName());
}
List<String> portNames = serialPortManager.getPortNames();
return R.ok(portNames);
}
/**
* 打开设备
*
* @param port 串口名
*/
@GetMapping("/openSerialPort")
public R openPort(String port) throws IOException {
try{
serialPortMap.remove(port);
}catch (Exception e){
}
SerialPort currentPort = serialPortManager.openDevice(port);
//打开串口失败
if (null == currentPort){
return R.fail("打开设备失败,请检查设备后重试!");
}
System.out.println("当前串口:"+currentPort);
serialPortMap.put(port, currentPort);
return R.ok("设备打开成功");
}
/**
* 关闭设备
*/
@GetMapping("/closePort")
public R closePort(String port){
Set<Map.Entry<String, SerialPort>> entrySet = serialPortMap.entrySet();
for (Map.Entry<String, SerialPort> entry : entrySet) {
String key = entry.getKey();
System.out.println("=======key========="+key);
if (serialPortMap.get(key).closePort()){
System.out.println(key+"==设备已关闭");
}
// 处理键值对
}
// if (!serialPortMap.containsKey(port)){
// return R.fail("当前未打开任何设备");
// }
// if (serialPortMap.get(port).closePort()){
// return R.success("设备已关闭");
// }
return R.ok("串口已关闭");
}
/**
* 发送信息
*/
@GetMapping ("/send")
public R sendMessage(String port, String msg,HttpServletResponse response){
if (!serialPortMap.containsKey(port)){
return R.fail("当前未打开设备");
}
return serialPortManager.sendMessage(serialPortMap.get(port), msg,response,port) ? R.ok("消息发送成功") : R.fail("消息发送失败");
}
}

View File

@ -1,20 +0,0 @@
package com.xhpc.wxma.serialPort;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class SerialPortExcel {
/**
* 原始数据
*/
@ColumnWidth(20)
@ExcelProperty("原始数据")
private String rawData;
}

View File

@ -1,131 +0,0 @@
package com.xhpc.wxma.serialPort;
import com.fazecast.jSerialComm.SerialPort;
import com.fazecast.jSerialComm.SerialPortDataListener;
import com.fazecast.jSerialComm.SerialPortEvent;
import com.xhpc.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@Component
public class SerialPortManager {
//串口设备描述
private static final String VIRTUAL_SERIAL = "ELTIMA_Virtual_Serial_Port";
private static final int SAFETY_SLEEP_TIME = 2000;
private static final int DEFAULT_BAUD_RATE = 9600;
private static final int DEFAULT_DATA_BITS = 8;
@Autowired
private RedisService redisService;
private final ConcurrentHashMap<String, HttpServletResponse> responseMap = new ConcurrentHashMap<>();
private final List<SerialPortExcel> list =new ArrayList<>();
private HttpServletResponse httpServletResponse;
/**
* 查询当前设备的端口名称
*/
public List<String> getPortNames(){
SerialPort[] ports = SerialPort.getCommPorts();
List<String> portNames = new ArrayList<>();
for (SerialPort port : ports) {
if (port.getPortDescription().contains(VIRTUAL_SERIAL)){
System.out.println("Port:"+port.getSystemPortName());//打印串口名称如COM4
System.out.println("PortDesc:"+port.getPortDescription());//打印串口类型如USB Serial
System.out.println("PortDesc:"+port.getDescriptivePortName());//打印串口的完整类型如USB-SERIAL CH340(COM4)
portNames.add(port.getSystemPortName());
}
}
return portNames;
}
/**
* 打开串口
*/
public SerialPort openDevice(String portName){
SerialPort commPort = SerialPort.getCommPort(portName);
if (commPort.isOpen()){
return commPort;
}
//打开串口成功设置端口参数
commPort.setBaudRate(9600);
commPort.setNumDataBits(8);
commPort.setNumStopBits(1);
commPort.setParity(SerialPort.NO_PARITY);
if (commPort.openPort()){
//设置监听器
commPort.addDataListener(new SerialPortDataListener() {
@Override
public int getListeningEvents() {
return SerialPort.LISTENING_EVENT_DATA_AVAILABLE;
}
@Override
public void serialEvent(SerialPortEvent event) {
if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE) {
System.out.println("=========结束===============");
return;
}
System.out.println("=========commPort.bytesAvailable()==============="+commPort.bytesAvailable());
byte[] newData = new byte[commPort.bytesAvailable()];
int numRead = commPort.readBytes(newData, newData.length);
try {
String s = new String(newData, "UTF-8");
compoundSerialPortExcelList(s,event.getSerialPort(),numRead);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
});
return commPort;
}
return null;
}
/**
* 串口发送信息
*/
public boolean sendMessage(SerialPort serialPort, String msg,HttpServletResponse response,String port){
//responseMap.put(port, response);
httpServletResponse = response;
msg = "PrintfInformation(0);\r\n";
String s = ConvertHexStrAndStrUtils.strToHexStr(msg);
byte[] msgBytes = ConvertHexStrAndStrUtils.hexStrToBytes(s);
return serialPort.writeBytes(msgBytes, msgBytes.length) != -1;
}
public void compoundSerialPortExcelList(String rawData,SerialPort serialPort,int numRead){
System.out.println("============rawData:=========="+rawData);
SerialPortExcel serialPortExcel = new SerialPortExcel();
serialPortExcel.setRawData(rawData);
list.add(serialPortExcel);
if(32!=numRead){
String systemPortName = serialPort.getSystemPortName();
//HttpServletResponse response = responseMap.get(systemPortName);
redisService.setCacheObject(systemPortName,list);
//exportDetectionInfo(list,httpServletResponse);
}
}
}

View File

@ -1,159 +0,0 @@
package com.xhpc.wxma.translate;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
class HttpGet {
protected static final int SOCKET_TIMEOUT = 10000; // 10S
protected static final String GET = "GET";
public static String get(String host, Map<String, String> params) {
try {
// 设置SSLContext
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, new TrustManager[] { myX509TrustManager }, null);
String sendUrl = getUrlWithQueryString(host, params);
// System.out.println("URL:" + sendUrl);
URL uri = new URL(sendUrl); // 创建URL对象
HttpURLConnection conn = (HttpURLConnection) uri.openConnection();
if (conn instanceof HttpsURLConnection) {
((HttpsURLConnection) conn).setSSLSocketFactory(sslcontext.getSocketFactory());
}
conn.setConnectTimeout(SOCKET_TIMEOUT); // 设置相应超时
conn.setRequestMethod(GET);
int statusCode = conn.getResponseCode();
if (statusCode != HttpURLConnection.HTTP_OK) {
System.out.println("Http错误码" + statusCode);
}
// 读取服务器的数据
InputStream is = conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null) {
builder.append(line);
}
String text = builder.toString();
close(br); // 关闭数据流
close(is); // 关闭数据流
conn.disconnect(); // 断开连接
return text;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
public static String getUrlWithQueryString(String url, Map<String, String> params) {
if (params == null) {
return url;
}
StringBuilder builder = new StringBuilder(url);
if (url.contains("?")) {
builder.append("&");
} else {
builder.append("?");
}
int i = 0;
for (String key : params.keySet()) {
String value = params.get(key);
if (value == null) { // 过滤空的key
continue;
}
if (i != 0) {
builder.append('&');
}
builder.append(key);
builder.append('=');
builder.append(encode(value));
i++;
}
return builder.toString();
}
protected static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 对输入的字符串进行URL编码, 即转换为%20这种形式
*
* @param input 原文
* @return URL编码. 如果编码失败, 则返回原文
*/
public static String encode(String input) {
if (input == null) {
return "";
}
try {
return URLEncoder.encode(input, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return input;
}
private static TrustManager myX509TrustManager = new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
};
}

View File

@ -1,127 +0,0 @@
package com.xhpc.wxma.translate;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* MD5编码相关的类
*
* @author wangjingtao
*
*/
public class MD5 {
// 首先初始化一个字符数组用来存放每个16进制字符
private static final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
'e', 'f' };
/**
* 获得一个字符串的MD5值
*
* @param input 输入的字符串
* @return 输入字符串的MD5值
*
*/
public static String md5(String input) {
if (input == null)
return null;
try {
try {
// 拿到一个MD5转换器如果想要SHA1参数换成SHA1
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
// 输入的字符串转换成字节数组
byte[] inputByteArray = input.getBytes("utf-8");
// inputByteArray是输入字符串转换得到的字节数组
messageDigest.update(inputByteArray);
// 转换并返回结果也是字节数组包含16个元素
byte[] resultByteArray = messageDigest.digest();
// 字符数组转换成字符串返回
return byteArrayToHex(resultByteArray);
} catch (UnsupportedEncodingException e) {
return null;
}
} catch (NoSuchAlgorithmException e) {
return null;
}
}
/**
* 获取文件的MD5值
*
* @param file
* @return
*/
public static String md5(File file) {
try {
if (!file.isFile()) {
System.err.println("文件" + file.getAbsolutePath() + "不存在或者不是文件");
return null;
}
FileInputStream in = new FileInputStream(file);
String result = md5(in);
in.close();
return result;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static String md5(InputStream in) {
try {
MessageDigest messagedigest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[1024];
int read = 0;
while ((read = in.read(buffer)) != -1) {
messagedigest.update(buffer, 0, read);
}
in.close();
String result = byteArrayToHex(messagedigest.digest());
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private static String byteArrayToHex(byte[] byteArray) {
// new一个字符数组这个就是用来组成结果字符串的解释一下一个byte是八位二进制也就是2位十六进制字符2的8次方等于16的2次方
char[] resultCharArray = new char[byteArray.length * 2];
// 遍历字节数组通过位运算位运算效率高转换成字符放到字符数组中去
int index = 0;
for (byte b : byteArray) {
resultCharArray[index++] = hexDigits[b >>> 4 & 0xf];
resultCharArray[index++] = hexDigits[b & 0xf];
}
// 字符数组组合成字符串返回
return new String(resultCharArray);
}
}

View File

@ -1,21 +0,0 @@
package com.xhpc.wxma.translate;
public class Main {
// 在平台申请的APP_ID 详见 https://fanyi-api.baidu.com/api/trans/product/desktop?req=developer
private static final String APP_ID = "20240726002109135";
private static final String SECURITY_KEY = "ZLsV_7lQvfK9J6TnEh6M";
public static void main(String[] args) {
TransApi api = new TransApi(APP_ID, SECURITY_KEY);
String query = "高度600米";
System.out.println(api.getTransResult(query, "zh", "ara"));
}
}

View File

@ -1,42 +0,0 @@
package com.xhpc.wxma.translate;
import java.util.HashMap;
import java.util.Map;
public class TransApi {
private static final String TRANS_API_HOST = "https://fanyi-api.baidu.com/api/trans/vip/translate";
private String appid;
private String securityKey;
public TransApi(String appid, String securityKey) {
this.appid = appid;
this.securityKey = securityKey;
}
public String getTransResult(String query, String from, String to) {
Map<String, String> params = buildParams(query, from, to);
return HttpGet.get(TRANS_API_HOST, params);
}
private Map<String, String> buildParams(String query, String from, String to) {
Map<String, String> params = new HashMap<String, String>();
params.put("q", query);
params.put("from", from);
params.put("to", to);
params.put("appid", appid);
// 随机数
String salt = String.valueOf(System.currentTimeMillis());
params.put("salt", salt);
// 签名
String src = appid + query + salt + securityKey; // 加密前的原文
params.put("sign", MD5.md5(src));
System.out.println("params===="+params.toString());
return params;
}
}