| | |
| | | SELECT |
| | | code,parent_code,name,ancestors,region_level,sort |
| | | FROM blade_region |
| | | where ancestors like concat('%',#{regionCode},'%') |
| | | where (ancestors like concat('%',#{regionCode},'%') or code = #{regionCode}) |
| | | union all |
| | | ( |
| | | SELECT |
| | |
| | | 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},'%') |
| | | where (br.ancestors like concat('%',#{regionCode},'%') or br.code = #{regionCode} or jg.grid_code = #{regionCode}) |
| | | ) |
| | | union all |
| | | ( |
| | | SELECT |
| | | t1.id,t1.parentId,t1.name |
| | | FROM |
| | | ( |
| | | SELECT |
| | | @ids AS ids, |
| | | ( SELECT @ids := GROUP_CONCAT( id ) FROM police_region WHERE FIND_IN_SET( parentId, @ids ) ) AS cids |
| | | FROM |
| | | police_region |
| | | WHERE |
| | | @ids IS NOT NULL |
| | | AND @ids := #{regionCode} |
| | | ) id, |
| | | police_region t1 |
| | | WHERE |
| | | FIND_IN_SET(t1.parentId,ids) |
| | | ) |
| | | </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} |
| | | </select> |
| | | |
| | | <!--查询公安相关的区域数据--> |
| | | <select id="getPoliceList" resultType="org.springblade.modules.system.entity.Region"> |
| | | SELECT id as code,parentId as parent_code,name,'' as ancestors,null as region_level,1 as sort FROM police_region |
| | | where 1=1 |
| | | <if test="communityCode!=null and communityCode!=''"> |
| | | and id like concat('%',#{communityCode},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | |