优化逻辑

This commit is contained in:
weitang 2025-05-22 15:33:27 +08:00
parent 3ae039735b
commit 998725b108
7 changed files with 90 additions and 26 deletions

View File

@ -1202,14 +1202,13 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
logMap.put("alarmCount", count); logMap.put("alarmCount", count);
JSONObject jsonObject = new JSONObject(logMap); JSONObject jsonObject = new JSONObject(logMap);
String stationCode = substation.getStationCode(); String stationCode = substation.getStationCode();
jsonObject.putOpt("deviceid", jsonObject.getStr("deviceId"));
// if (ObjectUtil.isNotEmpty(map.get("patroldeviceCode")) && ObjectUtil.isNotEmpty(map.get( // if (ObjectUtil.isNotEmpty(map.get("patroldeviceCode")) && ObjectUtil.isNotEmpty(map.get(
// "patroldeviceChannelcode"))) { // "patroldeviceChannelcode"))) {
// jsonObject.putOpt("channelId", map.get("patroldeviceChannelcode").toString()); // jsonObject.putOpt("channelId", map.get("patroldeviceChannelcode").toString());
// jsonObject.putOpt("deviceId", map.get("patroldeviceCode").toString()); // jsonObject.putOpt("deviceId", map.get("patroldeviceCode").toString());
// } // }
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
List<AlarmThreshold> list = List<AlarmThreshold> list =
alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId, alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId,
deviceid)); deviceid));
@ -1218,6 +1217,9 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid); Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
jsonObject.putAll(thresholdInterval); jsonObject.putAll(thresholdInterval);
} }
jsonObject.putOpt("deviceid", jsonObject.getStr("deviceId"));
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
// 如果是站端则区域也需要发送告警 // 如果是站端则区域也需要发送告警
WebSocketServer.sendInfo(stationId, jsonObject.toString()); WebSocketServer.sendInfo(stationId, jsonObject.toString());
return true; return true;

View File

