From 212eb8010c66c321dcdfc617725b37885573a44e Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期三, 02 七月 2025 21:20:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml |   49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml
index 3e9cef2..85d3ca7 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcDowntimeMapper.xml
@@ -2,25 +2,60 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.mdc.mapper.MdcDowntimeMapper">
 
-    <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcDowntime">
-        SELECT * FROM mdc_downtime
+    <select id="pageList" resultType="org.jeecg.modules.mdc.dto.MdcDowntimeDto">
+        SELECT
+            t1.* ,
+            t2.downtime_type downtimeType,
+            t2.downtime_description downtimeDescription
+        FROM mdc_downtime t1 LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id
         <where>
             <if test="mdcDowntimeVo.equipmentId != null and mdcDowntimeVo.equipmentId != ''">
-                AND equipment_id = #{ mdcDowntimeVo.equipmentId }
+                AND t1.equipment_id = #{ mdcDowntimeVo.equipmentId }
             </if>
             <if test="mdcDowntimeVo.equipmentName != null and mdcDowntimeVo.equipmentName != ''">
-                AND equipment_name = #{ mdcDowntimeVo.equipmentName }
+                AND t1.equipment_name = #{ mdcDowntimeVo.equipmentName }
             </if>
             <if test="mdcDowntimeVo.startTime != null and mdcDowntimeVo.startTime != '' and mdcDowntimeVo.endTime != null and mdcDowntimeVo.endTime != ''">
-                AND the_date BETWEEN #{ mdcDowntimeVo.startTime } AND #{ mdcDowntimeVo.endTime }
+                AND t1.the_date BETWEEN #{ mdcDowntimeVo.startTime } AND #{ mdcDowntimeVo.endTime }
             </if>
             <if test="mdcDowntimeVo.equipmentIdList != null and mdcDowntimeVo.equipmentIdList.size() > 0 ">
-                AND equipment_id IN
+                AND t1.equipment_id IN
                 <foreach collection="mdcDowntimeVo.equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=",">
                     #{ equipmentId }
                 </foreach>
             </if>
         </where>
-        ORDER BY create_time DESC
+        ORDER BY t1.create_time DESC
+    </select>
+
+    <select id="findPlanTimeDuration" resultType="org.jeecg.modules.mdc.entity.MdcDowntime">
+        SELECT
+            t1.*
+        FROM
+            mdc_downtime t1
+                LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id
+        WHERE
+            t1.status = 1
+            AND t1.equipment_id = #{equipmentId}
+            AND t2.downtime_type = #{closeType}
+            AND t1.the_date = #{validDate}
+    </select>
+
+    <select id="equDowntimeStatistics" resultType="org.jeecg.modules.board.vo.EquDowntimeInfo">
+        SELECT
+            t2.downtime_description AS shutdown_info,
+            SUM ( DATEDIFF( SECOND, t1.start_date, t1.end_date ) ) / 3600.0 AS duration
+        FROM
+            mdc_downtime t1
+                LEFT JOIN mdc_downtime_reason t2 ON t1.reason_id = t2.id
+        WHERE
+            t1.reason_id != ''
+            AND t1.the_date BETWEEN #{start} AND #{end}
+            AND t1.equipment_id IN
+            <foreach collection="equipmentIdList" item="equipmentId" index="index" open="(" close=")" separator=",">
+                #{ equipmentId }
+            </foreach>
+        GROUP BY
+            t2.downtime_description
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3