zrj
2024-07-03 0b1e9e70818f0e3eb32dd6c029d42d93236ecdc6
src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -103,28 +103,88 @@
    </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}
            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
        name,
        sort
        FROM blade_region
        where 1=1
        and district_code = '361102000000'
        and district_code = '361102'
        <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>
@@ -134,7 +194,7 @@
        code as id,
        parent_code as parentId,
        name
        FROM blade_region where district_code = '361102000000'
        FROM blade_region where district_code = '361102'
        and region_level = 4
        <if test="regionCode!=null  and regionCode!=''">
            and code = #{regionCode}
@@ -144,7 +204,7 @@
        code as id,
        parent_code as parentId,
        name
        FROM blade_region where district_code = '361102000000'
        FROM blade_region where district_code = '361102'
        and region_level = 4
        <if test="regionCode!=null  and regionCode!=''">
            and parent_code = #{regionCode}
@@ -167,4 +227,48 @@
        where length(parent_code) &lt; 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},'%')
        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},'%')
        )
    </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
    </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>
</mapper>