From d46ca134f82fd106bfbbbd71aef7184805e6d7e7 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Fri, 19 Jan 2024 09:17:54 +0800
Subject: [PATCH] bug 修复

---
 src/main/java/org/springblade/modules/grid/mapper/GridmanMapper.xml |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/springblade/modules/grid/mapper/GridmanMapper.xml b/src/main/java/org/springblade/modules/grid/mapper/GridmanMapper.xml
index c36fb17..0f3c3bb 100644
--- a/src/main/java/org/springblade/modules/grid/mapper/GridmanMapper.xml
+++ b/src/main/java/org/springblade/modules/grid/mapper/GridmanMapper.xml
@@ -20,9 +20,13 @@
     <!--自定义分页查询-->
     <select id="selectGridmanPage" resultType="org.springblade.modules.grid.vo.GridmanVO">
         select
-        jgm.*,jg.community_code communityCode
+        jgm.*,
+        jg.grid_name gridName,jg.community_code communityCode,
+        br.name as communityName,
+        br.town_name as townName
         from jczz_gridman jgm
         left join jczz_grid jg on jg.id = jgm.grid_id and jg.is_deleted = 0
+        left join blade_region br on br.code = jg.community_code
         where jgm.is_deleted = 0
         <if test="gridman.gridmanName!=null and gridman.gridmanName!=''">
             and jgm.gridman_name like concat('%',#{gridman.gridmanName},'%')
@@ -35,6 +39,25 @@
         </if>
         <if test="gridman.communityCode!=null and gridman.communityCode!=''">
             and jg.community_code like concat('%',#{gridman.communityCode},'%')
+        </if>
+        <if test="gridman.communityName!=null and gridman.communityName!=''">
+            and br.name like concat('%',#{gridman.communityName},'%')
+        </if>
+        <if test="gridman.townName!=null and gridman.townName!=''">
+            and br.town_name like concat('%',#{gridman.townName},'%')
+        </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>
+                <otherwise>
+                    and jg.community_code in ('')
+                </otherwise>
+            </choose>
         </if>
     </select>
 
@@ -55,11 +78,11 @@
     <select id="getGridStatistics" resultType="java.lang.Integer">
         SELECT count(1) number
         FROM jczz_gridman jgm
-        LEFT JOIN jczz_grid jg  ON jg.id = jgm.grid_id
+        LEFT JOIN jczz_grid jg ON jg.id = jgm.grid_id
         WHERE jg.community_code = #{code}
         AND jg.is_deleted = 0
         <if test="userId!=null and roleType == '1'">
-          and jgm.user_id= #{userId}
+            and jgm.user_id= #{userId}
         </if>
     </select>
 
@@ -96,7 +119,7 @@
         jczz_district jd ON jd.id = joc.area_id
         WHERE
         jd.community_code = #{code}
-        and jpcd.is_deleted= 0
+        and joc.delete_flag= 0
         <if test="userId!=null and roleType == '1'">
             AND jd.aoi_code in (
             SELECT distinct
@@ -124,4 +147,26 @@
         where jgm.is_deleted = 0
         and jgm.id = #{gridman.id}
     </select>
+
+    <!--查询网格id-->
+    <select id="getGridIdByUserId" resultType="java.lang.Integer">
+        select
+        jgm.grid_id
+        from jczz_gridman jgm
+        where jgm.is_deleted = 0
+        and jgm.user_id = #{userId}
+        limit 1
+    </select>
+
+    <select id="getGridManByCode" resultType="org.springblade.modules.system.entity.User">
+SELECT
+	*
+FROM
+	blade_user bu
+	LEFT JOIN jczz_gridman jgm ON bu.id = jgm.user_id
+	LEFT JOIN jczz_grid jg ON jgm.grid_id = jg.id
+WHERE
+	jg.community_code IN ( SELECT jg.community_code FROM jczz_grid jg LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id WHERE jgr.house_code = #{houseCode} )
+	AND bu.is_deleted = 0
+    </select>
 </mapper>

--
Gitblit v1.9.3