From f94c803da6bb1c32bae637246b8c070cea2f031f Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Sat, 16 Mar 2024 15:56:10 +0800
Subject: [PATCH] 新增房屋标签统计

---
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 1 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 c1de566..fda77a9 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -222,7 +222,12 @@
                                 )
                             </when>
                             <otherwise>
-
+                                and
+                                (
+                                jg.grid_code in ('')
+                                or
+                                jpag.community_code in ('')
+                                )
                             </otherwise>
                         </choose>
                     </otherwise>
@@ -800,5 +805,89 @@
         </if>
     </select>
 
+    <!--按房屋标签统计-->
+    <select id="getHouseLabelStatistic" resultType="java.util.Map">
+        select a.label_name as labelName,ifnull(b.numbers,0) numbers from
+        (
+        select label_name from jczz_label where parent_id = 1001 and is_deleted = 0
+        union all
+        select '未知' as label_name
+        ) a
+        left join (
+            select
+            ifnull(juhl.label_name,'未知') labelName,
+            count(*) as numbers
+            from jczz_doorplate_address jda
+            LEFT JOIN jczz_house jh on jda.address_code = jh.house_code and jh.is_deleted = 0
+            LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0
+            LEFT JOIN blade_region br on br.code = jg.community_code
+            LEFT JOIN jczz_police_affairs_grid jpag on jh.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+            LEFT JOIN jczz_user_house_label juhl ON juhl.house_code = jh.house_code and juhl.lable_type = 2
+            where jda.doorplate_type = '户室牌'
+            <if test="house.communityCode != null  and house.communityCode != ''">
+                and jg.community_code = #{house.communityCode}
+            </if>
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="house.roleName != null and house.roleName != ''">
+                        <if test="house.roleName=='wgy'">
+                            <choose>
+                                <when test="gridCodeList !=null and gridCodeList.size()>0">
+                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jh.grid_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                        <if test="house.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>
+                                and
+                                (
+                                jg.grid_code in ('')
+                                or
+                                jpag.community_code in ('')
+                                )
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
+            group by juhl.label_name
+        ) b on a.label_name =b.labelName
+    </select>
+
 
 </mapper>

--
Gitblit v1.9.3