Commit e91e52c8 authored by duanruiming's avatar duanruiming

[update] 信号机告警优化

parent 3777bf1a
...@@ -82,46 +82,51 @@ public class CommonEventWarnTask { ...@@ -82,46 +82,51 @@ public class CommonEventWarnTask {
* @return * @return
*/ */
private JsonViewObject getSignalWarnData() { private JsonViewObject getSignalWarnData() {
List<CommonEventAlarmOutVo> results = new ArrayList<>(); JsonViewObject jsonViewObject = null;
JsonViewObject jsonViewObject = utcFeignClients.runningStatusAlarm(); try {
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) { List<CommonEventAlarmOutVo> results = new ArrayList<>();
return jsonViewObject.fail("信号机告警UTC服务调用异常!"); jsonViewObject = utcFeignClients.runningStatusAlarm();
} if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机告警UTC服务调用异常!");
}
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String formatNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now); String formatNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);
List<Map<String, Object>> content = (List<Map<String, Object>>) jsonViewObject.getContent(); List<Map<String, Object>> content = (List<Map<String, Object>>) jsonViewObject.getContent();
content.forEach(map -> { content.forEach(map -> {
Map<String, Object> result = map; Map<String, Object> result = map;
String signalId = (String) result.get("signalId"); String signalId = (String) result.get("signalId");
String crossId = (String) result.get("crossId"); String crossId = (String) result.get("crossId");
Integer currentStatus = (Integer) result.get("status"); Integer currentStatus = (Integer) result.get("status");
Integer currentFaultType = (Integer) result.get("faultType"); Integer currentFaultType = (Integer) result.get("faultType");
String coordinate = ""; String coordinate = "";
String crossName = ""; String crossName = "";
TDeviceStatusInfo tDeviceStatusInfo1 = new TDeviceStatusInfo(); TDeviceStatusInfo tDeviceStatusInfo1 = new TDeviceStatusInfo();
if (StringUtils.isNotEmpty(crossId)) { if (StringUtils.isNotEmpty(crossId)) {
CrossInfoPO tBaseCrossInfo = situationDetectionService.selectCrossInfoById(crossId); CrossInfoPO tBaseCrossInfo = situationDetectionService.selectCrossInfoById(crossId);
if (Objects.nonNull(tBaseCrossInfo)) { if (Objects.nonNull(tBaseCrossInfo)) {
coordinate = tBaseCrossInfo.getLocation(); coordinate = tBaseCrossInfo.getLocation();
}
QueryWrapper<TDeviceStatusInfo> queryWrapper = new QueryWrapper<>();
TDeviceStatusInfo tDeviceStatusInfo = tDeviceStatusMapper.selectOne(queryWrapper.eq("code", crossId));
if (Objects.nonNull(tDeviceStatusInfo)) {
tDeviceStatusInfo1 =tDeviceStatusInfo;
crossName = tDeviceStatusInfo.getName();
}
} }
QueryWrapper<TDeviceStatusInfo> queryWrapper = new QueryWrapper<>();
TDeviceStatusInfo tDeviceStatusInfo = tDeviceStatusMapper.selectOne(queryWrapper.eq("code", crossId));
if (Objects.nonNull(tDeviceStatusInfo)) {
tDeviceStatusInfo1 =tDeviceStatusInfo;
crossName = tDeviceStatusInfo.getName();
}
}
buildSignalWarnData(results, formatNow, signalId, currentStatus, currentFaultType, coordinate, crossName, tDeviceStatusInfo1); buildSignalWarnData(results, formatNow, signalId, currentStatus, currentFaultType, coordinate, crossName, tDeviceStatusInfo1);
}); });
// 无告警数据 // 无告警数据
if (CollectionUtils.isEmpty(results)) { if (CollectionUtils.isEmpty(results)) {
return null; return null;
}
jsonViewObject.setTimestamp(now.toInstant(ZoneOffset.of("+8")).toEpochMilli());
jsonViewObject.setContent(results);
} catch (Exception e) {
log.error("获取信号机告警数据失败", e);
} }
jsonViewObject.setTimestamp(now.toInstant(ZoneOffset.of("+8")).toEpochMilli());
jsonViewObject.setContent(results);
return jsonViewObject; return jsonViewObject;
} }
...@@ -138,24 +143,28 @@ public class CommonEventWarnTask { ...@@ -138,24 +143,28 @@ public class CommonEventWarnTask {
* @param tDeviceStatusInfo1 * @param tDeviceStatusInfo1
*/ */
private static void buildSignalWarnData(List<CommonEventAlarmOutVo> results, String formatNow, String signalId, Integer currentStatus, Integer currentFaultType, String coordinate, String crossName, TDeviceStatusInfo tDeviceStatusInfo1) { private static void buildSignalWarnData(List<CommonEventAlarmOutVo> results, String formatNow, String signalId, Integer currentStatus, Integer currentFaultType, String coordinate, String crossName, TDeviceStatusInfo tDeviceStatusInfo1) {
if (SignalStatusTask.isExucuteUpdate(currentStatus, currentFaultType, tDeviceStatusInfo1)) { try {
CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo(); if (SignalStatusTask.isExucuteUpdate(currentStatus, currentFaultType, tDeviceStatusInfo1)) {
commonEventAlarmOutVo.setEventType(3); CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
commonEventAlarmOutVo.setEventId(signalId); commonEventAlarmOutVo.setEventType(3);
commonEventAlarmOutVo.setEventName(crossName); commonEventAlarmOutVo.setEventId(signalId);
if (currentStatus == 0) { commonEventAlarmOutVo.setEventName(crossName);
commonEventAlarmOutVo.setStatus("11"); if (currentStatus == 0) {
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机离线")); commonEventAlarmOutVo.setStatus("11");
} else if (currentStatus == 1){ commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机离线"));
commonEventAlarmOutVo.setStatus(String.valueOf(0)); } else if (currentStatus == 1){
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机上线")); commonEventAlarmOutVo.setStatus(String.valueOf(0));
} else { commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机上线"));
commonEventAlarmOutVo.setStatus(String.valueOf(currentFaultType)); } else {
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机故障")); commonEventAlarmOutVo.setStatus(String.valueOf(currentFaultType));
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机故障"));
}
commonEventAlarmOutVo.setStartTime(formatNow);
commonEventAlarmOutVo.setCoordinate(coordinate);
results.add(commonEventAlarmOutVo);
} }
commonEventAlarmOutVo.setStartTime(formatNow); } catch (Exception e) {
commonEventAlarmOutVo.setCoordinate(coordinate); log.error("构建信号机告警数据失败", e);
results.add(commonEventAlarmOutVo);
} }
} }
} }
...@@ -130,7 +130,7 @@ public class WebSocketServer { ...@@ -130,7 +130,7 @@ public class WebSocketServer {
*/ */
@OnError @OnError
public void onError(Session session, Throwable error) { public void onError(Session session, Throwable error) {
log.error("主题:{},socket:{},连接异常,异常信息:{}", topic, userId, error); log.error("主题:{},socket:{},连接异常,异常信息:{}", topic, userId, error.getMessage());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment