From c10d6358b9f014375a13821465bc978d0c0da22e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Wed, 29 May 2024 17:17:08 +0800
Subject: [PATCH] 通过E呼即办数据统计

---
 src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml |   62 ++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 10 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 1368830..17d99c3 100644
--- a/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml
+++ b/src/main/java/org/springblade/modules/place/mapper/PlacePractitionerMapper.xml
@@ -10,7 +10,7 @@
         jpp.name,
         jpp.telephone,
         jpp.temp_address,
-        TIMESTAMPDIFF(YEAR, DATE_FORMAT(jpp.id_card, '%Y%m%d%'), CURDATE()) as age,
+        TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) as age,
         jpp.gender,
         jpp.id_card,
         jp.place_name employer,
@@ -23,12 +23,17 @@
         jpp.employment_time,
         jpp.resignation_time,
         jpp.resignation_flag,
+        jpp.confirm_user_id,
+        jpp.confirm_flag,
+        jpp.confirm_time,
+        jpp.confirm_notion,
         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
         <where>
             <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
             <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
@@ -38,7 +43,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 =
@@ -61,17 +65,55 @@
             <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, DATE_FORMAT(jpp.id_card, '%Y%m%d%'), CURDATE()) &lt; 18
-                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 (TIMESTAMPDIFF(YEAR, DATE_FORMAT(jpp.id_card, '%Y%m%d%'), CURDATE()) &lt; 18  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
             order by jpp.id desc
@@ -132,12 +174,12 @@
         LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
         <where>
             <if test="placePractitioner.type == 1">
-                and (TIMESTAMPDIFF(YEAR, DATE_FORMAT(jpp.id_card, '%Y%m%d%'), CURDATE()) &lt; 18 or jpp.ethnicity != 1)
-                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.id != null ">and jpp.id = #{placePractitioner.id}</if>
             <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>

--
Gitblit v1.9.3