From 891442cd642c035ea7fbf65c3136509f97e24f0b Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 29 一月 2026 16:01:11 +0800
Subject: [PATCH] bug修改

---
 ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml b/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
index 407ec7a..35a5a7b 100644
--- a/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
@@ -52,12 +52,19 @@
         left join (
         select device_id, max(create_time) as record_time
         from record
+        where device_id is not null and deleted = 0 and record_type ='error'
         group by device_id
         ) latest on t2.id = latest.device_id
         left join project t3 on t1.project_id = t3.id
-        where  t1.deleted = 0 and t1.disabled = 0 and t3.client_id =#{query.clientId}
+        where  1=1
         <if test="query.projectId != null">
             and t1.project_id = #{query.projectId}
+        </if>
+        <if test="query.projectIds != null">
+            and t1.project_id in
+            <foreach item="item" index="index" collection="query.projectIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
         </if>
         <if test="query.type != null">
             and t2.type = #{query.type}
@@ -84,8 +91,22 @@
         group by project_id
         order by create_time desc
         ) result on t1.id = result.project_id
-        where t1.deleted = 0 and t1.status =1 and t1.type!=2 and t1.client_id =#{query.clientId}
-
+        where t1.deleted = 0 and t1.status =1
+        <if test="query.category == 1">
+            and t1.status = #{query.category}
+        </if>
+        <if test="query.category == 2">
+            and t1.type = #{query.category}
+        </if>
+        <if test="query.clientId != null">
+            and t1.client_id = #{query.clientId}
+        </if>
+        <if test="query.projectIds != null">
+            and t1.id in
+            <foreach item="item" index="index" collection="query.projectIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="query.projectId != null">
             and t1.id = #{query.projectId}
         </if>
@@ -93,16 +114,10 @@
             and t1.type = #{query.type}
         </if>
         <if test="query.riskLevel != null">
-            and result.risk_level = #{query.riskLevel}
+            and `result`.risk_level = #{query.riskLevel}
         </if>
         <if test="query.name!= null and query.name!=''">
-            and t1.name like CONCAT('%', #{query.content}, '%')
-        </if>
-        <if test="query.startTime != null and query.startTime != ''">
-            and latest.record_time >= #{query.startTime}
-        </if>
-        <if test="query.endTime != null and query.endTime != ''">
-            and #{query.endTime} >=latest.record_time
+            and t1.name like CONCAT('%', #{query.name}, '%')
         </if>
         GROUP BY t1.id
         order by t1.create_time desc

--
Gitblit v1.7.1