From 448464bbb8e043c2b8e410947db1f07aa4fd9a4d Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 17 Jun 2024 15:05:27 +0800
Subject: [PATCH] 入户宣传导出即查询优化

---
 src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml |  130 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml b/src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml
index 219df2a..87d7359 100644
--- a/src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml
+++ b/src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml
@@ -10,9 +10,11 @@
     <select id="selectBackblastPubRecordPage" resultMap="backblastPubRecordResultMap">
         select
         jbpr.*,
-        br.town_name as townName,
-        br.name as communityName,
+        br.town_name AS townName,
+        br.NAME AS communityName,
         jpag.pcs_name pcsName,
+        jda.aoi_name,
+        CONCAT( jda.building_name, '-', jda.unit_name, '-', jda.house_name ) houseName,
         bd.dept_name
         from jczz_backblast_pub_record jbpr
         LEFT JOIN jczz_grid jg on jg.grid_code = jbpr.grid_code and jg.is_deleted = 0
@@ -20,6 +22,7 @@
         LEFT JOIN blade_region br on br.code = jpag.community_code
         LEFT JOIN blade_user bu ON bu.id = jbpr.create_user
         LEFT JOIN blade_dept bd on bd.id = bu.dept_id
+        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jbpr.house_code
         where jbpr.is_deleted = 0
         <if test="backblastPubRecord.townName != null and backblastPubRecord.townName != ''">
             and br.town_name like concat('%',#{backblastPubRecord.townName},'%')
@@ -185,4 +188,127 @@
     </select>
 
 
+    <select id="selectBackblastPubRecordExport"
+            resultType="org.springblade.modules.backblast.excel.BackblastPubRecordExcel">
+        select
+        jbpr.*,
+        br.town_name AS townName,
+        br.NAME AS communityName,
+        jpag.pcs_name pcsName,
+        jda.aoi_name,
+        CONCAT( jda.building_name, '-', jda.unit_name, '-', jda.house_name ) houseName,
+        bd.dept_name
+        from jczz_backblast_pub_record jbpr
+        LEFT JOIN jczz_grid jg on jg.grid_code = jbpr.grid_code and jg.is_deleted = 0
+        LEFT JOIN jczz_police_affairs_grid jpag on jbpr.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        LEFT JOIN blade_region br on br.code = jpag.community_code
+        LEFT JOIN blade_user bu ON bu.id = jbpr.create_user
+        LEFT JOIN blade_dept bd on bd.id = bu.dept_id
+        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jbpr.house_code
+        where jbpr.is_deleted = 0
+        <if test="backblastPubRecord.townName != null and backblastPubRecord.townName != ''">
+            and br.town_name like concat('%',#{backblastPubRecord.townName},'%')
+        </if>
+        <if test="backblastPubRecord.communityName != null and backblastPubRecord.communityName != ''">
+            and jbr.name like concat('%',#{backblastPubRecord.communityName},'%')
+        </if>
+        <if test="backblastPubRecord.pcsName != null and backblastPubRecord.pcsName != ''">
+            and jpag.pcs_name like concat('%',#{backblastPubRecord.pcsName},'%')
+        </if>
+        <if test="backblastPubRecord.houseCode != null and backblastPubRecord.houseCode != ''">
+            and jbpr.house_code = #{backblastPubRecord.houseCode}
+        </if>
+        <if test="backblastPubRecord.address != null and backblastPubRecord.address != ''">
+            and jbpr.address like concat('%',#{backblastPubRecord.address},'%')
+        </if>
+        <if test="backblastPubRecord.deptName != null and backblastPubRecord.deptName != ''">
+            and  bd.dept_name like concat('%',#{backblastPubRecord.deptName},'%')
+        </if>
+        <if test="backblastPubRecord.pubContent != null and backblastPubRecord.pubContent != ''">
+            and jbpr.pub_content like concat('%',#{backblastPubRecord.pubContent},'%')
+        </if>
+        <if test="backblastPubRecord.policeman != null and backblastPubRecord.policeman != ''">
+            and jbpr.policeman like concat('%',#{backblastPubRecord.policeman},'%')
+        </if>
+        <if test="backblastPubRecord.createUser != null">
+            and jbpr.create_user = #{backblastPubRecord.createUser}
+        </if>
+        <if test="backblastPubRecord.policemanPhone != null and backblastPubRecord.policemanPhone != ''">
+            and jbpr.policeman_phone like concat('%',#{backblastPubRecord.policemanPhone},'%')
+        </if>
+        <if test="backblastPubRecord.startTime != null and backblastPubRecord.startTime != ''">
+            and date_format(jbpr.create_time,'%Y-%m-%d') &gt;= #{backblastPubRecord.startTime}
+        </if>
+        <if test="backblastPubRecord.endTime != null and backblastPubRecord.endTime != ''">
+            and date_format(jbpr.create_time,'%Y-%m-%d') &lt;= #{backblastPubRecord.endTime}
+        </if>
+        <if test="backblastPubRecord.searchKey!=null and backblastPubRecord.searchKey!=''">
+            and CONCAT(
+            ifnull(jbpr.policeman_phone,''),
+            ifnull(jbpr.address,''),
+            ifnull(jbpr.pub_content,''),
+            ifnull(jbpr.policeman,'')
+            ) like CONCAT ('%', #{backblastPubRecord.searchKey},'%')
+        </if>
+        <if test="isAdministrator==2">
+            <choose>
+                <when test="backblastPubRecord.roleName != null and backblastPubRecord.roleName != ''">
+                    <if test="backblastPubRecord.roleName=='wgy'">
+                        <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 jg.grid_code in ('')
+                            </otherwise>
+                        </choose>
+                    </if>
+                    <if test="backblastPubRecord.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>
+                <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>
+        order by jbpr.id desc,jbpr.create_time desc
+
+    </select>
+
+
 </mapper>

--
Gitblit v1.9.3