diff --git a/riis-system/src/main/java/com/yfd/platform/component/nettyserver/NettyServerHandler.java b/riis-system/src/main/java/com/yfd/platform/component/nettyserver/NettyServerHandler.java index 8b396f0..ebdc03f 100644 --- a/riis-system/src/main/java/com/yfd/platform/component/nettyserver/NettyServerHandler.java +++ b/riis-system/src/main/java/com/yfd/platform/component/nettyserver/NettyServerHandler.java @@ -125,6 +125,9 @@ public class NettyServerHandler extends SimpleChannelInboundHandler> items = (List>) map.get("Items"); for (Map item : items) { AlarmLog alarmLog = BeanUtil.toBean(item, AlarmLog.class); + alarmLog.setAlarmSourceType("1"); String patroldeviceCode = alarmLog.getPatroldeviceCode(); List substationPatroldevices = nettyServerHandler.substationPatroldeviceService.list(new LambdaQueryWrapper().eq(SubstationPatroldevice::getPatroldeviceCode, patroldeviceCode)); @@ -911,70 +916,11 @@ public class NettyServerHandler extends SimpleChannelInboundHandler 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 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 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 list = + alarmThresholdService.list(new LambdaQueryWrapper().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 thresholdInterval = alarmThresholdService.getThresholdInterval(deviceid); + jsonObject.putAll(thresholdInterval); + } // 如果是站端则区域也需要发送告警 WebSocketServer.sendInfo(stationId, jsonObject.toString()); return true; diff --git a/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationDeviceController.java b/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationDeviceController.java index bf833cc..cc092e2 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationDeviceController.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationDeviceController.java @@ -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("获取类型") diff --git a/riis-system/src/main/java/com/yfd/platform/modules/basedata/domain/SubstationDevice.java b/riis-system/src/main/java/com/yfd/platform/modules/basedata/domain/SubstationDevice.java index 9dcccb5..067815c 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/basedata/domain/SubstationDevice.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/basedata/domain/SubstationDevice.java @@ -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; /** * 识别类型列表,格式:多个识别类型名称,采用","分隔 diff --git a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/controller/AlarmLogController.java b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/controller/AlarmLogController.java index e7dd49e..c77ee29 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/controller/AlarmLogController.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/controller/AlarmLogController.java @@ -178,35 +178,18 @@ public class AlarmLogController { } @GetMapping("/getAlarmLogPage") - @ApiOperation("告警信息确认") + @ApiOperation("告警信息确认分页") public ResponseResult getAlarmLogPage(Page> 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> alarmList = alarmLogService.getAlarmLogPage(page, stationCode, taskAlarmType, - alarmLevel, checkFlag, startFormat, endFormat); + alarmLevel, checkFlag, startDate, endDate); + List> 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 queryWrapper1 = new LambdaQueryWrapper<>(); queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid, diff --git a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/mapper/AlarmLogMapper.java b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/mapper/AlarmLogMapper.java index 336c359..a96b953 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/mapper/AlarmLogMapper.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/mapper/AlarmLogMapper.java @@ -59,4 +59,6 @@ public interface AlarmLogMapper extends BaseMapper { List getNotCheckAlarmCount(String stationId); + Page> getAlarmLogPage(Page> page, String stationCode, String taskAlarmType, String alarmLevel, String checkFlag, String startDate, String endDate); + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/service/impl/AlarmLogServiceImpl.java b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/service/impl/AlarmLogServiceImpl.java index 0cc1a06..343941e 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/patroltask/service/impl/AlarmLogServiceImpl.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/patroltask/service/impl/AlarmLogServiceImpl.java @@ -709,6 +709,7 @@ public class AlarmLogServiceImpl extends ServiceImpl 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 i public Page> getAlarmLogPage(Page> page, String stationCode, String taskAlarmType, String alarmLevel, String checkFlag, String startDate, String endDate) { - - LambdaQueryWrapper 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 i } //根据识别类型和结果值判断是否为异常 - private Map judgeAbnormal_bak(String type, String value, String conf, String deviceid, - String resultId) throws Exception { - Map 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 list = - alarmThresholdService.list(new LambdaQueryWrapper().eq(AlarmThreshold::getDeviceId, - deviceid)); - if (StrUtil.isNotBlank(pictureDefectAnalysisType)) { - // 缺陷告警设置 - // List> 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 judgeAbnormal_bak(String type, String value, String conf, String deviceid, + // String resultId) throws Exception { + // Map 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 list = + // alarmThresholdService.list(new LambdaQueryWrapper().eq + // (AlarmThreshold::getDeviceId, + // deviceid)); + // if (StrUtil.isNotBlank(pictureDefectAnalysisType)) { + // // 缺陷告警设置 + // // List> 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 judgeAbnormal(String type, String value, String desc, String deviceid, @@ -1743,6 +1740,7 @@ public class AlarmLogServiceImpl extends ServiceImpl 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 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 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 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"); diff --git a/riis-system/src/main/java/com/yfd/platform/system/controller/SysDictionaryItemsController.java b/riis-system/src/main/java/com/yfd/platform/system/controller/SysDictionaryItemsController.java index 931037d..8987ec7 100644 --- a/riis-system/src/main/java/com/yfd/platform/system/controller/SysDictionaryItemsController.java +++ b/riis-system/src/main/java/com/yfd/platform/system/controller/SysDictionaryItemsController.java @@ -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> itemCode = sysDictionaryItemsService.getDictionaryItems(dictCodes); + return ResponseResult.successData(itemCode); + } + /********************************** * 用途说明: 导出数据字典项数据 * 参数说明 sysDictionaryItemsList 所需导出的字典项集合 diff --git a/riis-system/src/main/java/com/yfd/platform/system/service/ISysDictionaryItemsService.java b/riis-system/src/main/java/com/yfd/platform/system/service/ISysDictionaryItemsService.java index 69b025b..91b40b2 100644 --- a/riis-system/src/main/java/com/yfd/platform/system/service/ISysDictionaryItemsService.java +++ b/riis-system/src/main/java/com/yfd/platform/system/service/ISysDictionaryItemsService.java @@ -54,4 +54,6 @@ public interface ISysDictionaryItemsService extends IService List> getDeviceByType(String dictcode); List getDictItemByType(String dictcode, String alarmType); + + List> getDictionaryItems(String dictCodes); } diff --git a/riis-system/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryItemsServiceImpl.java b/riis-system/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryItemsServiceImpl.java index 6708dd8..7945f67 100644 --- a/riis-system/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryItemsServiceImpl.java +++ b/riis-system/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryItemsServiceImpl.java @@ -150,8 +150,32 @@ public class SysDictionaryItemsServiceImpl extends ServiceImpl getDictItemByType(String dictcode, String alarmType) { - return sysDictionaryItemsMapper.getDictItemByType(dictcode,alarmType); + return sysDictionaryItemsMapper.getDictItemByType(dictcode, alarmType); } + @Override + public List> getDictionaryItems(String dictCodes) { + + if (StrUtil.isBlank(dictCodes)) { + return null; + } + List dictCodeList = StrUtil.split(dictCodes, ","); + + List sysDictionaryList = + sysDictionaryMapper.selectList(new LambdaQueryWrapper().in(SysDictionary::getDictCode, + dictCodeList).select(SysDictionary::getId)); + if (sysDictionaryList == null || sysDictionaryList.size() <= 0) { + return null; + } + List distIdList = sysDictionaryList.stream().map(SysDictionary::getId).collect(Collectors.toList()); + LambdaQueryWrapper 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> maps = sysDictionaryItemsMapper.selectMaps(queryWrapper); + return maps; + } } diff --git a/riis-system/src/main/resources/mapper/patroltask/AlarmLogMapper.xml b/riis-system/src/main/resources/mapper/patroltask/AlarmLogMapper.xml index 639f055..b774b62 100644 --- a/riis-system/src/main/resources/mapper/patroltask/AlarmLogMapper.xml +++ b/riis-system/src/main/resources/mapper/patroltask/AlarmLogMapper.xml @@ -112,8 +112,39 @@ WHERE station_id = #{stationId} + + +