From 01fb223437289f8d81d6bc9645844947669c0721 Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期六, 24 一月 2026 18:32:32 +0800
Subject: [PATCH] fix:大屏接口联调修改

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
index 80c1689..ed7b47c 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
@@ -88,8 +88,7 @@
                     .eq(Project::getStatus, 1)  // 在建项目
                     .or(w -> w
                         .eq(Project::getStatus, 2)  // 已完成项目
-                        .ge(Project::getSuccessTime, monthStart)  // 完成时间 >= 开始日期
-                        .le(Project::getSuccessTime, monthEnd)    // 完成时间 <= 结束日期
+                        .ge(Project::getSuccessTime, monthStart)  // 完成时间 >= 开始日期// 完成时间 <= 结束日期
                     )
                 );
         if (clientId != null) {
@@ -225,16 +224,15 @@
     private FixedAssetDashboardVO calculateFixedAssetStatistics(Long clientId, Date monthStart, Date monthEnd) {
         FixedAssetDashboardVO vo = new FixedAssetDashboardVO();
 
-        // 查询固定资产项目(usage_type 表示项目用途类型,假设 1 表示固定资产)
+        // 查询固定资产项目
         LambdaQueryWrapper<Project> projectWrapper = new LambdaQueryWrapper<>();
         projectWrapper.eq(Project::getDeleted, false)
-                .eq(Project::getUsageType, 1) // 固定资产
+                .eq(Project::getType, 2) // 固定资产
                 .and(wrapper -> wrapper
                     .eq(Project::getStatus, 1)  // 在建项目
                     .or(w -> w
                         .eq(Project::getStatus, 2)  // 已完成项目
                         .ge(Project::getSuccessTime, monthStart)  // 完成时间 >= 开始日期
-                        .le(Project::getSuccessTime, monthEnd)    // 完成时间 <= 结束日期
                     )
                 );
         if (clientId != null) {
@@ -443,24 +441,37 @@
         log.debug("设备按类型分组完成,共 {} 种类型", deviceGroupMap.size());
 
         // 查询设备检查记录
-        List<Integer> deviceUsageIds = devices.stream()
-                .map(DeviceUsage::getId)
-                .collect(Collectors.toList());
+        // 建立 device.id 到 device_usage.id 的映射
+        Map<Integer, List<Integer>> deviceToUsageMap = devices.stream()
+                .filter(d -> d.getDeviceId() != null)
+                .collect(Collectors.groupingBy(
+                        DeviceUsage::getDeviceId,
+                        Collectors.mapping(DeviceUsage::getId, Collectors.toList())
+                ));
+
         Map<Integer, Boolean> deviceInspectionMap = new HashMap<>();
-        if (!deviceUsageIds.isEmpty()) {
+        if (!deviceIds.isEmpty()) {
             LambdaQueryWrapper<Record> recordWrapper = new LambdaQueryWrapper<>();
             recordWrapper.eq(Record::getRecordType, "error")
                     .isNotNull(Record::getDeviceId)
-                    .in(Record::getDeviceId, deviceUsageIds)
+                    .in(Record::getDeviceId, deviceIds)
                     .eq(Record::getDeleted, false);
             List<Record> records = recordMapper.selectList(recordWrapper);
 
+            // 获取已检查的 device.id 集合
             Set<Integer> inspectedDeviceIds = records.stream()
                     .map(Record::getDeviceId)
                     .collect(Collectors.toSet());
 
-            for (Integer deviceUsageId : deviceUsageIds) {
-                deviceInspectionMap.put(deviceUsageId, inspectedDeviceIds.contains(deviceUsageId));
+            // 通过映射关系,将 device.id 的检查状态映射到 device_usage.id
+            for (Map.Entry<Integer, List<Integer>> entry : deviceToUsageMap.entrySet()) {
+                Integer deviceId = entry.getKey();
+                boolean isInspected = inspectedDeviceIds.contains(deviceId);
+
+                // 将该设备的检查状态应用到所有使用该设备的 device_usage 记录
+                for (Integer usageId : entry.getValue()) {
+                    deviceInspectionMap.put(usageId, isInspected);
+                }
             }
         }
 

--
Gitblit v1.7.1