| | |
| | | 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 |
| | | ja_fw_police_station ps on ps.id::VARCHAR = ad.police_station_id::VARCHAR and ps.is_deleted = 0 |
| | | <where> |
| | | ad.is_deleted = 0 |
| | | <if test="param2.id != null and param2.id != ''"> |
| | |
| | | <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) |
| | | ARRAY_POSITION(string_to_array(ad.area_type_keys, ','), #{key}) IS NOT NULL |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | 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 |
| | | left join ja_fw_police_station ps on ps.id::VARCHAR = ad.police_station_id::VARCHAR and ps.is_deleted = 0 |
| | | <where> |
| | | ad.is_deleted = 0 |
| | | <if test="deptList != null and deptList.size > 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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | 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}) |
| | | ) |
| | |
| | | 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | <if test="sceneId != null"> |
| | | or exists ( |
| | |
| | | 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, ' ', '')) |
| | | and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </if> |
| | | ) |
| | |
| | | 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, ' ', '')) |
| | | and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </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) |
| | | ARRAY_POSITION(string_to_array(ad.area_type_keys, ','), #{key}) IS NOT NULL |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | <if test="deviceIds != null and deviceIds.size > 0"> |
| | | and ( |
| | | <foreach collection="deviceIds" item="deviceId" separator=" or "> |
| | | find_in_set(#{deviceId}, replace(ad.device_ids, ' ', '')) |
| | | #{deviceId} = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | <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, ' ', '')) |
| | | #{areaId} = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | ad.is_deleted = 0 |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and find_in_set(#{deviceId}, replace(ad.device_ids, ' ', '')) |
| | | and #{deviceId} = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | </where> |
| | | </select> |
| | | |
| | |
| | | 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 |
| | | left join ja_fw_police_station ps on ps.id::VARCHAR = ad.police_station_id::VARCHAR and ps.is_deleted = 0 |
| | | where ad.is_deleted = 0 |
| | | and ad.id = #{id} |
| | | </select> |
| | |
| | | ad.area_name, |
| | | ad.area_type_keys, |
| | | ( |
| | | select group_concat(distinct ds.scene_name) |
| | | select string_agg(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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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, |
| | | AND ad.id::VARCHAR = ANY(string_to_array(ds.area_divide_ids, ','))) AS scene_name, |
| | | ( |
| | | select group_concat(distinct ds.scene_type) |
| | | select string_agg(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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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, |
| | | AND ad.id::VARCHAR = ANY(string_to_array(ds.area_divide_ids, ','))) AS scene_name, |
| | | 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 |
| | |
| | | else ( |
| | | select count(1) |
| | | from ja_fw_drone_alarm_record ar |
| | | join ja_fw_device d on d.id = ar.device_id::VARCHAR and d.is_deleted = 0 |
| | | join ja_fw_device d on d.id::VARCHAR = ar.device_id::VARCHAR and d.is_deleted = 0 |
| | | where ar.is_deleted = 0 |
| | | and find_in_set(d.id, replace(ad.device_ids, ' ', '')) |
| | | and ad.id::VARCHAR = ANY(string_to_array(ad.device_ids, ',')) |
| | | ) |
| | | end as alarm_count, |
| | | case |
| | |
| | | from ja_fw_effect_eval ee |
| | | 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, ' ', '')) |
| | | and ad.id::VARCHAR = ANY(string_to_array(ad.device_ids, ',')) |
| | | ) |
| | | end as counter_count, |
| | | case |
| | |
| | | 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, ' ', '')) |
| | | and ad.id::VARCHAR = ANY(string_to_array(ad.device_ids, ',')) |
| | | ) |
| | | end as counter_success_count |
| | | from ja_fw_area_divide ad |
| | |
| | | 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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = ds.id::VARCHAR and dsm.is_deleted = 0 |
| | | where ds.is_deleted = 0 |
| | | and find_in_set(ad.id, ds.area_divide_ids) |
| | | and ad.id::VARCHAR = ANY(string_to_array(ad.device_ids, ',')) |
| | | ) |
| | | <if test="param2.id != null and param2.id != ''"> |
| | | and ad.id = #{param2.id} |
| | |
| | | select 1 |
| | | from ja_fw_defense_scene ds |
| | | where ds.is_deleted = 0 |
| | | and find_in_set(ad.id, ds.area_divide_ids) |
| | | and ad.id::VARCHAR = ANY(string_to_array(ad.device_ids, ',')) |
| | | and ds.scene_type = #{param2.sceneType} |
| | | ) |
| | | </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) |
| | | ARRAY_POSITION(string_to_array(ad.area_type_keys, ','), #{key}) IS NOT NULL |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | ad.area_name, |
| | | ad.area_type_keys, |
| | | ( |
| | | select group_concat(distinct ds.scene_name) |
| | | select string_agg(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) |
| | | and ad.id = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | ) as scene_name, |
| | | ( |
| | | select group_concat(distinct ds.scene_type) |
| | | select string_agg(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) |
| | | and ad.id = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | ) as scene_type, |
| | | case |
| | | when ad.device_ids is null or trim(ad.device_ids) = '' then 0 |
| | |
| | | from ja_fw_drone_alarm_record ar |
| | | 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, ' ', '')) |
| | | and d.id = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | end as alarm_count, |
| | | case |
| | |
| | | from ja_fw_effect_eval ee |
| | | 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, ' ', '')) |
| | | and d.id = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | end as counter_count, |
| | | case |
| | |
| | | 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, ' ', '')) |
| | | and d.id = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | end as counter_success_count |
| | | from ja_fw_area_divide ad |
| | |
| | | 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 |
| | | left join ja_fw_police_station ps on ps.id::VARCHAR = ad.police_station_id::VARCHAR and ps.is_deleted = 0 |
| | | inner join ( |
| | | SELECT |
| | | d.id |
| | |
| | | </if> |
| | | GROUP BY |
| | | d.id |
| | | ) dd on find_in_set(dd.id, ad.device_ids) |
| | | ) dd on dd.id = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')::bigint[]) |
| | | <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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </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 |
| | | join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | 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}) |
| | | ) |
| | |
| | | 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 ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | <if test="sceneId != null"> |
| | | or exists ( |
| | |
| | | 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, ' ', '')) |
| | | and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </if> |
| | | ) |
| | |
| | | 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, ' ', '')) |
| | | and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | ) |
| | | </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) |
| | | ARRAY_POSITION(string_to_array(ad.area_type_keys, ','), #{key}) IS NOT NULL |
| | | </foreach> |
| | | ) |
| | | </if> |
| | |
| | | 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 |
| | | left join ja_fw_defense_scene ds on ds.id::VARCHAR = 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 #{areaId} = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | and dsm.is_deleted = 0 |
| | | </select> |
| | | |
| | |
| | | #{createTime}, |
| | | #{updateUser}, |
| | | #{updateTime}, |
| | | IFNULL(#{status}, '0'), |
| | | IFNULL(#{isDeleted}, 0) |
| | | COALESCE(#{status}, '0'), |
| | | COALESCE(#{isDeleted}, 0) |
| | | ) |
| | | </insert> |
| | | |