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/place/mapper/PlacePractitionerMapper.xml |  259 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 217 insertions(+), 42 deletions(-)

diff --git a/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml b/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml
index f243d1c..c2bd26a 100644
--- a/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml
+++ b/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml
@@ -10,28 +10,42 @@
         jpp.name,
         jpp.telephone,
         jpp.temp_address,
-        TRUNCATE( DATEDIFF( CURDATE(), jpp.birthday )/ 365.2422,0 ) age,
+        TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) as age,
         jpp.gender,
         jpp.id_card,
-        jpp.card_type,
         jp.place_name employer,
-        jpp.registered_address,
-        jpp.job_nature,
         jpp.employer_img,
-        jpp.wx_account,
         jpp.create_time,
-        jpp.birthday,
         jpp.ethnicity,
         jpp.is_deleted,
         jpp.criminal_record_flag,
         jpp.fake_id_card,
+        jpp.employment_time,
+        jpp.resignation_time,
+        jpp.resignation_flag,
+        jpp.confirm_user_id,
+        jpp.confirm_flag,
+        jpp.confirm_time,
+        jpp.confirm_notion,
+        br.town_name as townStreetName,
+        br.name as neiName,
+        jp.place_name,
+        jp.location,
         jc.category_name
         FROM
         jczz_place_practitioner jpp
         LEFT JOIN jczz_place jp ON jp.id = jpp.place_id
         LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
         LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
