Commit e91e52c8 authored by duanruiming's avatar duanruiming

[update] 信号机告警优化

parent 3777bf1a
......@@ -82,46 +82,51 @@ public class CommonEventWarnTask {
* @return
*/
private JsonViewObject getSignalWarnData() {
List<CommonEventAlarmOutVo> results = new ArrayList<>();
JsonViewObject jsonViewObject = utcFeignClients.runningStatusAlarm();
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机告警UTC服务调用异常!");
}
JsonViewObject jsonViewObject = null;
try {
List<CommonEventAlarmOutVo> results = new ArrayList<>();
jsonViewObject = utcFeignClients.runningStatusAlarm();
if (Objects.isNull(jsonViewObject) || jsonViewObject.getCode() != 200) {
return jsonViewObject.fail("信号机告警UTC服务调用异常!");
}
LocalDateTime now = LocalDateTime.now();
String formatNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);
List<Map<String, Object>> content = (List<Map<String, Object>>) jsonViewObject.getContent();
content.forEach(map -> {
Map<String, Object> result = map;
String signalId = (String) result.get("signalId");
String crossId = (String) result.get("crossId");
Integer currentStatus = (Integer) result.get("status");
Integer currentFaultType = (Integer) result.get("faultType");
LocalDateTime now = LocalDateTime.now();
String formatNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);
List<Map<String, Object>> content = (List<Map<String, Object>>) jsonViewObject.getContent();
content.forEach(map -> {
Map<String, Object> result = map;
String signalId = (String) result.get("signalId");
String crossId = (String) result.get("crossId");
Integer currentStatus = (Integer) result.get("status");
Integer currentFaultType = (Integer) result.get("faultType");
String coordinate = "";
String crossName = "";
TDeviceStatusInfo tDeviceStatusInfo1 = new TDeviceStatusInfo();
if (StringUtils.isNotEmpty(crossId)) {
CrossInfoPO tBaseCrossInfo = situationDetectionService.selectCrossInfoById(crossId);
if (Objects.nonNull(tBaseCrossInfo)) {
coordinate = tBaseCrossInfo.getLocation();
String coordinate = "";
String crossName = "";
TDeviceStatusInfo tDeviceStatusInfo1 = new TDeviceStatusInfo();
if (StringUtils.isNotEmpty(crossId)) {
CrossInfoPO tBaseCrossInfo = situationDetectionService.selectCrossInfoById(crossId);
if (Objects.nonNull(tBaseCrossInfo)) {
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);
});
// 无告警数据
if (CollectionUtils.isEmpty(results)) {
return null;
buildSignalWarnData(results, formatNow, signalId, currentStatus, currentFaultType, coordinate, crossName, tDeviceStatusInfo1);
});
// 无告警数据
if (CollectionUtils.isEmpty(results)) {
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;
}
......@@ -138,24 +143,28 @@ public class CommonEventWarnTask {
* @param 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)) {
CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
commonEventAlarmOutVo.setEventType(3);
commonEventAlarmOutVo.setEventId(signalId);
commonEventAlarmOutVo.setEventName(crossName);
if (currentStatus == 0) {
commonEventAlarmOutVo.setStatus("11");
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机离线"));
} else if (currentStatus == 1){
commonEventAlarmOutVo.setStatus(String.valueOf(0));
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机上线"));
} else {
commonEventAlarmOutVo.setStatus(String.valueOf(currentFaultType));
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机故障"));
try {
if (SignalStatusTask.isExucuteUpdate(currentStatus, currentFaultType, tDeviceStatusInfo1)) {
CommonEventAlarmOutVo commonEventAlarmOutVo = new CommonEventAlarmOutVo();
commonEventAlarmOutVo.setEventType(3);
commonEventAlarmOutVo.setEventId(signalId);
commonEventAlarmOutVo.setEventName(crossName);
if (currentStatus == 0) {
commonEventAlarmOutVo.setStatus("11");
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机离线"));
} else if (currentStatus == 1){
commonEventAlarmOutVo.setStatus(String.valueOf(0));
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机上线"));
} else {
commonEventAlarmOutVo.setStatus(String.valueOf(currentFaultType));
commonEventAlarmOutVo.setEventDesc(crossName.concat("信号机故障"));
}
commonEventAlarmOutVo.setStartTime(formatNow);
commonEventAlarmOutVo.setCoordinate(coordinate);
results.add(commonEventAlarmOutVo);
}
commonEventAlarmOutVo.setStartTime(formatNow);
commonEventAlarmOutVo.setCoordinate(coordinate);
results.add(commonEventAlarmOutVo);
} catch (Exception e) {
log.error("构建信号机告警数据失败", e);
}
}
}
......@@ -130,7 +130,7 @@ public class WebSocketServer {
*/
@OnError
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