From af21084fa4d1e5f8432f61fbd26a3e4e99495616 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Thu, 11 Jan 2024 18:03:49 +0800
Subject: [PATCH] 三色任务完善

---
 src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml |   90 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml b/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
index 7251b49..c9c5a95 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
+++ b/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>

--
Gitblit v1.9.3