| | |
| | | |
| | | |
| | | <select id="selectFwDroneAlarmRecordPage" resultType="org.sxkj.fw.record.vo.FwDroneAlarmRecordVO"> |
| | | select dar.*,d.device_name,d.device_model from |
| | | SELECT |
| | | dar.*, |
| | | d.device_name, |
| | | d.status AS deviceStatus, |
| | | d.final_outbound_area, |
| | | EXISTS ( |
| | | SELECT 1 FROM ja_fw_alarm_favorite f |
| | | WHERE f.alarm_record_id::text = dar.id::text |
| | | AND f.user_id = #{param2.currentUserId}::bigint |
| | | AND f.is_deleted = 0 |
| | | ) AS favorited |
| | | FROM |
| | | ja_fw_drone_alarm_record dar |
| | | left join ja_fw_area_divide ad on dar.area_divide_id = ad.id |
| | | left join ja_fw_device d on dar.device_id = d.id |
| | | LEFT JOIN |
| | | ja_fw_device d ON dar.device_id::text = d.id::text |
| | | <where> |
| | | dar.is_deleted = 0 |
| | | AND d.is_enabled = 1 |
| | | <if test="param2.regionCode != null and param2.regionCode != ''"> |
| | | AND ( |
| | | d.final_outbound_area_code LIKE CONCAT(#{param2.regionCode}, '%') |
| | | <if test="param2.currentDeptId != null and param2.currentDeptId != '' "> |
| | | OR dar.device_id::text IN ( |
| | | SELECT device_id::text FROM ja_fw_device_per_share |
| | | WHERE loan_to_dept_id = #{param2.currentDeptId}::bigint |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | |
| | | <if test="param2.deviceId != null and param2.deviceId != ''"> |
| | | and dar.device_id = #{param2.deviceId} |
| | | AND dar.device_id::text = #{param2.deviceId}::text |
| | | </if> |
| | | |
| | | <if test="param2.droneName != null and param2.droneName != ''"> |
| | | and dar.drone_name like CONCAT('%', #{param2.droneName}, '%') |
| | | AND ( dar.drone_name::text LIKE CONCAT('%', #{param2.droneName}::text, '%') |
| | | or dar.drone_serial_no::text LIKE CONCAT('%', #{param2.droneName}::text, '%') |
| | | ) |
| | | </if> |
| | | <if test="param2.droneSerialNo != null and param2.droneSerialNo != ''"> |
| | | and dar.drone_serial_no = #{param2.droneSerialNo} |
| | | |
| | | <if test="param2.areaDivideId != null and param2.areaDivideId != ''"> |
| | | AND dar.area_divide_id::text = #{param2.areaDivideId}::text |
| | | </if> |
| | | |
| | | <if test="param2.defenseSceneId != null and param2.defenseSceneId != ''"> |
| | | AND dar.defense_scene_id::text = #{param2.defenseSceneId}::text |
| | | </if> |
| | | |
| | | <if test="param2.startTime != null and param2.startTime != '' and param2.endTime != null and param2.endTime != ''"> |
| | | AND dar.alarm_time BETWEEN #{param2.startTime}::timestamp AND #{param2.endTime}::timestamp |
| | | </if> |
| | | <if test="param2.deviceType != null and param2.deviceType != ''"> |
| | | AND dar.device_type = #{param2.deviceType} |
| | | </if> |
| | | <if test="param2.droneType != null and param2.droneType != ''"> |
| | | and dar.drone_type = #{param2.droneType} |
| | | AND dar.drone_type = #{param2.droneType} |
| | | </if> |
| | | <if test="param2.alarmType != null and param2.alarmType != ''"> |
| | | and dar.alarm_type = #{param2.alarmType} |
| | | </if> |
| | | <if test="param2.alarmTime != null and param2.alarmTime != ''"> |
| | | and dar.alarm_time = #{param2.alarmTime} |
| | | </if> |
| | | |
| | | <if test="param2.triggerReason != null and param2.triggerReason != ''"> |
| | | and dar.trigger_reason = #{param2.triggerReason} |
| | | </if> |
| | |
| | | <if test="param2.counterWay != null and param2.counterWay != ''"> |
| | | and dar.counter_way = #{param2.counterWay} |
| | | </if> |
| | | <if test="param2.areaDivideId != null and param2.areaDivideId != ''"> |
| | | and dar.area_divide_id = #{param2.areaDivideId} |
| | | </if> |
| | | <if test="param2.defenseSceneId != null and param2.defenseSceneId != ''"> |
| | | and dar.defense_scene_id = #{param2.defenseSceneId} |
| | | </if> |
| | | <if test="param2.startTime != null and param2.startTime != '' and param2.endTime != null and param2.endTime != ''"> |
| | | and dar.alarm_time BETWEEN #{param2.startTime} AND #{param2.endTime} |
| | | </if> |
| | | <if test="param2.deviceType != null and param2.deviceType != ''"> |
| | | and dar.device_type = #{param2.deviceType} |
| | | </if> |
| | | |
| | | <if test="param2.areaName != null and param2.areaName != ''"> |
| | | and ad.area_name like CONCAT('%', #{param2.areaName}, '%') |
| | | AND dar.area_name::text LIKE CONCAT('%', #{param2.areaName}::text, '%') |
| | | </if> |
| | | ORDER BY favorited DESC, dar.alarm_time DESC |
| | | </where> |
| | | |
| | | </select> |
| | | |
| | | |
| | | <select id="exportFwDroneAlarmRecord" resultType="org.sxkj.fw.record.excel.FwDroneAlarmRecordExcel"> |
| | | SELECT * FROM ja_fw_drone_alarm_record ${ew.customSqlSegment} |
| | | select |
| | | dar.*, |
| | | d.device_name, |
| | | d.status deviceStatus |
| | | from |
| | | ja_fw_drone_alarm_record dar |
| | | left join ja_fw_device d on dar.device_id::text = d.id::text |
| | | <where> |
| | | dar.is_deleted = 0 |
| | | <if test="ids != null and ids.size() > 0"> |
| | | and dar.id in |
| | | <foreach item="item" collection="ids" separator="," open="(" close=")"> |
| | | #{item}::bigint |
| | | </foreach> |
| | | </if> |
| | | <if test="regionCode != null and regionCode != ''"> |
| | | and (d.final_outbound_area_code::text like CONCAT(#{regionCode}::text, '%') |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | or dar.device_id in ( |
| | | SELECT device_id FROM ja_fw_device_per_share |
| | | WHERE |
| | | loan_to_dept_id = #{currentDeptId}::bigint |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="alarmTypeStatistics" resultType="org.sxkj.fw.cockpit.vo.AlarmStatisticsVO"> |
| | | SELECT |
| | | /* 1 和 2 如果是字符类型请加单引号 '1',如果是数字则保持现状 */ |
| | | COUNT(CASE WHEN alarm_type::text = '1' THEN 1 END) AS realTimeAlarmCount, |
| | | COUNT(CASE WHEN alarm_type::text = '2' THEN 2 END) AS historyAlarmCount |
| | | FROM |
| | | ja_fw_drone_alarm_record dar |
| | | left join |
| | | /* 修改点1:JOIN 两端对齐转为 text */ |
| | | ja_fw_device d on dar.device_id::text = d.id::text |
| | | WHERE dar.is_deleted = 0 |
| | | AND d.is_deleted = 0 |
| | | and d.is_enabled = 1 |
| | | <if test="regionCode != null and regionCode != ''"> |
| | | and (d.final_outbound_area_code::text like CONCAT(#{regionCode}, '%') |
| | | <if test="currentDeptId != null and currentDeptId != '' "> |
| | | /* 修改点2:dar.device_id 转 text 以匹配子查询返回的文本数组 */ |
| | | or dar.device_id::text in ( |
| | | SELECT device_id::text |
| | | FROM ja_fw_device_per_share |
| | | /* 修改点3:参数强转为 bigint 匹配数据库字段类型 */ |
| | | WHERE loan_to_dept_id = #{currentDeptId}::bigint |
| | | AND is_deleted = 0 |
| | | ) |
| | | </if> |
| | | ) |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |