From de478946803e8034a68751e18e7eed3805ac43dd Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Tue, 13 Jan 2026 09:16:32 +0800
Subject: [PATCH] 区域模块增加统计分页和统计详情

---
 drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml |  192 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 192 insertions(+), 0 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 19b5e74..ecc0d0f 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
@@ -31,6 +31,19 @@
         <result column="is_deleted" property="isDeleted"/>
     </resultMap>
 
+    <resultMap id="fwAreaDivideStatisticsResultMap" type="org.sxkj.fw.area.vo.FwAreaDivideStatisticsVO">
+        <result column="id" property="id"/>
+        <result column="area_name" property="areaName"/>
+        <result column="area_type" property="areaType"/>
+        <result column="scene_name" property="sceneName"/>
+        <result column="scene_type" property="sceneType"/>
+        <result column="device_count" property="deviceCount"/>
+        <result column="alarm_count" property="alarmCount"/>
+        <result column="counter_count" property="counterCount"/>
+        <result column="counter_success_count" property="counterSuccessCount"/>
+        <result column="control_effect" property="controlEffect"/>
+    </resultMap>
+
 
     <select id="selectFwAreaDividePage" resultMap="fwAreaDivideResultMap">
         select
@@ -150,6 +163,185 @@
           and ad.id = #{id}
     </select>
 
+    <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 '一般'
+            else '差'
+        end as control_effect
+        from (
+            select
+            ad.id,
+            ad.area_name,
+            ad.area_type,
+            (
+                select group_concat(distinct ds.scene_name)
+                from ja_fw_defense_scene ds
+                where ds.is_deleted = 0
+                  and find_in_set(ad.id, ds.area_divide_ids)
+            ) as scene_name,
+            (
+                select group_concat(distinct ds.scene_type)
+                from ja_fw_defense_scene ds
+                where ds.is_deleted = 0
+                  and find_in_set(ad.id, ds.area_divide_ids)
+            ) as scene_type,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else length(replace(ad.device_ids, ' ', '')) - length(replace(replace(ad.device_ids, ' ', ''), ',', '')) + 1
+            end as device_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_drone_alarm_record ar
+                    join ja_fw_device d on d.id = ar.device_id and d.is_deleted = 0
+                    where ar.is_deleted = 0
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as alarm_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_effect_eval ee
+                    join ja_fw_device d on d.id = ee.device_id and d.is_deleted = 0
+                    where ee.is_deleted = 0
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as counter_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_effect_eval ee
+                    join ja_fw_device d on d.id = ee.device_id and d.is_deleted = 0
+                    where ee.is_deleted = 0
+                      and ee.counter_effect = 'success'
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as counter_success_count
+            from ja_fw_area_divide ad
+            <where>
+                ad.is_deleted = 0
+                <if test="param2.id != null and param2.id != ''">
+                    and ad.id = #{param2.id}
+                </if>
+                <if test="param2.areaName != null and param2.areaName != ''">
+                    and ad.area_name like concat('%', #{param2.areaName}, '%')
+                </if>
+                <if test="param2.areaType != null and param2.areaType != ''">
+                    and ad.area_type = #{param2.areaType}
+                </if>
+                <if test="param2.sceneType != null and param2.sceneType != ''">
+                    and exists (
+                        select 1
+                        from ja_fw_defense_scene ds
+                        where ds.is_deleted = 0
+                          and find_in_set(ad.id, ds.area_divide_ids)
+                          and ds.scene_type = #{param2.sceneType}
+                    )
+                </if>
+                <if test="param2.areaCode != null and param2.areaCode != ''">
+                    and ad.area_code = #{param2.areaCode}
+                </if>
+            </where>
+        ) stats
+    </select>
+
+    <select id="selectFwAreaDivideStatisticsDetail" 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 '一般'
+            else '差'
+        end as control_effect
+        from (
+            select
+            ad.id,
+            ad.area_name,
+            ad.area_type,
+            (
+                select group_concat(distinct ds.scene_name)
+                from ja_fw_defense_scene ds
+                where ds.is_deleted = 0
+                  and find_in_set(ad.id, ds.area_divide_ids)
+            ) as scene_name,
+            (
+                select group_concat(distinct ds.scene_type)
+                from ja_fw_defense_scene ds
+                where ds.is_deleted = 0
+                  and find_in_set(ad.id, ds.area_divide_ids)
+            ) as scene_type,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else length(replace(ad.device_ids, ' ', '')) - length(replace(replace(ad.device_ids, ' ', ''), ',', '')) + 1
+            end as device_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_drone_alarm_record ar
+                    join ja_fw_device d on d.id = ar.device_id and d.is_deleted = 0
+                    where ar.is_deleted = 0
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as alarm_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_effect_eval ee
+                    join ja_fw_device d on d.id = ee.device_id and d.is_deleted = 0
+                    where ee.is_deleted = 0
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as counter_count,
+            case
+                when ad.device_ids is null or trim(ad.device_ids) = '' then 0
+                else (
+                    select count(1)
+                    from ja_fw_effect_eval ee
+                    join ja_fw_device d on d.id = ee.device_id and d.is_deleted = 0
+                    where ee.is_deleted = 0
+                      and ee.counter_effect = 'success'
+                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
+                )
+            end as counter_success_count
+            from ja_fw_area_divide ad
+            <where>
+                ad.is_deleted = 0
+                <if test="id != null and id != ''">
+                    and ad.id = #{id}
+                </if>
+                <if test="areaCode != null and areaCode != ''">
+                    and ad.area_code = #{areaCode}
+                </if>
+            </where>
+        ) stats
+    </select>
+
 
     <select id="exportFwAreaDivide" resultType="org.sxkj.fw.area.excel.FwAreaDivideExcel">
         SELECT

--
Gitblit v1.9.3