From b1c6171beabc1d0f916a3add396a1762d0f925fd Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Wed, 10 Nov 2021 10:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E9=A6=96=E9=A1=B5=E6=A1=A9=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XhpcChargingStationServiceImpl.java | 23 +- .../order/api/XhpcPileOrderController.java | 2 +- .../XhpcHistoryOrderController.java | 251 +++++++++++------- .../order/mapper/XhpcChargeOrderMapper.java | 5 + .../service/IXhpcChargeOrderService.java | 7 +- .../impl/XhpcChargeOrderServiceImpl.java | 5 + .../impl/XhpcHistoryOrderServiceImpl.java | 24 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 20 +- .../mapper/XhpcChargeOrderMapper.xml | 1 + .../mapper/XhpcHistoryOrderMapper.xml | 17 +- .../resources/mapper/XhpcStatisticsMapper.xml | 2 - .../service/impl/XhpcAppUserServiceImpl.java | 2 + .../src/main/resources/bootstrap.yml | 4 +- 13 files changed, 228 insertions(+), 135 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 88eb24e8..11ca509d 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -555,6 +555,14 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi Map map = xhpcChargingStationMapper.getXhpcChargingStationMessage(chargingStationId); + if(map !=null&& map.get("stationType") !=null){ + map.put("stationType",map.get("stationType").toString()); + } + + if(map !=null&& map.get("constructionSite") !=null){ + map.put("constructionSite",map.get("constructionSite").toString()); + } + //图片信息 List imgList = new ArrayList<>(); if (map !=null &&map.get("imgId") != null && map.get("imgId").toString() != "") { @@ -618,8 +626,10 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi for (int i = 0; i < list.size(); i++) { Map map = list.get(i); //桩(空闲和使用从redis获取) - if(map.get("serialNumbers") !=null){ - map.put("free", countTerminal(map.get("serialNumbers").toString())); + Map map1 =new HashMap<>(); + map1 = getTerminalStatusSum(map1, Long.valueOf(map.get("chargingStationId").toString()), 0); + if(map1 !=null && map1.get("free") !=null){ + map.put("free", map1.get("freeTime").toString()); }else{ map.put("free", 0); } @@ -638,8 +648,11 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi Map map = xhpcChargingStationMapper.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude); //桩(空闲和使用从redis获取) - if(map.get("serialNumbers") !=null){ - map.put("free", countTerminal(map.get("serialNumbers").toString())); + + Map map1 =new HashMap<>(); + map1 = getTerminalStatusSum(map1, chargingStationId, 0); + if(map1 !=null && map1.get("free") !=null){ + map.put("free", map1.get("freeTime").toString()); }else{ map.put("free", 0); } @@ -1105,7 +1118,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi //终端状态用 redis数据 if(!"".equals(serialNumber) && serialNumber!=null){ Map cacheMap =redisService.getCacheMap("gun:"+serialNumber); - if(!cacheMap.isEmpty()){ + if(cacheMap !=null && cacheMap.get("status") !=null){ if ("离线".equals(cacheMap.get("status").toString())){ status =0; }else if("故障".equals(cacheMap.get("status").toString())){ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java index 4bfd7e18..5ba8133a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java @@ -377,7 +377,7 @@ public class XhpcPileOrderController extends BaseController { public R abnormalOrder(@RequestParam(value = "orderNo") String orderNo) { xhpcHistoryOrderService.addXhpcChargeOrder(orderNo,1); //获取实时订单 - XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo); + XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo); Long userId = xhpcChargeOrder.getUserId(); Map map = new HashMap<>(); map.put("code", 500); 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 3dd85fbb..47f114e1 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 @@ -15,6 +15,8 @@ import com.xhpc.order.service.IXhpcChargeOrderService; import com.xhpc.order.service.IXhpcHistoryOrderService; import com.xhpc.order.service.IXhpcStatisticsService; import io.swagger.annotations.Api; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; @@ -46,6 +48,9 @@ public class XhpcHistoryOrderController extends BaseController { @Autowired private IXhpcChargeOrderService chargeOrderService; + + private static final Logger logger = LoggerFactory.getLogger(XhpcHistoryOrderController.class); + /** * 历史订单 * @param phone 用户账号 @@ -84,7 +89,7 @@ public class XhpcHistoryOrderController extends BaseController { @GetMapping("/test3") @Scheduled(cron = "0 0 12 * * ?") public void test3(){ - add(100,3); + add(1000,3); } /** * 场站统计 @@ -92,7 +97,7 @@ public class XhpcHistoryOrderController extends BaseController { @GetMapping("/test2") @Scheduled(cron = "0 0 11 * * ?") public void test2(){ - add(100,2); + add(1000,2); } /** @@ -105,7 +110,7 @@ public class XhpcHistoryOrderController extends BaseController { //跨时段,跨费率,计费模型 //日期统计 int type =1; - List list = xhpcHistoryOrderService.getStatistisList(100,type); + List list = xhpcHistoryOrderService.getStatistisList(1000,type); //是否跨天 if(list !=null && list.size()>0){ for (XhpcChargeHistoryOrder xhpc:list) { @@ -117,9 +122,18 @@ public class XhpcHistoryOrderController extends BaseController { DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd"); long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY); - BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP); - //每分钟多少度点 - BigDecimal divide = xhpc.getChargingDegree().divide(decimal, 2, RoundingMode.HALF_UP); + if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){ + continue; + } + if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){ + continue; + } + //每分钟多少度电 + BigDecimal decimal = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP); + if(decimal.compareTo(new BigDecimal(0)) !=1){ + continue; + } + BigDecimal divide = xhpc.getChargingDegree().divide(decimal,2,RoundingMode.HALF_UP); if(betweenDay==0){ XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); @@ -150,6 +164,9 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setType(type); xhpcStatisticsService.addStatisticsStation(xhpcSt); + + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1); }else{ //跨天 BigDecimal dec = new BigDecimal(DateUtil.between(startTime, DateUtil.endOfDay(startTime), DateUnit.MINUTE)/ 60).setScale(2, RoundingMode.HALF_UP); @@ -163,8 +180,6 @@ public class XhpcHistoryOrderController extends BaseController { addStation(xhpc, tim,type, DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime),divide); } - //修改历史订单表状态 - xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1); } } } @@ -175,103 +190,113 @@ public class XhpcHistoryOrderController extends BaseController { @GetMapping("/test") @Scheduled(cron = "0 */1 * * * ?") public void test(){ + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); //获取500条待统计历史订单 //跨时段,跨费率,计费模型 - //小时统计 - List list = xhpcHistoryOrderService.getStatistisList(50,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){ - break; - } - if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){ - break; - } - //每分钟多少度电 - BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP); - if(v.compareTo(new BigDecimal(0)) !=1){ - break; - } - BigDecimal multiply = xhpc.getChargingDegree().divide(v,2,RoundingMode.HALF_UP); - - //1时间没有跨天 - 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); - if(betweenDay==0){ - //没有跨天 - //是否跨时段 - int startHour = DateUtil.hour(startTime, true); - int endHour = DateUtil.hour(endTime, true); - if(endHour==startHour){ - //没有跨时段 - XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval(); - xhpcSt.setStatus(endHour+1); - xhpcSt.setChargingDegree(xhpc.getChargingDegree()); - xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, RoundingMode.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.setCreateTime(data); - xhpcSt.setTerminalId(terminalId); - xhpcSt.setHistoryOrderId(historyOrderId); - if(xhpc.getSource()==1){ - xhpcSt.setInternetUserId(xhpc.getUserId()); - } - 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")); - xhpcStatisticsService.addStatisticsTime(xhpcSt); - }else { - //跨时段 - //总共时段 endHour+1-startHour - String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd"); - addStatisTime(xhpc, startTime, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply); + try{ + //小时统计 + List list = xhpcHistoryOrderService.getStatistisList(50,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; } - }else{ - //跨天 - Date updateTime2= DateUtil.parse(parse+" 23:59:59"); - int startHour = DateUtil.hour(startTime, true); - int endHour = DateUtil.hour(updateTime2, true); - String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd"); - addInterval(xhpc, startTime, updateTime2, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply); - //明天 - DateTime tomorrow = DateUtil.offsetDay(startTime,1); - Date startTime3 =DateUtil.beginOfDay(tomorrow); - int startHour1 = DateUtil.hour(startTime3, true); - int endHour1 = DateUtil.hour(endTime, true); - String yyyyMMdd1 = DateUtil.format(startTime3, "yyyy-MM-dd"); - addInterval(xhpc, startTime3, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour1, endHour1,yyyyMMdd1,multiply); + if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){ + continue; + } + //每分钟多少度电 + BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP); + if(v.compareTo(new BigDecimal(0)) !=1){ + continue; + } + BigDecimal multiply = xhpc.getChargingDegree().divide(v,2,RoundingMode.HALF_UP); + + //1时间没有跨天 + 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); + if(betweenDay==0){ + //没有跨天 + //是否跨时段 + int startHour = DateUtil.hour(startTime, true); + int endHour = DateUtil.hour(endTime, true); + if(endHour==startHour){ + //没有跨时段 + XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval(); + xhpcSt.setStatus(endHour+1); + xhpcSt.setChargingDegree(xhpc.getChargingDegree()); + xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, RoundingMode.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.setCreateTime(data); + xhpcSt.setTerminalId(terminalId); + xhpcSt.setHistoryOrderId(historyOrderId); + if(xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + 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")); + xhpcStatisticsService.addStatisticsTime(xhpcSt); + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); + + }else { + //跨时段 + //总共时段 endHour+1-startHour + String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd"); + addStatisTime(xhpc, startTime, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply); + } + }else{ + //跨天 + Date updateTime2= DateUtil.endOfDay(startTime); + int startHour = DateUtil.hour(startTime, true); + int endHour = DateUtil.hour(updateTime2, true); + String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd"); + addInterval(xhpc, startTime, updateTime2, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply); + //明天 + DateTime tomorrow = DateUtil.offsetDay(startTime,1); + Date startTime3 =DateUtil.beginOfDay(tomorrow); + int startHour1 = DateUtil.hour(startTime3, true); + int endHour1 = DateUtil.hour(endTime, true); + String yyyyMMdd1 = DateUtil.format(startTime3, "yyyy-MM-dd"); + addInterval(xhpc, startTime3, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour1, endHour1,yyyyMMdd1,multiply); + } + } - //修改状态 - //修改历史订单表状态 - xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); } + }catch (Exception e){ + e.printStackTrace(); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"); + logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>"); } } @@ -293,6 +318,23 @@ public class XhpcHistoryOrderController extends BaseController { } } + /** + * 标记异常大于创建4小时,标记为异常 + * @param + * @param + */ + @GetMapping("/test5") + @Scheduled(cron = "0 0/5 * * * ?") + public void test5(){ + logger.info(">>>>>>>>>>>>>>>>>>>>>>>标记异常大于创建4小时,标记为异常>>>>>>>>>>>>>>>>>>>>>"); + chargeOrderService.updateStatus(); + } + + + + + + public void add(int number,int type){ //获取500条待统计历史订单 @@ -392,6 +434,9 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setType(type); xhpcStatisticsService.addStatisticsStation(xhpcSt); + + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1); } private void addStatisTime(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour,String yyyyMMdd,BigDecimal multiply) { @@ -448,6 +493,9 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss")); xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss")); xhpcStatisticsService.addStatisticsTime(xhpcSt); + //修改状态 + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); }else{ //跨时段 //总共时段 endHour+1-startHour @@ -550,6 +598,9 @@ public class XhpcHistoryOrderController extends BaseController { } xhpcStatisticsService.addStatisticsTime(xhpcSt); + //修改状态 + //修改历史订单表状态 + xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); } public static void main(String[] args) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index c213d7d1..b1d541de 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -177,4 +177,9 @@ public interface XhpcChargeOrderMapper { @Param(value = "chargingAmt") Integer chargingAmt, @Param(value = "plateNum") String plateNum, @Param(value = "status") Integer status); + + /** + * 标记异常大于创建4小时,标记为异常 + */ + void updateStatus(); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 0dcbb4ac..3bd77fdc 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -154,4 +154,9 @@ public interface IXhpcChargeOrderService { List getXhpcChargeOrderStatus(Integer status,Integer source); R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId); -} + + /** + * 标记异常大于创建4小时,标记为异常 + */ + void updateStatus(); +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index 3c1b26d9..09ed4732 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -488,6 +488,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { } + @Override + public void updateStatus() { + + } + public static boolean isValidDate(String str) { try { if (0 != str.length()) { 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 7d06f605..a0a8751d 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 @@ -87,11 +87,16 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { @Override public AjaxResult getById(Long historyOrderId) { - Map byId = xhpcHistoryOrderMapper.getById(historyOrderId); - if(byId !=null){ - byId.putAll(getRateTime(byId.get("serialNumber").toString(),byId.get("actPrice").toString())); + try{ + Map byId = xhpcHistoryOrderMapper.getById(historyOrderId); + if(byId !=null){ + byId.putAll(getRateTime(byId.get("serialNumber").toString(),byId.get("actPrice").toString())); + } + return AjaxResult.success(byId); + }catch (Exception e){ + } - return AjaxResult.success(byId); + return AjaxResult.success(); } @Override @@ -173,8 +178,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { powerPrice=getBigDecimal(rateModelId,startTime2,updateTime2,xhpcChargeOrder.getChargingDegree()); }else{ //跨天 - String startTime = DateUtil.format(startTime2, "yyyy-MM-dd"); - Date updateTime = DateUtil.parse(startTime+" 23:59:59"); + Date updateTime = DateUtil.endOfDay(startTime2); powerPrice=getBigDecimal(rateModelId,startTime2,updateTime,xhpcChargeOrder.getChargingDegree()); //明天 DateTime tomorrow = DateUtil.offsetDay(startTime2,1); @@ -435,11 +439,9 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { return getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime2, chargingDegree, list); }else{ //跨天 - String startTime = DateUtil.format(startTime2, "yyyy-MM-dd"); - Date updateTime = DateUtil.parse(startTime+" 23:59:59"); + Date updateTime = DateUtil.endOfDay(startTime2); Map map1 = getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list); //获取 - List> list1 = (List>)map1.get("list"); BigDecimal powerPriceTotal1 =(BigDecimal)map1.get("powerPriceTotal"); BigDecimal servicePriceTotal1 =(BigDecimal)map1.get("servicePriceTotal"); //明天 @@ -465,9 +467,9 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { int size = reatTimeList.size(); if(size==1){ BigDecimal powerFee = new BigDecimal(reatTimeList.get(0).get("powerFee").toString()).setScale(2, BigDecimal.ROUND_DOWN); - powerPriceTotal = powerFee.multiply(degree).setScale(2, BigDecimal.ROUND_DOWN); + //powerPriceTotal = powerFee.multiply(degree).setScale(2, BigDecimal.ROUND_DOWN); BigDecimal servicePrice = new BigDecimal(reatTimeList.get(0).get("serviceFee").toString()).setScale(2, BigDecimal.ROUND_DOWN); - servicePriceTotal=servicePrice.multiply(chargingDegree).setScale(2, BigDecimal.ROUND_DOWN); + //servicePriceTotal=servicePrice.multiply(chargingDegree).setScale(2, BigDecimal.ROUND_DOWN); map1.put("time",startTime+"-"+endTime); map1.put("powerPrice",powerFee); map1.put("servicePrice",servicePrice); 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 ea528a86..53c4ae59 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 @@ -138,13 +138,11 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { powerPriceTotal = getBigDecimal(rateModelId, startTime2, updateTime2, chargingDegree, powerPriceTotal); }else{ //跨天 - String startTime = DateUtil.format(startTime2, "yyyy-MM-dd"); - Date updateTime = DateUtil.parse(startTime+" 23:59:59"); + Date updateTime = DateUtil.endOfDay(startTime2); powerPriceTotal = getBigDecimal(rateModelId, startTime2, updateTime, chargingDegree, powerPriceTotal); //明天 DateTime tomorrow = DateUtil.offsetDay(startTime2,1); - String startTime1 = DateUtil.format(tomorrow, "yyyy-MM-dd"); - Date startTime3 = DateUtil.parse(startTime1+" 00:00:00"); + Date startTime3 = DateUtil.beginOfDay(tomorrow); powerPriceTotal = getBigDecimal(rateModelId, startTime3, updateTime2, chargingDegree, powerPriceTotal); } //算服务费和电费 @@ -188,6 +186,8 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { } //生成一条历史订单 XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder(); + + addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder); return AjaxResult.success(); @@ -425,12 +425,12 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); } // 另起线程处理业务上传redis数据 - executorService.execute(new Runnable() { - @Override - public void run() { - addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); - } - }); +// executorService.execute(new Runnable() { +// @Override +// public void run() { +// addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); +// } +// }); } xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index d8ef8544..a3b94da4 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -512,4 +512,5 @@ #{status},1) + 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 a466308e..6d471144 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -600,6 +600,7 @@ co.end_time as endTime, co.update_time as updateTime, co.source as source, + dispute_order_status as disputeOrderStatus, (SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone, (SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone from xhpc_history_order as ho @@ -608,6 +609,7 @@ left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id + left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2 where ho.status =0 and ho.del_flag=0 and ho.type=#{type} @@ -706,6 +708,14 @@ ho.operation_svc_commission as operationSvcCommission, ho.act_power_price as actPowerPrice, ho.act_service_price as actServicePrice, + ed.total_power as sanTotalPower, + ed.total_money as sanTotalMoney, + case when ed.dispute_reason=1 then "交易不存在" + when ed.dispute_reason=2 then "交易金额错误" + when ed.dispute_reason=3 then "交易电量错误" + else "自定义!" + end sanDisputeReason, + ed.check_order_seq as sanCheckOrderSeq, (SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone, (SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone, case when ho.stop_reason_evcs=40 then "APP远程停止" @@ -726,6 +736,7 @@ left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id + left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2 where ho.history_order_id=#{historyOrderId} @@ -749,8 +760,8 @@ co.charge_order_id as chargeOrderId, co.charging_station_id as chargingStationId, co.terminal_id as terminalId, - co.start_time as startTime, - co.end_time as endTime, + ho.start_time as startTime, + ho.end_time as endTime, co.charging_time_number as chargingTimeNumber, co.charging_degree as chargingDegree, co.rate_model_id as rateModelId, @@ -761,7 +772,7 @@ 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 state = #{state} + where ho.state = #{state} and ho.total_price >0 and ho.end_time > ho.start_time limit 0,#{number} 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 ce9b43c9..4c1a8d99 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -726,6 +726,4 @@ - - diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index a00f39d9..fb919528 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -130,11 +130,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { if (StringUtils.isEmpty(info.getWeixinOpenId())) { info.setWeixinOpenId(openid); + info.setWeixinLogin(1); xhpcAppUserMapper.update(info); } } else { if (StringUtils.isEmpty(info.getAlipayOpenId())) { info.setAlipayOpenId(openid); + info.setAlipayLogin(1); xhpcAppUserMapper.update(info); } } diff --git a/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml b/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml index 35c8095c..c6ad3564 100644 --- a/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml +++ b/xhpc-modules/xhpc-wxma/src/main/resources/bootstrap.yml @@ -16,10 +16,10 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8848 config: # 配置中心地址 - server-addr: 127.0.0.1:8848 + server-addr: 172.31.183.135:8848 # 配置文件格式 file-extension: yml # 共享配置