优化异常告警逻辑
This commit is contained in:
parent
6759aeb774
commit
ed03583917
@ -125,6 +125,9 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
private ISysDictionaryItemsService sysDictionaryItemsService;
|
||||
@Resource
|
||||
private IPlatformParentSystemService platformParentSystemService;
|
||||
|
||||
@Resource
|
||||
private IAlarmThresholdService alarmThresholdService;
|
||||
private long count = 1;
|
||||
// 事件管理器
|
||||
@Resource
|
||||
@ -156,6 +159,7 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
nettyServerHandler.sysDictionaryItemsService = this.sysDictionaryItemsService;
|
||||
nettyServerHandler.platformParentSystemService = this.platformParentSystemService;
|
||||
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");
|
||||
for (Map<String, String> item : items) {
|
||||
AlarmLog alarmLog = BeanUtil.toBean(item, AlarmLog.class);
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
String patroldeviceCode = alarmLog.getPatroldeviceCode();
|
||||
List<SubstationPatroldevice> substationPatroldevices =
|
||||
nettyServerHandler.substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, patroldeviceCode));
|
||||
@ -911,70 +916,11 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
taskResult.setLastmodifier("机器人系统");
|
||||
taskResult.setLastmodifydate(new Timestamp(System.currentTimeMillis()));
|
||||
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,
|
||||
taskResult.getDeviceId());
|
||||
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();
|
||||
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) {
|
||||
TaskResult taskResult1 = taskResultList.get(0);
|
||||
taskResult.setResultId(taskResult1.getResultId());
|
||||
@ -1264,15 +1210,14 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
// }
|
||||
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
|
||||
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
|
||||
List<AlarmThreshold> list =
|
||||
alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId,
|
||||
deviceid));
|
||||
// 告警阈值
|
||||
jsonObject.putOpt("earlyMin", device.getEarlyMin());
|
||||
jsonObject.putOpt("earlyMax", device.getEarlyMax());
|
||||
jsonObject.putOpt("sameMin", device.getSameMin());
|
||||
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 (list.size() > 0) {
|
||||
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
|
||||
jsonObject.putAll(thresholdInterval);
|
||||
}
|
||||
// 如果是站端则区域也需要发送告警
|
||||
WebSocketServer.sendInfo(stationId, jsonObject.toString());
|
||||
return true;
|
||||
|
@ -203,40 +203,6 @@ public class SubstationDeviceController {
|
||||
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")
|
||||
@ApiOperation("获取类型")
|
||||
|
@ -198,45 +198,6 @@ public class SubstationDevice implements Serializable {
|
||||
@TableField("identify_material_id")
|
||||
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;
|
||||
|
||||
/**
|
||||
* 识别类型列表,格式:多个识别类型名称,采用","分隔
|
||||
|
@ -178,35 +178,18 @@ public class AlarmLogController {
|
||||
}
|
||||
|
||||
@GetMapping("/getAlarmLogPage")
|
||||
@ApiOperation("告警信息确认")
|
||||
@ApiOperation("告警信息确认分页")
|
||||
public ResponseResult getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, String taskAlarmType,
|
||||
String alarmLevel, String checkFlag, String startDate, String endDate) {
|
||||
if (StrUtil.isBlank(stationCode)) {
|
||||
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,
|
||||
alarmLevel, checkFlag, startFormat, endFormat);
|
||||
alarmLevel, checkFlag, startDate, endDate);
|
||||
|
||||
List<Map<String, Object>> records = alarmList.getRecords();
|
||||
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();
|
||||
LambdaQueryWrapper<DeviceChannel> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid,
|
||||
|
@ -59,4 +59,6 @@ public interface AlarmLogMapper extends BaseMapper<AlarmLog> {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -709,6 +709,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
alarmLog.setAreaName(taskResult.getAreaName());
|
||||
alarmLog.setBayId(taskResult.getBayId());
|
||||
alarmLog.setBayName(taskResult.getBayName());
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setMainDeviceId(taskResult.getMainDeviceId());
|
||||
alarmLog.setMainDeviceName(taskResult.getMainDeviceName());
|
||||
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,
|
||||
String taskAlarmType, String alarmLevel, String checkFlag,
|
||||
String startDate, String endDate) {
|
||||
|
||||
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
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);
|
||||
return alarmLogMapper.getAlarmLogPage(page, stationCode, taskAlarmType,
|
||||
alarmLevel, checkFlag, startDate, endDate);
|
||||
}
|
||||
|
||||
@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,
|
||||
String resultId) throws Exception {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
SubstationDevice substationDevice = deviceMapper.selectById(deviceid);
|
||||
String pictureAnalysisTypeList = substationDevice.getPictureAnalysisTypeList();
|
||||
JSONObject jsonObject = JSONUtil.parseObj(pictureAnalysisTypeList);
|
||||
String pictureDefectAnalysisType = jsonObject.getStr("PictureDefectAnalysisType");
|
||||
result.put("isNormal", "1");
|
||||
List<AlarmThreshold> list =
|
||||
alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq(AlarmThreshold::getDeviceId,
|
||||
deviceid));
|
||||
if (StrUtil.isNotBlank(pictureDefectAnalysisType)) {
|
||||
// 缺陷告警设置
|
||||
// List<Map<String, Object>> mapList = sysDictionaryItemsService.getDeviceByType
|
||||
// ("PictureDefectAnalysisType");
|
||||
if ("1".equals(value)) {
|
||||
result.put("isNormal", "0");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
String PictureDiscriminateAnalysisType = jsonObject.getStr("PictureDiscriminateAnalysisType");
|
||||
if (StrUtil.isNotBlank(PictureDiscriminateAnalysisType)) {
|
||||
if ("1".equals(value)) {
|
||||
result.put("isNormal", "0");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if ("meter".equals(type)) {//仪表读数
|
||||
double resultvalue = Double.parseDouble(value);
|
||||
//String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
//未设置上下限,判定为正常
|
||||
result.put("isNormal", "1");//判定为正常
|
||||
} else {
|
||||
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getEarlyMax()) < 0) {
|
||||
result.put("alarmlevel", "1");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSameMax()) < 0) {
|
||||
result.put("alarmlevel", "2");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSeriousMax()) < 0) {
|
||||
result.put("alarmlevel", "3");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getCriticalMax()) < 0) {
|
||||
result.put("alarmlevel", "4");
|
||||
result.put("isNormal", "0");
|
||||
} else {
|
||||
result.put("isNormal", "1");//判定为正常
|
||||
}
|
||||
}
|
||||
|
||||
} else if ("infrared".equals(type)) {
|
||||
//温度 最高温度,最低温度(以逗号分隔)
|
||||
String highTemp = value.split(",")[0]; //最高温度
|
||||
double resultvalue = Double.parseDouble(highTemp);
|
||||
//String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
//未设置上下限,判定为正常
|
||||
result.put("isNormal", "1");//判定为正常
|
||||
} else {
|
||||
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getEarlyMax()) < 0) {
|
||||
result.put("alarmlevel", "1");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSameMax()) < 0) {
|
||||
result.put("alarmlevel", "2");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSeriousMax()) < 0) {
|
||||
result.put("alarmlevel", "3");
|
||||
result.put("isNormal", "0");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getCriticalMax()) < 0) {
|
||||
result.put("alarmlevel", "4");
|
||||
result.put("isNormal", "0");
|
||||
} else {
|
||||
//判定为正常
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
}
|
||||
|
||||
} else if ("isolator".equals(type)) {
|
||||
//刀闸状态
|
||||
if ("1".equals(value)) {
|
||||
result.put("desc", "分");
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
if ("2".equals(value)) {
|
||||
result.put("desc", "合");
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
if ("3".equals(value)) {
|
||||
result.put("desc", "分位异常");
|
||||
result.put("isNormal", "0");
|
||||
}
|
||||
if ("4".equals(value)) {
|
||||
result.put("desc", "合位异常");
|
||||
result.put("isNormal", "0");
|
||||
}
|
||||
|
||||
} else if ("yjsk".equals(type)) {
|
||||
//刀闸状态
|
||||
if ("2".equals(value) || "4".equals(value)) {
|
||||
result.put("isNormal", "0");
|
||||
} else {
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
} else if ("sound".equals(type)) {//声音 1 代表正常声音,2 代表异常声音
|
||||
double resultvalue = Double.parseDouble(value);
|
||||
//String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
//未设置上下限,判定为正常
|
||||
result.put("isNormal", "1");//判定为正常
|
||||
} else {
|
||||
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getCriticalMax()) < 0) { //异常
|
||||
result.put("isNormal", "0");//判定为异常
|
||||
result.put("alarmtype", "7");//<7>: = 声音超限制
|
||||
if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getEarlyMax()) < 0) {
|
||||
result.put("alarmlevel", "1");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSameMax()) < 0) {
|
||||
result.put("alarmlevel", "2");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getSeriousMax()) < 0) {
|
||||
result.put("alarmlevel", "3");
|
||||
} else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
device.getCriticalMax()) < 0) {
|
||||
result.put("alarmlevel", "4");
|
||||
} else {
|
||||
result.put("alarmlevel", "4");
|
||||
}
|
||||
} else if (NumberUtil.compare(resultvalue, device.getCriticalMax()) > 0) {
|
||||
result.put("isNormal", "0");//判定为异常
|
||||
result.put("alarmtype", "5");//<5>: = 声音异常
|
||||
} else {
|
||||
result.put("isNormal", "1");//判定为正常
|
||||
}
|
||||
}
|
||||
|
||||
} else if ("tx_pb".equals(type)) {
|
||||
//缺陷判别
|
||||
if ("1".equals(value)) {
|
||||
result.put("isNormal", "0");
|
||||
} else {
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
} else if ("light".equals(type)) {
|
||||
if ("red_on".equals(value)) {
|
||||
result.put("isNormal", "0");
|
||||
} else {
|
||||
result.put("isNormal", "1");
|
||||
}
|
||||
} else if ("switch".equals(type)) {
|
||||
//switch,light
|
||||
result.put("isNormal", "1");//正常
|
||||
} else if ("qrcode".equals(type)) {
|
||||
// 实物 ID
|
||||
} else {
|
||||
if ("1".equals(value)) {//外观缺陷
|
||||
if ("ws_ywzc".equals(type)
|
||||
|| "fhz_f".equals(type) || "fhz_h".equals(type)
|
||||
|| "kgg_ybf".equals(type) || "kgg_ybh".equals(type)
|
||||
|| "kk_f".equals(type) || "kk_h".equals(type)
|
||||
|| "zsd_l".equals(type) || "zsd_m".equals(type)
|
||||
|| "hxq_gjzc".equals(type) || "ywzt_yfzc".equals(type)
|
||||
|| "bjzc".equals(type) || "xmbhzc".equals(type)
|
||||
|| "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_bak(String type, String value, String conf, String deviceid,
|
||||
// String resultId) throws Exception {
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// SubstationDevice substationDevice = deviceMapper.selectById(deviceid);
|
||||
// String pictureAnalysisTypeList = substationDevice.getPictureAnalysisTypeList();
|
||||
// JSONObject jsonObject = JSONUtil.parseObj(pictureAnalysisTypeList);
|
||||
// String pictureDefectAnalysisType = jsonObject.getStr("PictureDefectAnalysisType");
|
||||
// result.put("isNormal", "1");
|
||||
// List<AlarmThreshold> list =
|
||||
// alarmThresholdService.list(new LambdaQueryWrapper<AlarmThreshold>().eq
|
||||
// (AlarmThreshold::getDeviceId,
|
||||
// deviceid));
|
||||
// if (StrUtil.isNotBlank(pictureDefectAnalysisType)) {
|
||||
// // 缺陷告警设置
|
||||
// // List<Map<String, Object>> mapList = sysDictionaryItemsService.getDeviceByType
|
||||
// // ("PictureDefectAnalysisType");
|
||||
// if ("1".equals(value)) {
|
||||
// result.put("isNormal", "0");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// String PictureDiscriminateAnalysisType = jsonObject.getStr("PictureDiscriminateAnalysisType");
|
||||
// if (StrUtil.isNotBlank(PictureDiscriminateAnalysisType)) {
|
||||
// if ("1".equals(value)) {
|
||||
// result.put("isNormal", "0");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// if ("meter".equals(type)) {//仪表读数
|
||||
// double resultvalue = Double.parseDouble(value);
|
||||
// //String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
// SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
// if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
// //未设置上下限,判定为正常
|
||||
// result.put("isNormal", "1");//判定为正常
|
||||
// } else {
|
||||
// if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
// device.getEarlyMax()) < 0) {
|
||||
// result.put("alarmlevel", "1");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getSameMax()) < 0) {
|
||||
// result.put("alarmlevel", "2");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getSeriousMax()) < 0) {
|
||||
// result.put("alarmlevel", "3");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getCriticalMax()) < 0) {
|
||||
// result.put("alarmlevel", "4");
|
||||
// result.put("isNormal", "0");
|
||||
// } else {
|
||||
// result.put("isNormal", "1");//判定为正常
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else if ("infrared".equals(type)) {
|
||||
// //温度 最高温度,最低温度(以逗号分隔)
|
||||
// String highTemp = value.split(",")[0]; //最高温度
|
||||
// double resultvalue = Double.parseDouble(highTemp);
|
||||
// //String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
// SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
// if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
// //未设置上下限,判定为正常
|
||||
// result.put("isNormal", "1");//判定为正常
|
||||
// } else {
|
||||
// if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
// device.getEarlyMax()) < 0) {
|
||||
// result.put("alarmlevel", "1");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getSameMax()) < 0) {
|
||||
// result.put("alarmlevel", "2");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getSeriousMax()) < 0) {
|
||||
// result.put("alarmlevel", "3");
|
||||
// result.put("isNormal", "0");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getCriticalMax()) < 0) {
|
||||
// result.put("alarmlevel", "4");
|
||||
// result.put("isNormal", "0");
|
||||
// } else {
|
||||
// //判定为正常
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else if ("isolator".equals(type)) {
|
||||
// //刀闸状态
|
||||
// if ("1".equals(value)) {
|
||||
// result.put("desc", "分");
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// if ("2".equals(value)) {
|
||||
// result.put("desc", "合");
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// if ("3".equals(value)) {
|
||||
// result.put("desc", "分位异常");
|
||||
// result.put("isNormal", "0");
|
||||
// }
|
||||
// if ("4".equals(value)) {
|
||||
// result.put("desc", "合位异常");
|
||||
// result.put("isNormal", "0");
|
||||
// }
|
||||
//
|
||||
// } else if ("yjsk".equals(type)) {
|
||||
// //刀闸状态
|
||||
// if ("2".equals(value) || "4".equals(value)) {
|
||||
// result.put("isNormal", "0");
|
||||
// } else {
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// } else if ("sound".equals(type)) {//声音 1 代表正常声音,2 代表异常声音
|
||||
// double resultvalue = Double.parseDouble(value);
|
||||
// //String alarmlevel = "0";// '1:预警;2:一般;3:严重;4;危急',
|
||||
// SubstationDevice device = deviceMapper.selectById(deviceid);
|
||||
// if (ObjUtil.isEmpty(device.getEarlyMin()) || ObjUtil.isEmpty(device.getCriticalMax())) {
|
||||
// //未设置上下限,判定为正常
|
||||
// result.put("isNormal", "1");//判定为正常
|
||||
// } else {
|
||||
// if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare(resultvalue,
|
||||
// device.getCriticalMax()) < 0) { //异常
|
||||
// result.put("isNormal", "0");//判定为异常
|
||||
// result.put("alarmtype", "7");//<7>: = 声音超限制
|
||||
// if (NumberUtil.compare(resultvalue, device.getEarlyMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getEarlyMax()) < 0) {
|
||||
// result.put("alarmlevel", "1");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSameMin()) >= 0 && NumberUtil.compare
|
||||
// (resultvalue,
|
||||
// device.getSameMax()) < 0) {
|
||||
// result.put("alarmlevel", "2");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getSeriousMin()) >= 0 && NumberUtil
|
||||
// .compare(resultvalue,
|
||||
// device.getSeriousMax()) < 0) {
|
||||
// result.put("alarmlevel", "3");
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getCriticalMin()) >= 0 && NumberUtil
|
||||
// .compare(resultvalue,
|
||||
// device.getCriticalMax()) < 0) {
|
||||
// result.put("alarmlevel", "4");
|
||||
// } else {
|
||||
// result.put("alarmlevel", "4");
|
||||
// }
|
||||
// } else if (NumberUtil.compare(resultvalue, device.getCriticalMax()) > 0) {
|
||||
// result.put("isNormal", "0");//判定为异常
|
||||
// result.put("alarmtype", "5");//<5>: = 声音异常
|
||||
// } else {
|
||||
// result.put("isNormal", "1");//判定为正常
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else if ("tx_pb".equals(type)) {
|
||||
// //缺陷判别
|
||||
// if ("1".equals(value)) {
|
||||
// result.put("isNormal", "0");
|
||||
// } else {
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// } else if ("light".equals(type)) {
|
||||
// if ("red_on".equals(value)) {
|
||||
// result.put("isNormal", "0");
|
||||
// } else {
|
||||
// result.put("isNormal", "1");
|
||||
// }
|
||||
// } else if ("switch".equals(type)) {
|
||||
// //switch,light
|
||||
// result.put("isNormal", "1");//正常
|
||||
// } else if ("qrcode".equals(type)) {
|
||||
// // 实物 ID
|
||||
// } else {
|
||||
// if ("1".equals(value)) {//外观缺陷
|
||||
// if ("ws_ywzc".equals(type)
|
||||
// || "fhz_f".equals(type) || "fhz_h".equals(type)
|
||||
// || "kgg_ybf".equals(type) || "kgg_ybh".equals(type)
|
||||
// || "kk_f".equals(type) || "kk_h".equals(type)
|
||||
// || "zsd_l".equals(type) || "zsd_m".equals(type)
|
||||
// || "hxq_gjzc".equals(type) || "ywzt_yfzc".equals(type)
|
||||
// || "bjzc".equals(type) || "xmbhzc".equals(type)
|
||||
// || "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,
|
||||
@ -1743,6 +1740,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
alarmLog.setComponentName(taskResult.getComponentName());
|
||||
alarmLog.setDeviceId(taskResult.getDeviceId());
|
||||
alarmLog.setDeviceName(taskResult.getDeviceName());
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setPatroldeviceCode(taskResult.getPatroldeviceCode());
|
||||
alarmLog.setPatroldeviceName(taskResult.getPatroldeviceName());
|
||||
alarmLog.setMaterialId(taskResult.getMaterialId());
|
||||
@ -1892,20 +1890,16 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
jsonObject.putOpt("channelId", taskResult.getPatroldeviceChannelcode());
|
||||
jsonObject.putOpt("deviceId", taskResult.getPatroldeviceCode());
|
||||
// 告警阈值
|
||||
jsonObject.putOpt("earlyMin", device.getEarlyMin());
|
||||
jsonObject.putOpt("earlyMax", device.getEarlyMax());
|
||||
jsonObject.putOpt("sameMin", device.getSameMin());
|
||||
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 (list.size() > 0) {
|
||||
Map<String, String> thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid);
|
||||
jsonObject.putAll(thresholdInterval);
|
||||
}
|
||||
// 如果是站端则区域也需要发送告警
|
||||
if (!"0".equals(parentid)) {
|
||||
WebSocketServer.sendInfo(parentid, jsonObject.toString());
|
||||
}
|
||||
WebSocketServer.sendInfo(stationId, jsonObject.toString());
|
||||
// this.sendTaskData("62", "", alarmLog.getStationCode(), alarmData.toString());
|
||||
// this.sendTaskData("62", "", alarmLog.getStationCode(), alarmData.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1959,6 +1953,7 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
if ("2000".equals(code)) {
|
||||
Thread.sleep(1500);//延迟1.5秒
|
||||
AlarmLog alarmLog = new AlarmLog();
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setId(IdUtil.fastSimpleUUID());
|
||||
//摄像机ID
|
||||
String deviceid = jsonObject.getStr("requestId");
|
||||
|
@ -198,7 +198,7 @@ public class SysDictionaryItemsController {
|
||||
}
|
||||
|
||||
@GetMapping("/getDeviceByType")
|
||||
@ApiOperation("获取类型")
|
||||
@ApiOperation("根据字典获取字典项")
|
||||
public ResponseResult getDeviceByType(String dictcode) {
|
||||
if (StrUtil.isBlank(dictcode)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
@ -207,6 +207,16 @@ public class SysDictionaryItemsController {
|
||||
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 所需导出的字典项集合
|
||||
|
@ -54,4 +54,6 @@ public interface ISysDictionaryItemsService extends IService<SysDictionaryItems>
|
||||
List<Map<String, Object>> getDeviceByType(String dictcode);
|
||||
|
||||
List<SysDictionaryItems> getDictItemByType(String dictcode, String alarmType);
|
||||
|
||||
List<Map<String, Object>> getDictionaryItems(String dictCodes);
|
||||
}
|
||||
|
@ -150,8 +150,32 @@ public class SysDictionaryItemsServiceImpl extends ServiceImpl<SysDictionaryItem
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,8 +112,39 @@
|
||||
WHERE
|
||||
station_id = #{stationId}
|
||||
</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 >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and al.alarm_date < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<!-- <select id="getDeviceAlarmRecordPage"-->
|
||||
<!-- resultType="com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord">-->
|
||||
<!-- SELECT-->
|
||||
<!-- dar.*,-->
|
||||
|
Loading…
Reference in New Issue
Block a user