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 a83a9b38..0c4579ef 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 @@ -105,6 +105,30 @@ public class ChargeOrderInfo { } } + public ChargeOrderInfo(XhpcHistoryOrder xhpcHistoryOrder) { + + this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16); + this.startChargeSeq = xhpcHistoryOrder.getInternetSerialNumber(); + this.endTime = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, xhpcHistoryOrder.getEndTime()); + this.connectorID = xhpcHistoryOrder.getSerialNumber().substring(0, 16); + this.endTime = DateUtil.date2String(xhpcHistoryOrder.getEndTime(), DateUtil.DATE_FORMAT_DATE_TIME); + this.startTime = DateUtil.date2String(xhpcHistoryOrder.getStartTime(), DateUtil.DATE_FORMAT_DATE_TIME); + this.chargeModel = xhpcHistoryOrder.getChargeModelEvcs(); + this.totalPower = xhpcHistoryOrder.getTotalPower(); + this.totalElecMoney = xhpcHistoryOrder.getPowerPriceTotal().doubleValue(); + this.totalSeviceMoney = xhpcHistoryOrder.getServicePriceTotal().doubleValue(); + this.totalMoney = xhpcHistoryOrder.getTotalPrice().doubleValue(); + this.stopReason = xhpcHistoryOrder.getStopReasonEvcs(); + this.sumPeriod = xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList().size(); + this.chargeDetails = translate(xhpcHistoryOrder.getXhpcStatisticsTimeIntervalList()); + Date starttime = xhpcHistoryOrder.getStartTime(); + Date endtime = xhpcHistoryOrder.getEndTime(); + int cl = 0; + if (starttime != null && endtime != null) { + cl = Math.toIntExact((endtime.getTime() - starttime.getTime()) / 1000); + } + } + private ChargeDetails[] translate(List xhpcStatisticsTimeIntervalList) { List details = new LinkedList<>(); 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 fb012927..276f81db 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.*; +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.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,13 +16,10 @@ 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 @@ -51,25 +48,7 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher { horder.getInternetSerialNumber().substring(0, 9); } if (authSecretToken.getOperatorId3irdpty().equals(operatorId3rdptyEvcs)) { - 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()); + ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder); final ChargeOrderInfoResponse pushResp = notify(chargeOrderInfo, authSecretToken); if (pushResp != null) { horder.setConfirmResult(pushResp.getConfirmResult());