优化异常告警逻辑

This commit is contained in:
weitang 2025-05-09 14:36:35 +08:00
parent 6759aeb774
commit ed03583917
10 changed files with 298 additions and 379 deletions

View File

@ -125,6 +125,9 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
private ISysDictionaryItemsService sysDictionaryItemsService; private ISysDictionaryItemsService sysDictionaryItemsService;
@Resource @Resource
private IPlatformParentSystemService platformParentSystemService; private IPlatformParentSystemService platformParentSystemService;
@Resource
private IAlarmThresholdService alarmThresholdService;
private long count = 1; private long count = 1;
// 事件管理器 // 事件管理器
@Resource @Resource
@ -156,6 +159,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
nettyServerHandler.sysDictionaryItemsService = this.sysDictionaryItemsService; nettyServerHandler.sysDictionaryItemsService = this.sysDictionaryItemsService;
nettyServerHandler.platformParentSystemService = this.platformParentSystemService; nettyServerHandler.platformParentSystemService = this.platformParentSystemService;
nettyServerHandler.eventManager = this.eventManager; nettyServerHandler.eventManager = this.eventManager;
nettyServerHandler.alarmThresholdService = this.alarmThresholdService;
} }
/** /**
@ -622,6 +626,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
List<Map<String, String>> items = (List<Map<String, String>>) map.get("Items"); List<Map<String, String>> items = (List<Map<String, String>>) map.get("Items");
for (Map<String, String> item : items) { for (Map<String, String> item : items) {
AlarmLog alarmLog = BeanUtil.toBean(item, AlarmLog.class); AlarmLog alarmLog = BeanUtil.toBean(item, AlarmLog.class);
alarmLog.setAlarmSourceType("1");
String patroldeviceCode = alarmLog.getPatroldeviceCode(); String patroldeviceCode = alarmLog.getPatroldeviceCode();
List<SubstationPatroldevice> substationPatroldevices = List<SubstationPatroldevice> substationPatroldevices =
nettyServerHandler.substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, patroldeviceCode)); nettyServerHandler.substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, patroldeviceCode));
@ -911,70 +916,11 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
taskResult.setLastmodifier("机器人系统"); taskResult.setLastmodifier("机器人系统");
taskResult.setLastmodifydate(new Timestamp(System.currentTimeMillis())); taskResult.setLastmodifydate(new Timestamp(System.currentTimeMillis()));
LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TaskResult> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(TaskResult::getTaskTodoId, taskResult.getTaskTodoId()).eq
// (TaskResult::getDeviceId,
// taskResult.getDeviceId()).eq(TaskResult::getTime, taskResult.getTime());
queryWrapper.eq(TaskResult::getTaskTodoId, taskResult.getTaskTodoId()).eq(TaskResult::getDeviceId, queryWrapper.eq(TaskResult::getTaskTodoId, taskResult.getTaskTodoId()).eq(TaskResult::getDeviceId,
taskResult.getDeviceId()); taskResult.getDeviceId());
List<TaskResult> taskResultList = nettyServerHandler.taskResultMapper.selectList(queryWrapper); List<TaskResult> taskResultList = nettyServerHandler.taskResultMapper.selectList(queryWrapper);
// if ("true".equals(nettyServerHandler.httpServerConfig.getCallAnalyse())) {
// taskResult.setFlag("0");
// taskResult.setValue("");
// taskResult.setUnit("");
// taskResult.setValid("");
// taskResult.setCustom1(item.toString());
// }
String callAnalyse = nettyServerHandler.httpServerConfig.getCallAnalyse(); String callAnalyse = nettyServerHandler.httpServerConfig.getCallAnalyse();
try { try {
if (iscall&&"true".equals(callAnalyse) && "4".equals(taskResult.getRecognitionType())) {
callAnalyse = "false";
String isAlarm = substationDevice.getIsAlarm();
if ("1".equals(isAlarm)) {
String isNormal;
String alarmlevel = "4";
//温度 最高温度最低温度以逗号分隔
String highTemp = taskResult.getValue();
double resultvalue = Double.parseDouble(highTemp);
if (ObjUtil.isEmpty(substationDevice.getEarlyMin()) || ObjUtil.isEmpty(substationDevice.getCriticalMax())) {
//未设置上下限判定为正常
//判定为正常
isNormal = "1";
} else {
if (NumberUtil.compare(resultvalue, substationDevice.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
substationDevice.getEarlyMax()) < 0) {
isNormal = "0";
alarmlevel = "1";
} else if (NumberUtil.compare(resultvalue, substationDevice.getSameMin()) >= 0 && NumberUtil.compare(resultvalue,
substationDevice.getSameMax()) < 0) {
isNormal = "0";
alarmlevel = "2";
} else if (NumberUtil.compare(resultvalue, substationDevice.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue,
substationDevice.getSeriousMax()) < 0) {
isNormal = "0";
alarmlevel = "3";
} else if (NumberUtil.compare(resultvalue, substationDevice.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue,
substationDevice.getCriticalMax()) < 0) {
isNormal = "0";
alarmlevel = "4";
} else {
//判定为正常
isNormal = "1";
}
}
if ("0".equals(isNormal)) {
taskResult.setValid("2");
Map<String, Object> map1 = new HashMap<>();
map1.put("alarmlevel", alarmlevel);
map1.put("alarmtype", "1");
createTaskAlarmLog(taskResult, map1);
}
}
if (taskResultList.size() > 0) {
TaskResult taskResult1 = taskResultList.get(0);
taskResult.setResultId(taskResult1.getResultId());
}
// nettyServerHandler.alarmLogService.sendNonCoherentMsg1(taskResult, 0);
}
if (taskResultList.size() > 0) { if (taskResultList.size() > 0) {
TaskResult taskResult1 = taskResultList.get(0); TaskResult taskResult1 = taskResultList.get(0);
taskResult.setResultId(taskResult1.getResultId()); taskResult.setResultId(taskResult1.getResultId());
@ -1264,15 +1210,14 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
// } // }
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode()); jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode()); jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
List<AlarmThreshold> list =
alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId,
deviceid));
// 告警阈值 // 告警阈值
jsonObject.putOpt("earlyMin", device.getEarlyMin()); if (list.size() > 0) {
jsonObject.putOpt("earlyMax", device.getEarlyMax()); Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
jsonObject.putOpt("sameMin", device.getSameMin()); jsonObject.putAll(thresholdInterval);
jsonObject.putOpt("sameMax", device.getSameMax()); }
jsonObject.putOpt("seriousMin", device.getSeriousMin());
jsonObject.putOpt("seriousMax", device.getSeriousMax());
jsonObject.putOpt("criticalMin", device.getCriticalMin());
jsonObject.putOpt("criticalMax", device.getCriticalMax());
// 如果是站端则区域也需要发送告警 // 如果是站端则区域也需要发送告警
WebSocketServer.sendInfo(stationId, jsonObject.toString()); WebSocketServer.sendInfo(stationId, jsonObject.toString());
return true; return true;

View File

@ -203,40 +203,6 @@ public class SubstationDeviceController {
return ResponseResult.successData(mapPage); return ResponseResult.successData(mapPage);
} }
@Log(module = "报警阈值设置", value = "批量修改告警阈值", type = "1")
@PostMapping("/updateAlarmThreshold")
@ApiOperation("批量修改告警阈值")
public ResponseResult updateAlarmThreshold(@RequestBody SubstationDevice substationDevice) {
if (substationDevice == null) {
return ResponseResult.error("未选择修改的列");
}
String deviceId = substationDevice.getDeviceId();
if (StrUtil.isBlank(deviceId)) {
return ResponseResult.error("未选择修改的列");
}
String[] split = deviceId.split(",");
for (String id : split) {
SubstationDevice substationDevice1 = substationDeviceService.getById(id);
Double earlyMin = substationDevice.getEarlyMin();
Double earlyMax = substationDevice.getEarlyMax();
Double sameMin = substationDevice.getSameMin();
Double sameMax = substationDevice.getSameMax();
Double seriousMin = substationDevice.getSeriousMin();
Double seriousMax = substationDevice.getSeriousMax();
Double criticalMin = substationDevice.getCriticalMin();
Double criticalMax = substationDevice.getCriticalMax();
substationDevice1.setEarlyMin(NumberUtil.round(earlyMin, 2).doubleValue());
substationDevice1.setEarlyMax(NumberUtil.round(earlyMax, 2).doubleValue());
substationDevice1.setSameMin(NumberUtil.round(sameMin, 2).doubleValue());
substationDevice1.setSameMax(NumberUtil.round(sameMax, 2).doubleValue());
substationDevice1.setSeriousMin(NumberUtil.round(seriousMin, 2).doubleValue());
substationDevice1.setSeriousMax(NumberUtil.round(seriousMax, 2).doubleValue());
substationDevice1.setCriticalMin(NumberUtil.round(criticalMin, 2).doubleValue());
substationDevice1.setCriticalMax(NumberUtil.round(criticalMax, 2).doubleValue());
substationDeviceService.updateById(substationDevice1);
}
return ResponseResult.success();
}
@GetMapping("/getDeviceType") @GetMapping("/getDeviceType")
@ApiOperation("获取类型") @ApiOperation("获取类型")

View File

@ -198,45 +198,6 @@ public class SubstationDevice implements Serializable {
@TableField("identify_material_id") @TableField("identify_material_id")
private String identifyMaterialId; private String identifyMaterialId;
/**
* 预警区间最小值
*/
private Double earlyMin;
/**
* 预警区间最大值
*/
private Double earlyMax;
/**
* 一般区间最小值
*/
private Double sameMin;
/**
* 一般区间最大值
*/
private Double sameMax;
/**
* 严重区间最小值
*/
private Double seriousMin;
/**
* 严重区间最大值
*/
private Double seriousMax;
/**
* 危急区间最小值
*/
private Double criticalMin;
/**
* 危急区间最大值
*/
private Double criticalMax;
/** /**
* 识别类型列表格式多个识别类型名称采用","分隔 * 识别类型列表格式多个识别类型名称采用","分隔

View File

@ -178,35 +178,18 @@ public class AlarmLogController {
} }
@GetMapping("/getAlarmLogPage") @GetMapping("/getAlarmLogPage")
@ApiOperation("告警信息确认") @ApiOperation("告警信息确认分页")
public ResponseResult getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, String taskAlarmType, public ResponseResult getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, String taskAlarmType,
String alarmLevel, String checkFlag, String startDate, String endDate) { String alarmLevel, String checkFlag, String startDate, String endDate) {
if (StrUtil.isBlank(stationCode)) { if (StrUtil.isBlank(stationCode)) {
return ResponseResult.error("未传变电站信息"); return ResponseResult.error("未传变电站信息");
} }
String startFormat = "";
if (StrUtil.isNotBlank(startDate)) {
Date parseStart = DateUtil.parse(startDate);
//一天的开始
Date beginOfDay = DateUtil.beginOfDay(parseStart);
startFormat = DateUtil.format(beginOfDay, "yyyy-MM-dd HH:mm:ss");
}
String endFormat = "";
if (StrUtil.isNotBlank(startDate)) {
Date parseEnd = DateUtil.parse(endDate);
//一天的结束
Date endOfDay = DateUtil.endOfDay(parseEnd);
endFormat = DateUtil.format(endOfDay, "yyyy-MM-dd HH:mm:ss");
}
Page<Map<String, Object>> alarmList = alarmLogService.getAlarmLogPage(page, stationCode, taskAlarmType, Page<Map<String, Object>> alarmList = alarmLogService.getAlarmLogPage(page, stationCode, taskAlarmType,
alarmLevel, checkFlag, startFormat, endFormat); alarmLevel, checkFlag, startDate, endDate);
List<Map<String, Object>> records = alarmList.getRecords(); List<Map<String, Object>> records = alarmList.getRecords();
records.forEach(r -> { records.forEach(r -> {
if (ObjectUtil.isNotEmpty(r.get("deviceId"))) {
String deviceId = r.get("deviceId").toString();
SubstationDevice substationDevice = substationDeviceService.getById(deviceId);
r.put("deviceClass", substationDevice.getDeviceClass());
}
String patroldeviceCode = r.get("patroldeviceCode").toString(); String patroldeviceCode = r.get("patroldeviceCode").toString();
LambdaQueryWrapper<DeviceChannel> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DeviceChannel> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid, queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid,

View File

@ -59,4 +59,6 @@ public interface AlarmLogMapper extends BaseMapper<AlarmLog> {
List<AlarmLog> getNotCheckAlarmCount(String stationId); List<AlarmLog> getNotCheckAlarmCount(String stationId);
Page<Map<String, Object>> getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, String taskAlarmType, String alarmLevel, String checkFlag, String startDate, String endDate);
} }

View File

@ -709,6 +709,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
alarmLog.setAreaName(taskResult.getAreaName()); alarmLog.setAreaName(taskResult.getAreaName());
alarmLog.setBayId(taskResult.getBayId()); alarmLog.setBayId(taskResult.getBayId());
alarmLog.setBayName(taskResult.getBayName()); alarmLog.setBayName(taskResult.getBayName());
alarmLog.setAlarmSourceType("1");
alarmLog.setMainDeviceId(taskResult.getMainDeviceId()); alarmLog.setMainDeviceId(taskResult.getMainDeviceId());
alarmLog.setMainDeviceName(taskResult.getMainDeviceName()); alarmLog.setMainDeviceName(taskResult.getMainDeviceName());
alarmLog.setComponentId(taskResult.getComponentId()); alarmLog.setComponentId(taskResult.getComponentId());
@ -1091,23 +1092,8 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
public Page<Map<String, Object>> getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, public Page<Map<String, Object>> getAlarmLogPage(Page<Map<String, Object>> page, String stationCode,
String taskAlarmType, String alarmLevel, String checkFlag, String taskAlarmType, String alarmLevel, String checkFlag,
String startDate, String endDate) { String startDate, String endDate) {
return alarmLogMapper.getAlarmLogPage(page, stationCode, taskAlarmType,
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>(); alarmLevel, checkFlag, startDate, endDate);
queryWrapper.eq(AlarmLog::getStationCode, stationCode);
if (StrUtil.isNotBlank(taskAlarmType)) {
queryWrapper.eq(AlarmLog::getTaskAlarmType, taskAlarmType);
}
if (StrUtil.isNotBlank(alarmLevel)) {
queryWrapper.eq(AlarmLog::getAlarmLevel, alarmLevel);
}
if (StrUtil.isNotBlank(checkFlag)) {
queryWrapper.eq(AlarmLog::getCheckFlag, checkFlag);
}
if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
queryWrapper.le(AlarmLog::getAlarmDate, endDate).ge(AlarmLog::getAlarmDate, startDate);
}
queryWrapper.orderByDesc(AlarmLog::getAlarmDate);
return this.pageMaps(page, queryWrapper);
} }
@Override @Override
@ -1195,195 +1181,206 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
} }
//根据识别类型和结果值判断是否为异常 //根据识别类型和结果值判断是否为异常
private Map<String, Object> judgeAbnormal_bak(String type, String value, String conf, String deviceid, // private Map<String, Object> judgeAbnormal_bak(String type, String value, String conf, String deviceid,
String resultId) throws Exception { // String resultId) throws Exception {
Map<String, Object> result = new HashMap<>(); // Map<String, Object> result = new HashMap<>();
SubstationDevice substationDevice = deviceMapper.selectById(deviceid); // SubstationDevice substationDevice = deviceMapper.selectById(deviceid);
String pictureAnalysisTypeList = substationDevice.getPictureAnalysisTypeList(); // String pictureAnalysisTypeList = substationDevice.getPictureAnalysisTypeList();
JSONObject jsonObject = JSONUtil.parseObj(pictureAnalysisTypeList); // JSONObject jsonObject = JSONUtil.parseObj(pictureAnalysisTypeList);
String pictureDefectAnalysisType = jsonObject.getStr("PictureDefectAnalysisType"); // String pictureDefectAnalysisType = jsonObject.getStr("PictureDefectAnalysisType");
result.put("isNormal", "1"); // result.put("isNormal", "1");
List<AlarmThreshold> list = // List<AlarmThreshold> list =
alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId, // alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq
deviceid)); // (AlarmThreshold::getDeviceId,
if (StrUtil.isNotBlank(pictureDefectAnalysisType)) { // deviceid));
// 缺陷告警设置 // if (StrUtil.isNotBlank(pictureDefectAnalysisType)) {
// List<Map<String, Object>> mapList = sysDictionaryItemsService.getDeviceByType // // 缺陷告警设置
// ("PictureDefectAnalysisType"); // // List<Map<String, Object>> mapList = sysDictionaryItemsService.getDeviceByType
if ("1".equals(value)) { // // ("PictureDefectAnalysisType");
result.put("isNormal", "0"); // if ("1".equals(value)) {
} // result.put("isNormal", "0");
return result; // }
} // return result;
String PictureDiscriminateAnalysisType = jsonObject.getStr("PictureDiscriminateAnalysisType"); // }
if (StrUtil.isNotBlank(PictureDiscriminateAnalysisType)) { // String PictureDiscriminateAnalysisType = jsonObject.getStr("PictureDiscriminateAnalysisType");
if ("1".equals(value)) { // if (StrUtil.isNotBlank(PictureDiscriminateAnalysisType)) {
result.put("isNormal", "0"); // if ("1".equals(value)) {
} // result.put("isNormal", "0");
return result; // }
} // return result;
if ("meter".equals(type)) {//仪表读数 // }
double resultvalue = Double.parseDouble(value); // if ("meter".equals(type)) {//仪表读数
//String alarmlevel = "0";// '1:预警2:一般3:严重4;危急', // double resultvalue = Double.parseDouble(value);
SubstationDevice device = deviceMapper.selectById(deviceid); // //String alarmlevel = "0";// '1:预警2:一般3:严重4;危急',
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) { // SubstationDevice device = deviceMapper.selectById(deviceid);
//未设置上下限判定为正常 // if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
result.put("isNormal", "1");//判定为正常 // //未设置上下限判定为正常
} else { // result.put("isNormal", "1");//判定为正常
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue, // } else {
device.getEarlyMax()) < 0) { // if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
result.put("alarmlevel", "1"); // device.getEarlyMax()) < 0) {
result.put("isNormal", "0"); // result.put("alarmlevel", "1");
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue, // result.put("isNormal", "0");
device.getSameMax()) < 0) { // } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
result.put("alarmlevel", "2"); // (resultvalue,
result.put("isNormal", "0"); // device.getSameMax()) < 0) {
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue, // result.put("alarmlevel", "2");
device.getSeriousMax()) < 0) { // result.put("isNormal", "0");
result.put("alarmlevel", "3"); // } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare
result.put("isNormal", "0"); // (resultvalue,
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue, // device.getSeriousMax()) < 0) {
device.getCriticalMax()) < 0) { // result.put("alarmlevel", "3");
result.put("alarmlevel", "4"); // result.put("isNormal", "0");
result.put("isNormal", "0"); // } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare
} else { // (resultvalue,
result.put("isNormal", "1");//判定为正常 // device.getCriticalMax()) < 0) {
} // result.put("alarmlevel", "4");
} // result.put("isNormal", "0");
// } else {
} else if ("infrared".equals(type)) { // result.put("isNormal", "1");//判定为正常
//温度 最高温度最低温度以逗号分隔 // }
String highTemp = value.split(",")[0]; //最高温度 // }
double resultvalue = Double.parseDouble(highTemp); //
//String alarmlevel = "0";// '1:预警2:一般3:严重4;危急', // } else if ("infrared".equals(type)) {
SubstationDevice device = deviceMapper.selectById(deviceid); // //温度 最高温度最低温度以逗号分隔
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) { // String highTemp = value.split(",")[0]; //最高温度
//未设置上下限判定为正常 // double resultvalue = Double.parseDouble(highTemp);
result.put("isNormal", "1");//判定为正常 // //String alarmlevel = "0";// '1:预警2:一般3:严重4;危急',
} else { // SubstationDevice device = deviceMapper.selectById(deviceid);
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue, // if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
device.getEarlyMax()) < 0) { // //未设置上下限判定为正常
result.put("alarmlevel", "1"); // result.put("isNormal", "1");//判定为正常
result.put("isNormal", "0"); // } else {
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue, // if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
device.getSameMax()) < 0) { // device.getEarlyMax()) < 0) {
result.put("alarmlevel", "2"); // result.put("alarmlevel", "1");
result.put("isNormal", "0"); // result.put("isNormal", "0");
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue, // } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
device.getSeriousMax()) < 0) { // (resultvalue,
result.put("alarmlevel", "3"); // device.getSameMax()) < 0) {
result.put("isNormal", "0"); // result.put("alarmlevel", "2");
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue, // result.put("isNormal", "0");
device.getCriticalMax()) < 0) { // } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare
result.put("alarmlevel", "4"); // (resultvalue,
result.put("isNormal", "0"); // device.getSeriousMax()) < 0) {
} else { // result.put("alarmlevel", "3");
//判定为正常 // result.put("isNormal", "0");
result.put("isNormal", "1"); // } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare
} // (resultvalue,
} // device.getCriticalMax()) < 0) {
// result.put("alarmlevel", "4");
} else if ("isolator".equals(type)) { // result.put("isNormal", "0");
//刀闸状态 // } else {
if ("1".equals(value)) { // //判定为正常
result.put("desc", ""); // result.put("isNormal", "1");
result.put("isNormal", "1"); // }
} // }
if ("2".equals(value)) { //
result.put("desc", ""); // } else if ("isolator".equals(type)) {
result.put("isNormal", "1"); // //刀闸状态
} // if ("1".equals(value)) {
if ("3".equals(value)) { // result.put("desc", "");
result.put("desc", "分位异常"); // result.put("isNormal", "1");
result.put("isNormal", "0"); // }
} // if ("2".equals(value)) {
if ("4".equals(value)) { // result.put("desc", "");
result.put("desc", "合位异常"); // result.put("isNormal", "1");
result.put("isNormal", "0"); // }
} // if ("3".equals(value)) {
// result.put("desc", "分位异常");
} else if ("yjsk".equals(type)) { // result.put("isNormal", "0");
//刀闸状态 // }
if ("2".equals(value) || "4".equals(value)) { // if ("4".equals(value)) {
result.put("isNormal", "0"); // result.put("desc", "合位异常");
} else { // result.put("isNormal", "0");
result.put("isNormal", "1"); // }
} //
} else if ("sound".equals(type)) {//声音 1 代表正常声音2 代表异常声音 // } else if ("yjsk".equals(type)) {
double resultvalue = Double.parseDouble(value); // //刀闸状态
//String alarmlevel = "0";// '1:预警2:一般3:严重4;危急', // if ("2".equals(value) || "4".equals(value)) {
SubstationDevice device = deviceMapper.selectById(deviceid); // result.put("isNormal", "0");
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) { // } else {
//未设置上下限判定为正常 // result.put("isNormal", "1");
result.put("isNormal", "1");//判定为正常 // }
} else { // } else if ("sound".equals(type)) {//声音 1 代表正常声音2 代表异常声音
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue, // double resultvalue = Double.parseDouble(value);
device.getCriticalMax()) < 0) { //异常 // //String alarmlevel = "0";// '1:预警2:一般3:严重4;危急',
result.put("isNormal", "0");//判定为异常 // SubstationDevice device = deviceMapper.selectById(deviceid);
result.put("alarmtype", "7");//<7>: = 声音超限制 // if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue, // //未设置上下限判定为正常
device.getEarlyMax()) < 0) { // result.put("isNormal", "1");//判定为正常
result.put("alarmlevel", "1"); // } else {
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue, // if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
device.getSameMax()) < 0) { // device.getCriticalMax()) < 0) { //异常
result.put("alarmlevel", "2"); // result.put("isNormal", "0");//判定为异常
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue, // result.put("alarmtype", "7");//<7>: = 声音超限制
device.getSeriousMax()) < 0) { // if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare
result.put("alarmlevel", "3"); // (resultvalue,
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue, // device.getEarlyMax()) < 0) {
device.getCriticalMax()) < 0) { // result.put("alarmlevel", "1");
result.put("alarmlevel", "4"); // } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
} else { // (resultvalue,
result.put("alarmlevel", "4"); // device.getSameMax()) < 0) {
} // result.put("alarmlevel", "2");
} else if (NumberUtil.compare(resultvalue, device.getCriticalMax()) > 0) { // } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil
result.put("isNormal", "0");//判定为异常 // .compare(resultvalue,
result.put("alarmtype", "5");//<5>: = 声音异常 // device.getSeriousMax()) < 0) {
} else { // result.put("alarmlevel", "3");
result.put("isNormal", "1");//判定为正常 // } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil
} // .compare(resultvalue,
} // device.getCriticalMax()) < 0) {
// result.put("alarmlevel", "4");
} else if ("tx_pb".equals(type)) { // } else {
//缺陷判别 // result.put("alarmlevel", "4");
if ("1".equals(value)) { // }
result.put("isNormal", "0"); // } else if (NumberUtil.compare(resultvalue, device.getCriticalMax()) > 0) {
} else { // result.put("isNormal", "0");//判定为异常
result.put("isNormal", "1"); // result.put("alarmtype", "5");//<5>: = 声音异常
} // } else {
} else if ("light".equals(type)) { // result.put("isNormal", "1");//判定为正常
if ("red_on".equals(value)) { // }
result.put("isNormal", "0"); // }
} else { //
result.put("isNormal", "1"); // } else if ("tx_pb".equals(type)) {
} // //缺陷判别
} else if ("switch".equals(type)) { // if ("1".equals(value)) {
//switch,light // result.put("isNormal", "0");
result.put("isNormal", "1");//正常 // } else {
} else if ("qrcode".equals(type)) { // result.put("isNormal", "1");
// 实物 ID // }
} else { // } else if ("light".equals(type)) {
if ("1".equals(value)) {//外观缺陷 // if ("red_on".equals(value)) {
if ("ws_ywzc".equals(type) // result.put("isNormal", "0");
|| "fhz_f".equals(type) || "fhz_h".equals(type) // } else {
|| "kgg_ybf".equals(type) || "kgg_ybh".equals(type) // result.put("isNormal", "1");
|| "kk_f".equals(type) || "kk_h".equals(type) // }
|| "zsd_l".equals(type) || "zsd_m".equals(type) // } else if ("switch".equals(type)) {
|| "hxq_gjzc".equals(type) || "ywzt_yfzc".equals(type) // //switch,light
|| "bjzc".equals(type) || "xmbhzc".equals(type) // result.put("isNormal", "1");//正常
|| "gzzc".equals(type) || "aqmzc".equals(type)) { // } else if ("qrcode".equals(type)) {
result.put("isNormal", "1");//正常 // // 实物 ID
} else { // } else {
result.put("isNormal", "0");//异常 // if ("1".equals(value)) {//外观缺陷
result.put("alarmtype", "6");//<6>: = 外观异常 // if ("ws_ywzc".equals(type)
} // || "fhz_f".equals(type) || "fhz_h".equals(type)
// || "kgg_ybf".equals(type) || "kgg_ybh".equals(type)
} else { // || "kk_f".equals(type) || "kk_h".equals(type)
result.put("isNormal", "1");//正常 // || "zsd_l".equals(type) || "zsd_m".equals(type)
} // || "hxq_gjzc".equals(type) || "ywzt_yfzc".equals(type)
} // || "bjzc".equals(type) || "xmbhzc".equals(type)
return result; // || "gzzc".equals(type) || "aqmzc".equals(type)) {
} // result.put("isNormal", "1");//正常
// } else {
// result.put("isNormal", "0");//异常
// result.put("alarmtype", "6");//<6>: = 外观异常
// }
//
// } else {
// result.put("isNormal", "1");//正常
// }
// }
// return result;
// }
//根据识别类型和结果值判断是否为异常 //根据识别类型和结果值判断是否为异常
private Map<String, Object> judgeAbnormal(String type, String value, String desc, String deviceid, private Map<String, Object> judgeAbnormal(String type, String value, String desc, String deviceid,
@ -1743,6 +1740,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
alarmLog.setComponentName(taskResult.getComponentName()); alarmLog.setComponentName(taskResult.getComponentName());
alarmLog.setDeviceId(taskResult.getDeviceId()); alarmLog.setDeviceId(taskResult.getDeviceId());
alarmLog.setDeviceName(taskResult.getDeviceName()); alarmLog.setDeviceName(taskResult.getDeviceName());
alarmLog.setAlarmSourceType("1");
alarmLog.setPatroldeviceCode(taskResult.getPatroldeviceCode()); alarmLog.setPatroldeviceCode(taskResult.getPatroldeviceCode());
alarmLog.setPatroldeviceName(taskResult.getPatroldeviceName()); alarmLog.setPatroldeviceName(taskResult.getPatroldeviceName());
alarmLog.setMaterialId(taskResult.getMaterialId()); alarmLog.setMaterialId(taskResult.getMaterialId());
@ -1892,20 +1890,16 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode()); jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode()); jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
// 告警阈值 // 告警阈值
jsonObject.putOpt("earlyMin", device.getEarlyMin()); if (list.size() > 0) {
jsonObject.putOpt("earlyMax", device.getEarlyMax()); Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
jsonObject.putOpt("sameMin", device.getSameMin()); jsonObject.putAll(thresholdInterval);
jsonObject.putOpt("sameMax", device.getSameMax()); }
jsonObject.putOpt("seriousMin", device.getSeriousMin());
jsonObject.putOpt("seriousMax", device.getSeriousMax());
jsonObject.putOpt("criticalMin", device.getCriticalMin());
jsonObject.putOpt("criticalMax", device.getCriticalMax());
// 如果是站端则区域也需要发送告警 // 如果是站端则区域也需要发送告警
if (!"0".equals(parentid)) { if (!"0".equals(parentid)) {
WebSocketServer.sendInfo(parentid, jsonObject.toString()); WebSocketServer.sendInfo(parentid, jsonObject.toString());
} }
WebSocketServer.sendInfo(stationId, jsonObject.toString()); WebSocketServer.sendInfo(stationId, jsonObject.toString());
// this.sendTaskData("62", "", alarmLog.getStationCode(), alarmData.toString()); // this.sendTaskData("62", "", alarmLog.getStationCode(), alarmData.toString());
return true; return true;
} }
@ -1959,6 +1953,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
if ("2000".equals(code)) { if ("2000".equals(code)) {
Thread.sleep(1500);//延迟1.5秒 Thread.sleep(1500);//延迟1.5秒
AlarmLog alarmLog = new AlarmLog(); AlarmLog alarmLog = new AlarmLog();
alarmLog.setAlarmSourceType("1");
alarmLog.setId(IdUtil.fastSimpleUUID()); alarmLog.setId(IdUtil.fastSimpleUUID());
//摄像机ID //摄像机ID
String deviceid = jsonObject.getStr("requestId"); String deviceid = jsonObject.getStr("requestId");

View File

@ -198,7 +198,7 @@ public class SysDictionaryItemsController {
} }
@GetMapping("/getDeviceByType") @GetMapping("/getDeviceByType")
@ApiOperation("获取类型") @ApiOperation("根据字典获取字典项")
public ResponseResult getDeviceByType(String dictcode) { public ResponseResult getDeviceByType(String dictcode) {
if (StrUtil.isBlank(dictcode)) { if (StrUtil.isBlank(dictcode)) {
return ResponseResult.error("参数为空"); return ResponseResult.error("参数为空");
@ -207,6 +207,16 @@ public class SysDictionaryItemsController {
return ResponseResult.successData(itemCode); return ResponseResult.successData(itemCode);
} }
@GetMapping("/getDictionaryItems")
@ApiOperation("根据字典获取多个字典项")
public ResponseResult getDictionaryItems(String dictCodes) {
if (StrUtil.isBlank(dictCodes)) {
return ResponseResult.error("参数为空");
}
List<Map<String, Object>> itemCode = sysDictionaryItemsService.getDictionaryItems(dictCodes);
return ResponseResult.successData(itemCode);
}
/********************************** /**********************************
* 用途说明: 导出数据字典项数据 * 用途说明: 导出数据字典项数据
* 参数说明 sysDictionaryItemsList 所需导出的字典项集合 * 参数说明 sysDictionaryItemsList 所需导出的字典项集合

View File

@ -54,4 +54,6 @@ public interface ISysDictionaryItemsService extends IService<SysDictionaryItems>
List<Map<String, Object>> getDeviceByType(String dictcode); List<Map<String, Object>> getDeviceByType(String dictcode);
List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType); List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType);
List<Map<String, Object>> getDictionaryItems(String dictCodes);
} }

View File

@ -150,8 +150,32 @@ public class SysDictionaryItemsServiceImpl extends ServiceImpl<SysDictionaryItem
@Override @Override
public List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType) { public List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType) {
return sysDictionaryItemsMapper.getDictItemByType(dictcode,alarmType); return sysDictionaryItemsMapper.getDictItemByType(dictcode, alarmType);
} }
@Override
public List<Map<String, Object>> getDictionaryItems(String dictCodes) {
if (StrUtil.isBlank(dictCodes)) {
return null;
}
List<String> dictCodeList = StrUtil.split(dictCodes, ",");
List<SysDictionary> sysDictionaryList =
sysDictionaryMapper.selectList(new LambdaQueryWrapper<SysDictionary>().in(SysDictionary::getDictCode,
dictCodeList).select(SysDictionary::getId));
if (sysDictionaryList == null || sysDictionaryList.size() <= 0) {
return null;
}
List<String> distIdList = sysDictionaryList.stream().map(SysDictionary::getId).collect(Collectors.toList());
LambdaQueryWrapper<SysDictionaryItems> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(SysDictionaryItems::getDictId, distIdList);
queryWrapper.select(SysDictionaryItems::getId, SysDictionaryItems::getItemCode,
SysDictionaryItems::getDictName, SysDictionaryItems::getCustom1, SysDictionaryItems::getCustom2,
SysDictionaryItems::getOrderNo).orderByAsc(SysDictionaryItems::getDictId,
SysDictionaryItems::getOrderNo);
List<Map<String, Object>> maps = sysDictionaryItemsMapper.selectMaps(queryWrapper);
return maps;
}
} }

View File

@ -112,8 +112,39 @@
WHERE WHERE
station_id = #{stationId} station_id = #{stationId}
</select> </select>
<select id="getAlarmLogPage" resultType="java.util.Map">
SELECT
al.*,
sd.device_class
FROM
iis_alarm_log al
LEFT JOIN iis_substation_device sd ON al.device_id = sd.device_id
WHERE 1=1
<if test="stationCode != null and stationCode != ''">
AND al.station_code = #{stationCode}
</if>
<if test="taskAlarmType != null and taskAlarmType != ''">
AND al.task_alarm_type = #{taskAlarmType}
</if>
<if test="alarmLevel != null and alarmLevel != ''">
AND al.alarm_level = #{alarmLevel}
</if>
<if test="checkFlag != null and checkFlag != ''">
AND al.check_flag = #{checkFlag}
</if>
<!-- <select id="getDeviceAlarmRecordPage"--> <if test="startDate != null and startDate != ''">
and al.alarm_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and al.alarm_date &lt; DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
</select>
<!-- <select id="getDeviceAlarmRecordPage"-->
<!-- resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord">--> <!-- resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord">-->
<!-- SELECT--> <!-- SELECT-->
<!-- dar.*,--> <!-- dar.*,-->