+        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="placePractitioner.townStreetName!=null and placePractitioner.townStreetName!=''">
+                and br.town_name like concat('%',#{placePractitioner.townStreetName},'%')
+            </if>
+            <if test="placePractitioner.neiName!=null and placePractitioner.neiName!=''">
+                and br.name like concat('%',#{placePractitioner.neiName},'%')
+            </if>
             <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
             <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
             <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
@@ -40,7 +54,6 @@
             </if>
             <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
                 concat('%', #{placePractitioner.telephone},'%')
-
             </if>
             <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
                 jpp.temp_address =
@@ -51,42 +64,70 @@
             <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
                 #{placePractitioner.idCard}
             </if>
-            <if test="placePractitioner.cardType != null  and placePractitioner.cardType != ''">and jpp.card_type =
-                #{placePractitioner.cardType}
+            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
+                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
             </if>
-            <if test="placePractitioner.employer != null  and placePractitioner.employer != ''">and jpp.employer =
-                #{placePractitioner.employer}
-            </if>
-            <if test="placePractitioner.registeredAddress != null  and placePractitioner.registeredAddress != ''">and
-                jpp.registered_address = #{placePractitioner.registeredAddress}
-            </if>
-            <if test="placePractitioner.jobNature != null  and placePractitioner.jobNature != ''">and jpp.job_nature =
-                #{placePractitioner.jobNature}
-            </if>
+
             <if test="placePractitioner.employerImg != null  and placePractitioner.employerImg != ''">and
                 jpp.employer_img =
                 #{placePractitioner.employerImg}
             </if>
-            <if test="placePractitioner.wxAccount != null  and placePractitioner.wxAccount != ''">and jpp.wx_account =
-                #{placePractitioner.wxAccount}
-            </if>
+
             <if test="placePractitioner.createTime != null ">and jpp.create_time = #{placePractitioner.createTime}</if>
-            <if test="placePractitioner.birthday != null ">and jpp.birthday = #{placePractitioner.birthday}</if>
             <if test="placePractitioner.ethnicity != null ">and jpp.ethnicity = #{placePractitioner.ethnicity}</if>
 
+            <if test="placePractitioner.confirmUserId != null "> and confirm_user_id = #{placePractitioner.confirmUserId}</if>
+            <if test="placePractitioner.confirmFlag != null "> and confirm_flag = #{placePractitioner.confirmFlag}</if>
+            <if test="placePractitioner.confirmTime != null "> and confirm_time = #{placePractitioner.confirmTime}</if>
+            <if test="placePractitioner.confirmNotion != null  and placePractitioner.confirmNotion != ''"> and confirm_notion = #{placePractitioner.confirmNotion}</if>
+
             <if test="placePractitioner.type == 1">
-                and (CURDATE() &lt; DATE_ADD( jpp.birthday, INTERVAL 18 YEAR )
-                and jc.category_no in (180202,180201)
+                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
+                and jc.category_no in (180202,180201,180200)
             </if>
             <if test="placePractitioner.type == 2">
                 and jpp.ethnicity != 1
-                and jc.category_no in (180202,180201)
+                and jc.category_no in (180202,180201,180200)
             </if>
             <if test="placePractitioner.type == 3">
-                and (CURDATE() &lt; DATE_ADD( jpp.birthday, INTERVAL 18 YEAR ) or ( jpp.ethnicity != 1))
-                and jc.category_no in (180202,180201)
+                and (TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18  or jpp.ethnicity != 1)
+                and jc.category_no in (180202,180201,180200)
+            </if>
+
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="placePractitioner.roleName != null and placePractitioner.roleName != ''">
+                        <if test="placePractitioner.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="placePractitioner.roleName=='mj'">
+                            <choose>
+                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                                    and jpag.community_code in
+                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jpag.community_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                    </when>
+                </choose>
             </if>
             and jpp.is_deleted = 0
+            GROUP BY jpp.place_id
             order by jpp.id desc
         </where>
     </select>
@@ -101,13 +142,16 @@
         <result property="age" column="age"/>
         <result property="gender" column="gender"/>
         <result property="idCard" column="id_card"/>
-        <result property="cardType" column="card_type"/>
-        <result property="employer" column="employer"/>
-        <result property="registeredAddress" column="registered_address"/>
         <result property="jobNature" column="job_nature"/>
         <result property="employerImg" column="employer_img"/>
-        <result property="wxAccount" column="wx_account"/>
         <result property="createTime" column="create_time"/>
+        <result property="ethnicity" column="ethnicity"/>
+        <result property="isDeleted" column="is_deleted"/>
+        <result property="criminalRecordFlag" column="criminal_record_flag"/>
+        <result property="fakeIdCard" column="fake_id_card"/>
+        <result property="anoTypeName" column="ano_type_name"/>
+        <result property="employmentTime" column="employment_time"/>
+        <result property="resignationTime" column="resignation_time"/>
     </resultMap>
 
     <sql id="selectJczzPlacePractitioner">
@@ -119,15 +163,16 @@
                age,
                gender,
                id_card,
-               card_type,
-               employer,
-               registered_address,
                job_nature,
                employer_img,
-               wx_account,
                create_time,
-               birthday,
-               ethnicity
+               ethnicity,
+               is_deleted,
+               criminal_record_flag,
+               fake_id_card,
+               ano_type_name,
+               employment_time,
+               resignation_time
         from jczz_place_practitioner
     </sql>
 
@@ -140,17 +185,147 @@
         LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
         LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
         <where>
-            <if test="type == 1">
-                and (CURDATE() &lt; DATE_ADD( jpp.birthday, INTERVAL 18 YEAR ) or ( jpp.ethnicity != 1))
-                and jc.category_no in (180202,180201)
+            <if test="placePractitioner.type == 1">
+                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
+                and jc.category_no in (180202,180201,180200)
             </if>
-            <if test="type == 2">
+            <if test="placePractitioner.type == 2">
                 and jpp.ethnicity != 1
-                and jc.category_no in (180202,180201)
+                and jc.category_no in (180202,180201,180200)
+            </if>
+            <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
+            <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
+            <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
+                #{placePractitioner.name},'%')
+            </if>
+            <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
+                concat('%', #{placePractitioner.telephone},'%')
+
+            </if>
+            <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
+                jpp.temp_address =
+                #{placePractitioner.tempAddress}
+            </if>
+            <if test="placePractitioner.age != null ">and jpp.age = #{placePractitioner.age}</if>
+            <if test="placePractitioner.gender != null ">and jpp.gender = #{placePractitioner.gender}</if>
+            <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
+                #{placePractitioner.idCard}
+            </if>
+            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
+                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
             </if>
             and jpp.is_deleted = 0
         </where>
     </select>
 
 
+    <select id="selectPlacePractitionerCount" resultType="java.lang.Integer">
+        SELECT count(1) from ( SELECT
+        count(1)
+        FROM
+        jczz_place_practitioner jpp
+        LEFT JOIN jczz_place jp ON jp.id = jpp.place_id
+        LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
+        LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
+        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="placePractitioner.townStreetName!=null and placePractitioner.townStreetName!=''">
+                and br.town_name like concat('%',#{placePractitioner.townStreetName},'%')
+            </if>
+            <if test="placePractitioner.neiName!=null and placePractitioner.neiName!=''">
+                and br.name like concat('%',#{placePractitioner.neiName},'%')
+            </if>
+            <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
+            <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
+            <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
+                #{placePractitioner.name},'%')
+
+            </if>
+            <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
+                concat('%', #{placePractitioner.telephone},'%')
+            </if>
+            <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
+                jpp.temp_address =
+                #{placePractitioner.tempAddress}
+            </if>
+            <if test="placePractitioner.age != null ">and jpp.age = #{placePractitioner.age}</if>
+            <if test="placePractitioner.gender != null ">and jpp.gender = #{placePractitioner.gender}</if>
+            <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
+                #{placePractitioner.idCard}
+            </if>
+            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
+                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
+            </if>
+
+            <if test="placePractitioner.employerImg != null  and placePractitioner.employerImg != ''">and
+                jpp.employer_img =
+                #{placePractitioner.employerImg}
+            </if>
+
+            <if test="placePractitioner.createTime != null ">and jpp.create_time = #{placePractitioner.createTime}</if>
+            <if test="placePractitioner.ethnicity != null ">and jpp.ethnicity = #{placePractitioner.ethnicity}</if>
+
+            <if test="placePractitioner.confirmUserId != null ">and confirm_user_id =
+                #{placePractitioner.confirmUserId}
+            </if>
+            <if test="placePractitioner.confirmFlag != null ">and confirm_flag = #{placePractitioner.confirmFlag}</if>
+            <if test="placePractitioner.confirmTime != null ">and confirm_time = #{placePractitioner.confirmTime}</if>
+            <if test="placePractitioner.confirmNotion != null  and placePractitioner.confirmNotion != ''">and
+                confirm_notion = #{placePractitioner.confirmNotion}
+            </if>
+
+            <if test="placePractitioner.type == 1">
+                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
+                and jc.category_no in (180202,180201,180200)
+            </if>
+            <if test="placePractitioner.type == 2">
+                and jpp.ethnicity != 1
+                and jc.category_no in (180202,180201,180200)
+            </if>
+            <if test="placePractitioner.type == 3">
+                and (TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18 or jpp.ethnicity != 1)
+                and jc.category_no in (180202,180201,180200)
+            </if>
+
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="placePractitioner.roleName != null and placePractitioner.roleName != ''">
+                        <if test="placePractitioner.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="placePractitioner.roleName=='mj'">
+                            <choose>
+                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                                    and jpag.community_code in
+                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
+                                             separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jpag.community_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                    </when>
+                </choose>
+            </if>
+            and jpp.is_deleted = 0
+            GROUP BY jpp.place_id
+            ) a
+        </where>
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3