| | |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectFwDeviceListByPolygons" resultMap="fwDeviceResultMap"> |
| | | select * from ja_fw_device |
| | | <where> |
| | | is_deleted = 0 |
| | | <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 find_in_set(ja_fw_device.id, 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 find_in_set(ja_fw_device.id, ad.device_ids) |
| | | 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 find_in_set(ja_fw_device.id, 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) > 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) = 0 |
| | | </if> |
| | | and longitude is not null |
| | | and longitude != '' |
| | | and latitude is not null |
| | | 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> |
| | | ) |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | |
| | | <select id="exportFwDevice" resultType="org.sxkj.fw.device.excel.FwDeviceExcel"> |
| | | SELECT * FROM ja_fw_device ${ew.customSqlSegment} |
| | |
| | | AND effective_range_km is not null |
| | | AND effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | |
| | | UNION ALL -- 合并拆分的反制部分 |
| | |
| | | AND effective_range_km is not null |
| | | AND effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS temp |
| | | GROUP BY split_device_type |
| | |
| | | and |
| | | effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS deviceCount, |
| | | -- 无线电设备数量 |
| | |
| | | and |
| | | effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS radioCount, |
| | | -- 光电设备数量 |
| | |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS opticalCount, |
| | | -- 雷达设备数量 |
| | |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS radarCount, |
| | | -- 设备告警 |
| | |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | <if test="deptList != null and deptList.size > 0"> |
| | | and create_dept in |
| | | and (create_dept in |
| | | <foreach collection="deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | ) AS deviceAlarmCount |
| | | </select> |
| | |
| | | and d.belong_dept = #{param2.belongDept} |
| | | </if> |
| | | <if test="param2.deptList != null and param2.deptList.size > 0"> |
| | | and d.create_dept in |
| | | and (d.create_dept in |
| | | <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="param2.currentDeptId != null and param2.currentDeptId != '' "> |
| | | or d.id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{param2.currentDeptId} |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | <if test="param2.deviceStatusList != null and param2.deviceStatusList != ''"> |
| | | and d.status in |