From 6eaebea3737e8db387a455f7fce824a12c64e6bc Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Thu, 18 Nov 2021 11:21:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=8F=8A=E6=B3=A8=E5=86=8C=EF=BC=8C=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=A1=A9=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IXhpcChargingStationService.java | 2 +- .../service/XhpcChargingPileServiceImpl.java | 2 +- .../XhpcChargingStationServiceImpl.java | 79 ++++++----- .../service/XhpcTerminalServiceImpl.java | 4 +- .../resources/mapper/XhpcTerminalMapper.xml | 2 +- .../order/api/XhpcPileOrderController.java | 7 +- .../XhpcHistoryOrderController.java | 134 +++++++++++++++--- .../impl/XhpcChargeOrderServiceImpl.java | 7 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 31 ++-- .../mapper/XhpcChargeOrderMapper.xml | 6 +- .../resources/mapper/XhpcStatisticsMapper.xml | 48 ++++--- .../service/impl/XhpcAppUserServiceImpl.java | 19 ++- 12 files changed, 243 insertions(+), 98 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java index 2cc52243..9f96bbff 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java @@ -196,7 +196,7 @@ public interface IXhpcChargingStationService { * @param serialNumber * @return */ - Integer getTerminalStatus(String serialNumber); + int getTerminalStatus(String serialNumber); /** * 通过id查找对应的场站 diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index b35c3022..f04dc550 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -180,7 +180,7 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { if(list !=null && list.size()>0){ for (int i = 0; i < list.size(); i++) { Map listMap =list.get(i); - Integer pileSerialNumber = xhpcChargingStationService.getTerminalStatus(listMap.get("serialNumber").toString()); + int pileSerialNumber = xhpcChargingStationService.getTerminalStatus(listMap.get("serialNumber").toString()); listMap.put("workStatus",pileSerialNumber); } } 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 aa9f039c..99dcc1bc 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 @@ -369,21 +369,28 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi XhpcRateDto xhpcRateDto = xhpcRateList.get(k); XhpcRate xhpcRate = new XhpcRate(); xhpcRate.setChargingStationId(chargingStationId); - if ("00".equals(xhpcRateDto.getId())) { - xhpcRate.setName("尖费率"); - } else if ("01".equals(xhpcRateDto.getId())) { - xhpcRate.setName("峰费率"); - } else if ("02".equals(xhpcRateDto.getId())) { - xhpcRate.setName("平费率"); - } else { - xhpcRate.setName("谷费率"); + + if ("00".equals(xhpcRateDto.getId()) || "01".equals(xhpcRateDto.getId()) || "02".equals(xhpcRateDto.getId()) || "03".equals(xhpcRateDto.getId())) { + + if ("00".equals(xhpcRateDto.getId())) { + xhpcRate.setName("尖费率"); + } else if ("01".equals(xhpcRateDto.getId())) { + xhpcRate.setName("峰费率"); + } else if ("02".equals(xhpcRateDto.getId())) { + xhpcRate.setName("平费率"); + } else { + xhpcRate.setName("谷费率"); + } + xhpcRate.setPowerFee(xhpcRateDto.getPowerFee()); + xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); + xhpcRate.setRateModelId(rateModelId); + xhpcRate.setRateValue(xhpcRateDto.getId()); + xhpcChargingStationMapper.addXhpcRate(xhpcRate); + map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); + }else{ + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return AjaxResult.error("添加费率错误,请稍后在试"); } - xhpcRate.setPowerFee(xhpcRateDto.getPowerFee()); - xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); - xhpcRate.setRateModelId(rateModelId); - xhpcRate.setRateValue(xhpcRateDto.getId()); - xhpcChargingStationMapper.addXhpcRate(xhpcRate); - map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); } //添加费率时段 @@ -826,7 +833,6 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi } } } - //添加费率计费模型 XhpcRateModel xhpcRateModel = new XhpcRateModel(); BeanUtils.copyProperties(xhpcChargingStationDto, xhpcRateModel); @@ -853,15 +859,20 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi for (int k = 0; k < xhpcRateList.size(); k++) { //存费率信息,并存储Map,费率时段使用,找到费率id XhpcRateDto xhpcRateDto = xhpcRateList.get(k); - XhpcRate xhpcRate = new XhpcRate(); - xhpcRate.setChargingStationId(chargingStationId); - xhpcRate.setName(xhpcRateDto.getName()); - xhpcRate.setPowerFee(xhpcRateDto.getPowerFee()); - xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); - xhpcRate.setRateModelId(rateModelId); - xhpcRate.setRateValue(xhpcRateDto.getId()); - xhpcChargingStationMapper.addXhpcRate(xhpcRate); - map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); + if ("00".equals(xhpcRateDto.getId()) || "01".equals(xhpcRateDto.getId()) || "02".equals(xhpcRateDto.getId()) || "03".equals(xhpcRateDto.getId())) { + XhpcRate xhpcRate = new XhpcRate(); + xhpcRate.setChargingStationId(chargingStationId); + xhpcRate.setName(xhpcRateDto.getName()); + xhpcRate.setPowerFee(xhpcRateDto.getPowerFee()); + xhpcRate.setServiceFee(xhpcRateDto.getServiceFee()); + xhpcRate.setRateModelId(rateModelId); + xhpcRate.setRateValue(xhpcRateDto.getId()); + xhpcChargingStationMapper.addXhpcRate(xhpcRate); + map.put(xhpcRateDto.getId(), xhpcRate.getRateId()); + }else{ + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return AjaxResult.error("添加费率错误,请稍后在试"); + } } //添加费率时段 @@ -1126,30 +1137,32 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi } @Override - public Integer getTerminalStatus(String serialNumber) { - - Integer status =5; + public int getTerminalStatus(String serialNumber) { + //0离线 1故障 2空闲 3充电 4 已插枪 5未知 + // Integer status =5; //终端状态用 redis数据 if(!"".equals(serialNumber) && serialNumber!=null){ Map cacheMap =redisService.getCacheMap("gun:"+serialNumber); if(cacheMap !=null && cacheMap.get("status") !=null){ if ("离线".equals(cacheMap.get("status").toString())){ - status =0; + return 0; }else if("故障".equals(cacheMap.get("status").toString())){ - status =1; + return 1; }else if("空闲".equals(cacheMap.get("status").toString())){ if("是".equals(cacheMap.get("vehicleGunStatus").toString())){ - status =4; + return 4; }else{ - status =2; + return 2; } }else{ //充电桩 - status = 3; + return 3; } } + return 5; + }else{ + return 5; } - return status; } @Override diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java index 0e1d192a..c9d5edb4 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java @@ -47,7 +47,7 @@ public class XhpcTerminalServiceImpl implements IXhpcTerminalService { for (int i = 0; i map = list.get(i); //状态 - Integer pileSerialNumber = xhpcChargingStationService.getTerminalStatus(map.get("serialNumber").toString()); + int pileSerialNumber = xhpcChargingStationService.getTerminalStatus(map.get("serialNumber").toString()); map.put("workStatus",pileSerialNumber); } } @@ -99,7 +99,7 @@ public class XhpcTerminalServiceImpl implements IXhpcTerminalService { if(map.get("chargingDegreeSum")==null || map.get("chargingDegreeSum").toString()==null || "".equals(map.get("chargingDegreeSum").toString())){ map.put("chargingDegreeSum",0); } - Integer status = xhpcChargingStationService.getTerminalStatus(map.get("serialNumber").toString()); + int status = xhpcChargingStationService.getTerminalStatus(map.get("serialNumber").toString()); map.put("workStatus",status); diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml index 1c208f19..75045e95 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcTerminalMapper.xml @@ -82,7 +82,7 @@ ct.name as chargingStationName, te.pile_serial_number as pileSerialNumber, cp.power as power, - cp.serial_number as serialNumber, + te.serial_number as serialNumber, cp.brand_model as brandModel, cp.type as pileType, te.status as status, 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 292df67a..8806f82f 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 @@ -364,9 +364,10 @@ public class XhpcPileOrderController extends BaseController { R.ok(); } }else{ -// Map pushOrder = redisService.getCacheMap("pushOrder:"+orderNo); -// xhpcHistoryOrder.setInternetSerialNumber(pushOrder.get("internetSerialNumber").toString()); -// xhpcChargeOrder.setOperatorId3rdptyEvcs((String) pushOrder.get("operatorId3rdpty")); + Map pushOrder = redisService.getCacheMap("pushOrder:"+orderNo); + xhpcHistoryOrder.setInternetSerialNumber(pushOrder.get("internetSerialNumber").toString()); + xhpcHistoryOrder.setOperatorId3rdptyEvcs((String) pushOrder.get("operatorId3rdpty")); + xhpcChargeOrder.setOperatorId3rdptyEvcs((String) pushOrder.get("operatorId3rdpty")); } //结算 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 9e19029e..f5d887f4 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 @@ -88,7 +88,7 @@ public class XhpcHistoryOrderController extends BaseController { * 终端统计 */ @GetMapping("/test3") - //@Scheduled(cron = "0 0/8 * * * ?") + @Scheduled(cron = "0 0/8 * * * ?") public void test3(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -99,7 +99,7 @@ public class XhpcHistoryOrderController extends BaseController { * 场站统计 */ @GetMapping("/test2") - //@Scheduled(cron = "0 0/7 * * * ?") + @Scheduled(cron = "0 0/7 * * * ?") public void test2(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -111,8 +111,16 @@ public class XhpcHistoryOrderController extends BaseController { * 日期统计 */ @GetMapping("/test1") - //@Scheduled(cron = "0 0/6 * * * ?") + @Scheduled(cron = "0 0/6 * * * ?") public void test1(){ + add(1000,1); + } + /** + * 日期统计(已废弃) + */ + @GetMapping("/test7") + //@Scheduled(cron = "0 0/6 * * * ?") + public void test7(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -173,7 +181,7 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setType(type); - xhpcSt.setCreateTime(xhpc.getCreateTime()); + xhpcSt.setCreateTime(xhpc.getEndTime()); xhpcStatisticsService.addStatisticsStation(xhpcSt); //修改历史订单表状态 xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1); @@ -376,11 +384,7 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setType(type); - if(number==1){ - xhpcSt.setCreateTime(xhpc.getCreateTime()); - }else{ - xhpcSt.setCreateTime(DateUtil.offset(xhpc.getCreateTime(), DateField.DAY_OF_MONTH, 1)); - } + xhpcSt.setCreateTime(xhpc.getEndTime()); xhpcStatisticsService.addStatisticsStation(xhpcSt); //修改历史订单表状态 @@ -403,8 +407,91 @@ public class XhpcHistoryOrderController extends BaseController { * 小时统计 */ @GetMapping("/test") - //@Scheduled(cron = "0 0/5 * * * ?") + @Scheduled(cron = "0 0/5 * * * ?") public void test(){ + 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()); + } + 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){ + + } + + } + + + + /** + * 小时统计(精确统计) + */ + @GetMapping("/test8") + //@Scheduled(cron = "0 0/5 * * * ?") + public void test8(){ logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); @@ -478,7 +565,7 @@ public class XhpcHistoryOrderController extends BaseController { 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.getCreateTime()); + xhpcSt.setCreateTime(xhpc.getEndTime()); xhpcStatisticsService.addStatisticsTime(xhpcSt); //修改历史订单表状态 xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1); @@ -730,11 +817,7 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setOperatorId(xhpc.getOperatorId()); xhpcSt.setChargingStationId(xhpc.getChargingStationId()); xhpcSt.setDelFlag(0); - if(type!=3){ - xhpcSt.setCreateTime(xhpc.getCreateTime()); - }else{ - xhpcSt.setCreateTime(DateUtil.offset(xhpc.getCreateTime(), DateField.DAY_OF_MONTH, 1)); - } + xhpcSt.setCreateTime(xhpc.getEndTime()); xhpcSt.setTerminalId(xhpc.getTerminalId()); xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+srt); @@ -803,8 +886,7 @@ public class XhpcHistoryOrderController extends BaseController { for (XhpcChargeHistoryOrder xhpc:list) { XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); xhpcSt.setChargingDegree(xhpc.getChargingDegree()); - BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, BigDecimal.ROUND_DOWN); - xhpcSt.setChargingTime(decimal); + 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()); @@ -829,7 +911,7 @@ public class XhpcHistoryOrderController extends BaseController { xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); xhpcSt.setChargingPileId(xhpc.getChargingPileId()); xhpcSt.setType(type); - xhpcSt.setCreateTime(xhpc.getCreateTime()); + xhpcSt.setCreateTime(xhpc.getEndTime()); xhpcStatisticsService.addStatisticsStation(xhpcSt); //修改历史订单表状态 @@ -848,5 +930,19 @@ public class XhpcHistoryOrderController extends BaseController { System.out.println(date1.getTime()-date.getTime()); + + DateTime startTime = DateUtil.parse("2021-10-19 17:35:19"); + DateTime endTime = DateUtil.parse("2021-10-19 17:36:02"); + + //充电时长 + Long tiem = (endTime.getTime() - startTime.getTime())/1000; + System.out.println(">>>>"+tiem); + + + BigDecimal decimal = new BigDecimal(72); + BigDecimal decimal1 = new BigDecimal(3600); + + System.out.println(decimal.divide(decimal1,2,BigDecimal.ROUND_DOWN)); + } } 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 f3c1f90c..376eb275 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 @@ -204,6 +204,7 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>"); if (r1.getCode() != 200) { return AjaxResult.error(r1.getMsg()); } @@ -460,9 +461,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + startChargingData.getSoc()); R r1 = powerPileService.startCharging(startChargingData); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方充电返回>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<第三方充电返回>>>>>>>>>>>>>>>>>"); if (r1.getCode() != 200) { r.setCode(500); r.setMsg(r1.getMsg()); @@ -470,7 +473,7 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { } String startTime = DateUtil.format(date, "yyyy-MM-dd HH: mm: ss"); Map extraData1 = xhpcChargeOrderMapper.selectDate3rdNeedBy(connectorId).get(0); - Long rateModelId = (Long) extraData1.get("rateModelId"); + Long rateModelId = Long.valueOf(r1.getData().toString()); Long terminalId = (Long) extraData1.get("terminalId"); Double power = (Double) extraData1.get("power"); Long chargingStationId = (Long) extraData1.get("chargingStationId"); 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 9d6bcc2d..5450aeee 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 @@ -244,14 +244,16 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { //0总金额提成 1服务费提成 if(new BigDecimal(0).compareTo(commissionRate)==-1){ if("0".equals(operatorIdEvcs.get("commissionType").toString())){ - internetCommission = actPrice.divide(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); - actPrice = actPrice.multiply(internetCommission); - surplusPowerPrice = surplusPowerPrice.subtract(internetCommission.divide(new BigDecimal(2),2,BigDecimal.ROUND_DOWN)); - surplusServicePrice =surplusServicePrice.subtract(internetCommission.divide(new BigDecimal(2),2,BigDecimal.ROUND_DOWN)); + //流量方的钱 + internetCommission=actPrice.multiply(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); + + actPrice = actPrice.subtract(internetCommission); + surplusPowerPrice = surplusPowerPrice.multiply(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); + surplusServicePrice =surplusServicePrice.multiply(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); }else{ - internetSvcCommission = actPrice.divide(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); - actPrice = actPrice.multiply(internetSvcCommission); - surplusServicePrice =surplusServicePrice.subtract(internetCommission.divide(new BigDecimal(2),2,BigDecimal.ROUND_DOWN)); + internetSvcCommission = actPrice.multiply(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); + actPrice = actPrice.subtract(internetSvcCommission); + surplusServicePrice =surplusServicePrice.multiply(commissionRate).setScale(2,BigDecimal.ROUND_DOWN); } } } @@ -284,22 +286,22 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { if(fan){ promotionDiscount=money.multiply(discount).setScale(2,BigDecimal.ROUND_DOWN); actPrice = money.subtract(promotionDiscount); - surplusPowerPrice = surplusPowerPrice.subtract(promotionDiscount.divide(new BigDecimal(2),BigDecimal.ROUND_DOWN)); - surplusServicePrice= surplusServicePrice.subtract(promotionDiscount.divide(new BigDecimal(2),BigDecimal.ROUND_DOWN)); + surplusPowerPrice = surplusPowerPrice.multiply(discount).setScale(2,BigDecimal.ROUND_DOWN); + surplusServicePrice= surplusServicePrice.multiply(discount).setScale(2,BigDecimal.ROUND_DOWN); } }else if("2".equals(state)){ if(fan){ //电费 promotionDiscount =powerPrice.multiply(balance).setScale(2,BigDecimal.ROUND_DOWN); actPrice = money.subtract(promotionDiscount); - surplusPowerPrice=surplusPowerPrice.subtract(promotionDiscount); + surplusPowerPrice=surplusPowerPrice.multiply(balance).setScale(2,BigDecimal.ROUND_DOWN); } }else if("3".equals(state)){ if(fan){ //服务费 promotionDiscount = servicePrice.multiply(balance).setScale(2,BigDecimal.ROUND_DOWN); actPrice = money.subtract(promotionDiscount); - surplusServicePrice =surplusServicePrice.subtract(promotionDiscount); + surplusServicePrice =surplusServicePrice.multiply(balance).setScale(2,BigDecimal.ROUND_DOWN); } } } @@ -330,10 +332,11 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); platformCommission = multiply1.add(multiply2); //剩下的钱 - surplusPowerPrice = surplusPowerPrice.subtract(multiply1); - surplusServicePrice = surplusServicePrice.subtract(multiply2); + surplusPowerPrice = surplusPowerPrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); + surplusServicePrice = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); BigDecimal multiply3 = surplusPowerPrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); + operationCommission = multiply1.add(multiply2); //剩下的钱 surplusPowerPrice = surplusPowerPrice.subtract(multiply3); @@ -343,7 +346,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); platformSvcCommission=multiply2; //剩下的钱 - surplusServicePrice = surplusServicePrice.subtract(multiply2); + surplusServicePrice = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_DOWN); operationCommission = multiply4; 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 7cfd00b1..98d339c7 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -586,11 +586,11 @@ select xt.charging_station_id as chargingStationId, xt.terminal_id as terminalId, - xt.rate_model_id as rateModelId, + cs.rate_model_id as rateModelId, power from xhpc_terminal as xt - left join xhpc_charging_pile as xcp - on xcp.serial_number = substring(#{serialNumber}, 1, 14) + left join xhpc_charging_pile as xcp on xcp.serial_number = substring(#{serialNumber}, 1, 14) + left join xhpc_charging_station as cs on xt.charging_station_id = cs.charging_station_id where xt.serial_number = #{serialNumber} 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 e20f8930..2e765986 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -88,9 +88,11 @@ #{chargingStationId} - - and #{startTime} <=create_time - and create_time <=#{endTime} + + and create_time >= #{startTime} + + + and create_time <= #{endTime} and operator_id=#{operatorId} @@ -135,9 +137,11 @@ #{chargingStationId} - - and #{startTime} <=create_time - and create_time <=#{endTime} + + and create_time >= #{startTime} + + + and create_time <= #{endTime} and operator_id=#{operatorId} @@ -179,9 +183,11 @@ left join xhpc_charging_station as cs on cs.charging_station_id = ss.charging_station_id left join xhpc_operator as op on op.operator_id = ss.operator_id where ss.del_flag=0 and ss.type=2 - - and #{startTime} <=ss.create_time - and ss.create_time <=#{endTime} + + and ss.create_time >= #{startTime} + + + and ss.create_time <= #{endTime} and ss.operator_id=#{operatorId} @@ -232,9 +238,11 @@ from xhpc_statistics_station as ss left join xhpc_operator as op on op.operator_id = ss.operator_id where ss.del_flag=0 and ss.type=2 - - and #{startTime} <=ss.create_time - and ss.create_time <=#{endTime} + + and ss.create_time >= #{startTime} + + + and ss.create_time <= #{endTime} and ss.operator_id in @@ -281,9 +289,11 @@ from xhpc_statistics_station as ss left join xhpc_internet_user as iu on iu.internet_user_id = ss.internet_user_id where ss.del_flag=0 and ss.type=2 and ss.internet_user_id !=null - - and #{startTime} <=ss.create_time - and ss.create_time <=#{endTime} + + and ss.create_time >= #{startTime} + + + and ss.create_time <= #{endTime} and ss.internet_user_id in @@ -322,9 +332,11 @@ left join xhpc_charging_station as cs on cs.charging_station_id = ss.charging_station_id left join xhpc_terminal as te on te.terminal_id = ss.terminal_id where ss.del_flag=0 and ss.type=3 - - and #{startTime} <=ss.create_time - and ss.create_time <=#{endTime} + + and ss.create_time >= #{startTime} + + + and ss.create_time <= #{endTime} and ss.operator_id=#{operatorId} 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 04e84d0d..a2c15ef5 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 @@ -206,7 +206,24 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { // 查询用户信息 XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username); if (StringUtils.isNull(user)) { - return R.fail(HttpStatus.DATA_ERROR, "登录用户:" + username + " 不存在"); + //注册 + XhpcAppUser xhpcAppUser = new XhpcAppUser(); + xhpcAppUser.setPhone(username); + String password = username.substring(username.length() - 6); + xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password)); + xhpcAppUser.setCreateTime(new Date()); + if (StatusConstants.OPERATION_WX_TYPE.equals(type)) { + xhpcAppUser.setWeixinOpenId(openid); + xhpcAppUser.setWeixinLogin(1); + } else { + xhpcAppUser.setAlipayOpenId(openid); + xhpcAppUser.setAlipayLogin(1); + } + xhpcAppUserMapper.insert(xhpcAppUser); + user = xhpcAppUserMapper.getAppUserByPhone(username); + // 获取登录token + //return R.ok(tokenService.createToken(userInfo)); + //return R.fail(HttpStatus.DATA_ERROR, "登录用户:" + username + " 不存在"); } LoginUser userInfo = new LoginUser(); SysUser sysUser = new SysUser();