diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/ChargeOrderInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/ChargeOrderInfo.java index 88b368a4..a83a9b38 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/ChargeOrderInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/ChargeOrderInfo.java @@ -81,7 +81,7 @@ public class ChargeOrderInfo { @Transient private Map additionalProperties = new HashMap(); - public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder) { + public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder, ChargeDetails[] calcemChargeDetails) { this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16); this.startChargeSeq = xhpcHistoryOrder.getInternetSerialNumber(); @@ -96,7 +96,7 @@ public class ChargeOrderInfo { this.totalMoney = xhpcHistoryOrder.getTotalPrice().doubleValue(); this.stopReason = xhpcHistoryOrder.getStopReasonEvcs(); this.sumPeriod = xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList().size(); - this.chargeDetails = translate(xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList()); + this.chargeDetails = calcemChargeDetails;//translate(xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList()); Date starttime = xhpcHistoryOrder.getStartTime(); Date endtime = xhpcHistoryOrder.getEndTime(); int cl = 0; diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java index 276f81db..fb012927 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java @@ -1,13 +1,13 @@ package com.xhpc.evcs.notification; import com.fasterxml.jackson.core.JsonProcessingException; +import com.xhpc.common.data.redis.CacheRateModel; +import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.evcs.domain.AuthSecretToken; -import com.xhpc.evcs.dto.ChargeOrderInfo; -import com.xhpc.evcs.dto.ChargeOrderInfoResponse; -import com.xhpc.evcs.dto.CommonRequest; -import com.xhpc.evcs.dto.DTOJsonHelper; +import com.xhpc.evcs.dto.*; import com.xhpc.evcs.jpa.AuthSecretTokenRepository; import com.xhpc.evcs.jpa.XhpcHistoryOrderRepository; +import com.xhpc.evcs.utils.DateUtil; import com.xhpc.evcs.utils.JSONUtil; import com.xhpc.order.domain.XhpcHistoryOrder; import org.slf4j.Logger; @@ -16,10 +16,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.util.Calendar; import java.util.List; import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.evcs.domain.AuthSecretToken.SECRET_TOKEN_TYPE_OUT; +import static com.xhpc.evcs.notification.NotificationEquipChargeStatusTask.calculateEm; +import static com.xhpc.evcs.utils.DateUtil.DATE_FORMAT_DATE_TIME; /** * @Author HongYun on 2021/11/1 @@ -48,7 +51,25 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher { horder.getInternetSerialNumber().substring(0, 9); } if (authSecretToken.getOperatorId3irdpty().equals(operatorId3rdptyEvcs)) { - ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder); + EquipChargeStatus equipChargeStatus = new EquipChargeStatus(); + String orderkey = "order:".concat(horder.getSerialNumber()); + CacheRealtimeData lord = REDIS.getCacheObject(orderkey.concat(".lord")); + String lordTime; + if (lord != null) { + lordTime = lord.getCreateTime(); + } else { + lordTime = DateUtil.date2String(Calendar.getInstance().getTime(), DATE_FORMAT_DATE_TIME); + } + equipChargeStatus.setEndTime(lordTime); + equipChargeStatus.setTotalPower(horder.getTotalPower()); + equipChargeStatus.setTotalMoney(horder.getTotalPrice().setScale(2).doubleValue()); + Long rateModelId = horder.getRateModelId(); + if (rateModelId == null) + rateModelId = REDIS.getCacheMapValue("gun:".concat(horder.getSerialNumber().substring(0, 14)), + "rateModelId"); + final CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:" + rateModelId); + calculateEm(equipChargeStatus, cacheRateModel); + ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder, equipChargeStatus.getChargeDetails()); final ChargeOrderInfoResponse pushResp = notify(chargeOrderInfo, authSecretToken); if (pushResp != null) { horder.setConfirmResult(pushResp.getConfirmResult()); diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java index 9b7644d9..b30b2ce4 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java @@ -246,11 +246,18 @@ public class XhpcHistoryOrder extends BaseEntity { */ private Integer confirmResult; + /** + * 费率模型id + */ + private Long rateModelId; + public Integer getConfirmResult() { + return confirmResult; } public void setConfirmResult(Integer confirmResult) { + this.confirmResult = confirmResult; } @@ -687,4 +694,14 @@ public class XhpcHistoryOrder extends BaseEntity { this.endTime = endTime; } + public Long getRateModelId() { + + return rateModelId; + } + + public void setRateModelId(Long rateModelId) { + + this.rateModelId = rateModelId; + } + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index 6aaf1937..c5fac094 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -42,7 +41,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { @Autowired private SmsService smsService; - private ExecutorService executorService = Executors.newFixedThreadPool(20); + private final ExecutorService executorService = Executors.newFixedThreadPool(20); private static final Logger logger = LoggerFactory.getLogger(XhpcHistoryOrderServiceImpl.class); @@ -265,10 +264,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { if(!"".equals(state)){ //查看是否优惠为0 - boolean fan = true; - if(discount.compareTo(new BigDecimal(0))==0){ - fan=false; - } + boolean fan = discount.compareTo(new BigDecimal(0)) != 0; if("1".equals(state)){ //总金额 if(fan){ @@ -359,6 +355,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { xhpcHistoryOrder.setStopReasonEvcs(xhpcChargeOrder.getStopReasonEvcs());//todo 从头开始设置所有evcs字段 xhpcHistoryOrder.setChargeModelEvcs(xhpcChargeOrder.getChargeModelEvcs()); xhpcHistoryOrder.setSerialNumber(xhpcChargeOrder.getSerialNumber()); + xhpcHistoryOrder.setRateModelId(xhpcChargeOrder.getRateModelId()); xhpcHistoryOrder.setStartSoc(xhpcChargeOrder.getStartSoc()); xhpcHistoryOrder.setReconciliationStatus(0); xhpcHistoryOrder.setSortingStatus(0); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 4a125bc3..1bacea1c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -15,7 +15,6 @@ import com.xhpc.order.mapper.XhpcRealTimeOrderMapper; import com.xhpc.order.service.IXhpcChargeOrderService; import com.xhpc.order.service.IXhpcHistoryOrderService; import com.xhpc.order.service.IXhpcRealTimeOrderService; -import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,13 +22,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; - /** * @author yuyang * @date 2021/8/7 15:07 @@ -53,7 +49,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { private SmsService smsService; - private ExecutorService executorService = Executors.newFixedThreadPool(20); + private final ExecutorService executorService = Executors.newFixedThreadPool(20); private static final Logger logger = LoggerFactory.getLogger(XhpcRealTimeOrderServiceImpl.class); @@ -486,6 +482,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { xhpcHistoryOrder.setStopReasonEvcs(xhpcChargeOrder.getStopReasonEvcs());//todo 从头开始设置所有evcs字段 xhpcHistoryOrder.setChargeModelEvcs(xhpcChargeOrder.getChargeModelEvcs()); xhpcHistoryOrder.setSerialNumber(xhpcChargeOrder.getSerialNumber()); + xhpcChargeOrder.setRateModelId(xhpcChargeOrder.getRateModelId()); xhpcHistoryOrder.setStartSoc(xhpcChargeOrder.getStartSoc()); xhpcHistoryOrder.setReconciliationStatus(0); xhpcHistoryOrder.setSortingStatus(0); @@ -706,7 +703,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { double mins = (remainingTime-(hours*60))/60; xhpcRealTimeOrder.setRemainingTime(hours+"时"+new BigDecimal(mins).setScale(0)+"分"); }else{ - double mins = (double)(remainingTime/60); + double mins = remainingTime / 60; xhpcRealTimeOrder.setRemainingTime(new BigDecimal(mins).setScale(0)+"分"); } BigDecimal decimal = new BigDecimal(10000); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 373a92ea..1c813676 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -49,6 +49,7 @@ + @@ -62,7 +63,7 @@ create_time, create_by, update_time, update_by, remark, `state`, vin_normal, search_value, operator_id_evcs, charge_model_evcs, connector_power_evcs, meter_value_end_evcs, meter_value_start_evcs, operator_id3rdpty_evcs, start_time, stop_reason_evcs, total_power, - user_name_evcs, phone + user_name_evcs, phone, rate_model_id @@ -197,6 +198,9 @@ stop_reason_evcs, + + rate_model_id, + total_power, @@ -337,6 +341,9 @@ #{stopReasonEvcs,jdbcType=INTEGER}, + + #{rateModelId}, + #{totalPower,jdbcType=DOUBLE},