From d35386e9b1a5d87aa32b4367a745ba550b06ba12 Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Sat, 02 Mar 2024 11:52:40 +0800
Subject: [PATCH] 房屋查询过滤

---
 src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 50 insertions(+), 5 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 b33fe92..07e5f12 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,56 @@
             <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>
+
+                            </otherwise>
+                        </choose>
+                    </otherwise>
                 </choose>
             </if>
             <if test="house.parentId != null ">

--
Gitblit v1.9.3