| | |
| | | and status = #{param2.status} |
| | | </if> |
| | | <if test="param2.isTrack != null and param2.isTrack == 1"> |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id = tmp.device_id::VARCHAR) > 0 |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id::VARCHAR = tmp.device_id::VARCHAR) > 0 |
| | | </if> |
| | | <if test="param2.isTrack != null and param2.isTrack == 2"> |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id = tmp.device_id::VARCHAR) = 0 |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id::VARCHAR = tmp.device_id::VARCHAR) = 0 |
| | | </if> |
| | | <if test="param2.deptList != null and param2.deptList.size > 0"> |
| | | and ( create_dept in |
| | |
| | | and track_status = 1 |
| | | <if test="query.isAreaSelect != null and query.isAreaSelect == 1"> |
| | | and ( |
| | | <choose> |
| | | <when test="query.areaId != null"> |
| | | exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | and ad.id = #{query.areaId} |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and ja_fw_device.id = ANY(string_to_array(ad.device_ids, ',')::bigint[]) |
| | | ) |
| | | or not exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and ja_fw_device.id = ANY(string_to_array(ad.device_ids, ',')::bigint[]) |
| | | and ad.id != #{query.areaId} |
| | | ) |
| | | </when> |
| | | <otherwise> |
| | | not exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and ja_fw_device.id = ANY(string_to_array(ad.device_ids, ',')::bigint[]) |
| | | ) |
| | | </otherwise> |
| | | </choose> |
| | | <choose> |
| | | <when test="query.areaId != null"> |
| | | exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | /* 修改点1:参数对齐 */ |
| | | and ad.id::text = #{query.areaId}::text |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | /* 修改点2:使用 text 匹配文本数组,去掉不稳定的 ::bigint[] */ |
| | | and ja_fw_device.id::text = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')) |
| | | ) |
| | | or not exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and ja_fw_device.id::text = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')) |
| | | and ad.id::text != #{query.areaId}::text |
| | | ) |
| | | </when> |
| | | <otherwise> |
| | | not exists ( |
| | | select 1 |
| | | from ja_fw_area_divide ad |
| | | where ad.is_deleted = 0 |
| | | and ad.device_ids is not null |
| | | and ad.device_ids != '' |
| | | and ja_fw_device.id::text = ANY(string_to_array(replace(ad.device_ids, ' ', ''), ',')) |
| | | ) |
| | | </otherwise> |
| | | </choose> |
| | | ) |
| | | </if> |
| | | <if test="query.status != null"> |
| | | and status = #{query.status} |
| | | </if> |
| | | <if test="query.isTrack != null and query.isTrack == 1"> |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id = tmp.device_id::VARCHAR) > 0 |
| | | /* 修改点3:解决 Position 575 报错,双向转 text */ |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id::text = tmp.device_id::text) > 0 |
| | | </if> |
| | | <if test="query.isTrack != null and query.isTrack == 2"> |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id = tmp.device_id::VARCHAR) = 0 |
| | | and (SELECT COUNT(*) FROM ja_fw_device_track tmp WHERE ja_fw_device.id::text = tmp.device_id::text) = 0 |
| | | </if> |
| | | and longitude is not null |
| | | and longitude != '' |
| | |
| | | and latitude != '' |
| | | <if test="query.polygons != null and query.polygons.size > 0"> |
| | | and ( |
| | | <foreach collection="query.polygons" item="polygon" separator=" OR "> |
| | | ST_Contains( |
| | | ST_SRID(ST_GeomFromText(#{polygon}), 4326), |
| | | ST_GeomFromText(CONCAT('POINT(', latitude, ' ', longitude, ')'), 4326) |
| | | ) |
| | | </foreach> |
| | | <foreach collection="query.polygons" item="polygon" separator=" OR "> |
| | | public.st_contains( |
| | | public.st_srid(public.st_geomfromtext(#{polygon}), 4326), |
| | | /* 注意:Kingbase/PostGIS 坐标顺序通常是 (经度, 纬度) 即 (longitude, latitude) */ |
| | | public.st_geomfromtext(CONCAT('POINT(', longitude, ' ', latitude, ')'), 4326) |
| | | ) |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | </where> |
| | |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | AND d.is_enabled = 1 |
| | | /* 修改点2:修正 bpchar <> integer 报错,给 3 加引号 */ |
| | | /* 修改点2:修正 bpchar integer 报错,给 3 加引号 */ |
| | | AND d.status::VARCHAR != '3' |
| | | <if test="regionCode != null and regionCode != ''"> |
| | | and (d.final_outbound_area_code like concat(#{regionCode}, '%') |
| | |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | AND is_enabled = 1 |
| | | /* 修改点5:修正 bpchar <> integer 报错 */ |
| | | /* 修改点5:修正 bpchar integer 报错 */ |
| | | AND d.status::VARCHAR != '3' |
| | | AND device_type = '3' |
| | | <if test="regionCode != null and regionCode != ''"> |
| | |
| | | END AS isShared |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ja_fw_device_per_share ps ON ps.device_id = d.id::VARCHAR |
| | | LEFT JOIN ja_fw_device_per_share ps ON ps.device_id::VARCHAR = d.id::VARCHAR |
| | | AND ps.loan_to_dept_id = #{currentDeptId} |
| | | AND ps.is_deleted = 0 |
| | | WHERE |