历史订单保存费率模型id;v1.1前使用倒推计算得到的计费明细
This commit is contained in:
parent
cbdbbcd7b6
commit
98eca09705
@ -81,7 +81,7 @@ public class ChargeOrderInfo {
|
||||
@Transient
|
||||
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
|
||||
|
||||
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;
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
|
||||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
|
||||
<result column="stop_reason_evcs" jdbcType="INTEGER" property="stopReasonEvcs"/>
|
||||
<result column="rate_model_id" jdbcType="BIGINT" property="rateModelId"/>
|
||||
<result column="total_power" jdbcType="DOUBLE" property="totalPower"/>
|
||||
<result column="user_name_evcs" jdbcType="VARCHAR" property="userNameEvcs"/>
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone"/>
|
||||
@ -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
|
||||
</sql>
|
||||
<insert id="insert" parameterType="com.xhpc.order.domain.XhpcHistoryOrder" useGeneratedKeys="true"
|
||||
keyProperty="historyOrderId">
|
||||
@ -197,6 +198,9 @@
|
||||
<if test="stopReasonEvcs != null">
|
||||
stop_reason_evcs,
|
||||
</if>
|
||||
<if test="null != rateModelId">
|
||||
rate_model_id,
|
||||
</if>
|
||||
<if test="totalPower != null">
|
||||
total_power,
|
||||
</if>
|
||||
@ -337,6 +341,9 @@
|
||||
<if test="stopReasonEvcs != null">
|
||||
#{stopReasonEvcs,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="null != rateModelId">
|
||||
#{rateModelId},
|
||||
</if>
|
||||
<if test="totalPower != null">
|
||||
#{totalPower,jdbcType=DOUBLE},
|
||||
</if>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user