main^2
黄海 12 months ago
parent eafbfdd8ba
commit 357a487c7c

@ -1,7 +1,6 @@
package com.charge.orderbk.controller;
import com.charge.orderbk.client.TaskServiceApi;
import com.charge.orderbk.dao.StationDOMapper;
import com.github.pagehelper.PageInfo;
import com.charge.orderbk.model.*;
import com.charge.orderbk.service.ChargeOrderMannageService;
@ -22,9 +21,6 @@ public class ChargeOrderMannageController {
@Autowired
ChargeOrderMannageService chargeOrderMannageService;
@Autowired
StationDOMapper stationDOMapper;
@Autowired
private TaskServiceApi taskServiceApi;
/**

@ -96,33 +96,35 @@ public class HandleOrderTarckService {
.build();
/**处理未上报的订单 将它挂起*/
public void handleUnReportOrder(){
/**
*
*/
public void handleUnReportOrder() {
List<String> unReportedOrderList = equipmentChargeOrderTrackDOMapper.queryUnReportedOrder(ToolDateTime.curTimeAgo(2));/**查询卡单信息*/
Stream.iterate(0,i->i+1).limit(unReportedOrderList.size()).forEach(i->{
EquipmentChargeOrderDO queryParam = new EquipmentChargeOrderDO();
Stream.iterate(0, i -> i + 1).limit(unReportedOrderList.size()).forEach(i -> {
EquipmentChargeOrderDO queryParam = new EquipmentChargeOrderDO();
queryParam.setOrderNo(unReportedOrderList.get(i));
EquipmentChargeOrderDO equipmentChargeOrderDO = equipmentChargeOrderDOMapper.selectOne(queryParam);
if (equipmentChargeOrderDO != null){
if ("2".equals(equipmentChargeOrderDO.getPayStatus().toString())){
equipmentChargeOrderDO.setState((byte)3);
if (equipmentChargeOrderDO != null) {
if ("2".equals(equipmentChargeOrderDO.getPayStatus().toString())) {
equipmentChargeOrderDO.setState((byte) 3);
equipmentChargeOrderDO.setFinishCode(200);
equipmentChargeOrderDO.setCancelCode(6);
equipmentChargeOrderDO.setCancelType(4);
equipmentChargeOrderDO.setCancelTime(ToolDateTime.getDate());
equipmentChargeOrderDO.setCancelMsg("已结束订单又被唤起");
equipmentChargeOrderDO.setId(equipmentChargeOrderDO.getId());
equipmentChargeOrderDO.setUpdateTime(ToolDateTime.getDate());
equipmentChargeOrderDO.setId(equipmentChargeOrderDO.getId());
equipmentChargeOrderDO.setUpdateTime(ToolDateTime.getDate());
equipmentChargeOrderDOMapper.updateByPrimaryKeySelective(equipmentChargeOrderDO);
}
if ("0".equals(equipmentChargeOrderDO.getPayStatus().toString())){
equipmentChargeOrderDO.setState((byte)5);
if ("0".equals(equipmentChargeOrderDO.getPayStatus().toString())) {
equipmentChargeOrderDO.setState((byte) 5);
equipmentChargeOrderDO.setCancelCode(5);
equipmentChargeOrderDO.setCancelType(3);
equipmentChargeOrderDO.setCancelTime(ToolDateTime.getDate());
equipmentChargeOrderDO.setCancelMsg("订单挂起");
equipmentChargeOrderDO.setId(equipmentChargeOrderDO.getId());
equipmentChargeOrderDO.setUpdateTime(ToolDateTime.getDate());
equipmentChargeOrderDO.setId(equipmentChargeOrderDO.getId());
equipmentChargeOrderDO.setUpdateTime(ToolDateTime.getDate());
equipmentChargeOrderDOMapper.updateByPrimaryKeySelective(equipmentChargeOrderDO);
// 共享用户,挂起订单解冻用户
UserDO userDO = userDOMapper.querUserInfoById(equipmentChargeOrderDO.getUserId().intValue());
@ -133,7 +135,9 @@ public class HandleOrderTarckService {
}
/**批量处理挂起订单,进行补单*/
/**
*
*/
// public void completeUnReportOrder(){
// List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpOrder();//查询挂起订单
// Stream.iterate(0,i->i+1).limit(hangUpOrderList.size()).forEach(i->{
@ -144,12 +148,11 @@ public class HandleOrderTarckService {
// }
// });
// }
public void completeUnReportOrder(){
public void completeUnReportOrder() {
Date startDate = ToolDateTime.startDateByDay(new Date(), -1);
Date endDate = ToolDateTime.endDateByDay(startDate);
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0,i->i+1).limit(hangUpOrderList.size()).forEach(i->{
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i -> {
asyncTaskService.completeUnReportOrder(hangUpOrderList.get(i));
});
}
@ -157,13 +160,13 @@ public class HandleOrderTarckService {
/**
*
*/
public void completeUnReportOrderV2(){
public void completeUnReportOrderV2() {
//处理前60天的挂起订单
Date startDate = ToolDateTime.startDateByDay(new Date(), -60);
Date endDate = ToolDateTime.startDateByDay(new Date(), 0);
// Date endDate = ToolDateTime.endDateByDay(new Date());
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i->{
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i -> {
asyncTaskService.completeUnReportOrder(hangUpOrderList.get(i));
});
}
@ -173,18 +176,42 @@ public class HandleOrderTarckService {
*/
public void completeUnReportReverseOrder() {
//处理指定 ~ 指定时间三天前 时间内的反向挂起的订单
// #{code} = push_reverse_orders.duration
// select value from t_biz_parameter where state = 1 and code = #{code} order by id desc limit 1
// select value from t_biz_parameter where state = 1 and code = 'push_reverse_orders.duration' order by id desc limit 1
// 返回值 72 小时
String time = equipmentChargeOrderDOMapper.getReverseFinishTime(Constant.REVERSE_ORDER_TIME);
int hour = new BigDecimal(time).intValue();
Date startDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -(hour + 720));
Date endDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -hour);
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpReverseOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i->{
Date startDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -(hour + 720));//33天之内的
Date endDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -hour);//72小时前也就是3天前
//查询这段时间内挂起的工单
/**
<select id="queryHangUpReverseOrder" resultMap="BaseResultMap">
SELECT
o.*
FROM
t_equipment_charge_order o left join t_station s on o.station_id = s.id
WHERE o.state = 5 and s.is_hlht = 1
<if test="startDate != null">
AND o.create_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND o.create_time &lt;= #{endDate}
</if>
ORDER BY o.id DESC
</select>
o.state = 5 0 1 2 3 4 5 6 7
is_hlht=1 1 0 , is_hlht=1,
*/
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpReverseOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i -> {
CompletableFuture<Map<String, Object>> sendCoupon = CompletableFuture.supplyAsync(() -> {
//处理挂起订单进行补单
asyncTaskService.completeUnReportReverseOrder(hangUpOrderList.get(i));
return null;
}, handleReverseService);
});
}
@ -194,18 +221,20 @@ public class HandleOrderTarckService {
public void handleInSettlementOrder() {
//指定时间24小时之前结算中的订单
Date time = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -24);
List<EquipmentChargeOrderDO> inSettlementOrderList = equipmentChargeOrderDOMapper.queryInSettlementOrder(time);
inSettlementOrderList.forEach(p->{
List<EquipmentChargeOrderDO> inSettlementOrderList = equipmentChargeOrderDOMapper.queryInSettlementOrder(time);
inSettlementOrderList.forEach(p -> {
try {
asyncTaskService.handleInSettlementOrder(p.getPlatformOrderNo(),p.getPayStatus().intValue());
}catch (Exception e){
log.error("处理结算中正向订单失败,原因:{}",e);
asyncTaskService.handleInSettlementOrder(p.getPlatformOrderNo(), p.getPayStatus().intValue());
} catch (Exception e) {
log.error("处理结算中正向订单失败,原因:{}", e);
}
});
}
/**补单结算*/
public void addSettle(EquipmentChargeOrderDO orderInfo,EquipmentOrder equipmentOrder,String equipmentSn){
/**
*
*/
public void addSettle(EquipmentChargeOrderDO orderInfo, EquipmentOrder equipmentOrder, String equipmentSn) {
String chargeDegree = orderInfo.getChargeDegree().toString();
String chargeBeginTime = ToolDateTime.dateToDateString(orderInfo.getChargeBeginTime());
String chargeEndTime = ToolDateTime.dateToDateString(orderInfo.getChargeEndTime());
@ -217,144 +246,150 @@ public class HandleOrderTarckService {
String actualPayAmount = settleValue.optString("fee");
String orderNo = orderInfo.getOrderNo();
if ("1000".equals(settleCode)) {
orderInfo = settle(orderInfo,settleValue);
orderInfo = settle(orderInfo, settleValue);
JSONObject outlayValue = financeServiceApi.chargeOrderOutlay(actualPayAmount,
orderNo,
activityFee,
isActivity,
orderInfo.getChargeServiceAmount().toString(),
Double.valueOf(chargeDegree),
orderInfo.getReceivableTotalFee().toString());//充电扣费
orderNo,
activityFee,
isActivity,
orderInfo.getChargeServiceAmount().toString(),
Double.valueOf(chargeDegree),
orderInfo.getReceivableTotalFee().toString());//充电扣费
String outlayCode = outlayValue.optString("code");
if ("1000".equals(outlayCode)) {
orderInfo = outlay(orderInfo,outlayValue);
orderInfo = outlay(orderInfo, outlayValue);
equipmentChargeOrderDOMapper.updateByPrimaryKeySelective(orderInfo);
//补单后推送账单
hlhtMqProducer.chargeBillsProducer(msgMq( equipmentOrder, chargeBeginTime, chargeEndTime, orderNo, chargeDegree,
equipmentSn, chargeTimesDegree));
hlhtMqProducer.chargeBillsProducer(msgMq(equipmentOrder, chargeBeginTime, chargeEndTime, orderNo, chargeDegree,
equipmentSn, chargeTimesDegree));
}
}
}
/**补全订单的计费信息*/
private EquipmentChargeOrderDO settle(EquipmentChargeOrderDO orderInfo, JSONObject settleValue){
/**
*
*/
private EquipmentChargeOrderDO settle(EquipmentChargeOrderDO orderInfo, JSONObject settleValue) {
String invoiceFee = settleValue.optString("invoiceFee");
String totalElectricFee = settleValue.optString("electricFee");
String totalServiceFee = settleValue.optString("serviceFee");
String chargeSettleType = settleValue.optString("chargeSettleType");
BigDecimal serviceFee = new BigDecimal(totalServiceFee);
String receivableElectricFee = settleValue.optString("oriElectricFee");//应收电费
String receivableServiceFee = settleValue.optString("oriServiceFee");//应收服务费
String receivableTotalFee = settleValue.optString("oriTotalFee");//应收总金额
Integer settleFlag = settleValue.optInt("settleFlag");
String activityServiceFee = settleValue.optString("activityServiceFee");
String activityElectricFee = settleValue.optString("activityElectricFee");
String chargeUnitServiceFee = settleValue.optString("serviceFeeUnitPrice");
String chargeUnitPrice = settleValue.optString("electricityBill");
String chargeUnitCost = settleValue.optString("costUnitPrice");
String chargeElecfeeCostAmount = settleValue.optString("costFee");
String chargeElecfeeCostAmounts = settleValue.optString("totalCostFee");
Object orderDetail = settleValue.opt("detail");
orderInfo.setState((byte)3);
String receivableElectricFee = settleValue.optString("oriElectricFee");//应收电费
String receivableServiceFee = settleValue.optString("oriServiceFee");//应收服务费
String receivableTotalFee = settleValue.optString("oriTotalFee");//应收总金额
Integer settleFlag = settleValue.optInt("settleFlag");
String activityServiceFee = settleValue.optString("activityServiceFee");
String activityElectricFee = settleValue.optString("activityElectricFee");
String chargeUnitServiceFee = settleValue.optString("serviceFeeUnitPrice");
String chargeUnitPrice = settleValue.optString("electricityBill");
String chargeUnitCost = settleValue.optString("costUnitPrice");
String chargeElecfeeCostAmount = settleValue.optString("costFee");
String chargeElecfeeCostAmounts = settleValue.optString("totalCostFee");
Object orderDetail = settleValue.opt("detail");
orderInfo.setState((byte) 3);
orderInfo.setChargeServiceAmount(serviceFee);
orderInfo.setChargeElecfeeAmount(new BigDecimal(totalElectricFee));
orderInfo.setChargeSettleType(Byte.parseByte(chargeSettleType));
orderInfo.setInvoiceFee(new BigDecimal(invoiceFee));
orderInfo.setTicketStatus((byte)0);
orderInfo.setActivityServiceFee(new BigDecimal(activityServiceFee));
orderInfo.setActivityElectricFee(new BigDecimal(activityElectricFee));
orderInfo.setSettlementType(settleFlag.byteValue());
orderInfo.setReceivableElectricFee(new BigDecimal(receivableElectricFee));
orderInfo.setReceivableServiceFee(new BigDecimal(Double.parseDouble(receivableServiceFee)));
orderInfo.setReceivableTotalFee(new BigDecimal(Double.parseDouble(receivableTotalFee)));
if ("1".equals(chargeSettleType)){ //全时段
orderInfo.setTicketStatus((byte) 0);
orderInfo.setActivityServiceFee(new BigDecimal(activityServiceFee));
orderInfo.setActivityElectricFee(new BigDecimal(activityElectricFee));
orderInfo.setSettlementType(settleFlag.byteValue());
orderInfo.setReceivableElectricFee(new BigDecimal(receivableElectricFee));
orderInfo.setReceivableServiceFee(new BigDecimal(Double.parseDouble(receivableServiceFee)));
orderInfo.setReceivableTotalFee(new BigDecimal(Double.parseDouble(receivableTotalFee)));
if ("1".equals(chargeSettleType)) { //全时段
orderInfo.setChargeUnitPrice(new BigDecimal(chargeUnitPrice));
orderInfo.setChargeUnitCost(new BigDecimal(chargeUnitCost));
orderInfo.setChargeUnitServiceFee(new BigDecimal(chargeUnitServiceFee));
orderInfo.setChargeElecfeeCostAmount(new BigDecimal(chargeElecfeeCostAmount));
orderInfo.setChargeSettleType(Byte.parseByte(chargeSettleType));
}
if ("2".equals(chargeSettleType)){
if ("2".equals(chargeSettleType)) {
orderInfo.setChargeElecfeeCostAmount(new BigDecimal(chargeElecfeeCostAmounts));
orderInfo.setChargeSettleType(Byte.parseByte(chargeSettleType));
int zeroResult = new BigDecimal(0.0).compareTo(new BigDecimal(orderInfo.getChargeDegree()));
if (zeroResult != 0){
BigDecimal avgServiceFeeUnitPrice = new BigDecimal(receivableServiceFee).divide(new BigDecimal(orderInfo.getChargeDegree()),2,BigDecimal.ROUND_HALF_UP);
BigDecimal avgChargeUnitPrice = new BigDecimal(receivableElectricFee).divide(new BigDecimal(orderInfo.getChargeDegree()),2,BigDecimal.ROUND_HALF_UP);
if (zeroResult != 0) {
BigDecimal avgServiceFeeUnitPrice = new BigDecimal(receivableServiceFee).divide(new BigDecimal(orderInfo.getChargeDegree()), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal avgChargeUnitPrice = new BigDecimal(receivableElectricFee).divide(new BigDecimal(orderInfo.getChargeDegree()), 2, BigDecimal.ROUND_HALF_UP);
orderInfo.setChargeUnitPrice(avgChargeUnitPrice);
orderInfo.setChargeUnitCost(avgChargeUnitPrice);
orderInfo.setChargeUnitServiceFee(avgServiceFeeUnitPrice);
}else{
} else {
orderInfo.setChargeUnitPrice(new BigDecimal(0.00));
orderInfo.setChargeUnitCost(new BigDecimal(0.00));
orderInfo.setChargeUnitServiceFee(new BigDecimal(0.00));
}
JSONArray subPeriods = JSONArray.fromObject(orderDetail);//分时段信息记录
insertOrderDetail(orderInfo.getOrderNo(),subPeriods);
insertOrderDetail(orderInfo.getOrderNo(), subPeriods);
}
equipmentChargeOrderDOMapper.updateByPrimaryKeySelective(orderInfo);
return orderInfo;
}
/**补全订单的结算信息*/
private EquipmentChargeOrderDO outlay(EquipmentChargeOrderDO orderInfo,JSONObject outlayValue){
/**
*
*/
private EquipmentChargeOrderDO outlay(EquipmentChargeOrderDO orderInfo, JSONObject outlayValue) {
String payAmount = outlayValue.optString("pay_amount");
String actualPayAmount = outlayValue.optString("actual_pay_amount");
String couponAmount = outlayValue.optString("coupon_amount");
String eleFeeCoupon = outlayValue.optString("eleFeeCoupon");
String serviceCouponFee = outlayValue.optString("serviceCouponFee");
String userCouponId = outlayValue.optString("user_coupon_id");
String activityServiceFee = outlayValue.optString("activityServiceFee");
String activityElectricFee = outlayValue.optString("activityElectricFee");
String serviceFee = outlayValue.optString("serviceFee");
String electricFee = outlayValue.optString("electricFee");
String userCouponId = outlayValue.optString("user_coupon_id");
String activityServiceFee = outlayValue.optString("activityServiceFee");
String activityElectricFee = outlayValue.optString("activityElectricFee");
String serviceFee = outlayValue.optString("serviceFee");
String electricFee = outlayValue.optString("electricFee");
orderInfo.setId(orderInfo.getId());
orderInfo.setPayStatus((byte)2);
orderInfo.setPayMethod((byte)0);
orderInfo.setPayStatus((byte) 2);
orderInfo.setPayMethod((byte) 0);
orderInfo.setPayAmount(new BigDecimal(payAmount));
orderInfo.setPayTime(new Date());
orderInfo.setActualPayAmount(new BigDecimal(actualPayAmount));
orderInfo.setActivityServiceFee(new BigDecimal(activityServiceFee));
orderInfo.setActivityElectricFee(new BigDecimal(activityElectricFee));
orderInfo.setChargeServiceAmount(new BigDecimal(serviceFee));
orderInfo.setChargeElecfeeAmount(new BigDecimal(electricFee));
orderInfo.setReportTime(new Date());
if(orderInfo.getSettlementType() != 0){ //使用了套餐
orderInfo.setActualPayAmount(new BigDecimal(actualPayAmount));
orderInfo.setActivityServiceFee(new BigDecimal(activityServiceFee));
orderInfo.setActivityElectricFee(new BigDecimal(activityElectricFee));
orderInfo.setChargeServiceAmount(new BigDecimal(serviceFee));
orderInfo.setChargeElecfeeAmount(new BigDecimal(electricFee));
orderInfo.setReportTime(new Date());
if (orderInfo.getSettlementType() != 0) { //使用了套餐
orderInfo.setCouponAmount(new BigDecimal(couponAmount));
}
if(!userCouponId.equals("")) { //用户 优惠劵id
if (!userCouponId.equals("")) { //用户 优惠劵id
orderInfo.setCouponAmount(new BigDecimal(couponAmount));
orderInfo.setElecfeeCouponAmount(new BigDecimal(eleFeeCoupon));
orderInfo.setServicefeeCouponAmount(new BigDecimal(serviceCouponFee));
orderInfo.setUserCouponId(Long.parseLong(userCouponId));
orderInfo.setCouponType((byte)0);
orderInfo.setCouponType((byte) 0);
}
return orderInfo;
}
/**记录订单的分时信息*/
public void insertOrderDetail(String orderNo,JSONArray detailJSONArray){
/**
*
*/
public void insertOrderDetail(String orderNo, JSONArray detailJSONArray) {
try {
for (int i=0 ; i < detailJSONArray.size() ;i++){
for (int i = 0; i < detailJSONArray.size(); i++) {
JSONObject myjObject = detailJSONArray.getJSONObject(i);
Double serviceFee = myjObject.optDouble("serviceFee");
Double degree = myjObject.optDouble("degree");
Double electricFee = myjObject.optDouble("electricFee");
Double costFee = myjObject.optDouble("costFee");
Double serviceFeeUnitPrice = myjObject.optDouble("serviceFeeUnitPrice");
Double electricityBill = myjObject.optDouble("electricityBill");
Double costUnitPrice = myjObject.optDouble("costUnitPrice");
Double activityServiceFee = myjObject.optDouble("activityServiceFee");
Double activityElectricFee = myjObject.optDouble("activityElectricFee");
String startTime = myjObject.optString("startTime");
String endTime = myjObject.optString("endTime");
String couponDegree = myjObject.optString("couponDegree").equals("") ? "0.00" : myjObject.optString("couponDegree");//优惠度数
Double cardUnitService = myjObject.optDouble("cardUnitService");//套餐服务费单价
Double cardUnitEle = myjObject.optDouble("cardUnitEle");//套餐电费单价
String cardEleFee = myjObject.optString("cardEleFee").equals("") ? "0.00" : myjObject.optString("cardEleFee");//套餐电费
String cardServiceFee = myjObject.optString("cardServiceFee").equals("") ? "0.00" : myjObject.optString("cardServiceFee");//套餐服务费
String cardFee = myjObject.optString("cardFee").equals("") ? "0.00" : myjObject.optString("cardFee");//套餐总金额
Integer timeFlag = myjObject.optInt("timeFlag");
Double electricityBill = myjObject.optDouble("electricityBill");
Double costUnitPrice = myjObject.optDouble("costUnitPrice");
Double activityServiceFee = myjObject.optDouble("activityServiceFee");
Double activityElectricFee = myjObject.optDouble("activityElectricFee");
String startTime = myjObject.optString("startTime");
String endTime = myjObject.optString("endTime");
String couponDegree = myjObject.optString("couponDegree").equals("") ? "0.00" : myjObject.optString("couponDegree");//优惠度数
Double cardUnitService = myjObject.optDouble("cardUnitService");//套餐服务费单价
Double cardUnitEle = myjObject.optDouble("cardUnitEle");//套餐电费单价
String cardEleFee = myjObject.optString("cardEleFee").equals("") ? "0.00" : myjObject.optString("cardEleFee");//套餐电费
String cardServiceFee = myjObject.optString("cardServiceFee").equals("") ? "0.00" : myjObject.optString("cardServiceFee");//套餐服务费
String cardFee = myjObject.optString("cardFee").equals("") ? "0.00" : myjObject.optString("cardFee");//套餐总金额
Integer timeFlag = myjObject.optInt("timeFlag");
EquipmentChargeOrderDetailDO equipmentChargeOrderDetailDO = new EquipmentChargeOrderDetailDO(orderNo, degree, new BigDecimal(serviceFee),
new BigDecimal(electricFee), new BigDecimal(costFee), new BigDecimal(serviceFeeUnitPrice),
new BigDecimal(electricityBill), new BigDecimal(costUnitPrice), new BigDecimal(activityServiceFee),
@ -369,165 +404,175 @@ public class HandleOrderTarckService {
}
public ChargeBillsBO msgMq(EquipmentOrder equipmentOrder,
String chargeBeginTime,
String chargeEndTime,
String orderNo,
String chargeDegree,
String equipmentSn,
double[] chargeTimesDegree){
String chargeBeginTime,
String chargeEndTime,
String orderNo,
String chargeDegree,
String equipmentSn,
double[] chargeTimesDegree) {
ChargeBillsBO chargeBillsBO = new ChargeBillsBO();
chargeBillsBO.setOrderNo(orderNo);
chargeBillsBO.setDegree(chargeDegree);
chargeBillsBO.setEquipmentSn(equipmentSn);
chargeBillsBO.setTimeAndDegree(chargeTimesDegree);
chargeBillsBO.setBeginDegree(equipmentOrder.getChargeBeginDegree()+"");
chargeBillsBO.setEndDegree(equipmentOrder.getChargeEndDegree()+"");
chargeBillsBO.setUsedTime(equipmentOrder.getChargeDuration()+"");
chargeBillsBO.setSocStart(equipmentOrder.getChargeBeginSoc()+"");
chargeBillsBO.setSocEnd(equipmentOrder.getChargeEndSoc()+"");
chargeBillsBO.setBeginDegree(equipmentOrder.getChargeBeginDegree() + "");
chargeBillsBO.setEndDegree(equipmentOrder.getChargeEndDegree() + "");
chargeBillsBO.setUsedTime(equipmentOrder.getChargeDuration() + "");
chargeBillsBO.setSocStart(equipmentOrder.getChargeBeginSoc() + "");
chargeBillsBO.setSocEnd(equipmentOrder.getChargeEndSoc() + "");
chargeBillsBO.setStopReason("5");
chargeBillsBO.setStopReasonMsg("补单结束");
chargeBillsBO.setStartType(equipmentOrder.getBootMode()+"");
chargeBillsBO.setStartType(equipmentOrder.getBootMode() + "");
chargeBillsBO.setStartTime(chargeBeginTime);
chargeBillsBO.setStartTime(chargeEndTime);
chargeBillsBO.setConnectorNo(equipmentOrder.getPlugNo()+"");
chargeBillsBO.setConnectorNo(equipmentOrder.getPlugNo() + "");
chargeBillsBO.setVin(equipmentOrder.getChargeVin());
chargeBillsBO.setChargeDetectionFlag("0");
return chargeBillsBO;
}
/**判断订单类型*/
private EquipmentChargeOrderDO judgeOrderType(EquipmentChargeOrderDO orderInfo){
/**
*
*/
private EquipmentChargeOrderDO judgeOrderType(EquipmentChargeOrderDO orderInfo) {
PlatformDO platformInfo = platformDOMapper.getPlatformInfoByUserId(orderInfo.getUserId().intValue());
if (platformInfo != null){
orderInfo.setOrderType((byte)4);
}else {
if (platformInfo != null) {
orderInfo.setOrderType((byte) 4);
} else {
Integer userType = userDOMapper.getUserType(orderInfo.getUserId().intValue());
orderInfo.setOrderType(userType.byteValue());
}
return orderInfo;
}
/**推送订单停止中到互通互联运营商*/
public void pullHthlStopResult(String orderNo,Integer userId){
/**
*
*/
public void pullHthlStopResult(String orderNo, Integer userId) {
PlatformDO platformInfo = platformDOMapper.getPlatformInfoByUserId(userId);
if (platformInfo != null){
if ("101437000".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"101437000",3);
if (platformInfo != null) {
if ("101437000".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "101437000", 3);
}
if ("351021524".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"351021524",3);
if ("351021524".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "351021524", 3);
}
if ("425010765".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"425010765",3);
if ("425010765".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "425010765", 3);
}
if ("MA01H3BQ1".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"MA01H3BQ1",3);
if ("MA01H3BQ1".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "MA01H3BQ1", 3);
}
if ("325616137".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"325616137",3);
if ("325616137".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "325616137", 3);
}
if ("717397615".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"717397615",3);
if ("717397615".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "717397615", 3);
}
if ("MA4KUHJ97".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,"MA4KUHJ97",3);
if ("MA4KUHJ97".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, "MA4KUHJ97", 3);
}
//兼容版
if (!"101437000".equals(platformInfo.getPlatformCode())&& !"350100001".equals(platformInfo.getPlatformCode())&&
!"351021524".equals(platformInfo.getPlatformCode())&& !"395815801".equals(platformInfo.getPlatformCode())&&
!"425010765".equals(platformInfo.getPlatformCode())&& !"MA01H3BQ1".equals(platformInfo.getPlatformCode())&&
!"325616137".equals(platformInfo.getPlatformCode())&& !"717397615".equals(platformInfo.getPlatformCode())&&
!"MA4KUHJ97".equals(platformInfo.getPlatformCode())){
hthlNotifyService.notifyStopChargeResult(orderNo,platformInfo.getPlatformCode(),3);
if (!"101437000".equals(platformInfo.getPlatformCode()) && !"350100001".equals(platformInfo.getPlatformCode()) &&
!"351021524".equals(platformInfo.getPlatformCode()) && !"395815801".equals(platformInfo.getPlatformCode()) &&
!"425010765".equals(platformInfo.getPlatformCode()) && !"MA01H3BQ1".equals(platformInfo.getPlatformCode()) &&
!"325616137".equals(platformInfo.getPlatformCode()) && !"717397615".equals(platformInfo.getPlatformCode()) &&
!"MA4KUHJ97".equals(platformInfo.getPlatformCode())) {
hthlNotifyService.notifyStopChargeResult(orderNo, platformInfo.getPlatformCode(), 3);
}
}
}
/**推送账单到互通互联运营商*/
public void pullHthl(String orderNo,Integer userId){
/**
*
*/
public void pullHthl(String orderNo, Integer userId) {
PlatformDO platformInfo = platformDOMapper.getPlatformInfoByUserId(userId);
if (platformInfo != null){
if ("101437000".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"101437000");
hthlNotifyService.notifyStopChargeResult(orderNo,"101437000",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"101437000");
}
if ("350100001".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"350100001");
hthlNotifyService.notifyChargeToCaocao(orderNo,"chargeStop");
}
if ("351021524".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"351021524");
hthlNotifyService.notifyStopChargeResult(orderNo,"351021524",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"351021524");
}
if ("425010765".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"425010765");
hthlNotifyService.notifyStopChargeResult(orderNo,"425010765",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"425010765");
}
if ("MA01H3BQ1".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"MA01H3BQ1");
hthlNotifyService.notifyStopChargeResult(orderNo,"MA01H3BQ1",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"MA01H3BQ1");
}
if ("325616137".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"325616137");
hthlNotifyService.notifyStopChargeResult(orderNo,"325616137",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"325616137");
}
if ("717397615".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"717397615");
hthlNotifyService.notifyStopChargeResult(orderNo,"717397615",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"717397615");
}
if ("MA4KUHJ97".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,"MA4KUHJ97");
hthlNotifyService.notifyStopChargeResult(orderNo,"MA4KUHJ97",4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,"MA4KUHJ97");
if (platformInfo != null) {
if ("101437000".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "101437000");
hthlNotifyService.notifyStopChargeResult(orderNo, "101437000", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "101437000");
}
if ("350100001".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "350100001");
hthlNotifyService.notifyChargeToCaocao(orderNo, "chargeStop");
}
if ("351021524".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "351021524");
hthlNotifyService.notifyStopChargeResult(orderNo, "351021524", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "351021524");
}
if ("425010765".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "425010765");
hthlNotifyService.notifyStopChargeResult(orderNo, "425010765", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "425010765");
}
if ("MA01H3BQ1".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "MA01H3BQ1");
hthlNotifyService.notifyStopChargeResult(orderNo, "MA01H3BQ1", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "MA01H3BQ1");
}
if ("325616137".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "325616137");
hthlNotifyService.notifyStopChargeResult(orderNo, "325616137", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "325616137");
}
if ("717397615".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "717397615");
hthlNotifyService.notifyStopChargeResult(orderNo, "717397615", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "717397615");
}
if ("MA4KUHJ97".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, "MA4KUHJ97");
hthlNotifyService.notifyStopChargeResult(orderNo, "MA4KUHJ97", 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, "MA4KUHJ97");
}
//兼容版
if (!"101437000".equals(platformInfo.getPlatformCode())&& !"350100001".equals(platformInfo.getPlatformCode())&&
!"351021524".equals(platformInfo.getPlatformCode())&& !"395815801".equals(platformInfo.getPlatformCode())&&
!"425010765".equals(platformInfo.getPlatformCode())&& !"MA01H3BQ1".equals(platformInfo.getPlatformCode())&&
!"325616137".equals(platformInfo.getPlatformCode())&& !"717397615".equals(platformInfo.getPlatformCode())&&
!"MA4KUHJ97".equals(platformInfo.getPlatformCode())){
saveOpenapiNotifyOrderInfo(orderNo,platformInfo.getPlatformCode());
hthlNotifyService.notifyStopChargeResult(orderNo,platformInfo.getPlatformCode(),4);
hthlNotifyService.notifyChargeOrderInfo(orderNo,platformInfo.getPlatformCode());
if (!"101437000".equals(platformInfo.getPlatformCode()) && !"350100001".equals(platformInfo.getPlatformCode()) &&
!"351021524".equals(platformInfo.getPlatformCode()) && !"395815801".equals(platformInfo.getPlatformCode()) &&
!"425010765".equals(platformInfo.getPlatformCode()) && !"MA01H3BQ1".equals(platformInfo.getPlatformCode()) &&
!"325616137".equals(platformInfo.getPlatformCode()) && !"717397615".equals(platformInfo.getPlatformCode()) &&
!"MA4KUHJ97".equals(platformInfo.getPlatformCode())) {
saveOpenapiNotifyOrderInfo(orderNo, platformInfo.getPlatformCode());
hthlNotifyService.notifyStopChargeResult(orderNo, platformInfo.getPlatformCode(), 4);
hthlNotifyService.notifyChargeOrderInfo(orderNo, platformInfo.getPlatformCode());
}
}
}
/**补全停止前最新一次的订单信息*/
public EquipmentChargeOrderDO beforeStopLastOrderInfo(EquipmentOrder equipmentOrder,EquipmentChargeOrderDO orderInfo){
/**
*
*/
public EquipmentChargeOrderDO beforeStopLastOrderInfo(EquipmentOrder equipmentOrder, EquipmentChargeOrderDO orderInfo) {
String timeShare = timeShareComputeStr(equipmentOrder.getMultiChargeDegree());
orderInfo.setChargeTimesDegree(timeShare);
orderInfo.setChargeEndTime(equipmentOrder.getChargeEndTime());
orderInfo.setChargeDuration(equipmentOrder.getChargeDuration());
orderInfo.setChargeBeginDegree(equipmentOrder.getChargeBeginDegree());
orderInfo.setChargeEndDegree(equipmentOrder.getChargeEndDegree());
orderInfo.setChargeDegree(equipmentOrder.getChargeDegree());
orderInfo.setChargeBeginSoc(Double.valueOf(equipmentOrder.getChargeBeginSoc()).intValue());
orderInfo.setChargeEndSoc(Double.valueOf(equipmentOrder.getChargeEndSoc()).intValue());
orderInfo.setChargeCurSoc(Double.valueOf(equipmentOrder.getChargeEndSoc()).intValue());
orderInfo.setChargeStrategy(equipmentOrder.getChargeStrategy());
orderInfo.setChargeStrategyParam(equipmentOrder.getChargeStrategyParam());
orderInfo.setBootMode(equipmentOrder.getBootMode());
orderInfo.setChargeVin(equipmentOrder.getChargeVin());
orderInfo.setChargeAh(equipmentOrder.getChargeDegree()*100);
orderInfo.setFinishCode(44);
orderInfo.setFinishType(2);
orderInfo.setFinishMsg("补单结束");
orderInfo.setFinishTime(ToolDateTime.getDate());
orderInfo.setChargeEndDegree(equipmentOrder.getChargeEndDegree());
orderInfo.setChargeDegree(equipmentOrder.getChargeDegree());
orderInfo.setChargeBeginSoc(Double.valueOf(equipmentOrder.getChargeBeginSoc()).intValue());
orderInfo.setChargeEndSoc(Double.valueOf(equipmentOrder.getChargeEndSoc()).intValue());
orderInfo.setChargeCurSoc(Double.valueOf(equipmentOrder.getChargeEndSoc()).intValue());
orderInfo.setChargeStrategy(equipmentOrder.getChargeStrategy());
orderInfo.setChargeStrategyParam(equipmentOrder.getChargeStrategyParam());
orderInfo.setBootMode(equipmentOrder.getBootMode());
orderInfo.setChargeVin(equipmentOrder.getChargeVin());
orderInfo.setChargeAh(equipmentOrder.getChargeDegree() * 100);
orderInfo.setFinishCode(44);
orderInfo.setFinishType(2);
orderInfo.setFinishMsg("补单结束");
orderInfo.setFinishTime(ToolDateTime.getDate());
return orderInfo;
}
/**保存第三方平台订单到第三方平台推送表*/
private void saveOpenapiNotifyOrderInfo(String orderNo,String platformCode){
/**
*
*/
private void saveOpenapiNotifyOrderInfo(String orderNo, String platformCode) {
Integer count = openapiNotifyOrderInfoDOMapper.countOpenapiNotifyOrderInfo(orderNo); //第三方平台需要推送的订单
if (count == 0){
if (count == 0) {
OpenapiNotifyOrderInfoDO openapiNotifyOrderInfoDO = new OpenapiNotifyOrderInfoDO();
openapiNotifyOrderInfoDO.setOrderNo(orderNo);
openapiNotifyOrderInfoDO.setPlatformCode(platformCode);
@ -536,10 +581,12 @@ public class HandleOrderTarckService {
}
}
/**处理分时段电量*/
private String timeShareComputeStr(double[] chargeTimesDegree){
/**
*
*/
private String timeShareComputeStr(double[] chargeTimesDegree) {
StringBuilder chargeTimesDegreeStr = new StringBuilder();
Stream.iterate(0,i->i+1).limit(chargeTimesDegree.length).forEach(i->{
Stream.iterate(0, i -> i + 1).limit(chargeTimesDegree.length).forEach(i -> {
chargeTimesDegreeStr.append(chargeTimesDegree[i]);
if (i < chargeTimesDegree.length - 1) {
chargeTimesDegreeStr.append(",");
@ -549,19 +596,18 @@ public class HandleOrderTarckService {
}
/**充电中订单挂起*/
public void chargeIngeSuspend(){
Date nowTime=new Date();
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryTimeOutOrderToStateTwo(Tools.getDayTime());//查询充电中订单
for(EquipmentChargeOrderDO order:hangUpOrderList){
Date updateTime=order.getUpdateTime();
if(null!=updateTime){
Long sec= dateDiff(nowTime,updateTime);
if(sec >= 900) {
equipmentChargeOrderDOMapper.editeOrderState(5,order.getOrderNo(),Tools.getDayTime(),"订单进行挂起");
/**
*
*/
public void chargeIngeSuspend() {
Date nowTime = new Date();
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryTimeOutOrderToStateTwo(Tools.getDayTime());//查询充电中订单
for (EquipmentChargeOrderDO order : hangUpOrderList) {
Date updateTime = order.getUpdateTime();
if (null != updateTime) {
Long sec = dateDiff(nowTime, updateTime);
if (sec >= 900) {
equipmentChargeOrderDOMapper.editeOrderState(5, order.getOrderNo(), Tools.getDayTime(), "订单进行挂起");
// 共享用户,挂起订单解冻用户
UserDO userDO = userDOMapper.querUserInfoById(order.getUserId().intValue());
removeFreezeUser(userDO);
@ -571,16 +617,15 @@ public class HandleOrderTarckService {
}
public static Long dateDiff(Date start,Date end) {
public static Long dateDiff(Date start, Date end) {
// 按照传入的格式生成一个simpledateformate对象
long interval=0;
long interval = 0;
try {
interval = (start.getTime() - end.getTime()) / 1000;
}
catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return interval;
return interval;
}
@ -591,10 +636,10 @@ public class HandleOrderTarckService {
//查询需要处理的订单列表
List<EquipmentChargeOrderDO> equipmentChargeOrderDOList = equipmentChargeOrderDOMapper.queryAbnormalOrder();
//从redis中获取数据进行处理
for(EquipmentChargeOrderDO equipmentChargeOrderDO : equipmentChargeOrderDOList) {
for (EquipmentChargeOrderDO equipmentChargeOrderDO : equipmentChargeOrderDOList) {
String platformOrderNo = equipmentChargeOrderDO.getPlatformOrderNo();
String jsonString = tokenService.getToken(platformOrderNo);
if(jsonString == null || "".equals(jsonString)) {
String jsonString = tokenService.getToken(platformOrderNo);
if (jsonString == null || "".equals(jsonString)) {
continue;
}
JSONObject jsonObject = JSONObject.fromObject(jsonString);
@ -606,15 +651,15 @@ public class HandleOrderTarckService {
String orderNo = equipmentChargeOrderDO.getOrderNo();
//进行异常订单的处理,不扣费
JSONObject outlay = financeServiceApi.getHlhtAbnormalOrder(totalMoney.toString(),
orderNo,
"0", "0",
totalServiceMoney.toString(),
totalPower, totalMoney.toString());
orderNo,
"0", "0",
totalServiceMoney.toString(),
totalPower, totalMoney.toString());
updateExceptionOrderOutlayInfo(outlay, notifyChargeOrderInfoBO, orderNo);
// 启明共享用户 解除冻结状态
UserDO userDO = userDOMapper.querUserInfoById(equipmentChargeOrderDO.getUserId().intValue());
if (userDO.getSharedUser()==1){
Boolean b=userAccountStateService.removeFreezeUser(equipmentChargeOrderDO.getUserId().intValue());
if (userDO.getSharedUser() == 1) {
Boolean b = userAccountStateService.removeFreezeUser(equipmentChargeOrderDO.getUserId().intValue());
log.info("定时任务处理已完成、未支付订单完成不扣费,解冻启明共享用户,结果:{}", b);
}
}
@ -752,24 +797,24 @@ public class HandleOrderTarckService {
OrderTrackInfo orderTrackInfo = orderTrackInfoDao.findOne(order.getOrderNo());
//轨迹日志为空,则全部补推
if(orderTrackInfo == null) {
if (orderTrackInfo == null) {
hlhtMqProducer.chargeBillsProducer(new ChargeBillsBO(order.getOrderNo()));
hlhtMqProducer.chargeBillsProducerMonitor(order.getStationId(), new ChargeBillsBO(order.getOrderNo()));
hlhtMqProducer.chargeBillsProducerProvincialMonitor(order, new ChargeBillsBO(order.getOrderNo()));
}
//渠道方补推
if(!orderTrackInfo.getPushChannelFlag()) {
if (!orderTrackInfo.getPushChannelFlag()) {
hlhtMqProducer.chargeBillsProducer(new ChargeBillsBO(order.getOrderNo()));
}
//监管平台补推
if(!orderTrackInfo.getPushMonitor()) {
if (!orderTrackInfo.getPushMonitor()) {
hlhtMqProducer.chargeBillsProducerMonitor(order.getStationId(), new ChargeBillsBO(order.getOrderNo()));
}
//省监管平台补推
if(!orderTrackInfo.getPushProvincialMonitor()) {
if (!orderTrackInfo.getPushProvincialMonitor()) {
hlhtMqProducer.chargeBillsProducerProvincialMonitor(order, new ChargeBillsBO(order.getOrderNo()));
}
@ -780,23 +825,23 @@ public class HandleOrderTarckService {
@Async
public void pushOrderToMonitor(DateTime beginTime, DateTime endTime, Integer scrollSize, String operatorIds) {
List<String> operatorIdList = null;
if(StringUtils.isNotBlank(operatorIds)){
if (StringUtils.isNotBlank(operatorIds)) {
operatorIdList = Arrays.asList(operatorIds.split(","));
}
final Long total = equipmentChargeOrderDOMapper.selectCountByDate(beginTime,endTime,operatorIdList);
final Long total = equipmentChargeOrderDOMapper.selectCountByDate(beginTime, endTime, operatorIdList);
if(Objects.equals(total,0L)|| Objects.isNull(total)){
if (Objects.equals(total, 0L) || Objects.isNull(total)) {
return;
}
final ForkJoinPool pool = new ForkJoinPool(THREAD_NUM);
final Long transCount = pool.invoke(new OrderTransTask(0L, total, Objects.isNull(scrollSize)?5000:scrollSize,
beginTime, endTime, equipmentChargeOrderDOMapper, hlhtMqProducer,operatorIdList));
final Long transCount = pool.invoke(new OrderTransTask(0L, total, Objects.isNull(scrollSize) ? 5000 : scrollSize,
beginTime, endTime, equipmentChargeOrderDOMapper, hlhtMqProducer, operatorIdList));
log.info("完成订单补推, 期望总数:{}, 实际总数:{}", total, transCount);
}
private void removeFreezeUser(UserDO userDO){
if(userDO.getSharedUser() == 1) {
private void removeFreezeUser(UserDO userDO) {
if (userDO.getSharedUser() == 1) {
Boolean removeFreezeUserResult = userAccountStateService.removeFreezeUser(userDO.getId().intValue());
log.info("挂起订单,解冻用户返回结果:{}", removeFreezeUserResult);
}

@ -0,0 +1,93 @@
```java
@Scheduled(cron = "0 0 3 * * ?")
public void completeUnReportReverseOrder() {
try{
log.info("批量处理挂起反向订单,进行补单");
handleOrderTarckService.completeUnReportReverseOrder();
}catch (Exception e){
log.error("批量处理挂起反向订单,进行补单失败,原因:", e);
e.printStackTrace();
}
}
```
定时了定时任务每天$3$点进行挂起反向订单的补单操作。
```java
/**
* 批量处理挂起反向订单,进行补单
*/
public void completeUnReportReverseOrder() {
//处理指定 ~ 指定时间三天前 时间内的反向挂起的订单
// #{code} = push_reverse_orders.duration
// select value from t_biz_parameter where state = 1 and code = #{code} order by id desc limit 1
// select value from t_biz_parameter where state = 1 and code = 'push_reverse_orders.duration' order by id desc limit 1
// 返回值 72 小时
String time = equipmentChargeOrderDOMapper.getReverseFinishTime(Constant.REVERSE_ORDER_TIME);
int hour = new BigDecimal(time).intValue();
Date startDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -(hour + 720));//33天之内的
Date endDate = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -hour);//72小时前也就是3天前
//查询这段时间内挂起的工单
/**
<select id="queryHangUpReverseOrder" resultMap="BaseResultMap">
SELECT
o.*
FROM
t_equipment_charge_order o left join t_station s on o.station_id = s.id
WHERE o.state = 5 and s.is_hlht = 1
<if test="startDate != null">
AND o.create_time &gt;= #{startDate}
</if>
<if test="endDate != null">
AND o.create_time &lt;= #{endDate}
</if>
ORDER BY o.id DESC
</select>
o.state = 5 订单状态 0 创建中 1准备充电中 2 充电中 3完成 4 取消 5挂起 6需要手动补单 7结算中
is_hlht=1 是否是互联互通站点 1是 0不是 , 注意这里只处理了互联互通的因为is_hlht=1,也就是说不是互联互通的挂单,调用这个接口补单是无效的!!!
*/
List<EquipmentChargeOrderDO> hangUpOrderList = equipmentChargeOrderDOMapper.queryHangUpReverseOrder(startDate, endDate);//查询挂起订单
Stream.iterate(0, i -> i + 1).limit(hangUpOrderList.size()).forEach(i -> {
CompletableFuture<Map<String, Object>> sendCoupon = CompletableFuture.supplyAsync(() -> {
//处理挂起订单进行补单
asyncTaskService.completeUnReportReverseOrder(hangUpOrderList.get(i));
return null;
}, handleReverseService);
});
}
```
从$JAVA$代码来看,依赖这个接口实现补单功能有两个问题:
- 它只能实现$72$小时的补单,为什么一定要强调$72$小时呢?为什么不是$24$小时或者$1$小时呢?
- 它只能实现互联互通的补单,对于直连桩的无效,因为它根本就没有查询直联桩的补单信息!
```java
/**
* 处理反向互通挂起订单
*/
public void completeUnReportReverseOrder(EquipmentChargeOrderDO orderDO) {
try {
//从mongo上获取最后一次推送的账单数据
NotificationChargeOrderInfoReqMongoDO notificationChargeOrderInfoReqMongoDO = notificationChargeOrderInfoReqDao.findOne(orderDO.getOrderNo());
if(notificationChargeOrderInfoReqMongoDO != null) {
completeWithPushedOrder(orderDO, notificationChargeOrderInfoReqMongoDO);
return;
}
//若是没有则从mongo中获取最后一次充电中推送的数据 进行结算
ReverseOrderInfo reverseOrderInfo = reverseOrderInfoDao.findOne(orderDO.getOrderNo());
if(reverseOrderInfo != null) {
completeWithLastPushedOrder(orderDO, reverseOrderInfo);
}
} catch (Exception e) {
addOrderTrack(orderDO.getOrderNo(), orderDO.getUserId(), orderDO.getConnectorId().toString(), (byte) 3, (byte) 0, "补单失败,补单异常,异常信息");
log.error("反向订单" + orderDO.getOrderNo() + "补单异常,异常信息:", e);
}
}
```
Loading…
Cancel
Save