|
|
@@ -4,17 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.zsElectric.boot.business.mapper.ChargeOrderInfoMapper;
|
|
|
-import com.zsElectric.boot.business.mapper.PolicyFeeMapper;
|
|
|
-import com.zsElectric.boot.business.mapper.UserAccountMapper;
|
|
|
-import com.zsElectric.boot.business.mapper.UserFirmMapper;
|
|
|
+import com.zsElectric.boot.business.mapper.*;
|
|
|
import com.zsElectric.boot.business.model.entity.ChargeOrderInfo;
|
|
|
+import com.zsElectric.boot.business.model.entity.PolicyFee;
|
|
|
import com.zsElectric.boot.business.model.entity.UserAccount;
|
|
|
import com.zsElectric.boot.business.model.entity.UserFirm;
|
|
|
-import com.zsElectric.boot.charging.entity.ConnectorStatusInfo;
|
|
|
-import com.zsElectric.boot.charging.entity.StationStatusInfo;
|
|
|
-import com.zsElectric.boot.charging.entity.ThirdPartyChargeStatus;
|
|
|
-import com.zsElectric.boot.charging.entity.ThirdPartyConnectorInfo;
|
|
|
+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.service.ChargingReceptionService;
|
|
|
@@ -69,6 +64,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
private final UserFirmMapper userFirmMapper;
|
|
|
private final PolicyFeeMapper policyFeeMapper;
|
|
|
private final DictItemMapper dictItemMapper;
|
|
|
+ private final ThirdPartyEquipmentInfoMapper thirdPartyEquipmentInfoMapper;
|
|
|
|
|
|
/** 熔断检查锁前缀 */
|
|
|
private static final String BREAK_CHECK_LOCK_KEY = "charging:break:check:";
|
|
|
@@ -293,7 +289,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
log.info("新增充电状态成功 - startChargeSeq: {}", startChargeSeq);
|
|
|
}
|
|
|
//熔断保护
|
|
|
- isNeedBreak(startChargeSeq);
|
|
|
+ isNeedBreak(chargeStatus);
|
|
|
} catch (Exception e) {
|
|
|
log.error("保存充电状态数据失败", e);
|
|
|
}
|
|
|
@@ -332,8 +328,8 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
* 根据充电订单号StartChargeSeq 获取订单信息判断是否需要熔断,提前跳枪
|
|
|
* 使用分布式锁防止并发重复检查
|
|
|
*/
|
|
|
- private void isNeedBreak(String startChargeSeq) {
|
|
|
- String lockKey = BREAK_CHECK_LOCK_KEY + startChargeSeq;
|
|
|
+ private void isNeedBreak(ThirdPartyChargeStatus chargeStatus) {
|
|
|
+ String lockKey = BREAK_CHECK_LOCK_KEY + chargeStatus.getStartChargeSeq();
|
|
|
RLock lock = redissonClient.getLock(lockKey);
|
|
|
try {
|
|
|
// 尝试获取锁,最多等待3秒,持有锁最多10秒
|
|
|
@@ -341,7 +337,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
try {
|
|
|
ChargeOrderInfo chargeOrderInfo = chargeOrderInfoMapper.selectOne(
|
|
|
Wrappers.<ChargeOrderInfo>lambdaQuery()
|
|
|
- .eq(ChargeOrderInfo::getChargeOrderNo, startChargeSeq)
|
|
|
+ .eq(ChargeOrderInfo::getChargeOrderNo, chargeStatus.getStartChargeSeq())
|
|
|
.eq(ChargeOrderInfo::getStatus, 1)
|
|
|
.eq(ChargeOrderInfo::getIsDeleted, 0)
|
|
|
);
|
|
|
@@ -365,7 +361,12 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
.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()));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -373,11 +374,11 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
} else {
|
|
|
- log.warn("获取熔断检查锁超时 - startChargeSeq: {}", startChargeSeq);
|
|
|
+ log.warn("获取熔断检查锁超时 - startChargeSeq: {}", chargeStatus.getStartChargeSeq());
|
|
|
}
|
|
|
} catch (InterruptedException e) {
|
|
|
Thread.currentThread().interrupt();
|
|
|
- log.error("获取熔断检查锁被中断 - startChargeSeq: {}", startChargeSeq, e);
|
|
|
+ log.error("获取熔断检查锁被中断 - startChargeSeq: {}", chargeStatus.getStartChargeSeq(), e);
|
|
|
}
|
|
|
}
|
|
|
}
|