From 9f8f9d13c42ca8cdccbf351069082a5fdccef2e4 Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Mon, 25 Mar 2024 17:30:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml |  202 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 183 insertions(+), 19 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 c3e33ab..8a9ebba 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -140,6 +140,7 @@
         from jczz_house jh
         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
         <where>
             <if test="house.id != null ">and jh.id = #{house.id}</if>
             <if test="house.streetCode != null and house.streetCode != ''">
@@ -175,12 +176,61 @@
             <if test="house.buildingNo != null ">and jh.building_no = #{house.buildingNo}</if>
             <if test="isAdministrator==2">
                 <choose>
-                    <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
-                        and jg.community_code in
-                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
-                            #{code}
-                        </foreach>
+                    <when test="house.roleName != null and house.roleName != ''">
+                        <if test="house.roleName=='wgy'">
+                            <choose>
+                                <when test="gridCodeList !=null and gridCodeList.size()>0">
+                                    and jh.grid_code in
+                                    <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>
             <if test="house.parentId != null ">
@@ -660,18 +710,40 @@
 
 
     <select id="labelCommunityStatistics" resultType="java.util.Map">
+        SELECT
+        br.code,
+        br.name,
+        br.id
+        FROM
+        blade_region br
+        <where>
+            <if test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                br.code IN
+                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                    #{code}
+                </foreach>
+            </if>
+            and br.parent_code = '361102'
+        </where>
+    </select>
+
+    <select id="getlabelCount" resultType="org.springblade.modules.label.vo.LabelVO">
 
         SELECT
-        jc.name,
-        (SELECT
-        count(DISTINCT jhl.house_code)
+        jl.label_name,
+        (	SELECT
+        count( DISTINCT jhl.house_code )
         FROM
         jczz_user_house_label jhl
         LEFT JOIN jczz_house jh ON jhl.house_code = jh.house_code
         LEFT JOIN jczz_grid jg ON jg.grid_code = jh.grid_code
         AND jg.is_deleted = 0
+        LEFT JOIN jczz_community jc ON jc.CODE = jg.community_code
         LEFT JOIN blade_region br ON br.CODE = jg.community_code
-        WHERE jhl.lable_type = 2 and jg.community_code = jc.code
+        WHERE
+        jhl.lable_type = 2
+        AND jl.id = jhl.label_id
+        AND jc.street_code = #{streetCode}
         <if test="house.townStreetName!=null and house.townStreetName!=''">
             and br.town_name like concat('%',#{house.townStreetName},'%')
         </if>
@@ -712,19 +784,111 @@
             AND juhl.label_id IS NOT NULL
             )
         </if>
-        )counts
+        ) num
         FROM
-        jczz_community jc
-        <where>
-            <if test="regionChildCodesList !=null and regionChildCodesList.size()>0">
-                jc.CODE IN
-                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
-                    #{code}
-                </foreach>
-            </if>
-        </where>
+        jczz_label jl
+        WHERE
+        jl.parent_id = '1001'
+        ORDER BY
+        jl.sort DESC
 
     </select>
 
+    <!--查询未绑定网格或警格的数据-->
+    <select id="getNotBindGridOrJwGridList" resultType="org.springblade.modules.house.entity.HouseEntity">
+        select id,lng,lat from jczz_house where is_deleted = 0 and lng != ''
+        <if test="type == 1">
+            and grid_code is null
+        </if>
+        <if test="type == 2">
+            and jw_grid_code is null
+        </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">
+                                    and jh.grid_code in
+                                    <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