From 764d883b5ea3bdc06abbec548b6df0511e567978 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 03 Sep 2024 09:46:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/binlog' into binlog
---
src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 220 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml b/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
index d418cbb..e014a13 100644
--- a/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -103,28 +103,103 @@
</select>
<!--根据父编号查询所有的下级-->
+<!-- <select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">-->
+<!-- <if test="region.cityCode!=null and region.cityCode!=''">-->
+<!-- SELECT-->
+<!-- code as id,-->
+<!-- parent_code as parentId,-->
+<!-- name,-->
+<!-- sort-->
+<!-- FROM blade_region-->
+<!-- where code = #{region.cityCode}-->
+<!-- union all-->
+<!-- select-->
+<!-- grid_code as id,-->
+<!-- community_code as parentId,-->
+<!-- grid_name as name,-->
+<!-- jg.sort-->
+<!-- FROM jczz_grid jg-->
+<!-- left join blade_region br on br.village_code = jg.community_code and br.region_level = 5-->
+<!-- where jg.is_deleted = 0 and br.city_code = #{region.cityCode}-->
+<!-- union all-->
+<!-- </if>-->
+<!-- SELECT-->
+<!-- code as id,-->
+<!-- parent_code as parentId,-->
+<!-- name,-->
+<!-- sort-->
+<!-- FROM blade_region-->
+<!-- where 1=1-->
+<!-- and district_code = '361102'-->
+<!-- <if test="region.parentCode!=null and region.parentCode!=''">-->
+<!-- and parent_code = #{region.parentCode}-->
+<!-- </if>-->
+<!-- <if test="isAdministrator==2">-->
+<!-- <choose>-->
+<!-- <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">-->
+<!-- and code in-->
+<!-- <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">-->
+<!-- #{code}-->
+<!-- </foreach>-->
+<!-- </when>-->
+<!-- <otherwise>-->
+<!-- and 1=1-->
+<!-- </otherwise>-->
+<!-- </choose>-->
+<!-- </if>-->
+<!-- </select>-->
+
+ <!--根据父编号查询所有的下级-->
<select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">
<if test="region.cityCode!=null and region.cityCode!=''">
- SELECT
- code as id,
- parent_code as parentId,
- name
- FROM blade_region
- where code = #{region.cityCode}
+ select
+ grid_code as id,
+ community_code as parentId,
+ grid_name as name,
+ jg.sort
+ FROM jczz_grid jg
+ left join blade_region br on br.village_code = jg.community_code and br.region_level = 5
+ where jg.is_deleted = 0 and jg.community_code like concat(#{region.cityCode},'%')
+ <if test="isAdministrator==2">
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and jg.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and 1=1
+ </otherwise>
+ </choose>
+ </if>
union all
</if>
SELECT
code as id,
parent_code as parentId,
- name
+ name,
+ sort
FROM blade_region
where 1=1
- and district_code = '361102'
+ <if test="region.districtCode!=null and region.districtCode!=''">
+ and district_code like concat(#{region.districtCode},'%')
+ </if>
<if test="region.parentCode!=null and region.parentCode!=''">
and parent_code = #{region.parentCode}
</if>
- <if test="region.regionCode!=null and region.regionCode!=''">
- and code like concat('%',#{region.regionCode},'%')
+ <if test="isAdministrator==2">
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and 1=1
+ </otherwise>
+ </choose>
</if>
</select>
@@ -161,4 +236,139 @@
where region_level >0 and region_level <4
</select>
+ <!--查询parentCode 长度少于12 的-->
+ <select id="getCodeLess12DataList" resultType="org.springblade.modules.system.entity.Region">
+ SELECT * FROM blade_region
+ where length(parent_code) < 12
+ </select>
+
+ <!--查询下级区域(拼接网格)-->
+ <select id="getRegionChildList" resultType="org.springblade.modules.system.entity.Region">
+ SELECT
+ code,parent_code,name,ancestors,region_level,sort
+ FROM blade_region
+ where (ancestors like concat('%',#{regionCode},'%') or code = #{regionCode})
+ union all
+ (
+ SELECT
+ jg.grid_code as code,
+ jg.community_code as parent_code,
+ jg.grid_name as name,
+ '' as ancestors,
+ 6 as region_level,
+ jg.sort
+ FROM blade_region br
+ right join jczz_grid jg on jg.community_code = br.village_code and jg.is_deleted = 0
+ where (br.ancestors like concat('%',#{regionCode},'%') or br.code = #{regionCode} or jg.grid_code = #{regionCode})
+ )
+ </select>
+
+ <!--查询网格员对应的网格区域-->
+ <select id="getGridRegionChildList" resultType="org.springblade.modules.system.entity.Region">
+ SELECT
+ jg.grid_code as code,
+ jg.community_code as parent_code,
+ jg.grid_name as name,
+ '' as ancestors,
+ 6 as region_level,
+ jg.sort
+ FROM blade_region br
+ right join jczz_grid jg on jg.community_code = br.village_code and jg.is_deleted = 0
+ where (
+ jg.grid_code = #{regionCode}
+ or jg.community_code = #{regionCode}
+ or br.town_code = #{regionCode}
+ or br.district_code = #{regionCode}
+ or br.city_code = #{regionCode}
+ )
+ </select>
+
+ <!--查询公安相关的区域数据-->
+ <select id="getPoliceList" resultType="org.springblade.modules.system.entity.Region">
+ SELECT id as code,parent_id as parent_code,name,'' as ancestors,null as region_level,1 as sort FROM v_police_region
+ where 1=1
+ <if test="communityCode!=null and communityCode!=''">
+ and id like concat('%',#{communityCode},'%')
+ </if>
+ </select>
+
+
+ <!--查询公安对应的辖区树-->
+ <select id="getPoliceTreeList" resultType="org.springblade.common.node.TreeStringNode">
+ SELECT
+ CODE AS id,
+ parent_code AS parentId,
+ NAME
+ FROM jczz_police_station
+ WHERE is_deleted = 0
+ UNION ALL
+ SELECT
+ jw_grid_code AS id,
+ pcs_code AS parentId,
+ community_name AS NAME
+ FROM jczz_police_affairs_grid
+ WHERE is_deleted = 0 AND pcs_code IS NOT NULL
+ </select>
+
+ <!--查询当前文章范围对应的社区编号字符串集合-->
+ <select id="getAllCommunityNameListString" resultType="java.lang.String">
+ SELECT
+ code
+ FROM blade_region
+ where
+ <foreach collection="articleRange.split(',')" item="item" open="(" close=")" separator="OR">
+ ancestors like concat('%',#{item},'%')
+ </foreach>
+ and region_level = 5
+ union
+ (
+ SELECT
+ br.code
+ FROM jczz_district jd
+ left join blade_region br on jd.community_code = br.village_code
+ where br.region_level = 5
+ and jd.id in
+ <foreach collection="articleRange.split(',')" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
+ )
+ union
+ (
+ SELECT
+ jd.id
+ FROM jczz_district jd
+ where
+ jd.id in
+ <foreach collection="articleRange.split(',')" item="item" open="(" close=")" separator=",">
+ #{item}
+ </foreach>
+ )
+ </select>
+
+
+ <!--根据父编号查询所有的下级-->
+ <select id="treeToCommunity" resultType="org.springblade.common.node.TreeStringNode">
+ select
+ br.code as id,
+ br.parent_code as parentId,
+ br.name as name,
+ br.sort
+ FROM blade_region br
+ left join jczz_grid jg on br.village_code = jg.community_code and jg.is_deleted = 0 and br.region_level = 5
+ where 1=1 and (br.ancestors like '%361102%' or br.code = '361102')
+ <if test="isAdministrator==2">
+ <choose>
+ <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+ and jg.community_code in
+ <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+ #{code}
+ </foreach>
+ </when>
+ <otherwise>
+ and jg.community_code in ('')
+ </otherwise>
+ </choose>
+ </if>
+ </select>
+
</mapper>
--
Gitblit v1.9.3