linwe
2023-11-12 8d8c7da4e91028fc877f101dcd244bef3e18c197
src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
@@ -2,6 +2,37 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.doorplateAddress.mapper.DoorplateAddressMapper">
    <!--过滤网格数据-->
    <sql id="filterHouseGrid">
        <if test="houseParam.roleName!=null and houseParam.roleName!=''">
            <if test="houseParam.roleName=='网格员'">
                <choose>
                    <when test="list != null and list.size()>0">
                        and address_code in
                        <foreach collection="list" item="houseCode" separator ="," open="("  close=")">
                            #{houseCode}
                        </foreach>
                    </when>
                    <otherwise>
                        and address_code in ('')
                    </otherwise>
                </choose>
            </if>
        </if>
    </sql>
    <!--门牌地址详情查询-->
    <resultMap id="doorplateAddressDetailMap" type="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO"
               autoMapping="true">
        <id property="id" column="id"/>
        <association property="place" javaType="org.springblade.modules.place.vo.PlaceVO"
                    autoMapping="true">
            <id property="id" column="cid"/>
            <result property="createTime" column="pcreateTime"/>
            <result property="createUserName" column="createUserName"/>
        </association>
    </resultMap>
    <!--自定义分页查询-->
    <select id="selectDoorplateAddressPage" resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO">
        select * from jczz_doorplate_address where 1=1
@@ -9,47 +40,118 @@
    <!--查询区域数据-街道-->
    <select id="getRegionListByGrouyTwon" resultType="org.springblade.common.node.TreeNode" >
        select town_street_name as name from jczz_doorplate_address group by town_street_name
    <select id="getRegionListByGroupTwon" resultType="org.springblade.common.node.TreeNode" >
        select town_street_code as id,town_street_name as name from jczz_doorplate_address
        where 1=1
        <include refid="filterHouseGrid"/>
        group by town_street_code,town_street_name
    </select>
    <!--查询区域数据-社区-->
    <select id="getRegionListByGrouyNei" resultType="org.springblade.common.node.TreeNode" >
        select nei_name as name from jczz_doorplate_address group by nei_name
    <select id="getRegionListByGroupNei" resultType="org.springblade.common.node.TreeNode" >
        select nei_code as id,nei_name as name,town_street_code as parentId from jczz_doorplate_address
        where 1=1
        <include refid="filterHouseGrid"/>
        group by nei_code,nei_name,town_street_code
    </select>
    <!--根据社区名称查询小区集合-->
    <select id="getDistrictList" resultType="org.springblade.common.node.TreeNode" >
        select district_code as id,district_name as name from jczz_doorplate_address
        select aoi_code as id,aoi_name as name,1 as addressType from jczz_doorplate_address
        where 1=1
        and nei_name = #{name}
        and district_name !=''
        and district_code !=''
        group by district_code,district_name
        and aoi_name !=''
        and aoi_code !=''
        <if test="houseParam.name != null and houseParam.name!=''">
            and nei_name = #{houseParam.name}
        </if>
        <if test="houseParam.code != null and houseParam.code!=''">
            and nei_code = #{houseParam.code}
        </if>
        <include refid="filterHouseGrid"/>
        group by aoi_code,aoi_name
        union all
        (
        select aoi_code as id,sub_aoi as name,1 as addressType from jczz_doorplate_address
        where 1=1
        and aoi_code !=''
        and sub_aoi != ''
        <if test="houseParam.name != null and houseParam.name!=''">
            and nei_name = #{houseParam.name}
        </if>
        <if test="houseParam.code != null and houseParam.code!=''">
            and nei_code = #{houseParam.code}
        </if>
        <include refid="filterHouseGrid"/>
        group by aoi_code,sub_aoi
        )
        union all
        (
        select nei_code as id,'自建房/商铺' as name,2 as addressType from jczz_doorplate_address
        where 1=1
        and aoi_code is null
        <if test="houseParam.name != null and houseParam.name!=''">
            and nei_name = #{houseParam.name}
        </if>
        <if test="houseParam.code != null and houseParam.code!=''">
            and nei_code = #{houseParam.code}
        </if>
        <include refid="filterHouseGrid"/>
        group by nei_code
        )
    </select>
    <!--根据社区名称查询楼栋集合-->
    <!--根据小区名称查询楼栋/商铺集合-->
    <select id="getBuildingList" resultType="org.springblade.common.node.TreeNode" >
        select building_code as id,building_name as name from jczz_doorplate_address
        where 1=1
        and district_code = #{code}
        and building_code !=''
        and building_name !=''
        group by building_code,building_name
        order by building_name
        (
            select building_code as id,ifnull(building_name,'1栋') as name,1 as addressType from jczz_doorplate_address
            where 1=1
            and aoi_code = #{houseParam.code}
            and building_code !=''
            and doorplate_type = '户室牌'
            <include refid="filterHouseGrid"/>
            group by building_code,building_name
            order by building_name
        )
        union all
        (
            select address_code as id,doorplate_name as name,2 as addressType from jczz_doorplate_address
            where 1=1
            and aoi_code = #{houseParam.code}
            and building_name is null
            and (doorplate_type = '小门牌' or (doorplate_type = '中门牌' and address_level = 1))
            <include refid="filterHouseGrid"/>
        )
    </select>
    <!--查询户室及住户相关信息,单元中包含住户-->
    <select id="getUnitHouseholdList" resultType="org.springblade.modules.doorplateAddress.vo.FuncNode" >
        select
        jda.unit_code unitCode,jda.floor,jda.house_name as houseNo,jda.address_code addressCode,
        jh.name as realName,jh.role_type as roleType
        from jczz_doorplate_address jda
        left join
         (select house_code,name,role_type from jczz_household where role_type = '业主') jh
      on jda.address_code = jh.house_code
        where 1=1 and floor != '' and house_name != ''
        and building_code = #{code}
        (
            select
            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.role_type as roleType,1 as addressType
            from jczz_doorplate_address jda
            left join
                (select house_code,name,role_type from jczz_household where role_type = 1) jh
            on jda.address_code = jh.house_code
            where 1=1
            and floor != ''
            and house_name != ''
            and doorplate_type = '户室牌'
            and building_code = #{houseParam.code}
            <include refid="filterHouseGrid"/>
        )
        union all
        (
            select '' as unitName,address_code as unitCode,doorplate_name as floor,'' as houseNo,address_code as addressCode,
            '' as realName,'' as roleType,2 as addressType
            from jczz_doorplate_address
            where 1=1
            and building_code = #{houseParam.code}
            and building_name != ''
            and (doorplate_type = '小门牌' or (doorplate_type = '中门牌' and address_level = 1))
            <include refid="filterHouseGrid"/>
        )
    </select>
    <!--先查询门牌信息-->
