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/doorplateAddress/mapper/DoorplateAddressMapper.xml | 123 ++++++++++++++++++++++++++++++++++-------
1 files changed, 102 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml b/src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
index cc565e7..4208aa7 100644
--- a/src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
+++ b/src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
@@ -21,6 +21,8 @@
</if>
</sql>
+
+
<!--过滤社区数据-->
<sql id="filterCommunity">
<if test="houseParam.roleName!=null and houseParam.roleName!=''">
@@ -39,6 +41,7 @@
</if>
</if>
</sql>
+
<!--门牌地址详情查询-->
<resultMap id="doorplateAddressDetailMap" type="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO"
@@ -68,27 +71,95 @@
<!--查询区域数据-街道-->
- <select id="getRegionListByGroupTwon" resultType="org.springblade.common.node.TreeStringNode" >
- select town_street_code as id,town_street_name as name from jczz_doorplate_address
- where 1=1
- <if test="houseParam.userId!=null and houseParam.userId!='' and houseParam.userId=='1726859808689696770'">
- and nei_name = '万达社区居民委员会'
+<!-- <select id="getRegionListByGroupTwon" resultType="org.springblade.common.node.TreeStringNode" >-->
+<!-- select town_street_code as id,town_street_name as name from jczz_doorplate_address-->
+<!-- where 1=1-->
+<!-- <if test="houseParam.userId!=null and houseParam.userId!='' and houseParam.userId=='1726859808689696770'">-->
+<!-- and nei_name = '万达社区居民委员会'-->
+<!-- </if>-->
+<!-- <include refid="filterHouseGrid"/>-->
+<!-- <include refid="filterCommunity"/>-->
+<!-- group by town_street_code,town_street_name-->
+<!-- </select>-->
+
+ <!--过滤网格数据-->
+ <sql id="filterHouseGridByTownOrCommunity">
+ <if test="houseParam.roleName!=null and houseParam.roleName!='' and houseParam.roleName!='系统管理员'">
+ <choose>
+ <when test="houseParam.roleName=='网格员' and houseParam.userId!='1726859808689696770'">
+ <choose>
+ <when test="list != null and list.size()>0">
+ and jg.grid_code in
+ <foreach collection="list" item="gridCode" separator ="," open="(" close=")">
+ #{gridCode}
+ </foreach>
+ </when>
+ <otherwise>
+ and jg.grid_code in ('')
+ </otherwise>
+ </choose>
+ </when>
+ <otherwise>
+ and jg.grid_code in ('')
+ </otherwise>
+ </choose>
</if>
- <include refid="filterHouseGrid"/>
- <include refid="filterCommunity"/>
- group by town_street_code,town_street_name
+ </sql>
+
+ <!--查询区域数据-街道-->
+ <select id="getRegionListByGroupTwon" resultType="org.springblade.common.node.TreeStringNode" >
+ select br.town_code as id,br.town_name as name from jczz_grid jg
+ left join blade_region br on jg.community_code = br.code
+ where jg.is_deleted = 0
+ <if test="houseParam.userId!=null and houseParam.userId!='' and houseParam.userId=='1726859808689696770'">
+ and br.name = '万达社区居民委员会'
+ </if>
+ <include refid="filterHouseGridByTownOrCommunity"/>
+ union
+ select br.town_code as id,br.town_name as name from jczz_police_affairs_grid jpag
+ left join blade_region br on jpag.community_code = br.code
+ where jpag.is_deleted = 0
+ <include refid="filterCommunityByTownOrCommunity"/>
</select>
+
+ <!--过滤社区数据-->
+ <sql id="filterCommunityByTownOrCommunity">
+ <if test="houseParam.roleName!=null and houseParam.roleName!=''">
+ <choose>
+ <when test="houseParam.roleName=='民警' and houseParam.userId!='1726859808689696770'">
+ <choose>
+ <when test="communityList != null and communityList.size()>0">
+ and br.code in
+ <foreach collection="communityList" item="code" separator ="," open="(" close=")">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and br.code in ('')
+ </otherwise>
+ </choose>
+ </when>
+ <otherwise>
+ and br.code in ('')
+ </otherwise>
+ </choose>
+ </if>
+ </sql>
<!--查询区域数据-社区-->
<select id="getRegionListByGroupNei" resultType="org.springblade.common.node.TreeStringNode" >
- select nei_code as id,nei_name as name,town_street_code as parentId from jczz_doorplate_address
- where 1=1
+ select br.village_code as id,br.village_name as name,br.town_code as parentId from jczz_grid jg
+ left join blade_region br on jg.community_code = br.code
+ where jg.is_deleted = 0
<if test="houseParam.userId!=null and houseParam.userId!='' and houseParam.userId=='1726859808689696770'">
and nei_name = '万达社区居民委员会'
</if>
- <include refid="filterHouseGrid"/>
- <include refid="filterCommunity"/>
- group by nei_code,nei_name,town_street_code
+ <include refid="filterHouseGridByTownOrCommunity"/>
+ union
+ select br.village_code as id,br.village_name as name,br.town_code as parentId from jczz_police_affairs_grid jpag
+ left join blade_region br on jpag.community_code = br.code
+ where jpag.is_deleted = 0
+ <include refid="filterCommunityByTownOrCommunity"/>
</select>
<!--根据社区名称查询小区集合-->
@@ -332,10 +403,21 @@
<!--查询社区信息-->
<select id="getAllDoorplateAddress" resultType="org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity">
- select * from jczz_doorplate_address
- where 1=1
- <if test="name!=null and name!=''">
- and nei_name = #{name}
+ select
+ jda.id,
+ jda.address_code,
+ jda.aoi_code,
+ jda.aoi_name,
+ jda.x,
+ jda.y
+ from jczz_doorplate_address jda
+ left join jczz_grid_range jgr on jda.address_code = jgr.house_code
+ where 1=1 and jgr.id is null
+ <if test="doorplateAddressEntity.neiName!=null and doorplateAddressEntity.neiName!=''">
+ and jda.nei_name = #{doorplateAddressEntity.neiName}
+ </if>
+ <if test="doorplateAddressEntity.townStreetName!=null and doorplateAddressEntity.townStreetName!=''">
+ and jda.town_street_name = #{doorplateAddressEntity.townStreetName}
</if>
</select>
@@ -471,13 +553,12 @@
<!--查询所有的地址表和场所表差集集合(小区和非小区的)-->
<select id="getNotInPlaceList" resultType="org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity">
select jda.* from jczz_doorplate_address jda
- left join jczz_place jp on locate(jda.address_code,jp.house_code)>0 and jp.is_deleted = 0
+ left join jczz_place jp on jda.address_code=jp.house_code and jp.is_deleted = 0
where 1=1
and (doorplate_type = '小门牌' or (doorplate_type = '中门牌' and address_level = 1))
and jp.id is null
- and jda.poi != ''
- <if test="doorplateAddress.townStreetName!=null and doorplateAddress.townStreetName!=''">
- and jda.town_street_name like concat('%',#{doorplateAddress.townStreetName},'%')
+ <if test="townName!=null and townName!=''">
+ and jda.town_street_name like concat('%',#{townName},'%')
</if>
</select>
--
Gitblit v1.9.3