|
@@ -3,7 +3,6 @@ package com.kym.service.miniapp.impl;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.kym.common.constant.ResponseEnum;
|
|
import com.kym.common.constant.ResponseEnum;
|
|
|
import com.kym.common.exception.BusinessException;
|
|
import com.kym.common.exception.BusinessException;
|
|
|
-import com.kym.common.utils.IDGenerator;
|
|
|
|
|
import com.kym.common.utils.OrderUtils;
|
|
import com.kym.common.utils.OrderUtils;
|
|
|
import com.kym.entity.enplus.response.EnBusinessPolicy;
|
|
import com.kym.entity.enplus.response.EnBusinessPolicy;
|
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
@@ -29,10 +28,6 @@ import java.util.Map;
|
|
|
public class ChargeServiceImpl implements ChargeService {
|
|
public class ChargeServiceImpl implements ChargeService {
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(ChargeServiceImpl.class);
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(ChargeServiceImpl.class);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IDGenerator idGenerator;
|
|
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EquipmentRelationService equipmentRelationService;
|
|
private EquipmentRelationService equipmentRelationService;
|
|
|
|
|
|
|
@@ -57,22 +52,7 @@ public class ChargeServiceImpl implements ChargeService {
|
|
|
@Override
|
|
@Override
|
|
|
public Map queryStartCharge(String connectorId, String stationId) {
|
|
public Map queryStartCharge(String connectorId, String stationId) {
|
|
|
var userId = StpUtil.getSession().getLong("userId");
|
|
var userId = StpUtil.getSession().getLong("userId");
|
|
|
- if (connectorId.length() == 6) {
|
|
|
|
|
- // 查询EN+设备SN
|
|
|
|
|
- var equipmentRelation = equipmentRelationService.getByShortId(connectorId);
|
|
|
|
|
- connectorId = equipmentRelation.getEquipmentId();
|
|
|
|
|
- if (connectorId.length() == 16) {
|
|
|
|
|
- // 如果是16位,末尾补1作为单枪枪号
|
|
|
|
|
- connectorId = connectorId.concat("1");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (connectorId.length() == 16) {
|
|
|
|
|
- connectorId = connectorId.concat("1");
|
|
|
|
|
- } else {
|
|
|
|
|
- // 充电桩编号错误
|
|
|
|
|
- LOGGER.error("用户:{}请求充电,设备编码错误:{}", userId, connectorId);
|
|
|
|
|
- throw new BusinessException(ResponseEnum.EQUIP_CONNECTOR_ID_ERROR);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ stationId = getConnectorId(stationId);
|
|
|
|
|
|
|
|
// 二维码文本
|
|
// 二维码文本
|
|
|
var qrCode = "";
|
|
var qrCode = "";
|
|
@@ -167,29 +147,47 @@ public class ChargeServiceImpl implements ChargeService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getConnectorId(String connectorId) {
|
|
|
|
|
+ if (connectorId.length() == 6) {
|
|
|
|
|
+ // 查询EN+设备SN
|
|
|
|
|
+ var equipmentRelation = equipmentRelationService.getByShortId(connectorId);
|
|
|
|
|
+ connectorId = equipmentRelation.getEquipmentId();
|
|
|
|
|
+ if (connectorId.length() == 16) {
|
|
|
|
|
+ // 如果是16位,末尾补1作为单枪枪号
|
|
|
|
|
+ connectorId = connectorId.concat("1");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (connectorId.length() == 16) {
|
|
|
|
|
+ connectorId = connectorId.concat("1");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 充电桩编号错误
|
|
|
|
|
+ LOGGER.error("设备编码错误:{}", connectorId);
|
|
|
|
|
+ throw new BusinessException(ResponseEnum.EQUIP_CONNECTOR_ID_ERROR);
|
|
|
|
|
+ }
|
|
|
|
|
+ return connectorId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 请求停止充电
|
|
* 请求停止充电
|
|
|
*
|
|
*
|
|
|
- * @param startChargeSeq
|
|
|
|
|
* @param connectorId
|
|
* @param connectorId
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void queryStopCharge(String startChargeSeq, String connectorId) {
|
|
|
|
|
- if (connectorId.length() == 6) {
|
|
|
|
|
- var equipmentRelation = equipmentRelationService.getByShortId(connectorId);
|
|
|
|
|
- var equipmentId = equipmentRelation.getEquipmentId();
|
|
|
|
|
- if (equipmentId.length() == 16) {
|
|
|
|
|
- // 如果是16位,末尾补1作为单枪枪号
|
|
|
|
|
- connectorId = equipmentId.concat("1");
|
|
|
|
|
- }
|
|
|
|
|
- } else if (connectorId.length() == 16) {
|
|
|
|
|
- connectorId = connectorId.concat("1");
|
|
|
|
|
|
|
+ public void queryStopCharge(String connectorId) {
|
|
|
|
|
+ var userId = StpUtil.getLoginIdAsLong();
|
|
|
|
|
+ connectorId = getConnectorId(connectorId);
|
|
|
|
|
+ // 查询充电订单
|
|
|
|
|
+ var chargeOrder = chargeOrderService.lambdaQuery().eq(ChargeOrder::getUserId, userId).eq(ChargeOrder::getConnectorId, connectorId).one();
|
|
|
|
|
+ if (chargeOrder == null) {
|
|
|
|
|
+ // 记录失败原因
|
|
|
|
|
+ LOGGER.error("用户:{}请求停止充电异常,设备:{}无进行中的订单", userId, connectorId);
|
|
|
|
|
+ throw new BusinessException(ResponseEnum.NO_ORDER_IN_PROGRESS);
|
|
|
}
|
|
}
|
|
|
- var data = enPlusService.queryStopCharge(startChargeSeq, connectorId);
|
|
|
|
|
|
|
+ var data = enPlusService.queryStopCharge(chargeOrder.getStartChargeSeq(), connectorId);
|
|
|
if (data.containsKey("SuccStat") && data.getIntValue("SuccStat") != 0) {
|
|
if (data.containsKey("SuccStat") && data.getIntValue("SuccStat") != 0) {
|
|
|
// 记录失败原因
|
|
// 记录失败原因
|
|
|
- LOGGER.error("订单:{}停止充电失败,返回结果{}", startChargeSeq, data);
|
|
|
|
|
|
|
+ LOGGER.error("订单:{}停止充电失败,返回结果:{}", chargeOrder.getStartChargeSeq(), data);
|
|
|
throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_STOP_FAIL);
|
|
throw new BusinessException(ResponseEnum.EN_PLUS_EQUIP_STOP_FAIL);
|
|
|
}
|
|
}
|
|
|
// 这里不更新订单状态,等待EN+推送停止充电结果信息再处理
|
|
// 这里不更新订单状态,等待EN+推送停止充电结果信息再处理
|