linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
src/main/java/org/springblade/modules/house/mapper/UserHouseLabelMapper.xml
@@ -98,7 +98,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '19'
                AND jl.id = '1025'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -117,7 +117,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '20'
                AND jl.id = '1034'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -137,7 +137,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '22'
                AND jl.id = '1035'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -157,7 +157,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '23'
                AND jl.id = '1036'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -177,7 +177,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1025'
                AND jl.id = '19'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -188,12 +188,71 @@
                    LEFT JOIN  jczz_community jc on  jc.`code` = jg.community_code
                WHERE
                    br.`code` = jc.`street_code`
                )) number5
                )) 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 = 361100000000
            AND br.city_code = 361100
    </select>
@@ -210,7 +269,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '19'
                AND jl.id = '1025'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -228,7 +287,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '20'
                AND jl.id = '1034'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -247,7 +306,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '22'
                AND jl.id = '1035'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -266,7 +325,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '23'
                AND jl.id = '1036'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -285,7 +344,7 @@
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
            WHERE
                juhl.lable_type = 1
                AND jl.id = '1025'
                AND jl.id = '19'
                AND juhl.household_id IS NOT NULL
                AND juhl.house_code IN (
                SELECT
@@ -295,7 +354,61 @@
                    LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
                WHERE
                jc.`code` = jg.community_code
                )) number5
                )) 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
@@ -303,5 +416,467 @@
    </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>
</mapper>