From c565114c4ca01e606ecf9ff3c1e09d14d8a2180f Mon Sep 17 00:00:00 2001 From: dy <2389062315@qq.com> Date: Sat, 6 Sep 2025 01:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/domain/vo/IndexCountVo.java | 10 ++--- .../service/impl/IndexServiceImpl.java | 45 ++++++++++++++----- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/IndexCountVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/IndexCountVo.java index ceb63769..d5e9b3f8 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/IndexCountVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/IndexCountVo.java @@ -58,7 +58,7 @@ public class IndexCountVo { @NoArgsConstructor @AllArgsConstructor(access = AccessLevel.PRIVATE) public static class StatusChartVo { - private String type; // 类型名称(如:维修、咨询) + private String state; // 使用状态(如:使用中,停用中,已报废,闲置中) private Integer quantity; // 数量 public static StatusChartVoBuilder builder() { @@ -66,11 +66,11 @@ public class IndexCountVo { } public static class StatusChartVoBuilder { - private String type; + private String state; private Integer quantity; - public StatusChartVoBuilder type(String type) { - this.type = type; + public StatusChartVoBuilder state(String state) { + this.state = state; return this; } @@ -80,7 +80,7 @@ public class IndexCountVo { } public StatusChartVo build() { - return new StatusChartVo(type, quantity); + return new StatusChartVo(state, quantity); } } } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/IndexServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/IndexServiceImpl.java index c0aab859..ce60a053 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/IndexServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/IndexServiceImpl.java @@ -74,6 +74,17 @@ public class IndexServiceImpl implements IndexService { //查询设备各状态数量 List statusChartVos = new ArrayList<>(); + indexCountVo.setStatusChartVoChartList(statusChartVos); + + //查询设备总数 + List machineList = machineMapper.selectList(); + //查询设备各状态数量 + List machineStatusChartVos = calculateMachineTypeDistribution(machineList); + statusChartVos.addAll(machineStatusChartVos); + indexCountVo.setStatusChartVoChartList(statusChartVos); + //查询各种工单状态 + + return indexCountVo; } // 计算工单类型分布 @@ -104,21 +115,33 @@ public class IndexServiceImpl implements IndexService { // 计算设备类型分布 private List calculateMachineTypeDistribution(List machinesList) { - // 按 typeId 分组统计数量 - Map machineTypeCounts = machinesList.stream() - .collect(Collectors.groupingBy(Machine::getMachineTypeId, Collectors.counting())); +// // 按 typeId 分组统计数量 +// Map machineTypeCounts = machinesList.stream() +// .collect(Collectors.groupingBy(Machine::getMachineTypeId, Collectors.counting())); List result = new ArrayList<>(); - for (Map.Entry entry : machineTypeCounts.entrySet()) { - Long typeId = entry.getKey(); - Integer count = entry.getValue().intValue(); +// for (Map.Entry entry : machineTypeCounts.entrySet()) { +// Long typeId = entry.getKey(); +// Integer count = entry.getValue().intValue(); +// +// // 查询类型名称 +// MachineType machineType = machineTypeMapper.selectById(typeId); +// String type = machineType != null ? machineType.getMachineTypeName() : "未知类型"; +// // 添加到结果中 +// result.add(IndexCountVo.StatusChartVo.builder() +// .type(type) +// .quantity(count) +// .build()); +// } - // 查询类型名称 - MachineType machineType = machineTypeMapper.selectById(typeId); - String type = machineType != null ? machineType.getMachineTypeName() : "未知类型"; - // 添加到结果中 + //计算状态分布 + Map machineStateCounts = machinesList.stream() + .collect(Collectors.groupingBy(Machine::getState, Collectors.counting())); + for (Map.Entry entry : machineStateCounts.entrySet()) { + String state = entry.getKey(); + Integer count = entry.getValue().intValue(); result.add(IndexCountVo.StatusChartVo.builder() - .type(type) + .state(state) .quantity(count) .build()); }