From 26b8dfb43e9b9d3eb13c04208ad3d6a43c6cb473 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 02 三月 2026 17:18:46 +0800
Subject: [PATCH] 设备管理查询优化

---
 src/main/resources/mapper/device/DeviceMaintenanceMapper.xml |   42 +++++++++++++++++++++++++++++-------------
 1 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/src/main/resources/mapper/device/DeviceMaintenanceMapper.xml b/src/main/resources/mapper/device/DeviceMaintenanceMapper.xml
index 7046102..4336014 100644
--- a/src/main/resources/mapper/device/DeviceMaintenanceMapper.xml
+++ b/src/main/resources/mapper/device/DeviceMaintenanceMapper.xml
@@ -5,8 +5,28 @@
 
 <mapper namespace="com.ruoyi.device.mapper.DeviceMaintenanceMapper">
 
-    <select id="queryPage" resultType="com.ruoyi.device.dto.DeviceMaintenanceDto">
-        select dm.id,
+    <resultMap id="deviceMaintenanceResultMap" type="com.ruoyi.device.dto.DeviceMaintenanceDto">
+        <id property="id" column="id"/>
+        <result property="deviceLedgerId" column="device_ledger_id"/>
+        <result property="maintenancePlanTime" column="maintenance_plan_time"/>
+        <result property="maintenanceActuallyTime" column="maintenance_actually_time"/>
+        <result property="status" column="status"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="createUser" column="create_user"/>
+        <result property="updateUser" column="update_user"/>
+        <result property="tenantId" column="tenant_id"/>
+        <result property="maintenanceActuallyName" column="maintenance_actually_name"/>
+        <result property="deviceName" column="device_name"/>
+        <result property="deviceModel" column="device_model"/>
+        <result property="createUserName" column="create_user_name"/>
+        <result property="imagesFile" column="images_file"
+                typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
+    </resultMap>
+
+    <select id="queryPage" resultMap="deviceMaintenanceResultMap">
+        select
+        dm.id,
         dm.device_ledger_id,
         dm.maintenance_plan_time,
         dm.maintenance_actually_time,
@@ -20,31 +40,27 @@
         dm.maintenance_actually_name,
         dl.device_name,
         dl.device_model,
-        su.nick_name as create_user_name
+        dm.spare_parts_ids,
+        su.nick_name as create_user_name,
+        dm.images_file
         from device_maintenance dm
         left join device_ledger dl on dm.device_ledger_id = dl.id
         left join sys_user su on dm.create_user = su.user_id
         <where>
             1 = 1
-            <if test="deviceMaintenanceDto.deviceName != null">
+            <if test="deviceMaintenanceDto.deviceName != null and deviceMaintenanceDto.deviceName != ''">
                 and dl.device_name like concat('%',#{deviceMaintenanceDto.deviceName},'%')
             </if>
-            <if test="deviceMaintenanceDto.deviceModel != null">
+            <if test="deviceMaintenanceDto.deviceModel != null and deviceMaintenanceDto.deviceModel != ''">
                 and dl.device_model like concat('%',#{deviceMaintenanceDto.deviceModel},'%')
             </if>
             <if test="deviceMaintenanceDto.status != null">
                 and dm.status = #{deviceMaintenanceDto.status}
             </if>
-            <if test="deviceMaintenanceDto.maintenanceActuallyName != null">
+            <if test="deviceMaintenanceDto.maintenanceActuallyName != null and deviceMaintenanceDto.maintenanceActuallyName != ''">
                 and dm.maintenance_actually_name like concat('%',#{deviceMaintenanceDto.maintenanceActuallyName},'%')
             </if>
-            <if test="deviceMaintenanceDto.maintenancePlanTimeReq != null">
-                and dm.maintenance_plan_time like concat('%',#{deviceMaintenanceDto.maintenancePlanTimeReq},'%')
-            </if>
-            <if test="deviceMaintenanceDto.maintenanceActuallyTimeReq != null">
-                and dm.maintenance_actually_time like concat('%',#{deviceMaintenanceDto.maintenanceActuallyTimeReq},'%')
-            </if>
-            <if test="deviceMaintenanceDto.maintenanceActuallyTime != null">
+            <if test="deviceMaintenanceDto.maintenanceActuallyTime != null and deviceMaintenanceDto.maintenanceActuallyTime != ''">
                 and dm.maintenance_actually_time >= str_to_date(#{deviceMaintenanceDto.maintenanceActuallyTime}, '%Y-%m-%d')
                 and dm.maintenance_actually_time &lt; date_add(str_to_date(#{deviceMaintenanceDto.maintenanceActuallyTime}, '%Y-%m-%d'), interval 1 day)
             </if>

--
Gitblit v1.9.3