From d39c0479c9ddd38dc36b3c2e29a4e5a3b24fd3d7 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期二, 02 七月 2024 17:06:28 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml |   63 +++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml b/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
index bce9660..9997a88 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/DeviceMaintenance.xml
@@ -63,10 +63,71 @@
     </insert>
 
     <select id="selectMaintenanceMp" resultMap="DeviceMaintenanceMapper">
-        select * from device_maintenance
+        select id,
+               device_id,
+               device_name,
+               type,
+               date(fault_time) as fault_time,
+               fault_reason,
+               date(maintenance_time) as maintenance_time,
+               maintenance_illustrate,
+               date(start_time) as start_time,
+               date(stop_time) as stop_time,
+               process,
+               personnel,
+               cost
+        from device_maintenance
+        where DATE_FORMAT((create_time), '%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
     </select>
 
     <delete id="deleteMaintenanceMp">
         delete from device_maintenance where id = #{id}
     </delete>
+
+    <select id="selectMachineMp">
+        select dm.device_id,dm.device_name,
+        if(dm.type=1,'缁翠慨','淇濆吇') as type,
+        (select count(*) from device_maintenance where id = dm.id and type = 1) as faultCount,
+        (select count(*) from device_maintenance where id = dm.id and type = 2) as maintenanceCount,
+        (select date(fault_time) from device_maintenance where id = dm.id and type = 1 order by fault_time desc limit 1) as faultLastTime,
+        (select date(maintenance_time) from device_maintenance where id = dm.id and type = 2 order by maintenance_time desc limit 1) as maintenanceLastTime,
+        (select sum(cost) from device_maintenance where id = dm.id and dm.type=1) as faultCost,
+        (select sum(cost) from device_maintenance where id = dm.id and dm.type=2) as maintenanceCost,
+        dm.process
+        from device_maintenance as dm
+        group by dm.device_id
+
+    </select>
+
+    <select id="openSelectIdMp">
+    select id,
+           device_id,
+           device_name,
+           type,
+           date(fault_time) as fault_time,
+           fault_reason,
+           date(maintenance_time) as maintenance_time,
+           maintenance_illustrate,
+           date(start_time) as start_time,
+           date(stop_time) as stop_time,
+           process,
+           personnel,
+           cost from device_maintenance where id = #{id}
+    </select>
+
+    <update id="updateMaintenanceMp">
+        update device_maintenance set
+        device_name = #{deviceName},
+        type = #{type},
+        fault_time = #{faultTime},
+        fault_reason = #{faultReason},
+        maintenance_time = #{maintenanceTime},
+        maintenance_illustrate = #{maintenanceIllustrate},
+        start_time = #{startTime},
+        stop_time = #{stopTime},
+        process = #{process},
+        personnel = #{personnel},
+        cost = #{cost}
+        where id = #{id}
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0