From 09aa0d2eebbdf7d0a584323babc02c4608ab852a Mon Sep 17 00:00:00 2001
From: “linengliang” <vanSuperEnergy@163.com>
Date: 星期二, 05 九月 2023 18:10:10 +0800
Subject: [PATCH] 设备台账维护子表

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml |  182 +++++++++++++++++----------------------------
 1 files changed, 68 insertions(+), 114 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
index 683bd55..6b7de40 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
@@ -3,75 +3,44 @@
 <mapper namespace="org.jeecg.modules.eam.mapper.EamEquipmentMapper">
 
     <select id="getResumeUseRecordList"  parameterType="Map" resultType="Map">
-        SELECT DISTINCT
-            t1.id,
-            t1.num,
-            '璁惧棰嗗��' AS 'type',
-            t3.item_text AS businessType,
-            t1.create_time AS createTime,
-            t1.create_by AS createBy
-        FROM
-            mom_eam_equipment_unloading t1
-        LEFT JOIN mom_eam_equipment_unloading_borrow_detail t2 ON t1.id = t2.equipment_unloading_id
-        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
-        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
+        select * from (
+            SELECT DISTINCT
+                t1.id,
+                t1.num,
+                '璁惧璋冨叆' AS 'type',
+                t1.create_time AS createTime,
+                t1.create_by AS createBy
+            FROM
+                mom_eam_equipment_transfer t1
+            left join mom_eam_equipment_transfer_in_detail t2 on t1.id = t2.equipment_transfer_id
+            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
-        UNION All
+            UNION
 
-        SELECT DISTINCT
-            t1.id,
-            t1.num,
-            '璁惧褰掕繕' AS 'type',
-            t3.item_text AS businessType,
-            t1.create_time AS createTime,
-            t1.create_by AS createBy
-        FROM
-            mom_eam_equipment_unloading t1
-        LEFT JOIN mom_eam_equipment_unloading_return_detail t2 ON t1.id = t2.equipment_unloading_id
-        LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'business_type' ) t3 ON t3.item_value = t1.business_type
-        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
+            SELECT DISTINCT
+                t1.id,
+                t1.num,
+                '璁惧璋冨嚭' AS 'type',
+                t1.create_time AS createTime,
+                t1.create_by AS createBy
+            FROM
+                mom_eam_equipment_transfer t1
+            left join mom_eam_equipment_transfer_out_detail t2 on t1.id = t2.equipment_transfer_id
+            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
 
-        UNION All
+            UNION
 
-        SELECT DISTINCT
-            t1.id,
-            t1.num,
-            '璁惧璋冨叆' AS 'type',
-            '' as  businessType,
-            t1.create_time AS createTime,
-            t1.create_by AS createBy
-        FROM
-            mom_eam_equipment_transfer t1
-        left join mom_eam_equipment_transfer_in_detail t2 on t1.id = t2.equipment_transfer_id
-        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
-
-        UNION All
-
-        SELECT DISTINCT
-            t1.id,
-            t1.num,
-            '璁惧璋冨嚭' AS 'type',
-            '' as  businessType,
-            t1.create_time AS createTime,
-            t1.create_by AS createBy
-        FROM
-            mom_eam_equipment_transfer t1
-        left join mom_eam_equipment_transfer_out_detail t2 on t1.id = t2.equipment_transfer_id
-        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
-
-        UNION All
-
-        SELECT DISTINCT
-            t1.id,
-            t1.num,
-            '璁惧鍙樺姩' AS 'type',
-            '' as  businessType,
-            t1.create_time AS createTime,
-            t1.create_by AS createBy
-        FROM
-            mom_eam_equipment_change t1
-        left join mom_eam_equipment_change_detail t2 on t1.id = t2.equipment_change_id
-        where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
+            SELECT DISTINCT
+                t1.id,
+                t1.num,
+                '璁惧鍙樺姩' AS 'type',
+                t1.create_time AS createTime,
+                t1.create_by AS createBy
+            FROM
+                mom_eam_equipment_change t1
+            left join mom_eam_equipment_change_detail t2 on t1.id = t2.equipment_change_id
+            where t1.del_flag = '0' and t2.del_flag = '0' and t2.equipment_id = #{params.equipmentId}
+        ) as equipmentChange
     </select>
 
     <select id="getResumeInspectionRecordList"  parameterType="Map" resultType="Map">
