linwe
2024-08-07 06df33f156924c564c17b11fdb96c5bb298a810d
src/main/java/org/springblade/modules/house/mapper/UserHouseLabelMapper.xml
@@ -2,16 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.house.mapper.UserHouseLabelMapper">
    <resultMap type="org.springblade.modules.house.dto.UserHouseLabelDTO" id="UserHouseLabelDTOResult">
        <result property="id"    column="id"    />
        <result property="houseCode"    column="house_code"    />
        <result property="labelId"    column="label_id"    />
        <result property="labelName"    column="label_name"    />
        <result property="color"    column="color"    />
        <result property="remark"    column="remark"    />
        <result property="userId"    column="user_id"    />
        <result property="lableType"    column="lable_type"    />
        <result property="id" column="id"/>
        <result property="houseCode" column="house_code"/>
        <result property="labelId" column="label_id"/>
        <result property="labelName" column="label_name"/>
        <result property="color" column="color"/>
        <result property="remark" column="remark"/>
        <result property="userId" column="user_id"/>
        <result property="lableType" column="lable_type"/>
    </resultMap>
    <sql id="selectUserHouseLabel">
@@ -23,38 +22,859 @@
            color,
            remark,
            user_id,
            lable_type
            lable_type,
            household_id
        from
            jczz_user_house_label
    </sql>
