|
@@ -140,7 +140,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
@Override
|
|
@Override
|
|
|
public ResponseParmsEntity chargeStatusResponse(RequestParmsEntity requestDTO) {
|
|
public ResponseParmsEntity chargeStatusResponse(RequestParmsEntity requestDTO) {
|
|
|
log.info("接收推送充电状态请求参数:{}", requestDTO);
|
|
log.info("接收推送充电状态请求参数:{}", requestDTO);
|
|
|
- return processChargeRequest(requestDTO, this::saveOrUpdateChargeStatus);
|
|
|
|
|
|
|
+ return processChargeStatusRequest(requestDTO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -279,6 +279,27 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理实时充电状态推送请求
|
|
|
|
|
+ * 数据格式:{"ConnectorID":"xxx","ConnectorStatus":3,"TotalPower":1.95,"ElecMoney":1.89,...}
|
|
|
|
|
+ */
|
|
|
|
|
+ private ResponseParmsEntity processChargeStatusRequest(RequestParmsEntity requestDTO) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ JsonNode jsonNode = verifyAndDecrypt(requestDTO);
|
|
|
|
|
+
|
|
|
|
|
+ // 保存或更新充电状态
|
|
|
|
|
+ saveOrUpdateChargeStatus(jsonNode);
|
|
|
|
|
+
|
|
|
|
|
+ // 构建响应
|
|
|
|
|
+ return buildChargeResponse(getTextValue(jsonNode, "StartChargeSeq"));
|
|
|
|
|
+ } catch (BusinessException e) {
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("处理充电状态推送失败:{}", e.getMessage(), e);
|
|
|
|
|
+ throw new BusinessException("处理充电状态推送失败:" + e.getMessage(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 处理设备状态变化推送请求
|
|
* 处理设备状态变化推送请求
|
|
|
*/
|
|
*/
|
|
@@ -415,7 +436,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
log.info("保存或更新充电状态数据 - StartChargeSeq: {}", jsonNode);
|
|
log.info("保存或更新充电状态数据 - StartChargeSeq: {}", jsonNode);
|
|
|
String startChargeSeq = jsonNode.get("StartChargeSeq").asText();
|
|
String startChargeSeq = jsonNode.get("StartChargeSeq").asText();
|
|
|
String connectorId = getTextValue(jsonNode, "ConnectorID");
|
|
String connectorId = getTextValue(jsonNode, "ConnectorID");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 获取第三方推送的实时数据
|
|
// 获取第三方推送的实时数据
|
|
|
BigDecimal totalPower = getDecimalValue(jsonNode, "TotalPower"); // 实际充电度数
|
|
BigDecimal totalPower = getDecimalValue(jsonNode, "TotalPower"); // 实际充电度数
|
|
|
BigDecimal totalMoney = getDecimalValue(jsonNode, "TotalMoney"); // 第三方总费用
|
|
BigDecimal totalMoney = getDecimalValue(jsonNode, "TotalMoney"); // 第三方总费用
|
|
@@ -427,17 +448,9 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
.eq(ChargeOrderInfo::getStartChargeSeq, startChargeSeq).last("limit 1"));
|
|
.eq(ChargeOrderInfo::getStartChargeSeq, startChargeSeq).last("limit 1"));
|
|
|
if(ObjUtil.isNotEmpty(chargeOrderInfo)){
|
|
if(ObjUtil.isNotEmpty(chargeOrderInfo)){
|
|
|
Integer connectorStatus = getIntValue(jsonNode, "ConnectorStatus");
|
|
Integer connectorStatus = getIntValue(jsonNode, "ConnectorStatus");
|
|
|
-
|
|
|
|
|
- // 实时更新订单表的消费字段
|
|
|
|
|
- chargeOrderInfo.setTotalCharge(totalPower); // 实际充电度数
|
|
|
|
|
- chargeOrderInfo.setThirdPartyTotalCost(totalMoney); // 第三方充电消费总额
|
|
|
|
|
- chargeOrderInfo.setThirdPartyElecfee(elecMoney); // 第三方充电金额
|
|
|
|
|
- chargeOrderInfo.setThirdPartyServerfee(serviceMoney); // 第三方充电服务费
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 计算平台实际收取金额(根据度数和平台价格策略计算)
|
|
// 计算平台实际收取金额(根据度数和平台价格策略计算)
|
|
|
BigDecimal realCost = calculateRealCost(chargeOrderInfo, totalPower);
|
|
BigDecimal realCost = calculateRealCost(chargeOrderInfo, totalPower);
|
|
|
- chargeOrderInfo.setRealCost(realCost);
|
|
|
|
|
-
|
|
|
|
|
if (Objects.equals(connectorStatus, SystemConstants.STATUS_THREE) && Objects.equals(chargeOrderInfo.getStatus(), SystemConstants.STATUS_ZERO)) {
|
|
if (Objects.equals(connectorStatus, SystemConstants.STATUS_THREE) && Objects.equals(chargeOrderInfo.getStatus(), SystemConstants.STATUS_ZERO)) {
|
|
|
// 充电中
|
|
// 充电中
|
|
|
log.info("充电中 - StartChargeSeq: {}", startChargeSeq);
|
|
log.info("充电中 - StartChargeSeq: {}", startChargeSeq);
|
|
@@ -451,7 +464,7 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
- log.info("实时更新订单消费 - startChargeSeq: {}, totalPower: {}, realCost: {}",
|
|
|
|
|
|
|
+ log.info("实时更新订单消费 - startChargeSeq: {}, totalPower: {}, realCost: {}",
|
|
|
startChargeSeq, totalPower, realCost);
|
|
startChargeSeq, totalPower, realCost);
|
|
|
}
|
|
}
|
|
|
|
|
|