From 5745a87f3a139ea2bbdaf4704978e4c151ecc45a Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Tue, 23 Jan 2024 17:39:48 +0800
Subject: [PATCH] 物业管理管和项目经理数据过滤

---
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml |   64 +++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 13 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 81a1a44..7fedafe 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -138,8 +138,7 @@
         br.town_name as townStreetName,br.name as neiName,
         jg.grid_name
         from jczz_house jh
-        left join jczz_grid_range jgr on jgr.house_code = jh.house_code
-        left join jczz_grid jg on jg.id = jgr.grid_id and jg.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
         <where>
             <if test="house.id != null ">and jh.id = #{house.id}</if>
@@ -171,8 +170,18 @@
             <if test="house.unit != null  and house.unit != ''">and jh.unit = #{house.unit}</if>
             <if test="house.room != null  and house.room != ''">and jh.room = #{house.room}</if>
             <if test="house.buildingNo != null ">and jh.building_no = #{house.buildingNo}</if>
-            <if test="house.regionCode != null and house.regionCode !='' ">
-                and jg.community_code like concat('%',#{house.regionCode},'%')
+            <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>
+                    <otherwise>
+                        and jg.community_code in ('')
+                    </otherwise>
+                </choose>
             </if>
             <if test="house.parentId != null ">
                 and jh.house_code in (
@@ -194,22 +203,51 @@
             </if>
             and jh.is_deleted = 0
             ORDER BY
-            jh.update_time DESC
+            jh.update_time desc,jh.id desc
         </where>
 
 
     </select>
 
+    <!--房屋详情-->
+    <resultMap id="houseAndHouseLabelDetailMap" type="org.springblade.modules.house.vo.HouseVO" autoMapping="true">
+        <result column="id" property="id"/>
+        <result column="house_code" property="houseCode"/>
+        <result column="district_code" property="districtCode"/>
+        <result column="district_name" property="districtName"/>
+        <result column="house_name" property="houseName"/>
+        <result column="phone" property="phone"/>
+        <result column="area" property="area"/>
+        <result column="property_price" property="propertyPrice"/>
+        <result column="service_due" property="serviceDue"/>
+        <result column="floor" property="floor"/>
+        <result column="building" property="building"/>
+        <result column="unit" property="unit"/>
+        <result column="room" property="room"/>
+        <result column="building_no" property="buildingNo"/>
+        <result column="image_urls" property="imageUrls"/>
+        <result column="create_user" property="createUser"/>
+        <result column="created_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="remark" property="remark"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <collection property="userHouseLabelVOList" javaType="java.util.List"
+                    ofType="org.springblade.modules.house.vo.UserHouseLabelVO" autoMapping="true">
+            <id property="id" column="cid"/>
+            <result property="remark" column="cremark"/>
+        </collection>
+    </resultMap>
+
     <!--房屋自定义详情查询-->
-    <select id="getHouseDetail" resultMap="houseAndHouseLabelMap">
+    <select id="getHouseDetail" resultMap="houseAndHouseLabelDetailMap">
         select
         jh.*,
         jhl.id as cid,jhl.*,jhl.remark as cremark,
-        br.code as neiCode,jg.id as gridId,br.town_code as streetCode
+        br.code as neiCode,br.town_code as streetCode
         from jczz_house jh
         left join jczz_user_house_label jhl on jh.house_code = jhl.house_code and jhl.lable_type = 2
-        left join jczz_grid_range jgr on jgr.house_code = jh.house_code
-        left join jczz_grid jg on jg.id = jgr.grid_id and jg.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
         where jh.is_deleted = 0
         <if test="house.houseCode!=null and house.houseCode!=''">
@@ -352,7 +390,7 @@
             jczz_doorplate_address jda
             LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
             WHERE
-            jc.res_police_user_id = #{userId})
+            jc.res_police_user_id  like concat('%',#{userId},'%'))
             )
         </if>
         ) a
@@ -406,7 +444,7 @@
             jczz_doorplate_address jda
             LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
             WHERE
-            jc.res_police_user_id = #{userId})
+            jc.res_police_user_id like concat('%',#{userId},'%'))
             )
         </if>
         ) a
@@ -456,7 +494,7 @@
             jczz_doorplate_address jda
             LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
             WHERE
-            jc.res_police_user_id = #{userId})
+            jc.res_police_user_id like concat('%',#{userId},'%'))
             )
         </if>
     </select>
@@ -507,7 +545,7 @@
             jczz_doorplate_address jda
             LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
             WHERE
-            jc.res_police_user_id = #{userId})
+            jc.res_police_user_id like concat('%',#{userId},'%'))
             )
         </if>
         ) a

--
Gitblit v1.9.3