@@ -57,4 +159,105 @@
        select * from jczz_doorplate_address where address_code = #{code}
    </select>
    <select id="getTownStreetVOTreeList"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT town_street_code as code,town_street_name as name FROM jczz_doorplate_address group by town_street_code , town_street_name
    </select>
    <select id="getNeiVOTreeList" resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT nei_code as code,nei_name as name FROM jczz_doorplate_address WHERE town_street_code =#{code} GROUP BY nei_code,nei_name
    </select>
    <select id="getStreetRuVOTreeList"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT street_ru_code as code,street_ru_name as name
        FROM jczz_doorplate_address
        WHERE nei_code =#{code}
        and street_ru_code is not null and street_ru_code !=''
        and street_ru_name is not null and street_ru_name !=''
        GROUP BY street_ru_code,street_ru_name
    </select>
    <select id="getDistrictVOTreeList"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT aoi_code as code,aoi_name as name
        FROM jczz_doorplate_address
        WHERE street_ru_code =#{code}
        and aoi_code is not null and aoi_code !=''
        and aoi_name is not null and aoi_name !=''
       GROUP BY aoi_code,aoi_name
    </select>
    <select id="getBuildingVOTreeList"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT building_code as code,building_name as name
        FROM jczz_doorplate_address
        WHERE aoi_code =#{code}
          and building_code is not null and building_code !=''
        and building_name is not null and building_name !=''
        GROUP BY building_code,building_name
    </select>
    <!--根据社区查询街路巷集合-->
    <select id="getStreetRuList" resultType="org.springblade.common.node.TreeNode" >
        select street_ru_code as id,street_ru_name as name,3 as addressType from jczz_doorplate_address
        where 1=1
        and aoi_code is null
        <if test="houseParam.name != null and houseParam.name!=''">
            and nei_name = #{houseParam.name}
        </if>
        <if test="houseParam.code != null and houseParam.code!=''">
            and nei_code = #{houseParam.code}
        </if>
        <include refid="filterHouseGrid"/>
        group by street_ru_code,street_ru_name
    </select>
    <!--根据街路巷编号查询街路巷门牌名称集合-->
    <select id="getDoorplateNameList" resultType="org.springblade.modules.doorplateAddress.vo.FuncNode">
      select address_code as addressCode,
      IFNULL(CONCAT(doorplate_num,sub_door_plate_no), IF(doorplate_num IS NULL, sub_door_plate_no, doorplate_num)) as floor
      from jczz_doorplate_address
      where 1=1
      and street_ru_code = #{houseParam.code}
      and nei_code = #{houseParam.name}
      and aoi_code is null
      <include refid="filterHouseGrid"/>
      order by doorplate_num,sub_door_plate_no
    </select>
    <select id="getDoorplateAddressDetail"
            resultMap="doorplateAddressDetailMap">
        SELECT
            jda.*,
            jp.id as cid,jp.*,jp.create_time as pcreateTime,
            bu.real_name as createUserName
        FROM jczz_doorplate_address jda
        left join jczz_place jp on jda.address_code = jp.house_code and jp.is_deleted = 0
        left join blade_user bu on bu.id = jp.create_user and bu.is_deleted = 0
        WHERE 1=1
        <if test="vo.stdId != null and vo.stdId != ''">
            AND address_code = #{vo.stdId}
        </if>
        <if test="vo.buildingCode != null and vo.buildingCode !='' ">
            AND building_code = #{vo.buildingCode}
        </if>
    </select>
    <select id="getDoorplateAddressList"
            resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO">
        SELECT * FROM jczz_doorplate_address
        WHERE 1=1
        <if test="vo.stdId != null and vo.stdId != ''">
            AND address_code = #{vo.stdId}
        </if>
        <if test="vo.buildingCode != null and vo.buildingCode !='' ">
            AND building_code = #{vo.buildingCode}
        </if>
    </select>
    <!--查询社区信息-->
    <select id="getAllDoorplateAddress" resultType="org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity">
        select * from jczz_doorplate_address where nei_name = #{name}
    </select>
</mapper>