| | |
| | | split_device_type |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | AND status != 3 |
| | | AND track_status = 1 |
| | | AND effective_range_km is not null |
| | | AND effective_range_km > 0 |
| | | AND d.is_enabled = 1 |
| | | AND status != 3 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | split_device_type |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | AND status != 3 |
| | | AND device_type = '3' |
| | | AND track_status = 1 |
| | | AND effective_range_km is not null |
| | | AND effective_range_km > 0 |
| | | AND is_enabled = 1 |
| | | AND status != 3 |
| | | AND device_type = '3' |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | <!-- 设备出库去向统计 --> |
| | | <select id="getDeviceOutStatistics" resultType="org.sxkj.fw.cockpit.vo.DeviceStatisticsVO"> |
| | | SELECT |
| | | t.out_target AS type, |
| | | d.final_outbound_area AS type, |
| | | COUNT(*) AS count |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t ON d.id = t.device_id |
| | | AND t.rn = 1 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | AND t.out_target IS NOT NULL |
| | | AND d.is_enabled = 1 |
| | | AND d.final_outbound_area IS NOT NULL |
| | | <if test="effectiveRangeKmIsNotNull != null and effectiveRangeKmIsNotNull == 1"> |
| | | and d.effective_range_km is not null |
| | | and d.effective_range_km > 0 |
| | |
| | | </foreach> |
| | | </if> |
| | | GROUP BY |
| | | t.out_target |
| | | d.final_outbound_area |
| | | </select> |
| | | |
| | | <!-- 设备生产厂商统计 --> |
| | |
| | | COUNT(*) |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | COUNT(*) |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | AND device_att = '1' |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | COUNT(*) |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | AND device_att = '2' |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | (SELECT |
| | | COUNT(*) |
| | | FROM ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | WHERE d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | AND device_att = '3' |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | -- 设备告警 |
| | | (SELECT |
| | | COUNT(*) |
| | | FROM ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | FROM ja_fw_device d |
| | | WHERE d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | AND status in ('1', '2', '3' ) |
| | | and effective_range_km is not null |
| | | and effective_range_km > 0 |
| | | AND track_status = 1 |
| | | <if test="regionName != null and regionName != ''"> |
| | | and (t.out_target = #{regionName} |
| | | and (d.final_outbound_area = #{regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | d.* |
| | | from |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t |
| | | ON d.id = t.device_id AND t.rn = 1 |
| | | <where> |
| | | d.is_deleted = 0 |
| | | and d.effective_range_km is not null |
| | | and d.effective_range_km > 0 |
| | | -- and d.effective_range_km is not null |
| | | -- and d.effective_range_km > 0 |
| | | and d.track_status = 1 |
| | | and d.is_enabled = 1 |
| | | <if test="param2.regionName != null and param2.regionName != ''"> |
| | | and (t.out_target = #{param2.regionName} |
| | | and (d.final_outbound_area = #{param2.regionName} |
| | | <!-- 或者设备是共享给当前部门的 --> |
| | | <if test="param2.currentDeptId != null and param2.currentDeptId != '' "> |
| | | or d.id in ( |
| | |
| | | END AS isShared |
| | | FROM |
| | | ja_fw_device d |
| | | LEFT JOIN ( |
| | | SELECT |
| | | device_id, |
| | | out_target, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY |
| | | device_id |
| | | ORDER BY |
| | | create_time DESC |
| | | ) AS rn |
| | | FROM |
| | | ja_fw_device_track |
| | | WHERE |
| | | out_target IS NOT NULL |
| | | ) t ON d.id = t.device_id |
| | | AND t.rn = 1 |
| | | LEFT JOIN ja_fw_device_per_share ps ON ps.device_id = d.id |
| | | AND ps.loan_to_dept_id = #{currentDeptId} |
| | | AND ps.is_deleted = 0 |
| | | WHERE |
| | | d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | and d.effective_range_km is not null |
| | | and d.effective_range_km > 0 |
| | | and d.track_status = 1 |
| | | AND t.out_target != #{regionName} |
| | | AND d.final_outbound_area != #{regionName} |
| | | </select> |
| | | |
| | | </mapper> |