From f7018ca7d42b7f84d0191d748cfdb2d38473ea86 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Wed, 17 Apr 2024 18:17:20 +0800
Subject: [PATCH] 新增房屋标签绑定初始化接口

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

diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
index 5de9fde..b477a44 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -922,5 +922,60 @@
         limit #{i},#{size}
     </select>
 
+    <!--查询无房屋状态的房屋数量-->
+    <select id="getNotBindLabelHouseNum" resultType="java.lang.Integer">
+        select count(*) from (
+            SELECT
+            jh.house_code,
+            case when c.house_code is not null then 1
+            when a.house_code is not null and b.house_code is null then 2
+            when b.house_code is not null then 3
+            end as status
+            FROM
+            jczz_house jh
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship = 1 and house_code is not null and house_code != '' GROUP BY house_code
+            ) a on a.house_code = jh.house_code
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship = 18 and house_code is not null and house_code != '' GROUP BY house_code
+            ) b on b.house_code = jh.house_code
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship is null or (relationship!=1 and relationship!=18) and house_code is not null and house_code != '' GROUP BY house_code
+            ) c on c.house_code = jh.house_code
+        ) d left join jczz_user_house_label juhl on d.house_code = juhl.house_code and lable_type = 2
+        where juhl.id is null and status is not null
+    </select>
+
+    <!--查询无房屋状态的房屋列表集合-->
+    <select id="getNotBindLabelHouseList" resultType="org.springblade.modules.house.vo.HouseVO">
+        select d.* from (
+            SELECT
+            jh.house_code,
+            case when c.house_code is not null then 1
+            when a.house_code is not null and b.house_code is null then 2
+            when b.house_code is not null then 3
+            end as status
+            FROM
+            jczz_house jh
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship = 1 and house_code is not null and house_code != '' GROUP BY house_code
+            ) a on a.house_code = jh.house_code
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship = 18 and house_code is not null and house_code != '' GROUP BY house_code
+            ) b on b.house_code = jh.house_code
+            left join
+            (
+            select house_code from jczz_household where is_deleted = 0 and relationship is null or (relationship!=1 and relationship!=18) and house_code is not null and house_code != '' GROUP BY house_code
+            ) c on c.house_code = jh.house_code
+        ) d left join jczz_user_house_label juhl on d.house_code = juhl.house_code and lable_type = 2
+        where juhl.id is null and status is not null
+        limit #{i},#{size}
+    </select>
+
 
 </mapper>

--
Gitblit v1.9.3