linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -175,6 +175,8 @@
        jh.marital_status,
        jh.card_number,
        jh.other_contact,
        jh.create_time,
        jh.update_time,
        IF
        ( jda.id IS NOT NULL, jda.address_name, jh.current_address ) AS current_address,
        jh.disability_cert,
@@ -192,6 +194,10 @@
        jhs.building,
        jhs.district_code aoiCode,
        jh.volunteer_org,
        case
        when TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) < 18 then 2
        when TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) >= 18 then 1
        end as minors,
        jhs.unit
        FROM
        jczz_household jh
@@ -235,13 +241,24 @@
            <if test="household.houseCode!=null and household.houseCode !=''">
                and jh.house_code = #{household.houseCode}
            </if>
            <if test="household.communityCode!=null and household.communityCode !=''">
                and jg.community_code = #{household.communityCode}
            </if>
                <!-- 等于18 就是租户 -->
            <if test="household.relationship!=null and household.relationship == 18">
                and jh.relationship = #{household.relationship}
                <if test="household.minors!=null and household.minors ==2">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &lt; 18
                </if>
                <if test="household.minors!=null and household.minors ==1">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &gt;= 18
                </if>
            </if>
            <!-- 不等于18 就是非租户 -->
            <if test="household.relationship!=null and household.relationship != 18">
                and jh.relationship != #{household.relationship}
                and jh.relationship != 18
            </if>
            <if test="household.phoneNumber!=null and household.phoneNumber !=''">
@@ -332,10 +349,8 @@
                and jhs.district_code = #{household.aoiCode}
            </if>
            and jh.is_deleted = 0
            order by jh.create_time desc
            order by jh.id desc
        </where>
    </select>
    <select id="getAllHouseHold" resultMap="householdPageAndLabelMap">
@@ -436,6 +451,7 @@
               jda.doorplate_type  doorplateType,
               jda.address_level   addressLevel,
               jda.nei_name        neiName,
               jda.nei_code        neiCode,
               jda.aoi_code        aoiCode,
               jh.relationship     relationship
        from jczz_household jh
@@ -508,6 +524,8 @@
               jh.confirm_flag,
               jh.housing_rental_id,
               jh.volunteer_org,
               jh.create_time,
               jh.update_time,
               if(jda.id is not null, substring(jda.town_street_code, 1, 9), jh.home_adcode) as home_adcode,
               br1.name                                                                      as residentAdName,
               br1.province_code                                                             as residentProvinceAdCode,
