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 |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 103 insertions(+), 1 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 8d97839..c9c5a95 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -718,7 +718,7 @@
     </select>
 
 
-    <select id="getKeynotePersonnelPage" resultType="org.springblade.modules.house.vo.HouseholdVO">
+    <select id="getKeynotePersonnelPage" resultMap="householdPageAndLabelMap">
 
         SELECT
         jh.id,
@@ -828,9 +828,111 @@
             <if test="household.aoiCode!=null and household.aoiCode!=''">
                 and jhs.district_code = #{household.aoiCode}
             </if>
+            AND EXISTS (
+            SELECT
+            *
+            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 = jh.id
+            AND juhl.label_id IS NOT NULL
+            )
             and jh.is_deleted = 0
             order by jh.create_time desc
         </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