| | |
| | | <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> |
| | |
| | | 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"> |
| | |
| | | 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> |
| | | |
| | |
| | | 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) |
| | | 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 |
| | | 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) |
| | | 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 = '1' |
| | | 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 |
| | |
| | | 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) |
| | | and ad.id = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | ) |
| | | <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 = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | 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 |
| | |
| | | </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"> |
| | |
| | | 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"> |
| | |
| | | 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> |
| | |
| | | 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 #{areaId} = ANY(string_to_array(ds.area_divide_ids, ',')::bigint[]) |
| | | and dsm.is_deleted = 0 |
| | | </select> |
| | | |