From 2c783432245859f3ee745e4e9d8cc98dfa7c0865 Mon Sep 17 00:00:00 2001
From: 邱宇豪 <qyh123230312>
Date: 星期二, 21 十一月 2023 11:28:46 +0800
Subject: [PATCH] 20231121_qiuyh_调整巡检打卡、防患举报导出

---
 hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml b/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
index 988783d..0bae3bf 100644
--- a/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
+++ b/hd/pipe/secure/src/main/resources/mapping/RegionInspectionRecordMapper.xml
@@ -165,7 +165,7 @@
                 a.task,
                 a.region,
                 a.realName,
-                IF(a.completeRegionNum = a.needRegionNum,"完成","未完成") statusName,
+                IF(a.completeRegionNum = a.needRegionNum,"已完成","待巡检") statusName,
                 IF(a.completeRegionNum = a.needRegionNum,1,0) status
         FROM (
                      SELECT
@@ -193,21 +193,63 @@
                         <if test="regionInspectionId !=null and regionInspectionId !=''">
                             and t.regionInspectionId = #{regionInspectionId}
                         </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
-        <if test="status !=null and status !='' and status ==0">
+        <if test="intStatus!=null and intStatus ==0">
             and a.completeRegionNum != a.needRegionNum
         </if>
-        <if test="status !=null and status !='' and status ==1">
+        <if test="intStatus!=null and intStatus ==1">
             and a.completeRegionNum = a.needRegionNum
         </if>
-        <if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
-            and a.inspectionTime BETWEEN #{startTime} and #{endTime}
+        <if test="page != null and limit != null">
+            limit #{page},#{limit}
         </if>
     </select>
-
+    <select id="selectCount" resultType="java.lang.Integer">
+        SELECT  count(0)
+        FROM (
+                SELECT
+                    t.userId ,
+                    t.regionInspectionId,
+                    MIN(t.inspectionTime) inspectionTime,
+                    tri.task task,
+                    GROUP_CONCAT(DISTINCT trhi.region) region,
+                    spu.real_name realName,
+                    SUM(t.`status`)/(SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId =  t.regionInspectionId) completeRegionNum,
+                    (SELECT count(regionInspectionId) FROM t_region_inspection_hazard_inform WHERE regionInspectionId =  t.regionInspectionId) needRegionNum
+                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="realName !=null and realName !=''">
+                    and spu.real_name REGEXP #{realName}
+                </if>
+                <if test="companyId !=null and companyId !=''">
+                    and tri.companyId = #{companyId}
+                </if>
+                <if test="regionInspectionId !=null and regionInspectionId !=''">
+                    and t.regionInspectionId = #{regionInspectionId}
+                </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
+        <if test="intStatus!=null and intStatus ==0">
+            and a.completeRegionNum != a.needRegionNum
+        </if>
+        <if test="intStatus!=null and intStatus ==1">
+            and a.completeRegionNum = a.needRegionNum
+        </if>
+    </select>
     <select id="selectInfo" resultType="com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionEntity">
         SELECT
                 t.id regionInspectionId,
@@ -263,7 +305,7 @@
             and a.status = #{status}
         </if>
         <if test="startTime != null and endTime != null and startTime !='' and endTime != ''">
-            and b.inspectionTime BETWEEN #{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
                 a.id

--
Gitblit v1.9.3