From e74cfe2c54dd4d7cf6726b0a5c468db558b3aed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Fri, 25 Oct 2024 13:33:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=91=E6=8F=B4=E5=A4=A7=E5=B1=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/RescueBigScreeController.java | 11 +++ .../rescue/service/IRescueInfoService.java | 8 ++ .../service/impl/RescueInfoServiceImpl.java | 93 +++++++++++++++++++ 3 files changed, 112 insertions(+) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java index 69182bf3..2cca8759 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/admin/RescueBigScreeController.java @@ -98,4 +98,15 @@ public class RescueBigScreeController { public CommonResult getRescueOrderByRoad(){ return CommonResult.success(rescueInfoService.getRescueOrderByRoad()); } + + /** + * 救援大屏获取救援详细数据接口 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + */ + @GetMapping("/getRescueStatistics") + public CommonResult getRescueMessage(String startTime, String endTime){ + return CommonResult.success(rescueInfoService.getRescueMessage(startTime,endTime)); + } } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java index 0771aaf7..670e1550 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java @@ -161,4 +161,12 @@ public interface IRescueInfoService extends IService * @return */ List> getRescueOrderByRoad(); + + /** + * 救援大屏获取救援详细数据 + * @param startTime + * @param endTime + * @return + */ + Map getRescueMessage(String startTime, String endTime); } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java index 716898db..6b258873 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java @@ -52,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -1318,6 +1319,98 @@ public class RescueInfoServiceImpl extends ServiceImpl getRescueMessage(String startTime, String endTime) { + Map resp = new HashMap<>(); + // 一.查询救援订单 + List rescueOrders = rescueOrderInfoService.list(new LambdaQueryWrapper() + .between(RescueOrderInfo::getCreateTime, startTime, endTime)); + + // 1.计算救援金额 + long totalRescueMoney = rescueOrders.stream().mapToLong(order -> order.getPayMoney() != null ? order.getPayMoney() : 0L).sum(); + resp.put("totalRescueMoney", totalRescueMoney); + // 2.计算出车次数 + long totalOutCarCount = rescueOrders.size(); + resp.put("totalOutCarCount", totalOutCarCount); + // 3.计算待支付订单数量 + long totalPayOrderCount = rescueOrders.stream().filter(info -> info.getOrderStatus().equals("1")).count(); + resp.put("totalPayOrderCount", totalPayOrderCount); + + // 二.查询加油记录表 + List rescueRefuelRecords = refuelRecordService.list(new LambdaQueryWrapper() + .between(RescueRefuelRecord::getRecordTime, startTime, endTime)); + // 1.计算加油金额 + Double totalRefuelMoney = rescueRefuelRecords.stream().mapToDouble(RescueRefuelRecord::getRefuelMoney).sum(); + resp.put("totalRefuelMoney", totalRefuelMoney); + + // 三.查询救援信息表 + List rescueInfos = baseMapper.selectList(new LambdaQueryWrapper() + .between(RescueInfo::getRescueTime, startTime, endTime)); + // 1.计算待取车数量 + long totalWaitCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("6")).count(); + resp.put("totalWaitCarCount", totalWaitCarCount); + // 2.计算救援中数量 + long totalRescueingCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("3")).count(); + resp.put("totalRescueingCarCount", totalRescueingCarCount); + // 3.计算已完成数量 + long totalCompletedCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("5")).count(); + resp.put("totalCompletedCarCount", totalCompletedCarCount); + // 4.计算扣车中 + long totalDeductedCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("9")).count(); + resp.put("totalDeductedCarCount", totalDeductedCarCount); + // 5.计算以还车 + long totalReturnCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("8")).count(); + resp.put("totalReturnCarCount", totalReturnCarCount); + + // 四.查询司机提成表 + Double rescueTcBig = 0d; + Double rescueTcMid = 0d; + Double rescueTcSmall = 0d; + RescueConfig rescueConfig = rescueConfigService.selectRescueConfigByDeptId(); + if (ObjectUtils.isNotEmpty(rescueConfig)) { + rescueTcBig = Optional.ofNullable(rescueConfig.getRescueTcBig()).orElse(0d); + rescueTcMid = Optional.ofNullable(rescueConfig.getRescueTcMid()).orElse(0d); + rescueTcSmall = Optional.ofNullable(rescueConfig.getRescueTcSmall()).orElse(0d); + } + + Double totalRoyaltyMoney = 0d; + + // 1.将救援信息转为map + Map rescueInfoMap = rescueInfos.stream().collect(Collectors.toMap(RescueInfo::getId, Function.identity())); + + // 2.循环救援订单 计算提成 + for (RescueOrderInfo info : rescueOrders) { + RescueInfo rescueInfo = rescueInfoMap.get(info.getRescueInfoId()); + if (ObjectUtil.isNotNull(rescueInfo) && ObjectUtil.isNotEmpty(rescueInfo.getCarType())) { + String carType = rescueInfo.getCarType(); + Double tempSetMoney = ObjectUtils.isNotEmpty(info.getSetMoney()) ? Double.valueOf(info.getSetMoney()) / 100d : 0d; + switch (carType) { + case "1": + // 大车 + totalRoyaltyMoney += tempSetMoney * rescueTcBig; + break; + case "2": + // 中车 + totalRoyaltyMoney += tempSetMoney * rescueTcMid; + break; + case "3": + // 小车 + totalRoyaltyMoney += tempSetMoney * rescueTcSmall; + break; + } + } + } + resp.put("totalRoyaltyMoney", totalRoyaltyMoney); + return resp; + } + public List filterRescueInfoByDate(List rescueInfos, Date startTime, Date endTime) { return rescueInfos.stream() .filter(info -> info.getRescueTime() != null &&