From 682de75a230a7c31f8b506094df0a84d0712e28c Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Wed, 24 Nov 2021 17:22:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E6=97=B6=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcHistoryOrderController.java | 138 ++++++++++-------- .../mapper/XhpcRealTimeOrderMapper.xml | 2 +- 2 files changed, 77 insertions(+), 63 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 c35fba2f..d8db4640 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 @@ -412,76 +412,90 @@ public class XhpcHistoryOrderController extends BaseController { logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); - try{ //小时统计 List list = xhpcHistoryOrderService.getStatistisList(500,0); if(list !=null && list.size()>0){ for (XhpcChargeHistoryOrder xhpc:list) { - //开始时间、结束时间、模型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(); - Long historyOrderId = xhpc.getHistoryOrderId(); - Date data = Calendar.getInstance().getTime(); - if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){ - continue; - } - if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){ - continue; - } - //每分钟多少度电 - BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,BigDecimal.ROUND_DOWN); - 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()); - xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, BigDecimal.ROUND_DOWN)); - 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.setCreateTime(data); - xhpcSt.setTerminalId(terminalId); - xhpcSt.setHistoryOrderId(historyOrderId); - if(xhpc.getSource()==1){ - xhpcSt.setInternetUserId(xhpc.getUserId()); + try{ + //开始时间、结束时间、模型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(); + Long historyOrderId = xhpc.getHistoryOrderId(); + Date data = Calendar.getInstance().getTime(); + if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){ + continue; + } + if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){ + continue; + } + //每分钟多少度电 + BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,BigDecimal.ROUND_DOWN); + 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()); + xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, BigDecimal.ROUND_DOWN)); + 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.setCreateTime(data); + xhpcSt.setTerminalId(terminalId); + xhpcSt.setHistoryOrderId(historyOrderId); + if(xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + + //时间没有跨天 +// DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd"); +// DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd"); +// long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY); +// Map map = new HashMap<>(); +// if(betweenDay==0){ +// List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId); +// map = reatTimeList.get(0); +// }else{ +// //明天 +// DateTime tomorrow = DateUtil.offsetDay(startTime,1); +// Date startTime3 =DateUtil.beginOfDay(tomorrow); +// List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime), rateModelId); +// map = reatTimeList.get(0); +// } +// xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString())); +// xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString())); + 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()); + xhpcStatisticsService.addStatisticsTime(xhpcSt); + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); + }catch (Exception e){ + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId()); } - List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId); - Map map = reatTimeList.get(0); - xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString())); - xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString())); - 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()); - xhpcStatisticsService.addStatisticsTime(xhpcSt); - //修改历史订单表状态 - xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); } } - }catch (Exception e){ - - } - } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index d7d86adc..daf24b5e 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -423,7 +423,7 @@ and co.serial_number like concat('%', #{transactionNumber}, '%') - and co.serial_number like concat('%', #{chargingStationName}, '%') + and ct.name like concat('%', #{chargingStationName}, '%') and ter.name like concat('%', #{terminalName}, '%')