From 2e1620e51fe6dad68447ae0783bc95e5dbf24804 Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 22 Jun 2022 10:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E8=AE=A1=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=85=A5=E5=BA=93=E6=9F=A5=E8=AF=A2=E6=9C=BA=E5=88=B6?= =?UTF-8?q?,=E4=BC=98=E5=8C=96=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/XhpcWorkOrderMapper.xml | 2 +- .../XhpcHistoryOrderController.java | 144 +++++++++++++++++- .../order/mapper/XhpcHistoryOrderMapper.java | 10 ++ .../service/IXhpcHistoryOrderService.java | 14 ++ .../impl/XhpcHistoryOrderServiceImpl.java | 21 +++ .../impl/XhpcRealTimeOrderServiceImpl.java | 23 ++- .../mapper/XhpcHistoryOrderMapper.xml | 89 ++++++++++- .../resources/mapper/XhpcStatisticsMapper.xml | 14 +- 8 files changed, 300 insertions(+), 17 deletions(-) diff --git a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml index d79b3a28..4b45bc74 100644 --- a/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml +++ b/xhpc-modules/xhpc-activity/src/main/resources/mapper/XhpcWorkOrderMapper.xml @@ -77,7 +77,7 @@ and o.tenant_id = #{params.tenantId} GROUP BY o.work_order_id - ORDER BY o.status ASC + ORDER BY o.status ASC,o.create_time desc diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index 55b23157..bd85f7b5 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -444,9 +444,6 @@ public class XhpcHistoryOrderController extends BaseController { } if(count==0){ //开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间 - Date startTime = xhpc.getStartTime(); - Date endTime = xhpc.getEndTime(); - Long rateModelId = xhpc.getRateModelId(); Long operatorId =xhpc.getOperatorId(); Long chargingStationId = xhpc.getChargingStationId(); Long terminalId = xhpc.getTerminalId(); @@ -462,10 +459,10 @@ public class XhpcHistoryOrderController extends BaseController { // if(v.compareTo(new BigDecimal(0)) !=1){ // continue; // } - int endHour = DateUtil.hour(endTime, true); + //没有跨时段 XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval(); - xhpcSt.setStatus(endHour+1); + xhpcSt.setChargingDegree(xhpc.getChargingDegree()); if(xhpc.getChargingTimeNumber() !=null){ xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP)); @@ -497,9 +494,15 @@ public class XhpcHistoryOrderController extends BaseController { } //时间没有跨天 xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission()); - xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss")); - xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss")); - xhpcSt.setCreateTime(xhpc.getEndTime()); + if(xhpc.getStartTime() !=null){ + xhpcSt.setStartTimeEvcs(DateUtil.format(xhpc.getStartTime(), "yyyy-MM-dd HH:mm:ss")); + } + if(xhpc.getEndTime() !=null){ + int endHour = DateUtil.hour(xhpc.getEndTime(), true); + xhpcSt.setStatus(endHour+1); + xhpcSt.setEndTimeEvcs(DateUtil.format(xhpc.getEndTime(), "yyyy-MM-dd HH:mm:ss")); + xhpcSt.setCreateTime(xhpc.getEndTime()); + } xhpcStatisticsService.addStatisticsTime(xhpcSt); //修改历史订单表状态 xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); @@ -940,6 +943,131 @@ public class XhpcHistoryOrderController extends BaseController { } } + + + //检查统计没有入库的订单 + @Scheduled(cron = "0 1 * * * ?") + @GetMapping("/getInvo") + public void getNoStatisticsOrderTime(){ + List list = xhpcHistoryOrderService.getNoStatisticsOrderTime(500); + if(list !=null && list.size()>0){ + for (XhpcChargeHistoryOrder xhpc:list) { + try{ + Long historyOrderId = xhpc.getHistoryOrderId(); + int count = xhpcStatisticsService.getStatisticsTimeHistoryOrderId(historyOrderId); + if(count>0){ + XhpcHistoryOrder historyOrder = xhpcHistoryOrderService.getHistoryOrderById(historyOrderId,null); + if(historyOrder.getState()==0){ + xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,1); + } + } + if(count==0){ + //开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间 + Long operatorId =xhpc.getOperatorId(); + Long chargingStationId = xhpc.getChargingStationId(); + Long terminalId = xhpc.getTerminalId(); + XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval(); + xhpcSt.setChargingDegree(xhpc.getChargingDegree()); + if(xhpc.getChargingTimeNumber() !=null){ + xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP)); + } + xhpcSt.setChargingNumber(1); + xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal()); + xhpcSt.setServicePrice(xhpc.getServicePriceTotal()); + xhpcSt.setTotalPrice(xhpc.getTotalPrice()); + xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount()); + xhpcSt.setActPrice(xhpc.getActPrice()); + xhpcSt.setActPowerPrice(xhpc.getActPowerPrice()); + xhpcSt.setActServicePrice(xhpc.getActServicePrice()); + xhpcSt.setInternetCommission(xhpc.getInternetCommission()); + xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission()); + xhpcSt.setPlatformCommission(xhpc.getPlatformCommission()); + xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion()); + xhpcSt.setOperationCommission(xhpc.getOperationCommission()); + xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission()); + xhpcSt.setOperatorId(operatorId); + xhpcSt.setChargingStationId(chargingStationId); + xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal()); + xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal()); + xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice()); + //xhpcSt.setCreateTime(data); + xhpcSt.setTerminalId(terminalId); + xhpcSt.setHistoryOrderId(historyOrderId); + if(xhpc.getSource()!=null && xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + //时间没有跨天 + xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission()); + if(xhpc.getStartTime() !=null){ + xhpcSt.setStartTimeEvcs(DateUtil.format(xhpc.getStartTime(), "yyyy-MM-dd HH:mm:ss")); + } + if(xhpc.getEndTime() !=null){ + int endHour = DateUtil.hour(xhpc.getEndTime(), true); + xhpcSt.setStatus(endHour+1); + xhpcSt.setEndTimeEvcs(DateUtil.format(xhpc.getEndTime(), "yyyy-MM-dd HH:mm:ss")); + xhpcSt.setCreateTime(xhpc.getEndTime()); + } + xhpcStatisticsService.addStatisticsTime(xhpcSt); + } + }catch (Exception e){ + e.printStackTrace(); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId()); + } + } + } + + List listOrder = xhpcHistoryOrderService.getNoStatisticsOrder(500); + if(listOrder !=null && listOrder.size()>0){ + for (XhpcChargeHistoryOrder xhpc:listOrder) { + Long historyOrderId = xhpc.getHistoryOrderId(); + for (int i = 1; i <4 ; i++) { + //查询统计表是否有已添加的数据 + int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i); + if(count==0){ + XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); + xhpcSt.setChargingDegree(xhpc.getChargingDegree()); + if(xhpc.getChargingTimeNumber() !=null){ + xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP)); + } + xhpcSt.setChargingNumber(1); + xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal()); + xhpcSt.setServicePrice(xhpc.getServicePriceTotal()); + xhpcSt.setTotalPrice(xhpc.getTotalPrice()); + xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount()); + xhpcSt.setActPrice(xhpc.getActPrice()); + xhpcSt.setInternetCommission(xhpc.getInternetCommission()); + xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission()); + xhpcSt.setPlatformCommission(xhpc.getPlatformCommission()); + xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion()); + xhpcSt.setOperationCommission(xhpc.getOperationCommission()); + xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission()); + xhpcSt.setActPowerPrice(xhpc.getActPowerPrice()); + xhpcSt.setActServicePrice(xhpc.getActServicePrice()); + if(xhpc.getSource()!=null && xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + xhpcSt.setOperatorId(xhpc.getOperatorId()); + xhpcSt.setChargingStationId(xhpc.getChargingStationId()); + //xhpcSt.setCreateTime(Calendar.getInstance().getTime()); + xhpcSt.setTerminalId(xhpc.getTerminalId()); + xhpcSt.setChargingMode(xhpc.getChargingMode()); + xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal()); + xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal()); + xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice()); + xhpcSt.setHistoryOrderId(historyOrderId); + xhpcSt.setChargingPileId(xhpc.getChargingPileId()); + xhpcSt.setCreateTime(xhpc.getEndTime()); + xhpcSt.setSource(xhpc.getSource()); + xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission()); + xhpcSt.setType(i); + xhpcStatisticsService.addStatisticsStation(xhpcSt); + } + } + } + } + } + + public void add(int number,int type){ //获取500条待统计历史订单 List list = xhpcHistoryOrderService.getStatistisList(number,type); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index e2339228..d5474dfc 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -102,6 +102,16 @@ public interface XhpcHistoryOrderMapper { */ List getStatistisList(@Param("number")int number,@Param("state")int state); + + /** + * 获取为统计的历史订单 + * @param number + * @return + */ + List getNoStatisticsOrderTime(@Param("number")int number); + + List getNoStatisticsOrder(@Param("number")int number); + XhpcHistoryOrder getHistoryOrderById(@Param("historyOrderId")Long historyOrderId,@Param("serialNumber")String serialNumber); /** * 更新历史订单 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index 890e23fd..d859477c 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -93,6 +93,20 @@ public interface IXhpcHistoryOrderService { List getStatistisList(int number,int state); + + /** + * 获取为统计的历史订单 + * @param number + * @return + */ + List getNoStatisticsOrderTime(int number); + + /** + * 获取为统计的历史订单 + * @param number + * @return + */ + List getNoStatisticsOrder(int number); /** * 更新历史订单 * 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 bf2cc1cb..d4de4379 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 @@ -457,6 +457,27 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis return xhpcHistoryOrderMapper.getStatistisList(number, state); } + /** + * 获取为统计的历史订单 + * + * @param number + * @return + */ + @Override + public List getNoStatisticsOrderTime(int number) { + return xhpcHistoryOrderMapper.getNoStatisticsOrderTime(number); + } + /** + * 获取为统计的历史订单 + * + * @param number + * @return + */ + @Override + public List getNoStatisticsOrder(int number) { + return xhpcHistoryOrderMapper.getNoStatisticsOrder(number); + } + @Override public void updateXhpcHistoryOrder(Long historyOrderId, Integer state) { 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 b59a0d1f..5340f639 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 @@ -535,6 +535,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe String internetSerialNumber = xhpcChargeOrder.getInternetSerialNumber(); Long chargingStationId = xhpcChargeOrder.getChargingStationId(); String tenantId = xhpcChargeOrder.getTenantId(); + int computeType =0; //判断是否有活动 logger.info("<<<<<<<<<<<<<<<判断是否有活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber()); boolean judge =false; @@ -554,7 +555,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe params1.put("S",servicePrice.doubleValue()); params1.put("E",totalPower); String computeFormula = judgeActivity.get("computeFormula").toString(); - int computeType = (int)judgeActivity.get("computeType"); + computeType = (int)judgeActivity.get("computeType"); BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params1)).setScale(2, BigDecimal.ROUND_HALF_UP); //活动总服务费 activityServicePriceTotal = servicePrice.setScale(2, BigDecimal.ROUND_HALF_UP); @@ -597,7 +598,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe params1.put("S",activityServicePriceTotal.doubleValue()); params1.put("E",totalPower); - int computeType = (int)judgeActivity.get("computeType"); + computeType = (int)judgeActivity.get("computeType"); BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params1)).setScale(2, BigDecimal.ROUND_HALF_UP); if(computeType==1){ BigDecimal decimal1 = eval.multiply(new BigDecimal(0.5)).setScale(2, BigDecimal.ROUND_HALF_UP); @@ -655,7 +656,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe for (int j = 0; j < activityFormulaTime1.size(); j++) { XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime1.get(j); //计费类型 - int computeType = activityInternet1.getComputeType(); + computeType = activityInternet1.getComputeType(); BigDecimal activityServicePriceFormula = activityFormula.getServicePrice(); BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice(); //计算公式 @@ -703,7 +704,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe if(activityFormulaTime2.size()>0){ for (int j = 0; j < activityFormulaTime2.size(); j++) { //计费类型 - int computeType = activityInternet1.getComputeType(); + computeType = activityInternet1.getComputeType(); XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime2.get(j); BigDecimal activityServicePriceFormula = activityFormula.getServicePrice(); BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice(); @@ -1072,6 +1073,20 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe xhpcHistoryOrder.setReconciliationStatus(0); xhpcHistoryOrder.setSortingStatus(0); if(judge){ + if(UserTypeUtil.INTERNET_TYPE.equals(source)){ + //computeType + BigDecimal totalMoney = actPrice.add(promotionDiscount).add(internetCommission).add(internetSvcCommission).add(internetDegreeCommission).add(platformCommission).add(platformSvcCommission).add(operationCommission).add(operationSvcCommission).setScale(2, BigDecimal.ROUND_HALF_UP); + if(money.compareTo(totalMoney)==1){ + BigDecimal remainMoney = money.subtract(totalMoney); + if(computeType==1){ + internetCommission = internetCommission.add(remainMoney); + }else if(computeType==2){ + internetSvcCommission = internetSvcCommission.add(remainMoney); + }else{ + internetDegreeCommission = internetDegreeCommission.add(remainMoney); + } + } + } xhpcHistoryOrder.setActivityTotalPrice(activityTotalPriceTotal.setScale(2, BigDecimal.ROUND_HALF_UP)); xhpcHistoryOrder.setActivityPowerPriceTotal(activityPowerPriceTotal.setScale(2, BigDecimal.ROUND_HALF_UP)); xhpcHistoryOrder.setActivityServicePriceTotal(activityServicePriceTotal.setScale(2, BigDecimal.ROUND_HALF_UP)); 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 93b893c7..a3dfc3ef 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -950,10 +950,97 @@ left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id left join xhpc_terminal as te on te.terminal_id = ho.terminal_id - where ho.state = #{state} and ho.total_price is not null + where ho.state = #{state} and ho.total_price is not null limit 0,#{number} + + + update xhpc_history_order set state = #{state} where history_order_id=#{historyOrderId} diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index c0dca6d6..4529be56 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -120,6 +120,7 @@ and operator_id =#{operatorId} + and operator_id is not null group by status order by status @@ -183,6 +184,7 @@ and operator_id =#{operatorId} + and operator_id is not null group by DATE_FORMAT(create_time,'%Y-%m-%d') order by DATE_FORMAT(create_time,'%Y-%m-%d') desc @@ -257,6 +259,7 @@ and ss.tenant_id = #{tenantId} + and ss.operator_id is not null group by ss.charging_station_id @@ -319,8 +322,9 @@ and ss.tenant_id = #{tenantId} - and operator_id =#{operatorId} + and ss.operator_id =#{operatorId} + and ss.operator_id is not null group by ss.operator_id @@ -370,8 +374,9 @@ and ss.tenant_id = #{tenantId} - and operator_id =#{operatorId} + and ss.operator_id =#{operatorId} + and ss.operator_id is not null group by ss.internet_user_id @@ -427,8 +432,9 @@ and ss.tenant_id = #{tenantId} - and operator_id =#{operatorId} + and ss.operator_id =#{operatorId} + and ss.operator_id is not null group by ss.terminal_id @@ -623,6 +629,7 @@ and tenant_id = #{tenantId} + and operator_id is not null group by source @@ -1118,6 +1125,7 @@ and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{sysUserId}) + and ss.operator_id is not null and ss.charging_mode is not null group by ss.charging_mode