@@ -541,32 +559,212 @@
    </select>
    <!--导出数据-->
    <select id="export" resultType="org.springblade.modules.house.excel.HouseHoldExcel">
        select
        jh.house_code houseCode,
        jh.name,jh.phone_number phoneNumber,jh.role_type roleType,jh.relationship relationship,
        jh.is_primary_contact isPrimaryContact,jh.residential_status residentialStatus,jh.gender,
        jh.birthday,jh.id_card idCard,jh.ethnicity,jh.education,
        jh.hukou_registration hukouRegistration,jh.work_status workStatus,jh.employer,jh.marital_status maritalStatus,
        jh.card_number cardNumber,jh.other_contact otherContact,jh.current_address currentAddress,jh.volunteer_org,
        jh.disability_cert disabilityCert,jh.party_ember partyEmber,jh.remark,
    <select id="export" resultType="org.springblade.modules.house.excel.ExportHouseholdExcel">
        SELECT
        jh.id,
        jh.house_code,
        jh.NAME,
        jh.phone_number,
        jh.relationship,
        jh.is_primary_contact,
        jh.residential_status,
        jh.birthday,
        jh.id_card,
        jh.card_type,
        ifnull( jh.gender, CASE WHEN substring( jh.id_card, 17, 1 )% 2 = 1 THEN 1 ELSE 0 END ) AS gender,
        jh.ethnicity,
        jh.education,
        jh.resident_type,
        jh.hukou_registration,
        jh.resident_adcode,
        jh.native_place_adcode,
        jh.religious_belief,
        jh.health_status,
        jh.disease_name,
        jh.work_status,
        jh.employer,
        jh.occupation,
        jh.cmpy_reg_addr,
        jh.go_out_addr,
        jh.go_out_where,
        jh.go_out_time,
        jh.go_out_reason,
        jh.marital_status,
        jh.card_number,
        jh.other_contact,
        IF
        ( jda.id IS NOT NULL, jda.address_name, jh.current_address ) AS current_address,
        jh.disability_cert,
        jh.party_ember,
        jh.remark,
        jhs.district_name aoiName,
        concat(jhs.building," ",unit," ",room) as address
        from
        jczz_household jh join jczz_house jhs on jh.house_code = jhs.house_code and jhs.is_deleted = 0
        where jh.is_deleted = 0
        <if test="household.name!=null and household.name !=''">
            and jh.name like concat('%',#{household.name},'%')
        </if>
        <if test="household.phoneNumber!=null and household.phoneNumber !=''">
            and jh.phone_number like concat('%',#{household.phoneNumber},'%')
        </if>
        <if test="household.idCard!=null and household.idCard !=''">
            and jh.id_card like concat('%',#{household.idCard},'%')
        </if>
        <if test="household.aoiName!=null and household.aoiName !=''">
            and jhs.district_name like concat('%',#{household.aoiName},'%')
        </if>
        jda.town_street_name AS townName,
        jda.nei_name AS communityName,
        jg.grid_name,
        jhs.building,
        jh.volunteer_org,
        case
        when TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &lt; 18 then 2
        when TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &gt;= 18 then 1
        end as minors,
        jhs.unit,
        juhl.label_name
        FROM
        jczz_household jh
        LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code and jhs.is_deleted = 0
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
        LEFT JOIN jczz_grid jg on jg.grid_code = jhs.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jhs.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN (
            select household_id,GROUP_CONCAT(label_name) as label_name from jczz_user_house_label where lable_type = 1 and household_id is not null GROUP BY household_id
        ) juhl on juhl.household_id = jh.id
        <where>
            <if test="household.labelIdList !=null and household.labelIdList.size() >0 ">
                EXISTS (
                SELECT
                *
                FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                where  juhl.household_id = jh.id
                and juhl.lable_type = 1
                AND juhl.household_id IS NOT NULL
                AND jl.id in
                <foreach collection="household.labelIdList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
                )
            </if>
            <if test="household.userId!=null">
                AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id =
                #{household.userId}
                )
            </if>
            <if test="household.searchKey!=null and household.searchKey!=''">
                and CONCAT(jh.name,jh.phone_number) like CONCAT ('%', #{household.searchKey},'%')
            </if>
            <if test="household.name!=null and household.name !=''">
                and jh.name like concat('%',#{household.name},'%')
            </if>
            <if test="household.volunteerOrg != null  and household.volunteerOrg != ''">
                and jh.volunteer_org  like concat('%',#{household.volunteerOrg},'%')
            </if>
            <if test="household.houseCode!=null and household.houseCode !=''">
                and jh.house_code = #{household.houseCode}
            </if>
            <if test="household.communityCode!=null and household.communityCode !=''">
                and jg.community_code = #{household.communityCode}
            </if>
            <!-- 等于18 就是租户 -->
            <if test="household.relationship!=null and household.relationship == 18">
                and jh.relationship = #{household.relationship}
                <if test="household.minors!=null and household.minors ==2">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &lt; 18
                </if>
                <if test="household.minors!=null and household.minors ==1">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &gt;= 18
                </if>
            </if>
            <!-- 不等于18 就是非租户 -->
            <if test="household.relationship!=null and household.relationship != 18">
                and jh.relationship != 18
            </if>
            <if test="household.phoneNumber!=null and household.phoneNumber !=''">
                and jh.phone_number like concat('%',#{household.phoneNumber},'%')
            </if>
            <if test="household.idCard!=null and household.idCard !=''">
                and jh.id_card like concat('%',#{household.idCard},'%')
            </if>
            <if test="household.aoiName!=null and household.aoiName !=''">
                and jhs.district_name like concat('%',#{household.aoiName},'%')
            </if>
            <if test="household.confirmFlag != null ">
                and jh.confirm_flag = #{household.confirmFlag}
            </if>
            <if test="household.townStreetName!=null and household.townStreetName!=''">
                and jda.town_street_name like concat('%',#{household.townStreetName},'%')
            </if>
            <if test="household.neiName!=null and household.neiName!=''">
                and jda.nei_name like concat('%',#{household.neiName},'%')
            </if>
            <if test="household.housingRentalId != null ">
                and jh.housing_rental_id = #{household.housingRentalId}
            </if>
            <if test="household.startTime != null and household.startTime != '' and household.endTime != null and household.endTime != '' ">
                AND jh.create_time BETWEEN #{household.startTime} and #{household.endTime}
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="household.roleName != null and household.roleName != ''">
                        <if test="household.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jhs.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jhs.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="household.roleName=='mj'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jpag.community_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
                                             separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jpag.community_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                    <otherwise>
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and
                                (
                                jg.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                or
                                jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                )
                            </when>
                            <otherwise>
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
            <if test="household.building!=null and household.building!=''">
                and jhs.building like concat(#{household.building},'%')
            </if>
            <if test="household.unit!=null and household.unit!=''">
                and jhs.unit like concat(#{household.unit},'%')
            </if>
            <if test="household.aoiCode!=null and household.aoiCode!=''">
                and jhs.district_code = #{household.aoiCode}
            </if>
            and jh.is_deleted = 0
        </where>
        order by jh.create_time desc
        limit 0,20000
    </select>
@@ -580,10 +778,15 @@
        LEFT JOIN jczz_grid jg on jg.grid_code = jhs.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jhs.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        <where>
            <if test="household.neiCode != null and household.neiCode != ''">
                and jda.nei_code = #{household.neiCode}
            <if test="household.communityCode != null and household.communityCode != ''">
                and jg.community_code = #{household.communityCode}
            </if>
            <if test="household.confirmFlag != null and household.confirmFlag != ''">
            <if test="household.userId!=null">
                AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id =
                #{household.userId}
                )
            </if>
            <if test="household.confirmFlag != null">
                and jh.confirm_flag =  #{household.confirmFlag}
            </if>
            <if test="isAdministrator==2">
@@ -694,36 +897,43 @@
        FROM
        jczz_household jh
        LEFT JOIN jczz_doorplate_address jda ON jh.house_code = jda.address_code
        WHERE
        jda.nei_code = #{code}
        AND jh.is_deleted = 0
        and jda.doorplate_type = '户室牌'
        <if test="userId != null and roleType == '1'">
            AND jda.address_code IN (
            SELECT DISTINCT
            jgr.house_code
            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 jg.is_deleted = 0
            )
        </if>
        <if test="userId != null and roleType == '3'">
            AND jda.address_code IN (SELECT
            jda.address_code
            FROM
            jczz_doorplate_address jda
            LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
            WHERE
            jc.res_police_user_id like concat('%',#{userId},'%'))
            )
        </if>
        ) a
        GROUP BY
        a.gender
        <where>
            <if test="communityCodeList != null and communityCodeList.size()>0">
                jda.nei_code in
                <foreach collection="communityCodeList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
            </if>
            AND jh.is_deleted = 0
            and jda.doorplate_type = '户室牌'
            <if test="userId != null and roleType == '1'">
                AND jda.address_code IN (
                SELECT DISTINCT
                jgr.house_code
                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 jg.is_deleted = 0
                )
            </if>
            <if test="userId != null and roleType == '3'">
                AND jda.address_code IN (SELECT
                jda.address_code
                FROM
                jczz_doorplate_address jda
                LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
                WHERE
                jc.res_police_user_id like concat('%',#{userId},'%'))
                )
            </if>
            ) a
            GROUP BY
            a.gender
        </where>
    </select>
    <select id="getHouseHoldStatisticsAge" resultType="java.util.Map">
@@ -745,34 +955,30 @@
        count(1) as number FROM
        jczz_household jh
        LEFT JOIN jczz_doorplate_address jda ON jh.house_code = jda.address_code
        WHERE
        jda.nei_code = #{code}
        and jda.doorplate_type = '户室牌'
        AND jh.is_deleted = 0
        <if test="userId != null and roleType == '1'">
            AND jda.address_code IN (
            SELECT
            distinct jgr.house_code
            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 jg.is_deleted = 0
            )
        </if>
        <where>
            <if test="communityCodeList != null and communityCodeList.size()>0">
                jda.nei_code in
                <foreach collection="communityCodeList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
            </if>
            and jda.doorplate_type = '户室牌'
            AND jh.is_deleted = 0
            <if test="userId != null and roleType == '1'">
                AND jda.address_code IN (
                SELECT
                distinct jgr.house_code
                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 jg.is_deleted = 0
                )
            </if>
        </where>
        <if test="userId != null and roleType == '3'">
            AND jda.address_code IN (SELECT
            jda.address_code
            FROM
            jczz_doorplate_address jda
            LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
            WHERE
            jc.res_police_user_id like concat('%',#{userId},'%'))
            )
        </if>
        GROUP BY age
    </select>
@@ -864,6 +1070,9 @@
            </if>
            <if test="household.confirmFlag != null ">
                and jh.confirm_flag = #{household.confirmFlag}
            </if>
            <if test="household.relationship != null ">
                and jh.relationship = #{household.relationship}
            </if>
            <if test="household.townStreetName!=null and household.townStreetName!=''">
                and jda.town_street_name like concat('%',#{household.townStreetName},'%')
@@ -1201,4 +1410,259 @@
        and jl.parent_id != '1001'
    </select>
    <select id="getUserInfoByDistrictIds" resultType="org.springblade.modules.house.vo.HouseholdVO">
        SELECT
        jh.*,
        jhe.house_name address,
        jhe.building,
        jhe.unit
        FROM
        jczz_household jh
        LEFT JOIN jczz_house jhe ON jhe.house_code = jh.house_code
        AND jh.is_deleted = 0
        LEFT JOIN jczz_district jd ON jd.aoi_code = jhe.district_code
        <where>
            and jd.id  in
            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
            and jh.relationship !=18
            <if test="vo.building != null and vo.building !=''">
                and jhe.building like concat('%',#{vo.building},'%')
            </if>
            <if test="vo.unit != null and vo.unit !=''">
                and jhe.unit like concat('%',#{vo.unit},'%')
            </if>
            <if test="vo.name != null and vo.name !=''">
                and jh.name like concat('%',#{vo.name},'%')
            </if>
            <if test="vo.phoneNumber != null and vo.phoneNumber !=''">
                and jh.phone_number like concat('%',#{vo.phoneNumber},'%')
            </if>
        </where>
    </select>
    <!--查询住户对应的社区编号-->
    <select id="getCommunityCode" resultType="java.lang.String">
        SELECT
        jpag.community_code
        FROM
        jczz_household jh
        LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code and jhs.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jhs.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        where jh.is_deleted = 0
        and jh.id = #{id}
    </select>
    <!--查询所有住户总数-->
    <select id="getAllListTotal" resultType="java.lang.Integer">
        SELECT
        count(*)
        FROM
        jczz_household jh
        where jh.is_deleted = 0
    </select>
    <!--查询对应的住户集合-->
    <select id="getAllList" resultType="org.springblade.modules.house.vo.HouseholdVO">
        SELECT
        jh.*,
        jhs.address,
        jpag.community_code
        FROM
        jczz_household jh
        LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code and jhs.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jhs.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        where jh.is_deleted = 0
        limit #{i},#{size}
    </select>
    <select id="exportTenant" resultType="org.springblade.modules.house.excel.HouseTenantExcel">
        SELECT
        jh.house_code,
        jh.NAME,
        jh.phone_number,
        jh.relationship,
        jh.residential_status,
        jh.birthday,
        jh.id_card,
        jh.card_type,
        jh.ethnicity,
        jh.education,
        jh.resident_type,
        jh.hukou_registration,
        jh.resident_adcode,
        jh.native_place_adcode,
        jh.religious_belief,
        jh.health_status,
        jh.disease_name,
        jh.work_status,
        jh.employer,
        jh.occupation,
        jh.cmpy_reg_addr,
        jh.go_out_addr,
        jh.go_out_where,
        jh.go_out_time,
        jh.go_out_reason,
        jh.marital_status,
        jh.card_number
        FROM
        jczz_household jh
        LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code and jhs.is_deleted = 0
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
        LEFT JOIN jczz_grid jg on jg.grid_code = jhs.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jhs.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN (
        select household_id,GROUP_CONCAT(label_name) as label_name from jczz_user_house_label where lable_type = 1 and household_id is not null GROUP BY household_id
        ) juhl on juhl.household_id = jh.id
        <where>
            <if test="household.labelIdList !=null and household.labelIdList.size() >0 ">
                EXISTS (
                SELECT
                *
                FROM
                jczz_user_house_label juhl
                LEFT JOIN jczz_label jl ON juhl.label_id = jl.id
                where  juhl.household_id = jh.id
                and juhl.lable_type = 1
                AND juhl.household_id IS NOT NULL
                AND jl.id in
                <foreach collection="household.labelIdList" item="code" open="(" close=")" separator=",">
                    #{code}
                </foreach>
                )
            </if>
            <if test="household.userId!=null">
                AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id =
                #{household.userId}
                )
            </if>
            <if test="household.searchKey!=null and household.searchKey!=''">
                and CONCAT(jh.name,jh.phone_number) like CONCAT ('%', #{household.searchKey},'%')
            </if>
            <if test="household.name!=null and household.name !=''">
                and jh.name like concat('%',#{household.name},'%')
            </if>
            <if test="household.volunteerOrg != null  and household.volunteerOrg != ''">
                and jh.volunteer_org  like concat('%',#{household.volunteerOrg},'%')
            </if>
            <if test="household.houseCode!=null and household.houseCode !=''">
                and jh.house_code = #{household.houseCode}
            </if>
            <if test="household.communityCode!=null and household.communityCode !=''">
                and jg.community_code = #{household.communityCode}
            </if>
            <!-- 等于18 就是租户 -->
            <if test="household.relationship!=null and household.relationship == 18">
                and jh.relationship = #{household.relationship}
                <if test="household.minors!=null and household.minors ==2">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &lt; 18
                </if>
                <if test="household.minors!=null and household.minors ==1">
                    and TIMESTAMPDIFF(year, substring(jh.id_card, 7, 8), now()) &gt;= 18
                </if>
            </if>
            <!-- 不等于18 就是非租户 -->
            <if test="household.relationship!=null and household.relationship != 18">
                and jh.relationship != #{household.relationship}
            </if>
            <if test="household.phoneNumber!=null and household.phoneNumber !=''">
                and jh.phone_number like concat('%',#{household.phoneNumber},'%')
            </if>
            <if test="household.idCard!=null and household.idCard !=''">
                and jh.id_card like concat('%',#{household.idCard},'%')
            </if>
            <if test="household.aoiName!=null and household.aoiName !=''">
                and jhs.district_name like concat('%',#{household.aoiName},'%')
            </if>
            <if test="household.confirmFlag != null ">
                and jh.confirm_flag = #{household.confirmFlag}
            </if>
            <if test="household.townStreetName!=null and household.townStreetName!=''">
                and jda.town_street_name like concat('%',#{household.townStreetName},'%')
            </if>
            <if test="household.neiName!=null and household.neiName!=''">
                and jda.nei_name like concat('%',#{household.neiName},'%')
            </if>
            <if test="household.housingRentalId != null ">
                and jh.housing_rental_id = #{household.housingRentalId}
            </if>
            <if test="household.startTime != null and household.startTime != '' and household.endTime != null and household.endTime != '' ">
                AND jh.create_time BETWEEN #{household.startTime} and #{household.endTime}
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="household.roleName != null and household.roleName != ''">
                        <if test="household.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jhs.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jhs.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="household.roleName=='mj'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jpag.community_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
                                             separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jpag.community_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                    <otherwise>
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and
                                (
                                jg.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                or
                                jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                )
                            </when>
                            <otherwise>
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
            <if test="household.building!=null and household.building!=''">
                and jhs.building like concat(#{household.building},'%')
            </if>
            <if test="household.unit!=null and household.unit!=''">
                and jhs.unit like concat(#{household.unit},'%')
            </if>
            <if test="household.aoiCode!=null and household.aoiCode!=''">
                and jhs.district_code = #{household.aoiCode}
            </if>
            and jh.is_deleted = 0
        </where>
        order by jh.create_time desc
        limit 0,10000
    </select>
</mapper>