| | |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ja_fw_area_divide ad |
| | | ON find_in_set(d.id, ad.device_ids) > 0 |
| | | AND ad.is_deleted = 0 |
| | | ON d.id = ANY(string_to_array(ad.device_ids, ',')::bigint[]) |
| | | AND ad.is_deleted = 0 |
| | | 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},'%') |
| | | and ( d.final_outbound_area_code::text LIKE concat(#{regionCode}, '%') |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | or d.id IN ( |
| | | SELECT device_id::bigint |
| | | FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND 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}) |
| | | and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[]) |
| | | and dsm.effective_date_start <= #{flyTime}::timestamp |
| | | and dsm.effective_date_end >= #{flyTime}::timestamp |
| | | ) |
| | | </if> |
| | | GROUP BY |