From 76cbf6741c91bf91469e406dc052e688e4fd6103 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 13 二月 2025 16:35:52 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 132 +++++++++++++++++++++++-------------------- 1 files changed, 70 insertions(+), 62 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index 13804be..d599596 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -66,6 +66,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -599,6 +600,7 @@ if(null != data && data.getChargeNum() > 0){ //计算折扣 List<AccountingStrategyDetailOrder> list = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); + list.get(list.size() - 1).setEndTime("23:59"); //将数据叠加两份,处理跨天的情况 list.addAll(list); boolean sta = false; @@ -1190,8 +1192,12 @@ @Override public TCharingOrderVO chargingOrder(ChargingOrderQuery dto) { TCharingOrderVO tCharingOrderVO = new TCharingOrderVO(); - - + List<TChargingGun> allGun = chargingGunClient.getAllGun().getData(); + List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); + List<Site> data9 = siteClient.getSiteAll().getData(); + List<TAppUser> data6 = appUserClient.getAllUser().getData(); + List<Partner> data7 = siteClient.getAllPartner().getData(); + List<TAppUserCar> data4 = appUserCarClient.getAllCar().getData(); String startTime1 = null; String startTime2 = null; String endTime1 = null; @@ -1208,7 +1214,7 @@ endTime2 = split[1]; } PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); - PageInfo<ChargingOrderVO> pageInfo1 = new PageInfo<>(1,9999999); + PageInfo<ChargingOrderVO> pageInfo1 = new PageInfo<>(1,999999999); if (StringUtils.hasLength(dto.getPhone())){ List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData(); @@ -1264,6 +1270,8 @@ BigDecimal refundMoney = new BigDecimal("0"); BigDecimal paymentMoney = new BigDecimal("0"); List<String> collect2 = list.stream().map(TChargingOrder::getCode).collect(Collectors.toList()); + List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>()); + for (ChargingOrderVO chargingOrderVO : list) { if (roleType == 2){ for (Integer siteId : siteIds) { @@ -1276,20 +1284,19 @@ chargingOrderVO.setCommissionAmount(chargingOrderVO.getOrderAmount()!=null?chargingOrderVO.getOrderAmount().multiply(new BigDecimal("0.006")):new BigDecimal("0")); chargingOrderVO.setPlatFormMoney(chargingOrderVO.getOrderAmount()!=null?chargingOrderVO.getOrderAmount().multiply(new BigDecimal("0.006")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); chargingOrderVO.setUid(chargingOrderVO.getId()+""); - TChargingGun data3 = chargingGunClient.getChargingGunById(chargingOrderVO.getChargingGunId()).getData(); - TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderVO.getChargingPileId()).getData(); + TChargingGun data3 = allGun.stream().filter(e->e.getId().equals(chargingOrderVO.getChargingGunId())).findFirst().orElse(null); + TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderVO.getChargingPileId())).findFirst().orElse(null); if (chargingOrderVO.getSiteId()!=null){ List<Integer> integers = new ArrayList<>(); integers.add(chargingOrderVO.getSiteId()); - List<Site> data = siteClient.getSiteByIds(integers).getData(); - if (!data.isEmpty())chargingOrderVO.setSiteName(data.get(0).getName()); + Site site = data9.stream().filter(e -> e.getId().equals(chargingOrderVO.getSiteId())).findFirst().orElse(null); + if (site!=null)chargingOrderVO.setSiteName(site.getName()); } if (data2!=null && data3!=null){ chargingOrderVO.setTerminalName(data2.getName()+"-"+data3.getName()); } // 充电订单 明细记录 - List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>() - .eq("charging_order_id", chargingOrderVO.getId())); + List<TChargingOrderAccountingStrategy> chargingOrderId = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ LocalDateTime startTime = chargingOrderVO.getStartTime(); LocalDateTime endTime = chargingOrderVO.getEndTime(); @@ -1302,16 +1309,16 @@ int size = chargingOrderId.size(); chargingOrderVO.setCount(size); // 用户手机号 - TAppUser data = appUserClient.getUserById(chargingOrderVO.getAppUserId()).getData(); + TAppUser data = data6.stream().filter(e -> e.getId().equals(chargingOrderVO.getAppUserId())).findFirst().orElse(null); if (data!=null){ // 车牌号 chargingOrderVO.setPhone(data.getPhone()); List<Long> longs = new ArrayList<>(); if (chargingOrderVO.getAppUserCarId()!=null){ longs.add(chargingOrderVO.getAppUserCarId()); - List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); - if (!data1.isEmpty()){ - chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); + TAppUserCar tAppUserCar = data4.stream().filter(e -> e.getId().equals(chargingOrderVO.getAppUserCarId())).findFirst().orElse(null); + if (tAppUserCar!=null){ + chargingOrderVO.setLicensePlate(tAppUserCar.getLicensePlate()); } } @@ -1438,6 +1445,9 @@ String endTime1 = null; String endTime2 = null; + List<TChargingGun> allGun = chargingGunClient.getAllGun().getData(); + List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); + if (StringUtils.hasLength(dto.getStartTime())){ String[] split = dto.getStartTime().split(" - "); startTime1 = split[0]; @@ -1534,8 +1544,8 @@ chargingOrderListVO.setSiteName(site.getName()); } if (chargingOrderListVO.getChargingGunId()!=null && chargingOrderListVO.getChargingPileId()!=null){ - TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrderListVO.getChargingGunId()).getData(); - TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderListVO.getChargingPileId()).getData(); + TChargingGun data1 = allGun.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingGunId())).findFirst().orElse(null); + TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingPileId())).findFirst().orElse(null); if (data2 != null && data1 != null) { chargingOrderListVO.setTerminalName(data2.getName() + "-" + data1.getName()); } @@ -1644,8 +1654,8 @@ chargingOrderListVO.setChargingSecond(between); } if (chargingOrderListVO.getChargingGunId()!=null && chargingOrderListVO.getChargingPileId()!=null){ - TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrderListVO.getChargingGunId()).getData(); - TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderListVO.getChargingPileId()).getData(); + TChargingGun data1 = allGun.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingGunId())).findFirst().orElse(null); + TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingPileId())).findFirst().orElse(null); if (data2 != null && data1 != null) { chargingOrderListVO.setTerminalName(data2.getName() + "-" + data1.getName()); } @@ -2184,7 +2194,7 @@ UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); if(null != uploadRealTimeMonitoringData && null == chargingOrder.getEndMode()){ Integer soc = uploadRealTimeMonitoringData.getSoc(); - if(soc > 98){ + if(soc >= 98){ order.setEndMode(2); }else if(chargingOrder.getResidualAmount().compareTo(new BigDecimal(1)) <= 0){ order.setEndMode(3); @@ -2911,6 +2921,8 @@ return pageInfo; } + @Autowired + private TChargingOrderService chargingOrderService; @Override public SettlementTotalVO settlementTotal(String time) { Long userId = tokenService.getLoginUser().getUserid(); @@ -2925,6 +2937,14 @@ if (siteIds.isEmpty()){ siteIds.add(-1); } + List<Site> siteList = siteClient.getSiteAll().getData(); + List<TChargingGun> gunList = chargingGunClient.getAllGun().getData(); + List<TChargingPile> pileList = chargingGunClient.getAllPile().getData(); + List<TAppUser> userList = appUserClient.getAllUser().getData(); + List<TAppUserCar> carList = appUserCarClient.getAllCar().getData(); + List<TChargingOrder> totalOrder = chargingOrderService.list(new LambdaQueryWrapper<>(TChargingOrder.class) + .eq(TChargingOrder::getRechargePaymentStatus, 2)); + List<TChargingOrderRefund> totalRefund = chargingOrderRefundService.lambdaQuery().eq(TChargingOrderRefund::getRefundStatus, 2).list(); SettlementTotalVO res = new SettlementTotalVO(); List<TSettlementConfirm> list1 = tSettlementConfirmMapper.settlementTotal(time,siteIds); LocalDateTime parse = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); @@ -2972,9 +2992,9 @@ for (TSettlementConfirm tSettlementConfirm : list1) { tSettlementConfirm.setXuhao(i); tSettlementConfirm.setMetering(tSettlementConfirm.getSupplyElectronic()); - List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); - if (!data1.isEmpty()){ - tSettlementConfirm.setSiteName(data1.get(0).getName()); + Site site = siteList.stream().filter(e -> e.getId().equals(tSettlementConfirm.getSiteId())).findFirst().orElse(null); + if (site!=null){ + tSettlementConfirm.setSiteName(site.getName()); } if (tSettlementConfirm.getMeteringElectronic()!=null){ meteringElectronic = meteringElectronic.add(tSettlementConfirm.getMeteringElectronic()); @@ -3019,26 +3039,17 @@ eq.between("end_time", tSettlementConfirm.getStartTime(), tSettlementConfirm.getEndTime()); break; } - List<TChargingOrder> tChargingOrders = this.baseMapper.selectList(eq); - Map<String,TChargingOrder> map = new HashMap<>(); - StringBuilder stringBuilder = new StringBuilder(); - for (TChargingOrder tChargingOrder : tChargingOrders) { - stringBuilder.append(tChargingOrder.getCode()).append(","); - - } + List<TChargingOrder> tChargingOrders = totalOrder.stream().filter(e-> e.getPayTime() + .isBefore(tSettlementConfirm.getEndTime()) + && e.getPayTime().isAfter(tSettlementConfirm.getStartTime())&&e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); // 充电总时长 - - Long temp = 1L; - if (StringUtils.hasLength(stringBuilder.toString())){ - String substring = stringBuilder.substring(0, stringBuilder.length() - 1); - for (String s : substring.split(",")) { - UploadRealTimeMonitoringData data6 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(s).getData(); - if (data6!=null){ - temp+=(data6.getCumulative_charging_time()*60); - - } - - } + Long temp = 0L; + for (TChargingOrder tChargingOrder : tChargingOrders) { + LocalDateTime startTime = tChargingOrder.getStartTime(); + LocalDateTime endTime = tChargingOrder.getEndTime(); + // 计算时间差 单位秒 + long between = ChronoUnit.SECONDS.between(startTime, endTime); + temp+=between; } List<TChargingPile> data = siteClient.getPileListBySiteId(tSettlementConfirm.getSiteId()).getData(); // 计算充电桩的功率平均值 @@ -3050,7 +3061,7 @@ tSettlementConfirm.setIncome(tSettlementConfirm.getElectrovalence().add(tSettlementConfirm.getServiceCharge())); //利用率=充电量/(桩数量*功率*时间) - List<TChargingPile> data2 = chargingPileClient.getChargingPileBySiteId(tSettlementConfirm.getSiteId()).getData(); + List<TChargingPile> data2 = pileList.stream().filter(e -> e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); BigDecimal bigDecimal2 = new BigDecimal("0"); if (data2!=null && (!data2.isEmpty())){ @@ -3166,11 +3177,16 @@ if (siteIds.isEmpty()){ siteIds.add(-1); } + List<Site> siteList = siteClient.getSiteAll().getData(); + List<TChargingGun> gunList = chargingGunClient.getAllGun().getData(); + List<TChargingPile> pileList = chargingGunClient.getAllPile().getData(); + List<TAppUser> userList = appUserClient.getAllUser().getData(); + List<TAppUserCar> carList = appUserCarClient.getAllCar().getData(); + List<TChargingOrder> totalOrder = chargingOrderService.list(new LambdaQueryWrapper<>(TChargingOrder.class) + .eq(TChargingOrder::getRechargePaymentStatus, 2)); SettlementTotalVO res = new SettlementTotalVO(); List<TSettlementConfirm> list1 = tSettlementConfirmMapper.settlementTotal(time,siteIds); LocalDateTime parse = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - // 减少一个月 - LocalDateTime minus = parse.minusMonths(1); List<TSettlementConfirm> list2 = tSettlementConfirmMapper.settlementTotal(time,siteIds); // 合计 List<TSettlementConfirm> total = new ArrayList<>(); @@ -3213,7 +3229,7 @@ for (TSettlementConfirm tSettlementConfirm : list1) { tSettlementConfirm.setXuhao(i); tSettlementConfirm.setMetering(tSettlementConfirm.getSupplyElectronic()); - List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); + List<Site> data1 = siteList.stream().filter(e -> e.getId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); if (!data1.isEmpty()){ tSettlementConfirm.setSiteName(data1.get(0).getName()); } @@ -3260,26 +3276,18 @@ eq.between("end_time", tSettlementConfirm.getStartTime(), tSettlementConfirm.getEndTime()); break; } - List<TChargingOrder> tChargingOrders = this.baseMapper.selectList(eq); - Map<String,TChargingOrder> map = new HashMap<>(); - StringBuilder stringBuilder = new StringBuilder(); - for (TChargingOrder tChargingOrder : tChargingOrders) { - stringBuilder.append(tChargingOrder.getCode()).append(","); - } + List<TChargingOrder> tChargingOrders = totalOrder.stream().filter(e-> e.getPayTime() + .isBefore(tSettlementConfirm.getEndTime()) + && e.getPayTime().isAfter(tSettlementConfirm.getStartTime())&&e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); // 充电总时长 - - Long temp = 1L; - if (StringUtils.hasLength(stringBuilder.toString())){ - String substring = stringBuilder.substring(0, stringBuilder.length() - 1); - for (String s : substring.split(",")) { - UploadRealTimeMonitoringData data6 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(s).getData(); - if (data6!=null){ - temp+=(data6.getCumulative_charging_time()*60); - - } - - } + Long temp = 0L; + for (TChargingOrder tChargingOrder : tChargingOrders) { + LocalDateTime startTime = tChargingOrder.getStartTime(); + LocalDateTime endTime = tChargingOrder.getEndTime(); + // 计算时间差 单位秒 + long between = ChronoUnit.SECONDS.between(startTime, endTime); + temp+=between; } List<TChargingPile> data = siteClient.getPileListBySiteId(tSettlementConfirm.getSiteId()).getData(); // 计算充电桩的功率平均值 -- Gitblit v1.7.1