From 82557600cb136161b44cf02a53589126978e04a9 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Thu, 24 Aug 2023 13:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/xiannccda/alert/AlertListenerJob.java | 5 ++++- .../joylink/xiannccda/alert/NccAlertInfo.java | 1 - .../convertor/DeviceChangeStatusConvertor.java | 5 ++--- .../collect/convertor/DeviceInitConvertor.java | 4 ++-- .../ats/warn/AxleSwitchTrackLedAlertListener.java | 4 ++-- .../ats/warn/PlatformAlertMonitoringTask.java | 2 +- .../ats/warn/SwitchLostAlertMonitoringTask.java | 4 ++-- .../ats/warn/TrainModeAlertListener.java | 2 +- .../joylink/xiannccda/entity/AlertRecord.java | 4 ++-- .../xiannccda/mock/message/MockLoadData.java | 8 ++++---- .../xiannccda/service/AlertInfoService.java | 15 ++++++++------- 11 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java b/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java index 1059f75..d7c256d 100644 --- a/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java +++ b/src/main/java/club/joylink/xiannccda/alert/AlertListenerJob.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Component; @Order @Component public class AlertListenerJob implements ApplicationRunner { + private final WsMessageServerManager wsMessageServerManager; private final IAlertRecordRepository alertRecordRepository; @@ -62,7 +63,9 @@ public class AlertListenerJob implements ApplicationRunner { record.setAlertType(nccAlertInfo.getAlertType().name()); record.setAlertObject(nccAlertInfo.getAlertObject()); record.setLineId(nccAlertInfo.getLineId()); - record.setAlertLocation(nccAlertInfo.getAlertLocationName()); + record.setAlertLocationId(nccAlertInfo.getAlertLocationId()); + +// record.setAlertLocation(nccAlertInfo.getAlertLocationName()); return record; } } diff --git a/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java b/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java index cd01d36..20e3d82 100644 --- a/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java +++ b/src/main/java/club/joylink/xiannccda/alert/NccAlertInfo.java @@ -33,7 +33,6 @@ public class NccAlertInfo implements AlertInfo { Long alertLocationId) { this.alertTime = alertTime; this.alertType = alertType; - this.alertTipId = alertTipId; this.lineId = lineId; this.alertObject = alertObject; this.locatorDeviceId = locatorDeviceId; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceChangeStatusConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceChangeStatusConvertor.java index cde1384..ceee803 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceChangeStatusConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceChangeStatusConvertor.java @@ -31,7 +31,7 @@ public class DeviceChangeStatusConvertor extends DefaultConvertor { @Override protected void eventHandle(List builders) { - AlertManager alertManager = AlertManager.getDefault(); + /*AlertManager alertManager = AlertManager.getDefault(); for (Builder builder : builders) { if (builder instanceof Rtu.Builder rtuBuild) { alertManager.emit(new BlueDisplayAlertEvent(rtuBuild)); @@ -43,7 +43,6 @@ public class DeviceChangeStatusConvertor extends DefaultConvertor { } else if (builder instanceof Platform.Builder platformBuild) { alertManager.emit(new PlatformAlertEvent(platformBuild)); } - } -// alertManager.emit(new DeviceAlertEvent>(builders)); + }*/ } } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceInitConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceInitConvertor.java index 3e4d1b2..2e6705e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceInitConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DeviceInitConvertor.java @@ -32,7 +32,7 @@ public class DeviceInitConvertor extends DefaultConvertor { @Override protected void eventHandle(List builders) { - AlertManager alertManager = AlertManager.getDefault(); +/* AlertManager alertManager = AlertManager.getDefault(); for (Builder builder : builders) { if (builder instanceof Rtu.Builder rtuBuild) { alertManager.emit(new BlueDisplayAlertEvent(rtuBuild)); @@ -44,6 +44,6 @@ public class DeviceInitConvertor extends DefaultConvertor { } else if (builder instanceof Platform.Builder platformBuild) { alertManager.emit(new PlatformAlertEvent(platformBuild)); } - } + }*/ } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java index 5b3b777..82c1f3e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/AxleSwitchTrackLedAlertListener.java @@ -106,11 +106,11 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener if (light) { if (alertManager.putAlterDevice(lineId.toString(), ledName, id)) { - NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build); + NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode()); alertManager.emit(alertInfo); } if (Objects.nonNull(ledMostName) && alertManager.needMostShow(lineId.toString(), ledMostName, overNums)) { - NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build); + NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode()); alertManager.emit(alertInfoMost); } } else { diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java index a9db8d4..6ce957e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/PlatformAlertMonitoringTask.java @@ -75,7 +75,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask { if (this.timeOver(build.getReceiveTime(), timeOut) && alertManager.putAlterDevice(lineId, CUSTOM_NAME, build.getId())) { LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(build.getLineId(), build.getId(), LayoutGraphicsProto.Platform.class); - NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), build); + NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), build, platform.getCode()); alertManager.emit(alertInfo); } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java index e7f6fef..940729d 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/SwitchLostAlertMonitoringTask.java @@ -84,7 +84,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask { if (saveIsLost && this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) { //失表超时 if (alertManager.putAlterDevice(lineIdStr, oneName, savedSwitchBuild.getId())) { - NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild); + NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, savedSwitchBuild.getId()); alertManager.emit(alertInfo); } Optional alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), @@ -92,7 +92,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask { //检测大面积失表 if (alertInfoMostOpt.isPresent() && alertManager.needMostShow(lineIdStr, alertInfoMostOpt.get().getAreaName(), guardConfig.getSwitchLostMostNums())) { - NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild); + NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, savedSwitchBuild.getId()); alertManager.emit(alertInfo); } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java index 6c88574..2435023 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java @@ -39,7 +39,7 @@ public class TrainModeAlertListener implements AlertSourceEventListener { // this.nccMockDataService.skip(170L, 1100L, 1180L); loadData(); @@ -40,9 +40,9 @@ public class MockLoadData implements ApplicationRunner { Wrapper wrapper = Wrappers.lambdaQuery() // .in(NccMockData::getMsgId, List.of("DEVICE_STATUS_BITMAP", "TRAIN_INDICATION_INIT", "TRAIN_INDICATION_UPDATE", "TRAIN_INDICATION_REMOVE")) // .eq(NccMockData::getMsgId, "DEVICE_STATUS_BITMAP") - .gt(NccMockData::getMockReceiveTime, "2023-08-06 12:20:20") + .gt(NccMockData::getMockReceiveTime, "2023-08-06 23:20:20") // .gt(NccMockData::getId, 2598023) - .gt(NccMockData::getId, 2933958) +// .gt(NccMockData::getId, 2933958) // .ne(NccMockData::getIsDelete, 1) .orderBy(true, true, NccMockData::getId); List dataList = this.nccMockDataService.loadALLData(wrapper); diff --git a/src/main/java/club/joylink/xiannccda/service/AlertInfoService.java b/src/main/java/club/joylink/xiannccda/service/AlertInfoService.java index 9868c73..682fae9 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertInfoService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertInfoService.java @@ -59,25 +59,26 @@ public class AlertInfoService { return findList; } - public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb) { + public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String targetDeviceCode) { Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class); Optional areaConfigOptional = this.findAreaDevice(alertType, dt, layoutId, lineId); - return this.createAlert2(areaConfigOptional, alertType, mb); + return this.createAlert2(areaConfigOptional, alertType, mb, targetDeviceCode); } - public NccAlertInfo createAlert2(Optional areaConfigOpt, AlertType alertType, MessageOrBuilder mb) { + public NccAlertInfo createAlert2(Optional areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String targetDeviceCode) { Long timestamp = DeviceStatusDataOperate.findFieldVal(mb, "timestamp", Long.class); Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class); String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "id", String.class); LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.of("+8")); DeviceAreaConfig areaConfig = areaConfigOpt.orElse(null); if (Objects.isNull(areaConfig)) { - return new NccAlertInfo(createTime, alertType, lineId, deviceCode, deviceCode, null); + return new NccAlertInfo(createTime, alertType, lineId, targetDeviceCode, deviceCode, null); } - return new NccAlertInfo(createTime, alertType, lineId, String.format("%-设备[%s]", areaConfig.getAreaName(), deviceCode), deviceCode, areaConfig.getId()); + String alertObject = String.format("%s-设备[%s]", areaConfig.getAreaName(), targetDeviceCode); + return new NccAlertInfo(createTime, alertType, lineId, alertObject, deviceCode, areaConfig.getId()); } - @Deprecated +/* @Deprecated public NccAlertInfo createAlert(DeviceAreaConfig areaConfig, AlertType alertType, MessageOrBuilder mb) { Long timestamp = DeviceStatusDataOperate.findFieldVal(mb, "timestamp", Long.class); Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class); @@ -94,7 +95,7 @@ public class AlertInfoService { LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), ZoneId.of("+8")); return new NccAlertInfo(createTime, alertType, Objects.nonNull(at) ? at.getId() : null, lineId, deviceCode, deviceCode, null); - } + }*/ public Optional findAreaDevice(AlertType alertType, AlertDeviceType dt, String layoutId, int lineId) { List areaConfigList = this.findDevice(alertType, dt, lineId);