From 9255543120e8ecc1ea7b1475224b9bfb80a9b57c Mon Sep 17 00:00:00 2001 From: sunhaoyuan <2269400447@qq.com> Date: Tue, 4 Nov 2025 14:45:29 +0800 Subject: [PATCH] 11.04 --- .../RescueBusinessStatisticsController.java | 1 - .../module/rescue/domain/RescueInfo.java | 3 + .../RescueBusinessStatisticsServiceImpl.java | 165 ++++++++++++------ .../rescue/vo/RescueBusinessStatisticsVO.java | 1 + .../mapper/rescue/RescueInfoMapper.xml | 40 +++++ .../src/main/resources/application-local.yaml | 12 +- 6 files changed, 157 insertions(+), 65 deletions(-) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueBusinessStatisticsController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueBusinessStatisticsController.java index fadc03e8..60c2a674 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueBusinessStatisticsController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueBusinessStatisticsController.java @@ -83,7 +83,6 @@ public class RescueBusinessStatisticsController extends BaseController { /** * ① 救援类型 * 实际上是故障类型,展示:道路救援、事故救援 - * 数据字典 */ @GetMapping("/rescueType") public CommonResult rescueType(@RequestParam String timeType, diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/RescueInfo.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/RescueInfo.java index dfe83206..ce33797e 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/RescueInfo.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/RescueInfo.java @@ -459,6 +459,9 @@ public class RescueInfo extends TenantBaseDO /** 二级调度名字集合 */ @TableField(exist = false) private Set secondDispatcherNames; + /** 移交事由 */ + @TableField(exist = false) + private String transferReason; /** * 调度等级 */ diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueBusinessStatisticsServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueBusinessStatisticsServiceImpl.java index 4d2da327..4dbd081a 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueBusinessStatisticsServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueBusinessStatisticsServiceImpl.java @@ -145,6 +145,7 @@ public class RescueBusinessStatisticsServiceImpl implements RescueBusinessStatis i.setName("未知"); } else { i.setName(dict.getOrDefault(code, code)); // 找不到字典就保留原值 + i.setValue(code); } }); @@ -189,32 +190,38 @@ public class RescueBusinessStatisticsServiceImpl implements RescueBusinessStatis // 1. 取原始分组结果(可能出现 null、''、'0'、'1' 四种) List raw = mapper.groupNewEnergy(s, e, driverName, secondDispatchName, driverCarNum); - // 2. code → 中文,并把相同中文归并求和 - Map merged = new HashMap<>(4); + // 2. code -> Item(同时做数量汇总) + Map merged = new HashMap<>(4); for (RescueBusinessStatisticsVO.Item it : raw) { String code = it.getName(); // '1' / '0' / null / '' - long cnt = it.getCount() == null ? 0 : it.getCount(); + long count = it.getCount() == null ? 0 : it.getCount(); - String key; + // 2-1. 计算中文标签 + String label; if ("1".equals(code)) { - key = "是"; + label = "是"; } else if ("0".equals(code)) { - key = "否"; + label = "否"; } else { // null、空串、其它 - key = "未知"; + label = "未知"; + code = ""; // 给未知一个空串,防止 NPE } - merged.merge(key, cnt, Long::sum); // 汇总 + + // 2-2. 汇总到同一个 Item + RescueBusinessStatisticsVO.Item agg = + merged.computeIfAbsent(code, k -> { + RescueBusinessStatisticsVO.Item tmp = new RescueBusinessStatisticsVO.Item(); + tmp.setName(label); // 中文展示 + tmp.setValue(k); // 前端真正要用的字典值 + tmp.setCount(0L); + return tmp; + }); + agg.setCount(agg.getCount() + count); } - // 3. 转回 List(按数量倒序,可选) - return merged.entrySet().stream() - .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) - .map(e1 -> { - RescueBusinessStatisticsVO.Item i = new RescueBusinessStatisticsVO.Item(); - i.setName(e1.getKey()); - i.setCount(e1.getValue()); - return i; - }) + // 3. List(按数量倒序,可微调) + return merged.values().stream() + .sorted((a, b) -> Long.compare(b.getCount(), a.getCount())) .collect(Collectors.toList()); } @@ -235,17 +242,28 @@ public class RescueBusinessStatisticsServiceImpl implements RescueBusinessStatis // 3. 批量翻译字典(dict_type = dljy_type) Map dict = dictDataService.getDictDataLabels("dljy_type", codes); - // 4. 置中文、兜底空值 - items.forEach(i -> { - String code = i.getName(); - if (StringUtils.isBlank(code)) { - i.setName("未知"); - } else { - i.setName(dict.getOrDefault(code, code)); - } - }); + // 4. 逐条转换 + return items.stream() + .map(it -> { + String code = it.getName(); // 原始 code + String label; // 中文标签 - return items; + if (StringUtils.isBlank(code)) { + label = "未知"; + code = ""; // 避免 null + } else { + // 若字典缺失,则直接显示原 code + label = dict.getOrDefault(code, code); + } + + RescueBusinessStatisticsVO.Item vo = new RescueBusinessStatisticsVO.Item(); + vo.setName(label); // 展示 + vo.setValue(code); // 查询用 + vo.setCount(it.getCount() == null ? 0 : it.getCount()); + return vo; + }) + .sorted((a, b) -> Long.compare(b.getCount(), a.getCount())) // 可选:数量倒序 + .collect(Collectors.toList()); } @Override @@ -256,51 +274,82 @@ public class RescueBusinessStatisticsServiceImpl implements RescueBusinessStatis return raw; } - // 2. 批量翻译 + // 2. 一次性取出所有 code → 中文 List codes = raw.stream() .map(RescueBusinessStatisticsVO.Item::getName) .collect(Collectors.toList()); Map dict = dictDataService.getDictDataLabels("fee_type", codes); - // 3. 合并相同中文;对未配置的 code -> “未知” - Map merged = new HashMap<>(); - for (RescueBusinessStatisticsVO.Item it : raw) { - String code = it.getName(); - Long count = it.getCount() == null ? 0 : it.getCount(); + // 3. 逐条转换(缺失的 code 显示“未知”) + return raw.stream() + .map(it -> { + String code = it.getName(); // 原始 code + String label = dict.getOrDefault(code, "未知"); // 中文 - String label = dict.get(code); // 可能为 null - String key = StringUtils.isBlank(label) ? "未知" : label; - - merged.merge(key, count, Long::sum); - } - - // 4. 转回 List(数量倒序,可选) - return merged.entrySet().stream() - .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) - .map(e1 -> { - RescueBusinessStatisticsVO.Item item = new RescueBusinessStatisticsVO.Item(); - item.setName(e1.getKey()); - item.setCount(e1.getValue()); - return item; + RescueBusinessStatisticsVO.Item vo = new RescueBusinessStatisticsVO.Item(); + vo.setName(label); // 展示 + vo.setValue(code); // 前端查询用 + vo.setCount(it.getCount() == null ? 0 : it.getCount()); + return vo; }) + .sorted((a, b) -> Long.compare(b.getCount(), a.getCount())) // 按量倒序,可选 .collect(Collectors.toList()); + + // 3. 合并相同中文;对未配置的 code -> “未知” +// Map merged = new HashMap<>(); +// for (RescueBusinessStatisticsVO.Item it : raw) { +// String code = it.getName(); +// Long count = it.getCount() == null ? 0 : it.getCount(); +// +// String label = dict.get(code); // 可能为 null +// String key = StringUtils.isBlank(label) ? "未知" : label; +// +// merged.merge(key, count, Long::sum); +// } +// +// // 4. 转回 List(数量倒序,可选) +// return merged.entrySet().stream() +// .sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) +// .map(e1 -> { +// RescueBusinessStatisticsVO.Item item = new RescueBusinessStatisticsVO.Item(); +// item.setName(e1.getKey()); +// item.setCount(e1.getValue()); +// return item; +// }) +// .collect(Collectors.toList()); } @Override public List listKouChe(String s, String e, String driverName,String secondDispatchName,String driverCarNum) { List items = mapper.groupKouChe(s, e, driverName, secondDispatchName, driverCarNum); - items.forEach(i -> { - String code = i.getName(); - if ("1".equals(code)) { - i.setName("是"); // 已扣车 - } else if ("0".equals(code)) { - i.setName("否"); // 未扣车 - } else { - i.setName("未知"); // 兜底 - } - }); - return items; + if (items.isEmpty()) { + return items; + } + + // 2. 逐条翻译 & 填充 value + return items.stream() + .map(it -> { + String code = it.getName(); // 原始 code:1 / 0 / null / "" + String label; // 中文标签 + + if ("1".equals(code)) { + label = "是"; + } else if ("0".equals(code)) { + label = "否"; + } else { + label = "未知"; + code = ""; // 给未知一个空串,防止 NPE + } + + RescueBusinessStatisticsVO.Item vo = new RescueBusinessStatisticsVO.Item(); + vo.setName(label); // 展示 + vo.setValue(code); // 查询用 + vo.setCount(it.getCount() == null ? 0 : it.getCount()); + return vo; + }) + .sorted((a, b) -> Long.compare(b.getCount(), a.getCount())) // 可选:按数量倒序 + .collect(Collectors.toList()); } @Override diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RescueBusinessStatisticsVO.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RescueBusinessStatisticsVO.java index b962d0b4..d92c92b6 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RescueBusinessStatisticsVO.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RescueBusinessStatisticsVO.java @@ -12,6 +12,7 @@ public class RescueBusinessStatisticsVO { public static class Item { private String name; private Long count; + private String value; //字典值 } /* 10 个统计维度 */ diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml index 3dd0eb2f..c8c79f3a 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml @@ -104,6 +104,46 @@ AND ri.second_dispatch_name = #{map.secondDispatchName} + + AND ri.fault_type = #{map.faultType} + + + AND ri.rescue_position like concat('%', #{map.rescuePosition}, '%') + + + AND ri.car_brand = #{map.carBrand} + + + AND ri.car_type = #{map.carType} + + + AND ri.estimate_down_car = #{map.estimateDownCar} + + + AND ri.if_new_energy = #{map.ifNewEnergy} + + + AND ri.rescue_type = #{map.rescueType} + + + AND ri.fee_type = #{map.feeType} + + + AND ri.is_kou_che = #{map.isKouChe} + + + AND EXISTS ( + SELECT 1 + FROM rescue_info_detail rd + WHERE rd.rescue_info_id = ri.id AND rd.deleted = '0' + AND rd.title = '车辆移交' + AND rd.auto_remark LIKE '%移交事由:%' + AND TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX( + rd.auto_remark, '移交事由:', -1), ',', 1)) + = #{map.transferReason} + ) + + order by ri.create_time desc diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 7b263a06..b49da582 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -46,9 +46,9 @@ spring: primary: master datasource: master: - url: jdbc:mysql://122.51.230.86:3306/lanan_platform_dev?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 +# url: jdbc:mysql://122.51.230.86:3306/lanan_platform_dev?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://localhost:3306/lanan_new?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 -# url: jdbc:mysql://122.51.230.86:3306/lanan_platform?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + url: jdbc:mysql://122.51.230.86:3306/lanan_platform?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 @@ -56,12 +56,12 @@ spring: # url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例 - username: lanan_dev - password: lighting@2024 +# username: lanan_dev +# password: lighting@2024 # username: root # password: 12345678 -# username: lanan -# password: 123456 + username: lanan + password: 123456 # username: sa # SQL Server 连接的示例 # password: Yudao@2024 # SQL Server 连接的示例 # username: SYSDBA # DM 连接的示例