From d59212d23b732d9fb5ddc254d08df45e73aa6f80 Mon Sep 17 00:00:00 2001 From: yuyang Date: Tue, 12 Jul 2022 09:59:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcHistoryOrderController.java | 192 +++++++++--------- .../order/mapper/XhpcHistoryOrderMapper.java | 2 + .../service/IXhpcHistoryOrderService.java | 9 +- .../impl/XhpcHistoryOrderServiceImpl.java | 12 ++ .../impl/XhpcRealTimeOrderServiceImpl.java | 2 +- .../mapper/XhpcHistoryOrderMapper.xml | 50 ++++- .../service/impl/XhpcInvoiceServiceImpl.java | 2 +- 7 files changed, 171 insertions(+), 98 deletions(-) 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 bd85f7b5..f5edf145 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 @@ -945,22 +945,16 @@ public class XhpcHistoryOrderController extends BaseController { - //检查统计没有入库的订单 - @Scheduled(cron = "0 1 * * * ?") - @GetMapping("/getInvo") + //检查统计没有入库的订单(小时) + @Scheduled(cron = "0 5 * * * ?") + @GetMapping("/getInvoTime") public void getNoStatisticsOrderTime(){ - List list = xhpcHistoryOrderService.getNoStatisticsOrderTime(500); + List list = xhpcHistoryOrderService.getNoStatisticsOrderTime(3000); 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(); @@ -1015,53 +1009,62 @@ public class XhpcHistoryOrderController extends BaseController { } } } - - List listOrder = xhpcHistoryOrderService.getNoStatisticsOrder(500); + } + //检查统计没有入库的订单(日期、电站) + @Scheduled(cron = "0 30 * * * ?") + @GetMapping("/getInvoDay") + public void getInvoDay(){ + List listOrder = xhpcHistoryOrderService.getNoStatisticsOrderDay(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)); + try{ + 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); } - 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); } + }catch (Exception e){ + e.printStackTrace(); + logger.info(">>>>>>>>>>>>>>>>>>>>>>日期电站统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId()); } } } @@ -1075,49 +1078,54 @@ public class XhpcHistoryOrderController extends BaseController { if(list !=null && list.size()>0){ for (XhpcChargeHistoryOrder xhpc:list) { Long historyOrderId = xhpc.getHistoryOrderId(); + try{ for (int i = type; 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)); + //查询统计表是否有已添加的数据 + 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), 4, 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); } - 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); } + }catch (Exception e){ + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId()); } //修改历史订单表状态 xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,type+1); 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 d5474dfc..095ccabc 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 @@ -110,6 +110,8 @@ public interface XhpcHistoryOrderMapper { */ List getNoStatisticsOrderTime(@Param("number")int number); + List getNoStatisticsOrderDay(@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 d859477c..0608d7f7 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 @@ -95,12 +95,19 @@ public interface IXhpcHistoryOrderService { /** - * 获取为统计的历史订单 + * 获取为统计的历史订单(时段) * @param number * @return */ List getNoStatisticsOrderTime(int number); + /** + * 获取为统计的历史订单(日期、电站) + * @param number + * @return + */ + List getNoStatisticsOrderDay(int number); + /** * 获取为统计的历史订单 * @param 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 a105c7f7..a6a617f7 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 @@ -467,6 +467,18 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis public List getNoStatisticsOrderTime(int number) { return xhpcHistoryOrderMapper.getNoStatisticsOrderTime(number); } + + /** + * 获取为统计的历史订单(日期、电站) + * + * @param number + * @return + */ + @Override + public List getNoStatisticsOrderDay(int number) { + return xhpcHistoryOrderMapper.getNoStatisticsOrderDay(number); + } + /** * 获取为统计的历史订单 * 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 f24fee51..84ad97bf 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 @@ -469,7 +469,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe xhpcHistoryOrder.setStatus(0); xhpcHistoryOrder.setDelFlag(0); addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder); - + logger.info("======================异常订单结算===================="+xhpcChargeOrder.getSerialNumber()); return AjaxResult.success(); } 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 c0467ec3..49ce589c 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -935,7 +935,7 @@ ho.start_time as startTime, ho.end_time as endTime, co.charging_time_number as chargingTimeNumber, - co.charging_degree as chargingDegree, + ho.total_power as chargingDegree, co.rate_model_id as rateModelId, cs.operator_id as operatorId, te.charging_pile_id as chargingPileId, @@ -993,8 +993,52 @@ 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.history_order_id not in (select history_order_id from xhpc_statistics_station where type =2 ) - and ho.total_price is not null and now() >DATE_ADD(ho.end_time,interval 6 hour) + where ho.history_order_id not in (select history_order_id from xhpc_statistics_time_interval where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= create_time) + and ho.total_price is not null and DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= ho.end_time and now() >DATE_ADD(ho.end_time,interval 6 hour) + limit 0,#{number} + + + diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java index cef2f9c4..3b6ebbd0 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcInvoiceServiceImpl.java @@ -618,7 +618,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService { xhpcInvoiceMapHistoryOrderMapper.insertSelective(xhpcInvoiceMapHistoryOrder); totalPowerPrice += xhpcHistoryOrder.getPowerPriceTotal().doubleValue(); totalServicePrice += (xhpcHistoryOrder.getServicePriceTotal().doubleValue() - xhpcHistoryOrder.getPromotionDiscount().doubleValue()); - totalActPrice += xhpcHistoryOrder.getTotalPrice().doubleValue(); + totalActPrice += xhpcHistoryOrder.getActPrice().doubleValue(); } BigDecimal bigDecimal = saveInvoiceInfoRequest.getInvoiceMoney().setScale(2, BigDecimal.ROUND_HALF_UP);