@@ -89,61 +58,46 @@
         left join mom_base_team t3 on t1.team_id = t3.id
         left join sys_user t4 on t1.inspection_user_id = t4.id
         left join mom_eam_inspection_cycle t5 on t1.inspection_cycle_id = t5.id
-        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
+        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = ${params.equipmentId}
 
-        UNION All
-
-        SELECT DISTINCT
-            t1.id,
-            '涓撲笟鐐规' as inspectionType,
-            t1.num,
-            t1.inspection_time as inspectionTime,
-            t3.name as teamName,
-            t4.realname as inspectionUserName,
-            t1.plan_end_time as actualEndTime
-        FROM
-            mom_eam_specialty_inspection_order t1
-        LEFT JOIN mom_eam_specialty_inspection_order_detail t2 on t1.id = t2.specialty_inspection_order_id
-        left join sys_user t4 on t1.inspection_user_id = t4.id
-        left join mom_eam_specialty_inspection_plan t5 on t1.specialty_inspection_plan_id = t5.id
-        left join mom_base_team t3 on t5.team_id = t3.id
-        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t5.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
     </select>
 
     <select id="getResumeMaintenanceRecordList"  parameterType="Map" resultType="Map">
-        SELECT DISTINCT
-            t1.id,
-            '鏃ュ父淇濆吇' as maintenanceType,
-            t1.num,
-            t4.name as teamName,
-            t5.realname as maintenanceuserName,
-            t1.actual_start_time as actualStartTime,
-            t1.actual_end_time as actualEndTime
-        FROM
-            mom_eam_daily_maintenance_order t1
-        LEFT JOIN mom_eam_daily_maintenance_order_detail t2 ON t1.id = t2.daily_maintenance_order_id
-        left join mom_eam_equipment t3 on t1.equipment_id = t3.id
-        left join mom_base_team t4 on t3.team_id = t4.id
-        left join sys_user t5 on t5.id= t1.maintenance_user_id
-        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
+        select * from (
+            SELECT DISTINCT
+                t1.id,
+                '鏃ュ父淇濆吇' as maintenanceType,
+                t1.num,
+                t4.name as teamName,
+                t5.realname as maintenanceuserName,
+                t1.actual_start_time as actualStartTime,
+                t1.actual_end_time as actualEndTime
+            FROM
+                mom_eam_daily_maintenance_order t1
+            LEFT JOIN mom_eam_daily_maintenance_order_detail t2 ON t1.id = t2.daily_maintenance_order_id
+            left join mom_eam_equipment t3 on t1.equipment_id = t3.id
+            left join mom_base_team t4 on t3.team_id = t4.id
+            left join sys_user t5 on t5.id= t1.maintenance_user_id
+            WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t1.equipment_id = #{params.equipmentId}
 
-        UNION All
+            UNION
 
-        SELECT DISTINCT
-            t1.id,
-            '涓撲笟淇濆吇' AS maintenanceType,
-            t1.num,
-            t4.name as teamName,
-            t5.realname as maintenanceuserName,
-            t1.actual_start_time as actualStartTime,
-            t1.actual_end_time as actualEndTime
-        FROM
-            mom_eam_specialty_maintenance_order t1
-        left join mom_eam_specialty_maintenance_order_detail t2 on t1.id = t2.specialty_maintenance_order_id
-        left join mom_eam_equipment t3 on t2.equipment_id = t3.id
-        left join mom_base_team t4 on t3.team_id = t4.id
-        left join sys_user t5 on t5.id= t1.maintenance_user_id
-        WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
+            SELECT DISTINCT
+                t1.id,
+                '涓撲笟淇濆吇' AS maintenanceType,
+                t1.num,
+                t4.name as teamName,
+                t5.realname as maintenanceuserName,
+                t1.actual_start_time as actualStartTime,
+                t1.actual_end_time as actualEndTime
+            FROM
+                mom_eam_specialty_maintenance_order t1
+            left join mom_eam_specialty_maintenance_order_detail t2 on t1.id = t2.specialty_maintenance_order_id
+            left join mom_eam_equipment t3 on t2.equipment_id = t3.id
+            left join mom_base_team t4 on t3.team_id = t4.id
+            left join sys_user t5 on t5.id= t1.maintenance_user_id
+            WHERE t1.del_flag = '0' and t2.del_flag= '0'  and t3.del_flag= '0' and t2.equipment_id = #{params.equipmentId}
+        ) as maintenance
     </select>
 
     <select id="getResumeRepairRecordList"  parameterType="Map" resultType="Map">

--
Gitblit v1.9.3