吉安感知网项目-后端
linwei
2026-04-02 b954d7a119eb635394bf4ff3619a9ab4b4978e48
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwAreaDivideMapper.xml
@@ -43,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 != ''">
@@ -99,7 +99,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
            <if test="deptList != null and deptList.size > 0">
@@ -112,7 +112,7 @@
                and exists (
                    select 1
                    from ja_fw_defense_scene ds
                    join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id and dsm.is_deleted = 0
                    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 != ''
@@ -123,7 +123,7 @@
                and exists (
                    select 1
                    from ja_fw_defense_scene ds
                    join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id and dsm.is_deleted = 0
                    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 != ''
@@ -234,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>
@@ -264,14 +264,14 @@
            (
                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 and dsm.is_deleted = 0
                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 and dsm.is_deleted = 0
                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,
@@ -284,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, ' ', ''))
                )
@@ -294,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, ' ', ''))
                )
@@ -304,7 +304,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 = '1'
                      and find_in_set(d.id, replace(ad.device_ids, ' ', ''))
@@ -316,7 +316,7 @@
                and exists (
                    select 1
                    from ja_fw_defense_scene ds
                    join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id and dsm.is_deleted = 0
                    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)
                )
@@ -398,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, ' ', ''))
                )
@@ -408,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, ' ', ''))
                )
@@ -418,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, ' ', ''))
@@ -467,7 +467,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
        inner join (
                SELECT
                    d.id
@@ -491,13 +491,81 @@
                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 &lt;= #{flyTime})
                and (dsm.effective_date_end is null or dsm.effective_date_end &gt;= #{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 and ds.is_deleted = 0
        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