From 74756c657109a4e48dd6c0b4d8959cdab89b33a9 Mon Sep 17 00:00:00 2001
From: xiebin <vip_xiaobin810@163.com>
Date: Wed, 28 Jan 2026 20:10:29 +0800
Subject: [PATCH] update-区域划分表结构调整

---
 drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml |  197 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 136 insertions(+), 61 deletions(-)

diff --git a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
index d561a38..f73938e 100644
--- a/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
+++ b/drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -28,7 +28,6 @@
         <result column="update_user" property="updateUser"/>
         <result column="update_time" property="updateTime"/>
         <result column="status" property="status"/>
-        <result column="is_deleted" property="isDeleted"/>
     </resultMap>
 
     <resultMap id="fwAreaDivideStatisticsResultMap" type="org.sxkj.fw.area.vo.FwAreaDivideStatisticsVO">
@@ -47,37 +46,39 @@
 
     <select id="selectFwAreaDividePage" resultMap="fwAreaDivideResultMap">
         select
-        ad.id,
-        ad.area_name,
-        ad.longitude,
-        ad.latitude,
-        ad.area_size,
-        case
-            when ad.geom is null then null
-            when ST_SRID(ad.geom) is null or ST_SRID(ad.geom) = 0 then ST_AsText(ad.geom)
-            else concat(ST_AsText(ST_SwapXY(ad.geom)), ' | ', ST_SRID(ad.geom))
-        end as geom,
-        ad.area_type,
-        ad.trigger_condition,
-        ad.response_mechanism,
-        ad.control_level,
-        ad.police_station_id,
-        ad.device_ids,
-        ad.fly_date_start,
-        ad.fly_date_end,
-        ad.area_code,
-        ps.station_name as police_station_name,
-        ad.create_user,
-        ad.create_dept,
-        ad.create_time,
-        ad.update_user,
-        ad.update_time,
-        ad.status,
-        ad.is_deleted
-        from ja_fw_area_divide ad
-        left join ja_fw_police_station ps on ps.id = ad.police_station_id and ps.is_deleted = 0
+            ad.id,
+            ad.area_name,
+            ad.longitude,
+            ad.latitude,
+            ad.area_size,
+            case
+                when ad.geom is null then null
+                when ST_SRID(ad.geom) is null or ST_SRID(ad.geom) = 0 then ST_AsText(ad.geom)
+                else concat(ST_AsText(ST_SwapXY(ad.geom)), ' | ', ST_SRID(ad.geom))
+            end as geom,
+            ad.area_type,
+            ad.trigger_condition,
+            ad.response_mechanism,
+            ad.control_level,
+            ad.police_station_id,
+            ad.device_ids,
+            ad.fly_date_start,
+            ad.fly_date_end,
+            ad.area_code,
+            ps.station_name as police_station_name,
+            ad.create_user,
+            ad.create_dept,
+            ad.create_time,
+            ad.update_user,
+            ad.update_time,
+            ad.status,
+            ad.is_deleted
+        from
+            ja_fw_area_divide ad
+        left join
+            ja_fw_police_station ps on ps.id = ad.police_station_id and ps.is_deleted = 0
         <where>
-            ad.is_deleted = 0
+                ad.is_deleted = 0
             <if test="param2.id != null and param2.id != ''">
                 and ad.id = #{param2.id}
             </if>
@@ -120,6 +121,12 @@
             <if test="param2.areaCode != null and param2.areaCode != ''">
                 and ad.area_code = #{param2.areaCode}
             </if>
+            <if test="param2.deptList != null and param2.deptList.size > 0">
+                and ad.create_dept in
+                <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
+                    #{deptId}
+                </foreach>
+            </if>
         </where>
     </select>
 
@@ -156,29 +163,91 @@
         left join ja_fw_police_station ps on ps.id = ad.police_station_id and ps.is_deleted = 0
         <where>
             ad.is_deleted = 0
