From 7bcd0d2d7510cb2ba67099cd768e1b2b6d047dc2 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 22 Feb 2024 17:16:27 +0800
Subject: [PATCH] 投票人员查询优化

---
 src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml |   57 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 33 insertions(+), 24 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 e7b0ec4..65b29b2 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
@@ -208,39 +208,48 @@
             AND jtrfr.create_time BETWEEN #{vo.startTime} and #{vo.endTime}
         </if>
         <if test="isAdministrator==2">
-            <choose>
-                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
-                    and jg.community_code in
-                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
-                        #{code}
+            <!-- 物业和居民 -->
+            <if test="vo.roleType !=null and (vo.roleType == 'wy' or vo.roleType == 'inhabitant')">
+                <if test="aoiCodeList!=null and aoiCodeList.size()>0">
+                    and jda.aoi_code in
+                    <foreach collection="aoiCodeList" item="item" separator="," open="(" close=")">
+                        #{item}
                     </foreach>
-                </when>
-            </choose>
-        </if>
-        <if test="vo.roleName!=null and vo.roleName!=''">
-            <if test="vo.roleName=='网格员'">
+                </if>
+
+                <if test="vo.roleType == 'wy' and vo.confirmUserId != null ">
+                    and jtrfr.confirm_user_id = #{vo.confirmUserId}
+                </if>
+            </if>
+            <!-- 网格员及其他 -->
+            <if test="vo.roleType ==null">
                 <choose>
-                    <when test="list != null and list.size()>0">
-                        and (jda.address_code in
-                        <foreach collection="list" item="houseCode" separator="," open="(" close=")">
-                            #{houseCode}
+                    <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                        and jg.grid_code in
+                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                            #{code}
                         </foreach>
-                        or jtrfr.confirm_user_id = #{vo.confirmUserId})
+                    </when>
+                </choose>
+
+                <choose>
+                    <when test="gridCodeList !=null and gridCodeList.size()>0">
+                        and jg.grid_code in
+                        <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+                            #{code}
+                        </foreach>
                     </when>
                     <otherwise>
-                        and (jtrfr.confirm_user_id = #{vo.confirmUserId})
+                        and jg.grid_code in ('')
                     </otherwise>
                 </choose>
+
+                <if test="vo.confirmUserId != null ">
+                    and jtrfr.confirm_user_id = #{vo.confirmUserId}
+                </if>
+
             </if>
         </if>
-
-        <if test="aoiCodeList!=null and aoiCodeList.size()>0">
-            and jda.aoi_code in
-            <foreach collection="aoiCodeList" item="item" separator="," open="(" close=")">
-                #{item}
-            </foreach>
-        </if>
-
         ORDER BY jtrfr.create_time DESC
     </select>
 

--
Gitblit v1.9.3