| | |
| | | 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 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 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"> |