From 8b7258c9427882bb1798f1502eaa35184c6e374e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 09 Aug 2024 14:29:18 +0800
Subject: [PATCH] 短信指定楼栋发送

---
 src/main/java/org/springblade/modules/task/mapper/TaskPlaceRectificationMapper.xml |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 102 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskPlaceRectificationMapper.xml b/src/main/java/org/springblade/modules/task/mapper/TaskPlaceRectificationMapper.xml
index 96aadd7..a257b77 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskPlaceRectificationMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskPlaceRectificationMapper.xml
@@ -193,8 +193,8 @@
         jp.principal,
         jp.principal_phone,
         jp.nine_type,
-        br.town_name,
-        br.village_name,
+        br.town_name streetName,
+        br.village_name communityName,
         bu.`name`,
         jpe.legal_tel,
         jpe.legal_person,
@@ -203,17 +203,17 @@
         jczz_task_place_rectification jtpr
         LEFT JOIN jczz_place jp ON jtpr.house_code = jp.house_code and jp.is_deleted = 0
         LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code and jg.is_deleted = 0
-        LEFT JOIN blade_region br ON br.`code` = jg.community_code
-        LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id
-        LEFT JOIN blade_user bu ON bu.id = jtpr.create_user
-        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code
+        LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id and jpe.is_deleted = 0
+        LEFT JOIN blade_user bu ON bu.id = jtpr.create_user and bu.is_deleted = 0
+        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        LEFT JOIN blade_region br ON br.`code` = jpag.community_code
         <where>
             <if test="taskPalce.id != null ">and jtpr.id = #{taskPalce.id}</if>
             <if test="taskPalce.placeCheckId != null ">and jtpr.place_check_id = #{taskPalce.placeCheckId}</if>
             <if test="taskPalce.taskId != null ">and jtpr.task_id = #{taskPalce.taskId}</if>
             <if test="taskPalce.status != null and taskPalce.status != 2  ">and jtpr.status = #{taskPalce.status}</if>
 
-            <if test="taskPalce.status != null and taskPalce.status = 2 ">and jtpr.status in (2,3)</if>
+            <if test="taskPalce.status != null and taskPalce.status == 2 ">and jtpr.status in (2,3)</if>
 
             <if test="taskPalce.taskName != null  and taskPalce.taskName != ''">and jtpr.task_name =
                 #{taskPalce.taskName}
@@ -224,6 +224,14 @@
             </if>
             <if test="taskPalce.endTime!=null and taskPalce.endTime!=''">
                 and jtpr.create_time&lt;=#{taskPalce.endTime}
+            </if>
+
+            <if test="taskPalce.streetName!=null and taskPalce.streetName!=''">
+                and br.town_name like concat('%',#{taskPalce.streetName},'%')
+            </if>
+
+            <if test="taskPalce.communityName!=null and taskPalce.communityName!=''">
+                and br.village_name like concat('%',#{taskPalce.communityName},'%')
             </if>
 
             <if test="taskPalce.placeName!=null and taskPalce.placeName!=''">
@@ -331,7 +339,7 @@
                             <otherwise>
                                 and
                                 (
-                                jg.grid_code in ('') or jpag.community_code in in ('')
+                                jg.grid_code in ('') or jpag.community_code in ('')
                                 )
                             </otherwise>
                         </choose>
@@ -466,8 +474,8 @@
         jp.principal,
         jp.principal_phone,
         jp.nine_type,
-        br.town_name,
-        br.village_name,
+        br.town_name streetName,
+        br.village_name communityName,
         bu.`name`,
         jpe.legal_tel,
         jpe.legal_person,
@@ -484,7 +492,10 @@
             <if test="taskPalce.id != null ">and jtpr.id = #{taskPalce.id}</if>
             <if test="taskPalce.placeCheckId != null ">and jtpr.place_check_id = #{taskPalce.placeCheckId}</if>
             <if test="taskPalce.taskId != null ">and jtpr.task_id = #{taskPalce.taskId}</if>
-            <if test="taskPalce.status != null ">and jtpr.status = #{taskPalce.status}</if>
+            <if test="taskPalce.status != null and taskPalce.status != 2  ">and jtpr.status = #{taskPalce.status}</if>
+
+            <if test="taskPalce.status != null and taskPalce.status == 2 ">and jtpr.status in (2,3)</if>
+
             <if test="taskPalce.taskName != null  and taskPalce.taskName != ''">and jtpr.task_name =
                 #{taskPalce.taskName}
             </if>
@@ -494,6 +505,14 @@
             </if>
             <if test="taskPalce.endTime!=null and taskPalce.endTime!=''">
                 and jtpr.create_time&lt;=#{taskPalce.endTime}
+            </if>
+
+            <if test="taskPalce.streetName!=null and taskPalce.streetName!=''">
+                and br.town_name like concat('%',#{taskPalce.streetName},'%')
+            </if>
+
+            <if test="taskPalce.communityName!=null and taskPalce.communityName!=''">
+                and br.village_name like concat('%',#{taskPalce.communityName},'%')
             </if>
 
             <if test="taskPalce.placeName!=null and taskPalce.placeName!=''">
@@ -601,7 +620,7 @@
                             <otherwise>
                                 and
                                 (
-                                jg.grid_code in ('') or jpag.community_code in in ('')
+                                jg.grid_code in ('') or jpag.community_code in ('')
                                 )
                             </otherwise>
                         </choose>
@@ -613,12 +632,77 @@
     </select>
 
     <select id="getCount" resultType="java.lang.Integer">
-        SELECT count(1)
-        FROM jczz_task_place_rectification jtpr
-                 LEFT JOIN jczz_place jp ON jp.house_code = jtpr.house_code
-        WHERE jp.jw_grid_code IN
-              (SELECT jpag.jw_grid_code FROM jczz_police_affairs_grid jpag WHERE jpag.police_user_id like concat('%',${userId},'%'))
-          AND jtpr.`status` = 1
+
+        SELECT   count(1)
+        FROM
+        jczz_task_place_rectification jtpr
+        LEFT JOIN jczz_place jp ON jtpr.house_code = jp.house_code
+        LEFT JOIN jczz_grid jg ON jg.grid_code = jp.grid_code
+        LEFT JOIN blade_region br ON br.`code` = jg.community_code
+        LEFT JOIN jczz_place_ext jpe ON jpe.place_id = jp.id
+        LEFT JOIN blade_user bu ON bu.id = jtpr.create_user
+        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code
+        <where>
+            <if test="taskPalce.communityCode != null ">and jg.community_code = #{taskPalce.communityCode}</if>
+            <if test="taskPalce.status != null ">and jtpr.status = #{taskPalce.status}</if>
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="taskPalce.roleName != null and taskPalce.roleName != ''">
+                        <if test="taskPalce.roleName=='wgy'">
+                            <choose>
+                                <when test="gridCodeList !=null and gridCodeList.size()>0">
+                                    and jp.grid_code in
+                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jp.grid_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                        <if test="taskPalce.roleName=='mj'">
+                            <choose>
+                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                                    and br.village_code in
+                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
+                                             separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and br.village_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                    </when>
+                    <otherwise>
+                        <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
+                                jpag.community_code in
+                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                    #{code}
+                                </foreach>
+                                )
+                            </when>
+                            <otherwise>
+                                and
+                                (
+                                jg.grid_code in ('') or jpag.community_code in ('')
+                                )
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
+        </where>
     </select>
 
 

--
Gitblit v1.9.3