zhongrj
2023-12-08 9c337d8dc09694005eda83df13d7972fddbfe2cc
src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -86,15 +86,19 @@
    <!--自定义分页列表-->
    <select id="selectHousePage" resultType="org.springblade.modules.house.vo.HouseVO">
        select *,concat(building," ",unit," ",room) as address from jczz_house
        select jh.*,concat(building," ",unit," ",room) as address from jczz_house jh
        left join jczz_doorplate_address jda on jda.address_code = jh.house_code
        where is_deleted = 0
        <if test="house.id != null "> and id = #{house.id}</if>
        <if test="house.streetCode != null and house.streetCode != ''">
         and jda.town_street_code like concat('%',#{house.streetCode},'%')
        </if>
        <if test="house.houseCode != null  and house.houseCode != ''"> and house_code = #{house.houseCode}</if>
        <if test="house.districtCode != null  and house.districtCode != ''"> and district_code = #{house.districtCode}</if>
        <if test="house.districtName != null  and house.districtName != ''">
            and district_name like concat('%',#{house.districtName},'%')
         </if>
        <if test="house.houseName != null  and house.houseName != ''"> and house_name = #{house.houseName}</if>
        <if test="house.houseName != null  and house.houseName != ''"> and jh.house_name like concat('%',#{house.houseName},'%')</if>
        <if test="house.phone != null  and house.phone != ''"> and phone = #{house.phone}</if>
        <if test="house.area != null "> and area = #{house.area}</if>
        <if test="house.propertyPrice != null "> and property_price = #{house.propertyPrice}</if>
@@ -192,7 +196,8 @@
        unit as parentCode
        FROM jczz_house jh
        left join
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by nei_code,aoi_code) jda
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by
        nei_code,aoi_code) jda
        on jda.aoi_code = jh.district_code
        WHERE jda.nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
@@ -200,4 +205,160 @@
    </select>
    <select id="getHouseStatisticsOne" resultType="java.lang.Integer">
        SELECT
        count( 1 )
        FROM
        jczz_house jh
        WHERE
        jh.is_deleted = 0
        AND
        EXISTS (
        SELECT
        jda.building_code
        FROM
        jczz_doorplate_address jda
        WHERE
        jh.house_code = jda.address_code
        AND jda.nei_code = #{code}
        AND jda.building_code IS NOT NULL
        <if test="userId != null">
            AND EXISTS (
            SELECT
            *
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jh.house_code = jgr.house_code
            AND jg.is_deleted = 0
            )
        </if>
        GROUP BY
        jda.building_code
        )
    </select>
    <select id="getHouseStatisticsTwo" resultType="java.lang.Integer">
        SELECT
        count( 1 )
        FROM
        jczz_house jh
        WHERE
        jh.is_deleted = 0
        AND
        EXISTS (
        SELECT
        jda.address_code
        FROM
        jczz_doorplate_address jda
        WHERE
        jh.house_code = jda.address_code
        AND jda.nei_code = #{code}
        AND jda.building_code IS NOT NULL
        <if test="userId != null">
            AND EXISTS (
            SELECT
            *
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jh.house_code = jgr.house_code
            AND jg.is_deleted = 0
            )
        </if>
        GROUP BY
        jda.address_code
        )
    </select>
    <select id="getHouseStatisticsThree" resultType="java.lang.Integer">
        SELECT
        count(1)
        FROM
        jczz_household jhh
        LEFT JOIN jczz_house jh ON jhh.house_code = jh.house_code
        WHERE
        jh.is_deleted = 0
        AND jhh.is_deleted = 0
        AND jhh.house_code IN (
        SELECT
        jda.address_code
        FROM
        jczz_doorplate_address jda
        WHERE
        jh.house_code = jda.address_code
        AND jda.nei_code = #{code}
        <if test="userId != null">
            AND EXISTS (
            SELECT
            *
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jh.house_code = jgr.house_code
            AND jg.is_deleted = 0
            )
        </if>
        )
    </select>
    <select id="getHouseStatisticsFour" resultType="java.lang.Integer">
        SELECT
        count( 1 )
        FROM
        jczz_house jh
        WHERE
        jh.is_deleted = 0
        AND
        EXISTS (
        SELECT
        jda.unit_code
        FROM
        jczz_doorplate_address jda
        WHERE
        jh.house_code = jda.address_code
        AND jda.nei_code = #{code}
        AND jda.building_code IS NOT NULL
        <if test="userId != null">
            AND EXISTS (
            SELECT
            *
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jh.house_code = jgr.house_code
            AND jg.is_deleted = 0
            )
        </if>
        GROUP BY
        jda.unit_code
        )
    </select>
</mapper>