zhongrj
2024-01-11 af21084fa4d1e5f8432f61fbd26a3e4e99495616
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -845,4 +845,94 @@
        </where>
    </select>
    <!--根据人员标签编号集合查询对应的住户(按颜色区分近多少天没有发过任务的住户)-->
    <select id="getHouseholdListByParam" resultType="org.springblade.modules.house.vo.HouseholdVO">
        select jh.* from jczz_household jh
        left join jczz_user_house_label juhl on juhl.household_id = jh.id
        where jh.is_deleted = 0
        and juhl.lable_type = 1
        and juhl.color = '#30D17C'
        and jh.id in (
        select household_id from jczz_grid_work_log where is_deleted = 0 and source = 2 and TIMESTAMPDIFF( day, now(), create_time )=30
        )
        <choose>
            <when test="list!=null and list.size()>0">
                and juhl.label_id in
                <foreach collection="list" item="id" separator="," open="(" close=")">
                    #{id}
                </foreach>
            </when>
            <otherwise>
                and juhl.label_id in ('')
            </otherwise>
        </choose>
        union all
        (
        select jh.* from jczz_household jh
        left join jczz_user_house_label juhl on juhl.household_id = jh.id
        where jh.is_deleted = 0
        and juhl.lable_type = 1
        and juhl.color = '#FFB42B'
        and jh.id in (
        select household_id from jczz_grid_work_log where is_deleted = 0 and source = 2 and TIMESTAMPDIFF( day, now(), create_time )=14
        )
        <choose>
            <when test="list!=null and list.size()>0">
                and juhl.label_id in
                <foreach collection="list" item="id" separator="," open="(" close=")">
                    #{id}
                </foreach>
            </when>
            <otherwise>
                and juhl.label_id in ('')
            </otherwise>
        </choose>
        )
        union all
        (
        select jh.* from jczz_household jh
        left join jczz_user_house_label juhl on juhl.household_id = jh.id
        where jh.is_deleted = 0
        and juhl.lable_type = 1
        and juhl.color = '#EA1F1F'
        and jh.id in (
        select household_id from jczz_grid_work_log where is_deleted = 0 and source = 2 and TIMESTAMPDIFF( day, now(), create_time )=7
        )
        <choose>
            <when test="list!=null and list.size()>0">
                and juhl.label_id in
                <foreach collection="list" item="id" separator="," open="(" close=")">
                    #{id}
                </foreach>
            </when>
            <otherwise>
                and juhl.label_id in ('')
            </otherwise>
        </choose>
        )
        union all
        (
        select jh.* from jczz_household jh
        left join jczz_user_house_label juhl on juhl.household_id = jh.id
        where jh.is_deleted = 0 and juhl.lable_type = 1
        and jh.id not in (
        select household_id from jczz_grid_work_log where is_deleted = 0
        and household_id is not null
        and source = 2
        group by household_id
        )
        <choose>
            <when test="list!=null and list.size()>0">
                and juhl.label_id in
                <foreach collection="list" item="id" separator="," open="(" close=")">
                    #{id}
                </foreach>
            </when>
            <otherwise>
                and juhl.label_id in ('')
            </otherwise>
        </choose>
        )
    </select>
</mapper>