linwe
2024-05-29 c10d6358b9f014375a13821465bc978d0c0da22e
src/main/java/org/springblade/modules/house/mapper/UserHouseLabelMapper.xml
@@ -86,36 +86,351 @@
    <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
   br.region_level,
   br.NAME regionName,
   jc.`street_code`,
   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.parent_id = '103'
      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
      )) numbers
FROM
   jczz_community jc
   LEFT JOIN `blade_region` br ON br.`code` = jc.`street_code`
WHERE
   jc.street_code IS NOT NULL
        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>