From eb55b4133ae6b3df80d8d14fbc5b32928f296fd7 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 26 Dec 2023 14:17:07 +0800
Subject: [PATCH] bug修复

---
 src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml |   92 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 83 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml b/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
index 5f46893..b23021f 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
@@ -24,6 +24,9 @@
         jda.address_name as addressName
         from jczz_task_report_for_repairs jtrfr
         left join jczz_doorplate_address jda on jda.address_code = jtrfr.address_code
+        left join jczz_grid_range jgr on jgr.house_code = jtrfr.address_code
+        left join jczz_grid jg on jg.id = jgr.grid_id and jg.is_deleted = 0
+        left join blade_region br on br.code = jg.community_code
         where jtrfr.is_deleted = 0
         <if test="vo.createUser != null and vo.createUser != ''">
             AND jtrfr.create_user = #{vo.createUser}
@@ -39,6 +42,18 @@
         </if>
         <if test="vo.confirmFlag != null">
             AND jtrfr.confirm_flag = #{vo.confirmFlag}
+        </if>
+        <if test="vo.status != null">
+            AND jtrfr.status = #{vo.status}
+        </if>
+        <if test="vo.viewType != null">
+            AND jtrfr.view_type = #{vo.viewType}
+        </if>
+        <if test="vo.startTime != null and vo.startTime != '' and vo.endTime != null and vo.endTime != '' ">
+            AND jtrfr.create_time BETWEEN #{vo.startTime} and #{vo.endTime}
+        </if>
+        <if test="vo.regionCode != null and vo.regionCode !='' ">
+            and jg.community_code like concat('%',#{vo.regionCode},'%')
         </if>
         <if test="vo.roleName!=null and vo.roleName!=''">
             <if test="vo.roleName=='网格员'">
@@ -59,10 +74,53 @@
     </select>
 
     <!--统计查询,个人-->
+    <select id="getReportForStatistics" resultType="java.lang.Integer">
+
+        SELECT
+        COUNT( 1 )
+        FROM
+        jczz_task_report_for_repairs jtrfr
+        LEFT JOIN jczz_doorplate_address jda ON jtrfr.address_code = jda.address_code
+        WHERE
+        jda.nei_code = #{code}
+        AND jtrfr.is_deleted = 0
+        <if test="status != null">
+            and jtrfr.confirm_flag = #{status}
+        </if>
+        <if test="type != null">
+            and jtrfr.type = #{type}
+        </if>
+
+        <if test="userId != null and roleType == '1'">
+            AND jda.address_code IN (
+            SELECT DISTINCT
+            jgr.house_code
+            FROM
+            jczz_grid jg
+            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
+            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
+            WHERE
+            jgm.user_id = #{userId}
+            AND jg.is_deleted = 0
+            )
+        </if>
+        <if test="userId != null and roleType == '3'">
+            AND jda.address_code IN (SELECT
+            jda.address_code
+            FROM
+            jczz_doorplate_address jda
+            LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
+            WHERE
+            jc.res_police_user_id = #{userId})
+            )
+        </if>
+    </select>
+
+
     <select id="getStatisticsCount" resultType="org.springblade.modules.task.vo.TaskReportStatistics">
         SELECT
-            COUNT( 1 ) AS total,
-            ifnull(SUM( CASE WHEN STATUS = 10 THEN 1 ELSE 0 END ),0) AS handle
+        COUNT( 1 ) AS total,
+        ifnull(SUM( CASE WHEN STATUS = 10 THEN 1 ELSE 0 END ),0) AS handle
         FROM jczz_task_report_for_repairs
         WHERE is_deleted = 0
         <if test="userId != null">
@@ -72,19 +130,35 @@
 
 
     <select id="getStatistics" resultType="java.lang.Integer">
-
         SELECT
-            count(1)
+        count( 1 )
         FROM
-            jczz_grid_range jgr
-                LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
-                LEFT JOIN jczz_task_report_for_repairs jtr on jtr.address_code=jgr.house_code
+        jczz_task_report_for_repairs jtr
+        LEFT JOIN jczz_doorplate_address jda ON jtr.address_code = jda.address_code
         WHERE
+        jtr.is_deleted = 0
+        <if test="neiCode != null and neiCode != ''">
+            and jda.nei_code = #{neiCode}
+        </if>
+        <if test="userId != null">
+            AND jtr.address_code IN (
+            SELECT
+            jgr.house_code
+            FROM
+            jczz_grid_range jgr
+            LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
+            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
+            WHERE
             jg.is_deleted = 0
-          and jh.confirm_flag = 1
-          AND jg.user_id = #{userId}
+            AND jgm.user_id = #{userId} )
+        </if>
 
     </select>
 
+    <!--更新状态-临时接口-->
+    <update id="updateView">
+        update jczz_task_report_for_repairs set view_type = 1
+    </update>
+
 
 </mapper>

--
Gitblit v1.9.3