-            <choose>
-                <when test="sceneId != null">
-                    and exists (
+            <if test="filterSelected != null and filterSelected == 1">
+                and (
+                    not exists (
                         select 1
                         from ja_fw_defense_scene ds
                         where ds.is_deleted = 0
-                          and ds.id = #{sceneId}
                           and ds.area_divide_ids is not null
                           and ds.area_divide_ids != ''
                           and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                     )
-                </when>
-                <when test="filterSelected != null and filterSelected == 1">
-                    and not exists (
-                        select 1
-                        from ja_fw_defense_scene ds
-                        where ds.is_deleted = 0
-                          and ds.area_divide_ids is not null
-                          and ds.area_divide_ids != ''
-                          and find_in_set(ad.id, ds.area_divide_ids)
-                    )
-                </when>
-            </choose>
+                    <if test="sceneId != null">
+                        or exists (
+                            select 1
+                            from ja_fw_defense_scene ds
+                            where ds.is_deleted = 0
+                              and ds.id = #{sceneId}
+                              and ds.area_divide_ids is not null
+                              and ds.area_divide_ids != ''
+                              and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
+                        )
+                    </if>
+                )
+            </if>
+            <if test="sceneId != null and (filterSelected == null or filterSelected != 1)">
+                and exists (
+                    select 1
+                    from ja_fw_defense_scene ds
+                    where ds.is_deleted = 0
+                      and ds.id = #{sceneId}
+                      and ds.area_divide_ids is not null
+                      and ds.area_divide_ids != ''
+                      and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
+                )
+            </if>
+        </where>
+    </select>
+
+    <select id="selectFwAreaDivideListByDeviceIds" resultMap="fwAreaDivideResultMap">
+        select
+        ad.id,
+        ad.area_name,
+        ad.device_ids
+        from ja_fw_area_divide ad
+        <where>
+            ad.is_deleted = 0
+            and ad.device_ids is not null
+            and ad.device_ids != ''
+            <if test="deviceIds != null and deviceIds.size > 0">
+                and (
+                    <foreach collection="deviceIds" item="deviceId" separator=" or ">
+                        find_in_set(#{deviceId}, replace(ad.device_ids, ' ', ''))
+                    </foreach>
+                )
+            </if>
+        </where>
+    </select>
+
+    <select id="selectFwDefenseSceneListByAreaIds" resultType="org.sxkj.fw.area.vo.FwDefenseSceneVO">
+        select
+        ds.id,
+        ds.scene_name as sceneName,
+        ds.area_divide_ids as areaDivideIds
+        from ja_fw_defense_scene ds
+        <where>
+            ds.is_deleted = 0
+            and ds.area_divide_ids is not null
+            and ds.area_divide_ids != ''
+            <if test="areaIds != null and areaIds.size > 0">
+                and (
+                    <foreach collection="areaIds" item="areaId" separator=" or ">
+                        find_in_set(#{areaId}, replace(ds.area_divide_ids, ' ', ''))
+                    </foreach>
+                )
+            </if>
+        </where>
+    </select>
+
+    <select id="selectAreaCountByDeviceId" resultType="java.lang.Integer">
+        select count(1)
+        from ja_fw_area_divide ad
+        <where>
+            ad.is_deleted = 0
+            and ad.device_ids is not null
+            and ad.device_ids != ''
+            and find_in_set(#{deviceId}, replace(ad.device_ids, ' ', ''))
         </where>
     </select>
 
@@ -221,21 +290,21 @@
 
     <select id="selectFwAreaDivideStatisticsPage" resultMap="fwAreaDivideStatisticsResultMap">
         select
-        stats.id,
-        stats.area_name,
-        stats.area_type,
-        stats.scene_name,
-        stats.scene_type,
-        stats.device_count,
-        stats.alarm_count,
-        stats.counter_count,
-        stats.counter_success_count,
-        case
-            when stats.counter_count = 0 then '/'
-            when stats.counter_success_count * 100.0 / stats.counter_count &gt;= 80 then '好'
-            when stats.counter_success_count * 100.0 / stats.counter_count &gt;= 60 then '一般'
+            stats.id,
+            stats.area_name,
+            stats.area_type,
+            stats.scene_name,
+            stats.scene_type,
+            stats.device_count,
+            stats.alarm_count,
+            stats.counter_count,
+            stats.counter_success_count,
+            case
+                when stats.counter_count = 0 then '/'
+                when stats.counter_success_count * 100.0 / stats.counter_count &gt;= 80 then '好'
+                when stats.counter_success_count * 100.0 / stats.counter_count &gt;= 60 then '一般'
             else '差'
-        end as control_effect
+                end as control_effect
         from (
             select
             ad.id,
@@ -312,6 +381,12 @@
                 <if test="param2.areaCode != null and param2.areaCode != ''">
                     and ad.area_code = #{param2.areaCode}
                 </if>
+                <if test="param2.deptList != null and param2.deptList.size > 0">
+                    and ad.create_dept in
+                    <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
+                        #{deptId}
+                    </foreach>
+                </if>
             </where>
         ) stats
     </select>

--
Gitblit v1.9.3