From 6195b0dadf2a2d9d433d9059a20a53b702297bee Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Sat, 16 Mar 2024 16:19:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java |   17 +++++
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.java            |   13 ++++
 src/main/java/org/springblade/modules/house/service/IHouseService.java         |    7 ++
 src/main/java/org/springblade/modules/house/controller/HouseController.java    |   11 +++
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml             |   91 ++++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 1 deletions(-)

diff --git a/src/main/java/org/springblade/modules/house/controller/HouseController.java b/src/main/java/org/springblade/modules/house/controller/HouseController.java
index 6c4da2e..1623399 100644
--- a/src/main/java/org/springblade/modules/house/controller/HouseController.java
+++ b/src/main/java/org/springblade/modules/house/controller/HouseController.java
@@ -278,4 +278,15 @@
 		return R.data(houseService.houseJwGridHandle());
 	}
 
+
+	/**
+	 * 房屋画像统计-按房屋标签统计
+	 * @return
+	 */
+	@GetMapping("/getHouseLabelStatistic")
+	@ApiOperation(value = "房屋画像统计")
+	public R getHouseLabelStatistic(HouseVO house) {
+		return R.data(houseService.getHouseLabelStatistic(house));
+	}
+
 }
diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
index 4eede44..92ba0e9 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
@@ -110,4 +110,17 @@
 	 * @return
 	 */
 	List<HouseEntity> getNotBindGridOrJwGridList(@Param("type") Integer type);
+
+	/**
+	 * 按房屋标签统计
+	 * @param house
+	 * @param isAdministrator
+	 * @param regionChildCodesList
+	 * @param gridCodeList
+	 * @return
+	 */
+	List<Map<String, Object>> getHouseLabelStatistic(@Param("house") HouseVO house,
+													 @Param("isAdministrator") Integer isAdministrator,
+													 @Param("regionChildCodesList")List<String> regionChildCodesList,
+													 @Param("gridCodeList")List<String> gridCodeList);
 }
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>
diff --git a/src/main/java/org/springblade/modules/house/service/IHouseService.java b/src/main/java/org/springblade/modules/house/service/IHouseService.java
index a644ab0..1f3c7cc 100644
--- a/src/main/java/org/springblade/modules/house/service/IHouseService.java
+++ b/src/main/java/org/springblade/modules/house/service/IHouseService.java
@@ -102,4 +102,11 @@
 	 * @return
 	 */
 	Object houseJwGridHandle();
+
+	/**
+	 * 房屋画像统计-按房屋标签统计
+	 * @param house
+	 * @return
+	 */
+	List<Map<String,Object>> getHouseLabelStatistic(HouseVO house);
 }
diff --git a/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java b/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
index 9a11b3e..08d98a6 100644
--- a/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
+++ b/src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
@@ -758,4 +758,21 @@
 		}
 		return null;
 	}
+
+	/**
+	 * 房屋画像统计-按房屋标签统计
+	 * @param house
+	 * @return
+	 */
+	@Override
+	public List<Map<String,Object>> getHouseLabelStatistic(HouseVO house) {
+		CommonParamSet commonParamSet = new CommonParamSet<>().invoke(HouseVO.class, house);
+		// 按房屋标签统计
+		List<Map<String,Object>> list = baseMapper.getHouseLabelStatistic(house,
+			commonParamSet.getIsAdministrator(),
+			commonParamSet.getRegionChildCodesList(),
+			commonParamSet.getGridCodeList());
+		// 返回
+		return list;
+	}
 }

--
Gitblit v1.9.3