<!--    <select id="selectUserHouseLabelList" parameterType="org.springblade.modules.house.dto.UserHouseLabelDTO" resultMap="UserHouseLabelDTOResult">-->
<!--        <include refid="selectUserHouseLabel"/>-->
<!--        <where>-->
<!--            <if test="id != null "> and id = #{id}</if>-->
<!--            <if test="houseCode != null  and houseCode != ''"> and house_code = #{houseCode}</if>-->
<!--            <if test="labelId != null "> and label_id = #{labelId}</if>-->
<!--            <if test="labelName != null  and labelName != ''"> and label_name = #{labelName}</if>-->
<!--            <if test="color != null  and color != ''"> and color = #{color}</if>-->
<!--            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>-->
<!--            <if test="userId != null "> and user_id = #{userId}</if>-->
<!--            <if test="lableType != null "> and lable_type = #{lableType}</if>-->
<!--        </where>-->
<!--    </select>-->
    <!--    <select id="selectUserHouseLabelList" parameterType="org.springblade.modules.house.dto.UserHouseLabelDTO" resultMap="UserHouseLabelDTOResult">-->
    <!--        <include refid="selectUserHouseLabel"/>-->
    <!--        <where>-->
    <!--            <if test="id != null "> and id = #{id}</if>-->
    <!--            <if test="houseCode != null  and houseCode != ''"> and house_code = #{houseCode}</if>-->
    <!--            <if test="labelId != null "> and label_id = #{labelId}</if>-->
    <!--            <if test="labelName != null  and labelName != ''"> and label_name = #{labelName}</if>-->
    <!--            <if test="color != null  and color != ''"> and color = #{color}</if>-->
    <!--            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>-->
    <!--            <if test="userId != null "> and user_id = #{userId}</if>-->
    <!--            <if test="lableType != null "> and lable_type = #{lableType}</if>-->
    <!--        </where>-->
    <!--    </select>-->
    <select id="selectHouseLabelPage" resultMap="UserHouseLabelDTOResult">
        <include refid="selectUserHouseLabel"/>
        <where>
            <if test="houseLabel.id != null "> and id = #{houseLabel.id}</if>
            <if test="houseLabel.houseCode != null  and houseLabel.houseCode != ''"> and house_code = #{houseLabel.houseCode}</if>
            <if test="houseLabel.labelId != null "> and label_id = #{houseLabel.labelId}</if>
            <if test="houseLabel.labelName != null  and houseLabel.labelName != ''"> and label_name = #{houseLabel.labelName}</if>
            <if test="houseLabel.color != null  and houseLabel.color != ''"> and color = #{houseLabel.color}</if>
            <if test="houseLabel.remark != null  and remark != ''"> and remark = #{houseLabel.remark}</if>
            <if test="houseLabel.userId != null "> and user_id = #{houseLabel.userId}</if>
            <if test="houseLabel.lableType != null "> and lable_type = #{houseLabel.lableType}</if>
            <if test="houseLabel.id != null ">and id = #{houseLabel.id}</if>
            <if test="houseLabel.houseCode != null  and houseLabel.houseCode != ''">and house_code =
                #{houseLabel.houseCode}
            </if>
            <if test="houseLabel.labelId != null ">and label_id = #{houseLabel.labelId}</if>
            <if test="houseLabel.labelName != null  and houseLabel.labelName != ''">and label_name =
                #{houseLabel.labelName}
            </if>
            <if test="houseLabel.color != null  and houseLabel.color != ''">and color = #{houseLabel.color}</if>
            <if test="houseLabel.remark != null  and remark != ''">and remark = #{houseLabel.remark}</if>
            <if test="houseLabel.userId != null ">and user_id = #{houseLabel.userId}</if>
            <if test="houseLabel.lableType != null ">and lable_type = #{houseLabel.lableType}</if>
        </where>
    </select>
    <!--    &lt;!&ndash;自定义分页查询&ndash;&gt;-->
    <!--    <select id="selectHouseholdLabelPage" resultMap="householdLabelResultMap">-->
    <!--        select * from jczz_household_label where is_deleted = 0-->
    <!--    </select>-->
    <select id="getUserLabelList" resultType="java.lang.Integer"
            parameterType="org.springblade.modules.house.dto.UserHouseLabelDTO">
        select label_id
        from jczz_user_house_label
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="houseCode != null  and houseCode != ''">and house_code = #{houseCode}</if>
            <if test="labelId != null ">and label_id = #{labelId}</if>
            <if test="labelName != null  and labelName != ''">and label_name = #{labelName}</if>
            <if test="color != null  and color != ''">and color = #{color}</if>
            <if test="remark != null  and remark != ''">and remark = #{remark}</if>
            <if test="userId != null ">and user_id = #{userId}</if>
            <if test="lableType != null ">and lable_type = #{lableType}</if>
        </where>
    </select>
    <select id="statisticalLabels" resultType="org.springblade.modules.house.vo.HouseholdLabelVO"
            parameterType="org.springblade.modules.house.vo.HouseholdLabelVO">
               SELECT
            br.region_level,
            br.`code` regionCode,
            br.NAME regionName,
            (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1025'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number1,(
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1034'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number2,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1035'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number3,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1036'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number4,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '19'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number5,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '20'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number6,(
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '22'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number7,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '23'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number8
        FROM
            `blade_region` br
        WHERE
            br.region_level = 4
            AND br.city_code = 361100
    </select>
    <select id="getCommunityStatisticalLabels" resultType="org.springblade.modules.house.vo.HouseholdLabelVO">
        SELECT
        jc.NAME communityName,
                jc.code communityCode,
            (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1025'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                        WHERE
                jc.`code` = jg.community_code
                )) number1,(
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1034'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                        WHERE
                jc.`code` = jg.community_code
                )) number2,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1035'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    WHERE
                jc.`code` = jg.community_code
                )) number3,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1036'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                    WHERE
                jc.`code` = jg.community_code
                )) number4,
                (
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '19'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                WHERE
                jc.`code` = jg.community_code
                )) number5,(
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                    LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
              AND jl.id = '20'
              AND juhl.household_id IS NOT NULL
              AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                        LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                WHERE
                    jc.`code` = jg.community_code
            )) number6,(
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                    LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
              AND jl.id = '22'
              AND juhl.household_id IS NOT NULL
              AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                        LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                WHERE
                    jc.`code` = jg.community_code
            )) number7,(
            SELECT
                count( 1 )
            FROM
                jczz_user_house_label juhl
                    LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
              AND jl.id = '23'
              AND juhl.household_id IS NOT NULL
              AND juhl.house_code IN (
                SELECT
                    jgr.house_code
                FROM
                    jczz_grid jg
                        LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                WHERE
                    jc.`code` = jg.community_code
            )) number8
        FROM
            `jczz_community` jc
        WHERE
           jc.street_code like concat(#{householdLabel.regionCode},'%')
    </select>
    <!--查询对应的label集合信息-->
    <select id="getLabelList" resultType="org.springblade.modules.house.entity.UserHouseLabelEntity">
        SELECT id as label_id,label_name FROM jczz_label
        WHERE is_deleted = 0
        <choose>
            <when test="labelNames!=null and labelNames!=''">
                and label_name in
                <foreach collection="labelNames.split(',')" item="labelName" open="(" separator="," close=")">
                    #{labelName}
                </foreach>
            </when>
            <otherwise>
                and label_name = #{labelNames}
            </otherwise>
        </choose>
    </select>
    <select id="orgStatisticalLabels" resultType="org.springblade.modules.house.vo.HouseholdLabelVO">
        SELECT
            br.region_level,
            br.`code` regionCode,
            br.NAME regionName,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '24'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number1,(
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '25'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number2,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '26'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number3,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '27'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number4,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '28'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number5
        FROM
            `blade_region` br
        WHERE
            br.region_level = 4
          AND br.city_code = 361100
    </select>
    <select id="unitedFrontStatisticalLabels" resultType="org.springblade.modules.house.vo.HouseholdLabelVO">
        SELECT
            br.region_level,
            br.`code` regionCode,
            br.NAME regionName,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1041'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number1,(
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1042'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number2,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1043'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number3,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1044'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number4,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1045'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number5,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1046'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number6,(
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1047'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number7,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1048'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number8,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1049'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number9,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1050'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number10,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1051'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number11,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1052'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number12
        FROM
            `blade_region` br
        WHERE
            br.region_level = 4
          AND br.city_code = 361100
    </select>
    <select id="followStatisticalLabels" resultType="org.springblade.modules.house.vo.HouseholdLabelVO">
        SELECT
            br.region_level,
            br.`code` regionCode,
            br.NAME regionName,
            (
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '1025'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number1,(
                SELECT
                    count( 1 )
                FROM
                    jczz_user_house_label juhl
                        LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                WHERE
                    juhl.lable_type = 1
                  AND jl.id = '23'
                  AND juhl.household_id IS NOT NULL
                  AND juhl.house_code IN (
                    SELECT
                        jgr.house_code
                    FROM
                        jczz_grid jg
                            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                            LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                    WHERE
                        br.`code` = jc.`street_code`
                )) number2
        FROM
            `blade_region` br
        WHERE
            br.region_level = 4
          AND br.city_code = 361100
    </select>
    <select id="getUserHouseLabelList" resultType="org.springblade.modules.house.entity.UserHouseLabelEntity">
        SELECT
        juhl.id,
        juhl.house_code,
        juhl.label_id,
        juhl.label_name,
        juhl.color,
        juhl.remark,
        juhl.user_id,
        juhl.lable_type,
        juhl.household_id
        FROM
        jczz_user_house_label juhl
        LEFT JOIN jczz_house jh ON juhl.house_code = jh.house_code
        LEFT JOIN jczz_grid jg on jg.id= jh.grid_id
        LEFT JOIN blade_region br on br.code = jg.community_code
        <where>
            juhl.lable_type = 1
            and juhl.color = #{userHouseLabelVO.color}
            and juhl.label_id = #{userHouseLabelVO.labelId}
            and juhl.household_id is not null
            <if test="userHouseLabelVO.taskRange != null ">and br.code like concat(#{userHouseLabelVO.taskRange},'%')
            </if>
        </where>
    </select>