lin
2024-03-22 774c8b2ee14eef5fd10bbd46d85a180e7b19ab21
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>
    <!--根据社区名称查询小区集合-->
@@ -192,7 +263,8 @@
            jda.id,ifnull(jda.unit_name,"未知单元") unitName,jda.unit_code unitCode,jda.floor,jda.house_name as houseNo,
            jda.address_code addressCode,
            jh.name as realName,jh.relationship as roleType,1 as addressType,
            juhl.id as cid,juhl.house_code,juhl.label_id,juhl.label_name,juhl.color,juhl.household_id
            juhl.id as cid,juhl.house_code,juhl.label_id,juhl.label_name,juhl.color,juhl.household_id,
            juhlh.color as houseColor
            from jczz_doorplate_address jda
            left join
            (
@@ -201,7 +273,8 @@
                )
            ) jh
            on jda.address_code = jh.house_code
            left join jczz_user_house_label juhl on juhl.house_code = jda.address_code and lable_type=1
            left join jczz_user_house_label juhl on juhl.house_code = jda.address_code and juhl.lable_type=1
            left join jczz_user_house_label juhlh on juhlh.house_code = jda.address_code and juhlh.lable_type=2
            where 1=1
            and floor != ''
            and house_name != ''
@@ -216,9 +289,11 @@
        (
            select jda2.id,'' as unitName,address_code as unitCode,doorplate_name as floor,'' as houseNo,address_code as addressCode,
            '' as realName,'' as roleType,2 as addressType,
            juhl.id as cid,juhl.house_code,juhl.label_id,juhl.label_name,juhl.color,juhl.household_id
            juhl.id as cid,juhl.house_code,juhl.label_id,juhl.label_name,juhl.color,juhl.household_id,
            juhlh.color as houseColor
            from jczz_doorplate_address jda2
            left join jczz_user_house_label juhl on juhl.house_code = jda2.address_code and lable_type=1
            left join jczz_user_house_label juhl on juhl.house_code = jda2.address_code and juhl.lable_type=1
            left join jczz_user_house_label juhlh on juhlh.house_code = jda2.address_code and juhlh.lable_type=2
            where 1=1
            and building_code = #{houseParam.code}
            and building_name != ''
@@ -332,10 +407,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>
@@ -402,6 +488,10 @@
        where 1=1
        and jh.house_code is null
        and doorplate_type = '户室牌'
        <if test="townName!=null and townName!=''">
            and jda.town_street_name like concat('%',#{townName},'%')
        </if>
        limit 0,1000
    </select>
    <!--查询商超-->
@@ -454,16 +544,18 @@
    <!--查询所有的地址表id集合-->
    <select id="getAoiCodeList" resultType="java.lang.Long">
        select
        max(id)
        min(id)
        from jczz_doorplate_address
        where aoi_code != "" and aoi_name !=""
            and doorplate_type = '大门牌'
        GROUP BY aoi_code
        union all
        (
        select
        max(id)
        min(id)
        from jczz_doorplate_address
        where aoi_code != "" and sub_aoi != ""
            and doorplate_type = '大门牌'
        group by aoi_code
        )
    </select>
@@ -471,13 +563,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>
@@ -485,14 +576,78 @@
    <select id="getPlaceList" resultType="org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity">
        select jda.*
        from jczz_doorplate_address jda
        left join jczz_grid_range jgr on jda.address_code = jgr.house_code
        where 1=1
        and (doorplate_type = '小门牌' or (doorplate_type = '中门牌' and address_level = 1))
--         and (doorplate_type = '小门牌' or (doorplate_type = '中门牌' and address_level = 1))
        <if test="doorplateAddress.addressName!=null and doorplateAddress.addressName!=''">
            and address_name like concat('%',#{doorplateAddress.addressName},'%')
            and jda.address_name like concat('%',#{doorplateAddress.addressName},'%')
        </if>
        <if test="doorplateAddress.poi!=null and doorplateAddress.poi!=''">
            and poi like concat('%',#{doorplateAddress.poi},'%')
            and jda.poi like concat('%',#{doorplateAddress.poi},'%')
        </if>
        <if test="doorplateAddress.addressCode!=null and doorplateAddress.addressCode!=''">
            and jda.address_code in
            <foreach collection="addressCode.split(',')" item="addressCode" open="(" close=")" separator=",">
                #{addressCode}
            </foreach>
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="doorplateAddress.roleName != null and doorplateAddress.roleName != ''">
                    <if test="doorplateAddress.roleName=='wgy'">
                        <choose>
                            <when test="gridCodeList !=null and gridCodeList.size()>0">
                                and jgr.grid_code in
                                <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jgr.grid_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                    <if test="doorplateAddress.roleName=='mj'">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and jda.nei_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jda.nei_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </when>
                <otherwise>
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and
                            (
                            jgr.grid_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            or
                            jda.nei_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            )
                        </when>
                        <otherwise>
                            and
                            (
                            jgr.grid_code in ('') or jda.nei_code in ('')
                            )
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        limit 0,#{size}
    </select>
    <!--查询地址表详情-->
@@ -515,4 +670,34 @@
            jda.nei_name,
            jda.town_street_code
    </select>
    <select id="getHouseBuildingCode"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO">
        SELECT DISTINCT
            jda.building_code,
            jda.building_name
        FROM
            jczz_doorplate_address jda
                LEFT JOIN jczz_district jd ON jd.aoi_code = jda.aoi_code
        WHERE
            jd.id = #{districtId}
          and jda.building_code is not null
    </select>
    <!--查询所有户室数据-->
    <select id="getNotHouseListCount" resultType="java.lang.Integer">
        select count(*) from jczz_doorplate_address jda
        left join jczz_house jh on jh.house_code = jda.address_code
        where 1=1
        and jh.house_code is null
        and doorplate_type = '户室牌'
        <if test="townName!=null and townName!=''">
            and jda.town_street_name like concat('%',#{townName},'%')
        </if>
        limit 0,1000
    </select>
</mapper>