|
|
@@ -14,6 +14,8 @@ import com.zsElectric.boot.business.service.ChargeOrderInfoService;
|
|
|
import com.zsElectric.boot.charging.entity.*;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyChargeStatusMapper;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
|
|
|
+import com.zsElectric.boot.charging.mapper.ThirdPartyPolicyInfoMapper;
|
|
|
+import com.zsElectric.boot.charging.service.ChargingBusinessService;
|
|
|
import com.zsElectric.boot.charging.service.ChargingReceptionService;
|
|
|
import com.zsElectric.boot.charging.vo.ChargeResponseVO;
|
|
|
import com.zsElectric.boot.charging.vo.QueryStationStatusVO;
|
|
|
@@ -69,6 +71,9 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
private final PolicyFeeMapper policyFeeMapper;
|
|
|
private final DictItemMapper dictItemMapper;
|
|
|
private final ThirdPartyEquipmentInfoMapper thirdPartyEquipmentInfoMapper;
|
|
|
+ private final ChargingBusinessService chargingBusinessService;
|
|
|
+ private final ThirdPartyStationInfoMapper thirdPartyStationInfoMapper;
|
|
|
+ private final ThirdPartyPolicyInfoMapper thirdPartyPolicyInfoMapper;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -325,46 +330,66 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
try {
|
|
|
log.info("保存或更新充电状态数据 - StartChargeSeq: {}", jsonNode);
|
|
|
String startChargeSeq = jsonNode.get("StartChargeSeq").asText();
|
|
|
-// //修改订单状态
|
|
|
-// ChargeOrderInfo chargeOrderInfo = chargeOrderInfoService.getOne(new LambdaQueryWrapper<ChargeOrderInfo>()
|
|
|
-// .eq(ChargeOrderInfo::getStartChargeSeq, startChargeSeq).last("limit 1"));
|
|
|
-// if(ObjUtil.isNotEmpty(chargeOrderInfo)){
|
|
|
-// Integer connectorStatus = getIntValue(jsonNode, "ConnectorStatus");
|
|
|
-// if (Objects.equals(connectorStatus, SystemConstants.STATUS_THREE) && Objects.equals(chargeOrderInfo.getStatus(), SystemConstants.STATUS_ZERO)) {
|
|
|
-// // 充电中
|
|
|
-// log.info("充电中 - StartChargeSeq: {}", startChargeSeq);
|
|
|
-// chargeOrderInfo.setStatus(SystemConstants.STATUS_ONE);
|
|
|
-// chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
-// }
|
|
|
-// if (Objects.equals(connectorStatus, SystemConstants.STATUS_FOUR) && Objects.equals(chargeOrderInfo.getStatus(),
|
|
|
-// SystemConstants.STATUS_ONE)) {
|
|
|
-// // 结算中
|
|
|
-// log.info("结算中 - StartChargeSeq: {}", startChargeSeq);
|
|
|
-// chargeOrderInfo.setStatus(SystemConstants.STATUS_TWO);
|
|
|
-// chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- // 查询是否已存在该订单
|
|
|
-// ThirdPartyChargeStatus existing = chargeStatusMapper.selectOne(
|
|
|
-// Wrappers.<ThirdPartyChargeStatus>lambdaQuery()
|
|
|
-// .eq(ThirdPartyChargeStatus::getStartChargeSeq, startChargeSeq)
|
|
|
-// );
|
|
|
-
|
|
|
-// ThirdPartyChargeStatus chargeStatus = (existing != null) ? existing : new ThirdPartyChargeStatus();
|
|
|
- ThirdPartyChargeStatus chargeStatus = new ThirdPartyChargeStatus();
|
|
|
+ String connectorId = getTextValue(jsonNode, "ConnectorID");
|
|
|
+
|
|
|
+ // 获取第三方推送的实时数据
|
|
|
+ BigDecimal totalPower = getDecimalValue(jsonNode, "TotalPower"); // 实际充电度数
|
|
|
+ BigDecimal totalMoney = getDecimalValue(jsonNode, "TotalMoney"); // 第三方总费用
|
|
|
+ BigDecimal elecMoney = getDecimalValue(jsonNode, "ElecMoney"); // 第三方电费
|
|
|
+ BigDecimal serviceMoney = getDecimalValue(jsonNode, "SeviceMoney"); // 第三方服务费
|
|
|
+
|
|
|
+ // 修改订单状态并实时更新消费字段
|
|
|
+ ChargeOrderInfo chargeOrderInfo = chargeOrderInfoService.getOne(new LambdaQueryWrapper<ChargeOrderInfo>()
|
|
|
+ .eq(ChargeOrderInfo::getStartChargeSeq, startChargeSeq).last("limit 1"));
|
|
|
+ if(ObjUtil.isNotEmpty(chargeOrderInfo)){
|
|
|
+ Integer connectorStatus = getIntValue(jsonNode, "ConnectorStatus");
|
|
|
+
|
|
|
+ // 实时更新订单表的消费字段
|
|
|
+ chargeOrderInfo.setTotalCharge(totalPower); // 实际充电度数
|
|
|
+ chargeOrderInfo.setThirdPartyTotalCost(totalMoney); // 第三方充电消费总额
|
|
|
+ chargeOrderInfo.setThirdPartyElecfee(elecMoney); // 第三方充电金额
|
|
|
+ chargeOrderInfo.setThirdPartyServerfee(serviceMoney); // 第三方充电服务费
|
|
|
+
|
|
|
+ // 计算平台实际收取金额(根据度数和平台价格策略计算)
|
|
|
+ BigDecimal realCost = calculateRealCost(chargeOrderInfo, totalPower);
|
|
|
+ chargeOrderInfo.setRealCost(realCost);
|
|
|
+
|
|
|
+ if (Objects.equals(connectorStatus, SystemConstants.STATUS_THREE) && Objects.equals(chargeOrderInfo.getStatus(), SystemConstants.STATUS_ZERO)) {
|
|
|
+ // 充电中
|
|
|
+ log.info("充电中 - StartChargeSeq: {}", startChargeSeq);
|
|
|
+ chargeOrderInfo.setStatus(SystemConstants.STATUS_ONE);
|
|
|
+ }
|
|
|
+ if (Objects.equals(connectorStatus, SystemConstants.STATUS_FOUR) && Objects.equals(chargeOrderInfo.getStatus(),
|
|
|
+ SystemConstants.STATUS_ONE)) {
|
|
|
+ // 结算中
|
|
|
+ log.info("结算中 - StartChargeSeq: {}", startChargeSeq);
|
|
|
+ chargeOrderInfo.setStatus(SystemConstants.STATUS_TWO);
|
|
|
+ }
|
|
|
+
|
|
|
+ chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
+ log.info("实时更新订单消费 - startChargeSeq: {}, totalPower: {}, realCost: {}",
|
|
|
+ startChargeSeq, totalPower, realCost);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询是否已存在该充电状态记录
|
|
|
+ ThirdPartyChargeStatus existing = chargeStatusMapper.selectOne(
|
|
|
+ Wrappers.<ThirdPartyChargeStatus>lambdaQuery()
|
|
|
+ .eq(ThirdPartyChargeStatus::getStartChargeSeq, startChargeSeq)
|
|
|
+ );
|
|
|
+
|
|
|
+ ThirdPartyChargeStatus chargeStatus = (existing != null) ? existing : new ThirdPartyChargeStatus();
|
|
|
|
|
|
// 设置字段值
|
|
|
chargeStatus.setStartChargeSeq(startChargeSeq);
|
|
|
- chargeStatus.setConnectorId(getTextValue(jsonNode, "ConnectorID"));
|
|
|
+ chargeStatus.setConnectorId(connectorId);
|
|
|
chargeStatus.setConnectorStatus(getIntValue(jsonNode, "ConnectorStatus"));
|
|
|
chargeStatus.setStartChargeSeqStat(getIntValue(jsonNode, "StartChargeSeqStat"));
|
|
|
chargeStatus.setStartTime(parseDateTime(getTextValue(jsonNode, "StartTime")));
|
|
|
chargeStatus.setEndTime(parseDateTime(getTextValue(jsonNode, "EndTime")));
|
|
|
- chargeStatus.setTotalPower(getDecimalValue(jsonNode, "TotalPower"));
|
|
|
- chargeStatus.setTotalMoney(getDecimalValue(jsonNode, "TotalMoney"));
|
|
|
- chargeStatus.setElecMoney(getDecimalValue(jsonNode, "ElecMoney"));
|
|
|
- chargeStatus.setServiceMoney(getDecimalValue(jsonNode, "SeviceMoney")); // 注意:第三方字段名SeviceMoney
|
|
|
+ chargeStatus.setTotalPower(totalPower);
|
|
|
+ chargeStatus.setTotalMoney(totalMoney);
|
|
|
+ chargeStatus.setElecMoney(elecMoney);
|
|
|
+ chargeStatus.setServiceMoney(serviceMoney);
|
|
|
chargeStatus.setSoc(getIntValue(jsonNode, "Soc"));
|
|
|
chargeStatus.setVoltageA(getDecimalValue(jsonNode, "VoltageA"));
|
|
|
chargeStatus.setVoltageB(getDecimalValue(jsonNode, "VoltageB"));
|
|
|
@@ -378,25 +403,111 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
chargeStatus.setChargeDetails(jsonNode.get("ChargeDetails").toString());
|
|
|
}
|
|
|
|
|
|
-// if (existing != null) {
|
|
|
-// chargeStatus.setUpdateTime(LocalDateTime.now());
|
|
|
-// chargeStatusMapper.updateById(chargeStatus);
|
|
|
-// log.info("更新充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
-// } else {
|
|
|
-// chargeStatus.setCreateTime(LocalDateTime.now());
|
|
|
-// chargeStatusMapper.insert(chargeStatus);
|
|
|
-// log.info("新增充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
-// }
|
|
|
- chargeStatus.setCreateTime(LocalDateTime.now());
|
|
|
- chargeStatusMapper.insert(chargeStatus);
|
|
|
- log.info("新增充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
-
|
|
|
- //熔断保护
|
|
|
- isNeedBreak(chargeStatus);
|
|
|
+ if (existing != null) {
|
|
|
+ chargeStatus.setUpdateTime(LocalDateTime.now());
|
|
|
+ chargeStatusMapper.updateById(chargeStatus);
|
|
|
+ log.info("更新充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
+ } else {
|
|
|
+ chargeStatus.setCreateTime(LocalDateTime.now());
|
|
|
+ chargeStatusMapper.insert(chargeStatus);
|
|
|
+ log.info("新增充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 熔断保护 - 余额不足判断
|
|
|
+ isNeedBreak(chargeStatus, chargeOrderInfo);
|
|
|
} catch (Exception e) {
|
|
|
log.error("保存充电状态数据失败", e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算平台实际收取金额
|
|
|
+ * 根据充电度数 * 当前时段的平台价格策略计算(支持跨时段计费)
|
|
|
+ */
|
|
|
+ private BigDecimal calculateRealCost(ChargeOrderInfo chargeOrderInfo, BigDecimal totalPower) {
|
|
|
+ if (totalPower == null || totalPower.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 获取用户企业信息
|
|
|
+ UserFirm userFirm = userFirmMapper.selectOne(Wrappers.<UserFirm>lambdaQuery()
|
|
|
+ .eq(UserFirm::getUserId, chargeOrderInfo.getUserId())
|
|
|
+ .eq(UserFirm::getIsDeleted, 0));
|
|
|
+
|
|
|
+ // 获取设备信息
|
|
|
+ ThirdPartyEquipmentInfo equipmentInfo = thirdPartyEquipmentInfoMapper.selectOne(
|
|
|
+ Wrappers.<ThirdPartyEquipmentInfo>lambdaQuery()
|
|
|
+ .eq(ThirdPartyEquipmentInfo::getEquipmentId, chargeOrderInfo.getEquipmentId())
|
|
|
+ .eq(ThirdPartyEquipmentInfo::getIsDeleted, 0));
|
|
|
+
|
|
|
+ if (equipmentInfo == null) {
|
|
|
+ log.warn("未找到设备信息 - equipmentId: {}", chargeOrderInfo.getEquipmentId());
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取站点信息
|
|
|
+ ThirdPartyStationInfo stationInfo = thirdPartyStationInfoMapper.selectOne(
|
|
|
+ Wrappers.<ThirdPartyStationInfo>lambdaQuery()
|
|
|
+ .eq(ThirdPartyStationInfo::getStationId, equipmentInfo.getStationId())
|
|
|
+ .eq(ThirdPartyStationInfo::getIsDeleted, 0));
|
|
|
+
|
|
|
+ if (stationInfo == null) {
|
|
|
+ log.warn("未找到站点信息 - stationId: {}", equipmentInfo.getStationId());
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前时间,格式为 HHmmss
|
|
|
+ String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
|
|
|
+
|
|
|
+ // 根据当前时间查询当前时段的价格策略(核心:支持跨时段计费)
|
|
|
+ ThirdPartyPolicyInfo currentPeriodPolicy = thirdPartyPolicyInfoMapper
|
|
|
+ .selectCurrentPeriodPolicyByStation(stationInfo.getId(), currentTime);
|
|
|
+
|
|
|
+ if (currentPeriodPolicy == null || currentPeriodPolicy.getPeriodFlag() == null) {
|
|
|
+ log.warn("未找到当前时段价格策略 - stationInfoId: {}, currentTime: {}",
|
|
|
+ stationInfo.getId(), currentTime);
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer currentPeriodFlag = currentPeriodPolicy.getPeriodFlag();
|
|
|
+ log.info("当前时段 - stationInfoId: {}, currentTime: {}, periodFlag: {}",
|
|
|
+ stationInfo.getId(), currentTime, currentPeriodFlag);
|
|
|
+
|
|
|
+ // 查询当前时段对应的价格策略
|
|
|
+ Integer salesType = (userFirm != null) ? 1 : 0; // 1-企业 0-平台
|
|
|
+ Long firmId = (userFirm != null) ? userFirm.getFirmId() : null;
|
|
|
+
|
|
|
+ PolicyFee policyFee = policyFeeMapper.selectOne(Wrappers.<PolicyFee>lambdaQuery()
|
|
|
+ .eq(PolicyFee::getStationInfoId, stationInfo.getId())
|
|
|
+ .eq(PolicyFee::getPeriodFlag, currentPeriodFlag)
|
|
|
+ .eq(PolicyFee::getSalesType, salesType)
|
|
|
+ .eq(salesType == 1, PolicyFee::getFirmId, firmId)
|
|
|
+ .eq(PolicyFee::getIsDeleted, 0)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+
|
|
|
+ if (policyFee == null) {
|
|
|
+ log.warn("未找到当前时段的价格策略 - stationInfoId: {}, periodFlag: {}, salesType: {}",
|
|
|
+ stationInfo.getId(), currentPeriodFlag, salesType);
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取综合销售费作为单价
|
|
|
+ BigDecimal unitPrice = policyFee.getCompSalesFee() != null ? policyFee.getCompSalesFee() : BigDecimal.ZERO;
|
|
|
+
|
|
|
+ // 实际收取金额 = 充电度数 * 当前时段单价
|
|
|
+ BigDecimal realCost = totalPower.multiply(unitPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ log.info("计算实际收取金额 - totalPower: {}, periodFlag: {}, unitPrice: {}, realCost: {}",
|
|
|
+ totalPower, currentPeriodFlag, unitPrice, realCost);
|
|
|
+
|
|
|
+ return realCost;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算平台实际收取金额失败", e);
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// ==================== JSON解析工具方法 ====================
|
|
|
|
|
|
@@ -430,49 +541,79 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
/**
|
|
|
* 根据充电订单号StartChargeSeq 获取订单信息判断是否需要熔断,提前跳枪
|
|
|
* 使用分布式锁防止并发重复检查
|
|
|
+ *
|
|
|
+ * @param chargeStatus 充电状态
|
|
|
+ * @param chargeOrderInfo 订单信息
|
|
|
*/
|
|
|
- private void isNeedBreak(ThirdPartyChargeStatus chargeStatus) {
|
|
|
+ private void isNeedBreak(ThirdPartyChargeStatus chargeStatus, ChargeOrderInfo chargeOrderInfo) {
|
|
|
+ // 订单为空或不是充电中状态,不需要熔断检查
|
|
|
+ if (chargeOrderInfo == null || !Objects.equals(chargeOrderInfo.getStatus(), SystemConstants.STATUS_ONE)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
String lockKey = BREAK_CHECK_LOCK_KEY + chargeStatus.getStartChargeSeq();
|
|
|
RLock lock = redissonClient.getLock(lockKey);
|
|
|
try {
|
|
|
// 尝试获取锁,最多等待3秒,持有锁最多10秒
|
|
|
if (lock.tryLock(LOCK_WAIT_TIME, LOCK_LEASE_TIME, TimeUnit.SECONDS)) {
|
|
|
try {
|
|
|
- ChargeOrderInfo chargeOrderInfo = chargeOrderInfoService.getOne(
|
|
|
- Wrappers.<ChargeOrderInfo>lambdaQuery()
|
|
|
- .eq(ChargeOrderInfo::getChargeOrderNo, chargeStatus.getStartChargeSeq())
|
|
|
- .eq(ChargeOrderInfo::getStatus, 1)
|
|
|
- .eq(ChargeOrderInfo::getIsDeleted, 0)
|
|
|
- );
|
|
|
- if (null != chargeOrderInfo) {
|
|
|
- // TODO: 根据业务需求实现熔断条件判断(例如:余额不足、超时等)
|
|
|
- DictItem dictItem = dictItemMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<DictItem>()
|
|
|
- .eq(DictItem::getDictCode, "up_recharge")
|
|
|
- .eq(DictItem::getStatus, 1)
|
|
|
- .last("LIMIT 1"));
|
|
|
- //安全价
|
|
|
- BigDecimal upRecharge = new BigDecimal(dictItem.getValue());
|
|
|
- //获取用户余额
|
|
|
- BigDecimal balance = userAccountMapper.selectOne(Wrappers.<UserAccount>lambdaQuery()
|
|
|
- .eq(UserAccount::getUserId, chargeOrderInfo.getUserId())
|
|
|
- .eq(UserAccount::getIsDeleted, 0)).getBalance();
|
|
|
- //企业价
|
|
|
- BigDecimal firmPrice;
|
|
|
- //根据用户ID去查询当前用户是否有归属企业
|
|
|
- UserFirm userFirm = userFirmMapper.selectOne(Wrappers.<UserFirm>lambdaQuery()
|
|
|
- .eq(UserFirm::getUserId, chargeOrderInfo.getUserId())
|
|
|
- .eq(UserFirm::getIsDeleted, 0));
|
|
|
- if (null != userFirm) {
|
|
|
- ThirdPartyEquipmentInfo thirdPartyEquipmentInfo = thirdPartyEquipmentInfoMapper.selectOne(Wrappers.<ThirdPartyEquipmentInfo>lambdaQuery()
|
|
|
- .eq(ThirdPartyEquipmentInfo::getEquipmentId, chargeOrderInfo.getEquipmentId())
|
|
|
- .eq(ThirdPartyEquipmentInfo::getIsDeleted, 0));
|
|
|
- List<PolicyFee> policyFees = policyFeeMapper.selectList(Wrappers.<PolicyFee>lambdaQuery()
|
|
|
- .eq(PolicyFee::getStationInfoId, thirdPartyEquipmentInfo.getStationId())
|
|
|
- .eq(PolicyFee::getFirmId, userFirm.getFirmId()));
|
|
|
+ // 获取安全阈值配置
|
|
|
+ DictItem dictItem = dictItemMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<DictItem>()
|
|
|
+ .eq(DictItem::getDictCode, "up_recharge")
|
|
|
+ .eq(DictItem::getStatus, 1)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+
|
|
|
+ BigDecimal safetyThreshold = BigDecimal.ZERO;
|
|
|
+ if (dictItem != null && dictItem.getValue() != null) {
|
|
|
+ safetyThreshold = new BigDecimal(dictItem.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取用户余额
|
|
|
+ UserAccount userAccount = userAccountMapper.selectOne(Wrappers.<UserAccount>lambdaQuery()
|
|
|
+ .eq(UserAccount::getUserId, chargeOrderInfo.getUserId())
|
|
|
+ .eq(UserAccount::getIsDeleted, 0));
|
|
|
+
|
|
|
+ if (userAccount == null) {
|
|
|
+ log.warn("未找到用户账户信息 - userId: {}", chargeOrderInfo.getUserId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal balance = userAccount.getBalance() != null ? userAccount.getBalance() : BigDecimal.ZERO;
|
|
|
+
|
|
|
+ // 获取当前实时消费金额
|
|
|
+ BigDecimal realCost = chargeOrderInfo.getRealCost() != null ? chargeOrderInfo.getRealCost() : BigDecimal.ZERO;
|
|
|
+
|
|
|
+ // 剩余可用余额 = 账户余额 - 实时消费 - 安全阈值
|
|
|
+ BigDecimal remainingBalance = balance.subtract(realCost).subtract(safetyThreshold);
|
|
|
+
|
|
|
+ log.info("熔断检查 - startChargeSeq: {}, 用户余额: {}, 实时消费: {}, 安全阈值: {}, 剩余可用: {}",
|
|
|
+ chargeStatus.getStartChargeSeq(), balance, realCost, safetyThreshold, remainingBalance);
|
|
|
+
|
|
|
+ // 如果剩余可用余额小于0,触发熔断
|
|
|
+ if (remainingBalance.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ log.warn("余额不足,触发熔断停止充电 - startChargeSeq: {}, 用户余额: {}, 实时消费: {}",
|
|
|
+ chargeStatus.getStartChargeSeq(), balance, realCost);
|
|
|
+
|
|
|
+ // 调用第三方停止充电接口
|
|
|
+ try {
|
|
|
+ chargingBusinessService.stopCharging(
|
|
|
+ chargeStatus.getStartChargeSeq(),
|
|
|
+ chargeStatus.getConnectorId());
|
|
|
+ log.info("已发送停止充电请求 - startChargeSeq: {}, connectorId: {}",
|
|
|
+ chargeStatus.getStartChargeSeq(), chargeStatus.getConnectorId());
|
|
|
+
|
|
|
+ // 更新订单停止类型为余额不足停止
|
|
|
+ chargeOrderInfo.setStopType(3); // 3-余额不足停止
|
|
|
+ chargeOrderInfo.setStopReason("余额不足,系统自动停止充电");
|
|
|
+ chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("调用第三方停止充电接口失败 - startChargeSeq: {}",
|
|
|
+ chargeStatus.getStartChargeSeq(), e);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
@@ -482,6 +623,8 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
} catch (InterruptedException e) {
|
|
|
Thread.currentThread().interrupt();
|
|
|
log.error("获取熔断检查锁被中断 - startChargeSeq: {}", chargeStatus.getStartChargeSeq(), e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("熔断检查失败 - startChargeSeq: {}", chargeStatus.getStartChargeSeq(), e);
|
|
|
}
|
|
|
}
|
|
|
}
|