From 0c4986436ecf233a4fe71d4ef665bdfff8a4ef97 Mon Sep 17 00:00:00 2001
From: 邱宇豪 <qyh123230312>
Date: 星期四, 30 十一月 2023 14:04:11 +0800
Subject: [PATCH] 20231130_qiuyh_调整巡检打卡

---
 hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml |   53 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml b/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
index 47cc911..741dde0 100644
--- a/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
+++ b/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
@@ -199,9 +199,13 @@
                         <if test="regionInspectionId !=null and regionInspectionId !=''">
                             and t.regionInspectionId = #{regionInspectionId}
                         </if>
+                        <if test="userId !=null and userId !=''">
+                            and t.userId = #{userId}
+                        </if>
                         <if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
                             and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime}, "%Y-%m-%d %H:%i:%s")
                         </if>
+
         GROUP BY t.regionInspectionId,t.userId
                      )a
         WHERE 1=1
@@ -296,27 +300,42 @@
     </select>
 
     <select id="selectAppList" resultType="java.util.Map">
+        select * from (
         SELECT
-                a.id,
-                MIN( b.inspectionTime ) inspectionTime,
-                a.`status`,
-                a.task,
-                GROUP_CONCAT(DISTINCT d.region) region
-        FROM
-                t_region_inspection a
-                        LEFT JOIN t_region_inspection_record b ON b.regionInspectionId = a.id
-                        LEFT JOIN t_region_inspection_hazard_inform c ON c.regionInspectionId = a.id
-                        LEFT JOIN t_region_hazard_inform d ON c.regionHazardInformId = d.id
-                        LEFT JOIN t_region_inspection_user e on e.regionInspectionId = a.id
-        WHERE a.companyId = #{companyId} and  e.userId = #{userId}
-        <if test="status != null and status != ''">
-            and a.status = #{status}
+        tri.id,
+        t.userId ,
+        t.regionInspectionId,
+        MIN(t.inspectionTime) inspectionTime,
+        tri.task task,
+        GROUP_CONCAT(DISTINCT trhi.region) region,
+        spu.real_name realName,
+        if(
+        SUM(t.`status`)/(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE
+        regionInspectionId = t.regionInspectionId)
+        =
+        (SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId =
+        t.regionInspectionId)
+        ,1,0) status
+        from
+        t_region_inspection_record t
+        LEFT JOIN t_region_inspection tri on tri.id = t.regionInspectionId
+        LEFT JOIN t_region_inspection_hazard_inform trihi on trihi.regionInspectionId = t.regionInspectionId
+        LEFT JOIN t_region_hazard_inform trhi on trhi.id = trihi.regionHazardInformId
+        LEFT JOIN sys_plat_user spu on spu.user_id = t.userId
+        WHERE 1=1
+        <if test="userId != null and userId != ''">
+            and t.userId = #{userId}
         </if>
         <if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
-            and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime}, "%Y-%m-%d %H:%i:%s")
+            and t.inspectionTime BETWEEN str_to_date(#{startTime}, "%Y-%m-%d %H:%i:%s") and str_to_date(#{endTime},
+            "%Y-%m-%d %H:%i:%s")
         </if>
-        GROUP BY
-                a.id
+        GROUP BY t.regionInspectionId,t.userId
+    ) entity where 1=1
+        <if test="status != null and status != ''">
+            and entity.status = #{status}
+        </if>
+
     </select>
 
     <select id="selectPlatUserId" resultType="java.lang.String">

--
Gitblit v1.9.3