@ -206,14 +206,19 @@ public class AnalyseCallController {
@GetMapping("/playAudioFile") @GetMapping("/playAudioFile")
@ApiOperation("在线在线播放音频文件") @ApiOperation("在线在线播放音频文件")
@ResponseBody @ResponseBody
public void playAudioFile(HttpServletResponse response, String filename) throws IOException { public void playAudioFile(HttpServletResponse response, String filename,String type) throws IOException {
OsInfo osInfo = new OsInfo(); OsInfo osInfo = new OsInfo();
boolean isLinux = osInfo.isLinux(); boolean isLinux = osInfo.isLinux();
filename = URLDecoder.decode(filename, "utf-8"); filename = URLDecoder.decode(filename, "utf-8");
if (isLinux) {//linux系统替换文件路径字符 if (isLinux) {//linux系统替换文件路径字符
filename = StrUtil.replace(filename, "\\", "/"); filename = StrUtil.replace(filename, "\\", "/");
} }
String originfilename = Config.getSnapFilePath() + filename; String originfilename = "";
if (StrUtil.isNotEmpty(type) && "alarm".equals(type)) {//报警显示不同目录
originfilename = Config.getAlarmFilePath() + filename;
} else {
originfilename = Config.getSnapFilePath() + filename;
}
if (cn.hutool.core.io.FileUtil.exist(originfilename)) { if (cn.hutool.core.io.FileUtil.exist(originfilename)) {
FileUtil.playAudio(originfilename, response); FileUtil.playAudio(originfilename, response);
} }

View File

@ -1170,15 +1170,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
@Override @Override
public Map<String, Object> getAlarmLogById(String id) { public Map<String, Object> getAlarmLogById(String id) {
Map<String, Object> alarmLog = alarmLogMapper.getAlarmLogById(id); Map<String, Object> alarmLog = alarmLogMapper.getAlarmLogById(id);
alarmLog.put("deviceid", alarmLog.get("adeviceId"));
if (ObjectUtil.isNotEmpty(alarmLog.get("deviceid"))) {
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(alarmLog.get("deviceId"
).toString());
if (thresholdInterval != null) {
alarmLog.putAll(thresholdInterval);
}
}
return alarmLog; return alarmLog;
} }
@ -1919,19 +1911,21 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
SysOrganization sysOrganization = SysOrganization sysOrganization =
sysOrganizationMapper.selectOne(new LambdaUpdateWrapper<SysOrganization>().eq(SysOrganization::getOrgcode, stationCode)); sysOrganizationMapper.selectOne(new LambdaUpdateWrapper<SysOrganization>().eq(SysOrganization::getOrgcode, stationCode));
String parentid = sysOrganization.getParentid(); String parentid = sysOrganization.getParentid();
jsonObject.putOpt("deviceid", jsonObject.getStr("deviceId"));
// if (ObjectUtil.isNotEmpty(map.get("patroldeviceCode")) && ObjectUtil.isNotEmpty(map.get( // if (ObjectUtil.isNotEmpty(map.get("patroldeviceCode")) && ObjectUtil.isNotEmpty(map.get(
// "patroldeviceChannelcode"))) { // "patroldeviceChannelcode"))) {
// jsonObject.putOpt("channelId", map.get("patroldeviceChannelcode").toString()); // jsonObject.putOpt("channelId", map.get("patroldeviceChannelcode").toString());
// jsonObject.putOpt("deviceId", map.get("patroldeviceCode").toString()); // jsonObject.putOpt("deviceId", map.get("patroldeviceCode").toString());
// } // }
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
// 告警阈值 // 告警阈值
if (list.size() > 0) { if (list.size() > 0) {
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid); Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
jsonObject.putAll(thresholdInterval); jsonObject.putAll(thresholdInterval);
} }
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
jsonObject.putOpt("deviceid", jsonObject.getStr("deviceId"));
// 如果是站端则区域也需要发送告警 // 如果是站端则区域也需要发送告警
if (!"0".equals(parentid)) { if (!"0".equals(parentid)) {
WebSocketServer.sendInfo(parentid, jsonObject.toString()); WebSocketServer.sendInfo(parentid, jsonObject.toString());

View File

@ -11,9 +11,9 @@ import java.util.Map;
@ApiModel("查询构造器") @ApiModel("查询构造器")
public class QueryCondition { public class QueryCondition {
@ApiModelProperty("当前页") @ApiModelProperty("当前页")
private Integer current; private Integer current = 1;
@ApiModelProperty("页大小") @ApiModelProperty("页大小")
private Integer size; private Integer size = 10;
@ApiModelProperty("条件过滤器") @ApiModelProperty("条件过滤器")
private Map<String, Object> filters; private Map<String, Object> filters;
// 修改为 SortOrder 列表 // 修改为 SortOrder 列表

View File

@ -95,6 +95,11 @@ public class QueryWrapperBuilder {
wrapper.in(column, (Collection<?>) value); wrapper.in(column, (Collection<?>) value);
} }
break; break;
case "notin":
if (value instanceof Collection) {
wrapper.notIn(column, (Collection<?>) value);
}
break;
default: default:
throw new IllegalArgumentException("不支持的运算符: " + operator); throw new IllegalArgumentException("不支持的运算符: " + operator);
} }

View File

@ -5,7 +5,7 @@
<select id="getThresholdInterval" resultType="java.util.Map"> <select id="getThresholdInterval" resultType="java.util.Map">
SELECT SELECT
device_id, device_id deviceId,
MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS commonLower, MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS commonLower,
MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='7') THEN base_line_value ELSE NULL END) AS commonUpper, MAX(CASE WHEN (alarm_level = '1' AND decide_rule ='7') THEN base_line_value ELSE NULL END) AS commonUpper,
MAX(CASE WHEN (alarm_level = '2' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS seriousLower, MAX(CASE WHEN (alarm_level = '2' AND decide_rule ='6') THEN base_line_value ELSE NULL END) AS seriousLower,

View File

@ -92,16 +92,74 @@
</select> </select>
<select id="getAlarmLogById" resultType="java.util.Map"> <select id="getAlarmLogById" resultType="java.util.Map">
SELECT SELECT
al.*, al.id,
al.device_id deviceid, al.station_id,
al.device_id adeviceId,
al.station_name,
al.station_code,
al.area_id,
al.area_name,
al.bay_id,
al.bay_name,
al.main_device_id,
al.main_device_name,
al.component_id,
al.component_name,
al.device_name,
al.patroldevice_id,
al.patroldevice_code,
al.patroldevice_name,
al.task_id,
al.task_patrolled_id,
al.task_result_id,
al.task_name,
al.task_code,
al.material_id,
al.task_alarm_type,
al.monitor_type,
al.defect_type,
al.alarm_level,
al.alarm_type,
al.recognition_type,
al.file_type,
al.file_path,
al.defect_file_path,
al.VALUE
,
al.unit,
al.content,
al.alarm_date,
al.check_flag,
al.check_user_code,
al.check_user_name,
al.check_date,
al.check_result,
al.check_comment,
al.rectangle,
al.systemcode,
al.fk_alarm_type,
al.normal_range,
al.notice_action,
al.notice_emails,
al.notice_linkages,
al.alarm_class,
al.region,
al.alarm_source_type,
tr.patroldevice_code deviceId, tr.patroldevice_code deviceId,
tr.patroldevice_channelcode channelId, tr.patroldevice_channelcode channelId,
tr.patroldevice_pos patroldevicePos tr.patroldevice_pos patroldevicePos,
MAX( CASE WHEN ( iat.alarm_level = '1' AND iat.decide_rule = '6' ) THEN base_line_value ELSE NULL END ) AS commonLower,
MAX( CASE WHEN ( iat.alarm_level = '1' AND iat.decide_rule = '7' ) THEN base_line_value ELSE NULL END ) AS commonUpper,
MAX( CASE WHEN ( iat.alarm_level = '2' AND iat.decide_rule = '6' ) THEN base_line_value ELSE NULL END ) AS seriousLower,
MAX( CASE WHEN ( iat.alarm_level = '2' AND iat.decide_rule = '7' ) THEN base_line_value ELSE NULL END ) AS seriousUpper,
MAX( CASE WHEN ( iat.alarm_level = '3' AND iat.decide_rule = '6' ) THEN base_line_value ELSE NULL END ) AS dangerLower,
MAX( CASE WHEN ( iat.alarm_level = '3' AND iat.decide_rule = '7' ) THEN base_line_value ELSE NULL END ) AS dangerUpper
FROM FROM
iis_alarm_log al iis_alarm_log al
LEFT JOIN iis_alarm_threshold iat ON al.device_id = iat.device_id
LEFT JOIN iis_task_result tr ON al.task_result_id = tr.result_id LEFT JOIN iis_task_result tr ON al.task_result_id = tr.result_id
WHERE WHERE
al.id = #{id} al.id = #{id}
</select> </select>
<select id="getNotCheckAlarmCount" resultType="com.yfd.platform.modules.patroltask.domain.AlarmLog"> <select id="getNotCheckAlarmCount" resultType="com.yfd.platform.modules.patroltask.domain.AlarmLog">
SELECT SELECT
@ -147,7 +205,7 @@
<if test="endDate != null and endDate != ''"> <if test="endDate != null and endDate != ''">
and al.alarm_date &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY) and al.alarm_date &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if> </if>
ORDER BY al.alarm_date DESC
</select> </select>