11.04
This commit is contained in:
parent
e05da6f0a6
commit
9255543120
@ -83,7 +83,6 @@ public class RescueBusinessStatisticsController extends BaseController {
|
||||
/**
|
||||
* ① 救援类型
|
||||
* 实际上是故障类型,展示:道路救援、事故救援
|
||||
* 数据字典
|
||||
*/
|
||||
@GetMapping("/rescueType")
|
||||
public CommonResult<RescueBusinessStatisticsVO> rescueType(@RequestParam String timeType,
|
||||
|
||||
@ -459,6 +459,9 @@ public class RescueInfo extends TenantBaseDO
|
||||
/** 二级调度名字集合 */
|
||||
@TableField(exist = false)
|
||||
private Set<String> secondDispatcherNames;
|
||||
/** 移交事由 */
|
||||
@TableField(exist = false)
|
||||
private String transferReason;
|
||||
/**
|
||||
* 调度等级
|
||||
*/
|
||||
|
||||
@ -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<RescueBusinessStatisticsVO.Item> raw = mapper.groupNewEnergy(s, e, driverName, secondDispatchName, driverCarNum);
|
||||
|
||||
// 2. code → 中文,并把相同中文归并求和
|
||||
Map<String, Long> merged = new HashMap<>(4);
|
||||
// 2. code -> Item(同时做数量汇总)
|
||||
Map<String, RescueBusinessStatisticsVO.Item> 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<Item>(按数量倒序,可选)
|
||||
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<Item>(按数量倒序,可微调)
|
||||
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<String, String> 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<String> codes = raw.stream()
|
||||
.map(RescueBusinessStatisticsVO.Item::getName)
|
||||
.collect(Collectors.toList());
|
||||
Map<String, String> dict = dictDataService.getDictDataLabels("fee_type", codes);
|
||||
|
||||
// 3. 合并相同中文;对未配置的 code -> “未知”
|
||||
Map<String, Long> 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<Item>(数量倒序,可选)
|
||||
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<String, Long> 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<Item>(数量倒序,可选)
|
||||
// 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<RescueBusinessStatisticsVO.Item> listKouChe(String s, String e, String driverName,String secondDispatchName,String driverCarNum) {
|
||||
List<RescueBusinessStatisticsVO.Item> 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
|
||||
|
||||
@ -12,6 +12,7 @@ public class RescueBusinessStatisticsVO {
|
||||
public static class Item {
|
||||
private String name;
|
||||
private Long count;
|
||||
private String value; //字典值
|
||||
}
|
||||
|
||||
/* 10 个统计维度 */
|
||||
|
||||
@ -104,6 +104,46 @@
|
||||
<if test="map.secondDispatchName!=null and map.secondDispatchName!='' ">
|
||||
AND ri.second_dispatch_name = #{map.secondDispatchName}
|
||||
</if>
|
||||
<if test="map.faultType!=null and map.faultType!='' ">
|
||||
AND ri.fault_type = #{map.faultType}
|
||||
</if>
|
||||
<if test="map.rescuePosition!=null and map.rescuePosition!='' ">
|
||||
AND ri.rescue_position like concat('%', #{map.rescuePosition}, '%')
|
||||
</if>
|
||||
<if test="map.carBrand!=null and map.carBrand!='' ">
|
||||
AND ri.car_brand = #{map.carBrand}
|
||||
</if>
|
||||
<if test="map.carType!=null and map.carType!='' ">
|
||||
AND ri.car_type = #{map.carType}
|
||||
</if>
|
||||
<if test="map.estimateDownCar!=null and map.estimateDownCar!='' ">
|
||||
AND ri.estimate_down_car = #{map.estimateDownCar}
|
||||
</if>
|
||||
<if test="map.ifNewEnergy!=null and map.ifNewEnergy!='' ">
|
||||
AND ri.if_new_energy = #{map.ifNewEnergy}
|
||||
</if>
|
||||
<if test="map.rescueType!=null and map.rescueType!='' ">
|
||||
AND ri.rescue_type = #{map.rescueType}
|
||||
</if>
|
||||
<if test="map.feeType!=null and map.feeType!='' ">
|
||||
AND ri.fee_type = #{map.feeType}
|
||||
</if>
|
||||
<if test="map.isKouChe!=null and map.isKouChe!='' ">
|
||||
AND ri.is_kou_che = #{map.isKouChe}
|
||||
</if>
|
||||
<if test="map.transferReason != null and map.transferReason != '' ">
|
||||
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}
|
||||
)
|
||||
</if>
|
||||
|
||||
</where>
|
||||
order by ri.create_time desc
|
||||
</select>
|
||||
|
||||
@ -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 连接的示例
|
||||
|
||||
Loading…
Reference in New Issue
Block a user