From b954d7a119eb635394bf4ff3619a9ab4b4978e48 Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Thu, 02 Apr 2026 09:33:34 +0800
Subject: [PATCH] sql改造首页
---
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml | 198 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 187 insertions(+), 11 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 71cf5bc..2fdfeb3 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
@@ -23,6 +23,7 @@
<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_keys" property="areaTypeKeys"/>
<result column="scene_name" property="sceneName"/>
<result column="scene_type" property="sceneType"/>
<result column="device_count" property="deviceCount"/>
@@ -42,7 +43,7 @@
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
+ ja_fw_police_station ps on ps.id = ad.police_station_id::VARCHAR and ps.is_deleted = 0
<where>
ad.is_deleted = 0
<if test="param2.id != null and param2.id != ''">
@@ -75,6 +76,13 @@
<if test="param2.areaCode != null and param2.areaCode != ''">
and ad.area_code = #{param2.areaCode}
</if>
+ <if test="param2.areaTypeKeyList != null and param2.areaTypeKeyList.size > 0">
+ and (
+ <foreach collection="param2.areaTypeKeyList" item="key" separator=" or ">
+ find_in_set(#{key}, ad.area_type_keys)
+ </foreach>
+ )
+ </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=")">
@@ -91,9 +99,39 @@
ps.contact_person as police_station_contact_person,
ps.contact_phone as police_station_contact_phone
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
+ left join ja_fw_police_station ps on ps.id = ad.police_station_id::VARCHAR and ps.is_deleted = 0
<where>
- ad.is_deleted = 0
+ ad.is_deleted = 0
+ <if test="deptList != null and deptList.size > 0">
+ and ad.create_dept in
+ <foreach collection="deptList" item="deptId" open="(" separator="," close=")">
+ #{deptId}
+ </foreach>
+ </if>
+ <if test="isSetSceneManage != null and isSetSceneManage == 1">
+ and exists (
+ select 1
+ from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
+ where ds.is_deleted = 0
+ 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 test="isSetSceneManage != null and isSetSceneManage == 1 and flyTime != null">
+ and exists (
+ select 1
+ from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
+ where ds.is_deleted = 0
+ and ds.area_divide_ids is not null
+ and ds.area_divide_ids != ''
+ and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
+ and (dsm.effective_date_start is null or dsm.effective_date_start <= #{flyTime})
+ and (dsm.effective_date_end is null or dsm.effective_date_end >= #{flyTime})
+ )
+ </if>
<if test="filterSelected != null and filterSelected == 1">
and (
not exists (
@@ -126,6 +164,13 @@
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 test="areaTypeKeyList != null and areaTypeKeyList.size > 0">
+ and (
+ <foreach collection="areaTypeKeyList" item="key" separator=" or ">
+ find_in_set(#{key}, ad.area_type_keys)
+ </foreach>
)
</if>
</where>
@@ -189,7 +234,7 @@
ps.contact_person as police_station_contact_person,
ps.contact_phone as police_station_contact_phone
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
+ left join ja_fw_police_station ps on ps.id = ad.police_station_id::VARCHAR and ps.is_deleted = 0
where ad.is_deleted = 0
and ad.id = #{id}
</select>
@@ -198,6 +243,7 @@
select
stats.id,
stats.area_name,
+ stats.area_type_keys,
stats.scene_name,
stats.scene_type,
stats.device_count,
@@ -214,15 +260,18 @@
select
ad.id,
ad.area_name,
+ ad.area_type_keys,
(
select group_concat(distinct ds.scene_name)
from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
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
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
where ds.is_deleted = 0
and find_in_set(ad.id, ds.area_divide_ids)
) as scene_type,
@@ -235,7 +284,7 @@
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
+ join ja_fw_device d on d.id = ar.device_id::VARCHAR and d.is_deleted = 0
where ar.is_deleted = 0
and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
)
@@ -245,7 +294,7 @@
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
+ join ja_fw_device d on d.id = ee.device_id::VARCHAR and d.is_deleted = 0
where ee.is_deleted = 0
and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
)
@@ -255,15 +304,22 @@
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
+ join ja_fw_device d on d.id = ee.device_id::VARCHAR and d.is_deleted = 0
where ee.is_deleted = 0
- and ee.counter_effect = 'success'
+ and ee.counter_effect = '1'
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
+ and exists (
+ select 1
+ from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
+ where ds.is_deleted = 0
+ and find_in_set(ad.id, ds.area_divide_ids)
+ )
<if test="param2.id != null and param2.id != ''">
and ad.id = #{param2.id}
</if>
@@ -282,6 +338,13 @@
<if test="param2.areaCode != null and param2.areaCode != ''">
and ad.area_code = #{param2.areaCode}
</if>
+ <if test="param2.areaTypeKeyList != null and param2.areaTypeKeyList.size > 0">
+ and (
+ <foreach collection="param2.areaTypeKeyList" item="key" separator=" or ">
+ find_in_set(#{key}, ad.area_type_keys)
+ </foreach>
+ )
+ </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=")">
@@ -296,6 +359,7 @@
select
stats.id,
stats.area_name,
+ stats.area_type_keys,
stats.scene_name,
stats.scene_type,
stats.device_count,
@@ -312,6 +376,7 @@
select
ad.id,
ad.area_name,
+ ad.area_type_keys,
(
select group_concat(distinct ds.scene_name)
from ja_fw_defense_scene ds
@@ -333,7 +398,7 @@
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
+ join ja_fw_device d on d.id = ar.device_id::VARCHAR and d.is_deleted = 0
where ar.is_deleted = 0
and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
)
@@ -343,7 +408,7 @@
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
+ join ja_fw_device d on d.id = ee.device_id::VARCHAR and d.is_deleted = 0
where ee.is_deleted = 0
and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
)
@@ -353,7 +418,7 @@
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
+ join ja_fw_device d on d.id = ee.device_id::VARCHAR 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, ' ', ''))
@@ -395,6 +460,117 @@
FROM ja_fw_area_divide ${ew.customSqlSegment}
</select>
+ <select id="selectFwAreaDivideListCockpit" resultType="org.sxkj.fw.area.vo.FwAreaDivideVO">
+ select
+ ad.*,
+ ps.station_name as police_station_name,
+ ps.contact_person as police_station_contact_person,
+ ps.contact_phone as police_station_contact_phone
+ from ja_fw_area_divide ad
+ left join ja_fw_police_station ps on ps.id = ad.police_station_id::VARCHAR and ps.is_deleted = 0
+ inner join (
+ SELECT
+ d.id
+ FROM
+ ja_fw_device d
+ WHERE
+ d.is_deleted = 0
+ AND d.is_enabled = 1
+ AND d.final_outbound_area IS NOT NULL
+ <if test="regionCode != null and regionCode != ''">
+ and ( d.final_outbound_area_code like concat(#{regionCode},'%')
+ <if test="currentDeptId != null and currentDeptId != '' ">
+ or d.id in (
+ SELECT device_id FROM ja_fw_device_per_share
+ WHERE loan_to_dept_id = #{currentDeptId}
+ AND is_deleted = 0
+ )
+ </if>
+ )
+ </if>
+ GROUP BY
+ d.id
+ ) dd on find_in_set(dd.id, ad.device_ids)
+ <where>
+ ad.is_deleted = 0
+ <if test="isSetSceneManage != null and isSetSceneManage == 1">
+ and exists (
+ select 1
+ from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
+ where ds.is_deleted = 0
+ 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 test="isSetSceneManage != null and isSetSceneManage == 1 and flyTime != null">
+ and exists (
+ select 1
+ from ja_fw_defense_scene ds
+ join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id::VARCHAR and dsm.is_deleted = 0
+ where ds.is_deleted = 0
+ and ds.area_divide_ids is not null
+ and ds.area_divide_ids != ''
+ and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
+ and (dsm.effective_date_start is null or dsm.effective_date_start <= #{flyTime})
+ and (dsm.effective_date_end is null or dsm.effective_date_end >= #{flyTime})
+ )
+ </if>
+ <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.area_divide_ids is not null
+ and ds.area_divide_ids != ''
+ and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
+ )
+ <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>
+ <if test="areaTypeKeyList != null and areaTypeKeyList.size > 0">
+ and (
+ <foreach collection="areaTypeKeyList" item="key" separator=" or ">
+ find_in_set(#{key}, ad.area_type_keys)
+ </foreach>
+ )
+ </if>
+ </where>
+ </select>
+
+ <select id="checkAreaBindScene" resultType="java.lang.Boolean">
+ select
+ count(1)
+ from ja_fw_defense_scene_manage dsm
+ left join ja_fw_defense_scene ds on ds.id = dsm.defense_scene_id::VARCHAR and ds.is_deleted = 0
+ where ds.is_deleted = 0
+ and find_in_set(#{areaId}, ds.area_divide_ids)
+ and dsm.is_deleted = 0
+ </select>
+
<insert id="insertWithGeom" parameterType="org.sxkj.fw.area.entity.FwAreaDivideEntity" useGeneratedKeys="true" keyProperty="id">
insert into ja_fw_area_divide (
id,
--
Gitblit v1.9.3