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/TaskMapper.xml |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskMapper.xml b/src/main/java/org/springblade/modules/task/mapper/TaskMapper.xml
index 1d2bf3b..971cc51 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskMapper.xml
@@ -29,6 +29,8 @@
         br.town_code streetCode,
         jp.principal as realName,
         jp.principal_phone as phone,
+        jp.nine_type ,
+        jp.front_type ,
         jt.id,
         jt.NAME,
         jt.type,
@@ -123,7 +125,7 @@
                 and br.town_code = #{task.streetCode}
             </if>
             <if test="task.realName != null and task.realName != null">
-                and bu.name like concat('%', #{task.realName}, '%')
+                and jp.principal like concat('%', #{task.realName}, '%')
             </if>
             <if test="task.phone != null and task.phone != null">
                 and bu.phone like concat('%', #{task.phone}, '%')
@@ -147,8 +149,8 @@
                 AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
             </if>
             <!-- 场所店铺 -->
-            <if test="task.reportType != null and task.reportType == 2 ">
-                and jt.report_type in (2,3,4,5,6,7,8)
+            <if test="task.reportType != null">
+                and jt.report_type = #{task.reportType}
             </if>
             <if test="task.reportType == null">
                 and jt.report_type in (2,3,4,5,6,7,8)
@@ -185,8 +187,7 @@
         jczz_task jt
         LEFT JOIN jczz_house jh ON jt.house_code=jh.house_code and jh.is_deleted = 0
         LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0
-        LEFT JOIN jczz_grid_range jgr on jgr.house_code= jt.house_code
-        LEFT JOIN jczz_grid jg on jg.id = jgr.grid_id and jg.is_deleted = 0
+        LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0
         LEFT JOIN blade_region br on br.code = jg.community_code
         <where>
             <if test="task.roleName != null and task.roleName != ''">
@@ -218,6 +219,30 @@
                         </otherwise>
                     </choose>
                 </if>
+            </if>
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                        and
+                        (
+                        jg.grid_code in
+                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                            #{code}
+                        </foreach>
+                        or
+                        br.village_code in
+                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                            #{code}
+                        </foreach>
+                        )
+                    </when>
+                    <otherwise>
+                        and
+                        (
+                        jg.grid_code in ('') or br.village_code in ('')
+                        )
+                    </otherwise>
+                </choose>
             </if>
             <if test="task.status != null and task.status != null">
                 and jt.status = #{task.status}
@@ -269,7 +294,6 @@
                 and jt.report_type = #{task.reportType}
             </if>
             and jt.is_deleted = 0
-            and jt.house_code is not null
             order by jt.create_time desc
         </where>
     </select>

--
Gitblit v1.9.3