代码调整

This commit is contained in:
tiger_zhou 2023-09-12 16:48:39 +08:00
parent d938b084fc
commit 260b7e65ec
28 changed files with 323 additions and 195 deletions

View File

@ -2,18 +2,26 @@ package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedMostAlertListener;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedMostAlertListener.SwitchAndTrackLedMostAlertEvent;
import club.joylink.xiannccda.ats.warn.BlueAlertListener;
import club.joylink.xiannccda.ats.warn.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.PlatformAlertMonitoringTask;
import club.joylink.xiannccda.ats.warn.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener.SwitchLostAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertMonitoringTask;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostMostAlertListener;
import club.joylink.xiannccda.ats.warn.SwitchLostMostAlertListener.SwitchLostMostEvent;
import club.joylink.xiannccda.ats.warn.TrainAtpCutAlertMonitoringTask;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener;
import club.joylink.xiannccda.ats.warn.TrainRecordAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener.TrainRecordAlertEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
@ -42,6 +50,10 @@ public class AlertEmitJob implements ApplicationRunner {
private TrainAtpCutAlertMonitoringTask trainAtpCutAlertMonitoringTask;
@Autowired
private TrainReacrdAlertListener trainReacrdAlertListener;
@Autowired
private AxleSwitchTrackLedMostAlertListener mostAlertListener;
@Autowired
private SwitchLostMostAlertListener lostMostAlertListener;
@Override
public void run(ApplicationArguments args) throws Exception {
@ -62,6 +74,8 @@ public class AlertEmitJob implements ApplicationRunner {
alertManager.on(this.trainModeAlertListener, TrainAlertEvent.class);
//列车报点监听
alertManager.on(this.trainReacrdAlertListener, TrainRecordAlertEvent.class);
alertManager.on(this.mostAlertListener, SwitchAndTrackLedMostAlertEvent.class);
alertManager.on(this.lostMostAlertListener, SwitchLostMostEvent.class);
}
}

View File

@ -64,7 +64,8 @@ public class AlertListenerJob implements ApplicationRunner {
record.setAlertObject(nccAlertInfo.getAlertObject());
record.setLineId(nccAlertInfo.getLineId());
record.setAlertLocationId(nccAlertInfo.getAlertLocationId());
record.setAlertDeviceType(nccAlertInfo.getAlertDeviceType().name());
record.setAlertDeviceId(nccAlertInfo.getLocatorDeviceId());
// record.setAlertLocation(nccAlertInfo.getAlertLocationName());
return record;
}

View File

@ -1,5 +1,6 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertInfo;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
@ -28,10 +29,11 @@ public class NccAlertInfo implements AlertInfo {
private boolean mock;
@Setter
private Integer alarmStatus;
private AlertDeviceType alertDeviceType;
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType,
Integer lineId, String alertObject, String locatorDeviceId,
Long alertLocationId, boolean mockData) {
Long alertLocationId, AlertDeviceType alertDeviceType, boolean mockData) {
this.alertTime = alertTime;
this.alertType = alertType;
this.lineId = lineId;
@ -42,11 +44,12 @@ public class NccAlertInfo implements AlertInfo {
this.alertLocationId = alertLocationId;
this.mock = mockData;
this.level = buildLevel();
this.alertDeviceType = alertDeviceType;
}
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
Integer lineId, String alertObject, String locatorDeviceId,
Long alertLocationId) {
Long alertLocationId, AlertDeviceType alertDeviceType) {
this.alertTime = alertTime;
this.alertType = alertType;
this.alertTipId = alertTipId;
@ -56,6 +59,7 @@ public class NccAlertInfo implements AlertInfo {
this.alertLocationId = alertLocationId;
this.mock = false;
this.level = buildLevel();
this.alertDeviceType = alertDeviceType;
}
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,

View File

@ -3,9 +3,11 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertEvent;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener.SwitchLostAlertEvent;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;

View File

@ -3,9 +3,11 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertEvent;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener.SwitchLostAlertEvent;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;

View File

@ -3,7 +3,8 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;

View File

@ -3,7 +3,8 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainRecordAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener.TrainRecordAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;

View File

@ -3,7 +3,8 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;

View File

@ -3,7 +3,8 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;

View File

@ -9,6 +9,8 @@ import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedMostAlertListener.SwitchAndTrackLedMostAlertEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
@ -34,14 +36,10 @@ import org.springframework.stereotype.Component;
@Slf4j
public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener<SwitchAndTrackLedAlertEvent> {
private final DeviceGuardConfigService configService;
private final AlertInfoService alertInfoService;
private final AlertManager alertManager = AlertManager.getDefault();
public AxleSwitchTrackLedAlertListener(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
this.configService = configService;
public AxleSwitchTrackLedAlertListener(AlertInfoService alertInfoService) {
this.alertInfoService = alertInfoService;
}
@ -94,41 +92,20 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
Integer lineId = DeviceStatusDataOperate.findFieldVal(build, "lineId", Integer.class);
String id = DeviceStatusDataOperate.findFieldVal(build, "id", String.class);
GuardConfig guardConfig = configService.getGuardConfig(lineId);
AlertType mostType = alertType == AlertType.AXLE_LED_RED ? AlertType.AXLE_LED_RED_MOST : AlertType.AXLE_LED_ORANGE_MOST;
String layoutDeviceId = this.findSectionId(lineId, section, id);
int overNums = guardConfig.getRedLedMostNums();
if (mostType == AlertType.AXLE_LED_ORANGE_MOST) {
overNums = guardConfig.getOrangeLedMostNums();
}
Optional<DeviceAreaConfig> alertInfoOptional = this.alertInfoService.findAreaDevice(alertType, AlertDeviceType.DEVICE_TYPE_TRACK, layoutDeviceId, lineId);
Optional<DeviceAreaConfig> alertInfoMostOptional = this.alertInfoService.findAreaDevice(mostType, AlertDeviceType.DEVICE_TYPE_TRACK, layoutDeviceId, lineId);
// String customName = this.getCustomName(alertInfoOptional, alertInfoMostOptional, alertType);
String alertInfoName = alertInfoOptional.map(DeviceAreaConfig::getAreaName).orElse(this.getDefaultName(alertType));
String alertInfoMostName = alertInfoMostOptional.map(DeviceAreaConfig::getAreaName).orElse(null);
String ledName = alertType == AlertType.AXLE_LED_RED ? "红光带" : "橙光带";
if (light) {
log.info("光带检测到[{}] 线路[{}] 设备[{}] 告警[{}] 自定义名称[{}]", ledName, lineId, id, alertType.name(), alertInfoName);
if (alertManager.putAlterDevice(lineId, alertInfoName, id)) {
log.info("光带检测到[{}] 线路[{}] 设备[{}] 告警[{}]", ledName, lineId, id, alertType.name());
if (alertManager.putAlterDevice(lineId, this.getDefaultName(alertType), id)) {
String alertMsg = String.format("出现%s设备[%s]", ledName, id);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, alertMsg, section.getCommon().getId(), false);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), alertType, build, alertMsg, section.getCommon().getId(), AlertDeviceType.DEVICE_TYPE_TRACK, false);
alertManager.emit(alertInfo);
}
if (StringUtils.isNotEmpty(alertInfoMostName) && alertManager.needMostShow(lineId, alertInfoMostName, overNums)) {
String warnDevices = alertManager.findAllWarnDevice(lineId, alertInfoMostName);
String alertMsg = String.format("%s-出现大面积%s设备[%s]", alertInfoMostOptional.get().getAreaName(), ledName, warnDevices);
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, mostType, build, alertMsg, section.getCommon().getId(), false);
alertManager.emit(alertInfoMost);
alertManager.emit(new SwitchAndTrackLedMostAlertEvent(build, alertType, lineId, layoutDeviceId, true));
}
} else {
alertManager.removeAlterDevice(lineId, alertInfoName, id);
if (StringUtils.isNotEmpty(alertInfoMostName)) {
alertManager.removeAlterDevice(lineId, alertInfoMostName, id);
alertManager.removeAlterDevice(lineId, this.getDefaultName(alertType), id);
alertManager.emit(new SwitchAndTrackLedMostAlertEvent(build, alertType, lineId, layoutDeviceId, false));
}
}
}
@ -147,4 +124,11 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
return section.getCommon().getId();
}
public static class SwitchAndTrackLedAlertEvent extends DeviceAlertEvent<GeneratedMessageV3.Builder> {
public SwitchAndTrackLedAlertEvent(Builder source) {
super(source);
}
}
}

View File

@ -0,0 +1,94 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener.SwitchAndTrackLedAlertEvent;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedMostAlertListener.SwitchAndTrackLedMostAlertEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceInfoProto;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class AxleSwitchTrackLedMostAlertListener implements AlertSourceEventListener<SwitchAndTrackLedMostAlertEvent> {
private final DeviceGuardConfigService configService;
private final AlertInfoService alertInfoService;
private final AlertManager alertManager = AlertManager.getDefault();
public AxleSwitchTrackLedMostAlertListener(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
this.configService = configService;
this.alertInfoService = alertInfoService;
}
@Override
public void accept(SwitchAndTrackLedMostAlertEvent event) {
int lineId = event.lineId;
String id = DeviceStatusDataOperate.findFieldVal(event.getSource(), "id", String.class);
AlertType mostType = event.alertType == AlertType.AXLE_LED_RED ? AlertType.AXLE_LED_RED_MOST : AlertType.AXLE_LED_ORANGE_MOST;
Optional<DeviceAreaConfig> alertInfoMostOptional = this.alertInfoService.findAreaDevice(mostType, AlertDeviceType.DEVICE_TYPE_TRACK, event.layoutDeviceId, lineId);
String alertInfoMostName = alertInfoMostOptional.map(DeviceAreaConfig::getAreaName).orElse(null);
if (event.alert) {
GuardConfig guardConfig = configService.getGuardConfig(lineId);
int overNums = guardConfig.getRedLedMostNums();
if (mostType == AlertType.AXLE_LED_ORANGE_MOST) {
overNums = guardConfig.getOrangeLedMostNums();
}
if (StringUtils.isNotEmpty(alertInfoMostName)) {
alertManager.putAlterDevice(lineId, alertInfoMostName, id);
if (alertManager.needMostShow(lineId, alertInfoMostName, overNums)) {
String ledName = event.alertType == AlertType.AXLE_LED_RED ? "红光带" : "橙光带";
String warnDevices = alertManager.findAllWarnDevice(lineId, alertInfoMostName);
String alertMsg = String.format("%s-出现大面积%s设备[%s]", alertInfoMostOptional.get().getAreaName(), ledName, warnDevices);
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoMostOptional, mostType, event.getSource(), alertMsg, event.layoutDeviceId, AlertDeviceType.DEVICE_TYPE_TRACK, false);
alertManager.emit(alertInfoMost);
}
}
} else if (StringUtils.isNotEmpty(alertInfoMostName)) {
alertManager.removeAlterDevice(lineId, alertInfoMostName, id);
}
}
public static class SwitchAndTrackLedMostAlertEvent extends DeviceAlertEvent<Builder> {
private AlertType alertType;
private int lineId;
private String layoutDeviceId;
private boolean alert;
public SwitchAndTrackLedMostAlertEvent(Builder source, AlertType alertType, int lineId, String layoutDeviceId, boolean alert) {
super(source);
this.alertType = alertType;
this.lineId = lineId;
this.layoutDeviceId = layoutDeviceId;
this.alert = alert;
}
}
}

View File

@ -5,8 +5,10 @@ import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.warn.BlueAlertListener.BlueDisplayAlertEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu.Builder;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.service.AlertInfoService;
@ -72,14 +74,15 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
//保存蓝显联锁id
if (alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, areaConfig.getId().toString())) {
String alertMsg = String.format("%s 蓝显", areaConfig.getAreaName());
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, alertMsg, station.getCommon().getId(), false);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, alertMsg, station.getCommon().getId(), AlertDeviceType.DEVICE_TYPE_RTU, false);
alertManager.emit(alertInfo);
}
int allControlStationSize = CONTROL_STATION_MAPER.get(rtu.getLineId()).size();
//查看是否全部的集中站已经蓝显
if (alertManager.needMostShow(rtu.getLineId(), COLL_RTU_NAME, allControlStationSize)
&& alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, ALL_BLUE_DISPLAY_VAL)) {
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL, station.getCommon().getId(), false);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL, station.getCommon().getId(),
AlertDeviceType.DEVICE_TYPE_RTU, false);
alertManager.emit(alertInfo);
}
} else {
@ -104,4 +107,12 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
Optional<Station> optionalStation = stationList.stream().filter(d -> StringUtils.equalsIgnoreCase(d.getCode(), rtuName)).findAny();
return optionalStation.orElse(null);
}
public static class BlueDisplayAlertEvent extends DeviceAlertEvent<Rtu.Builder> {
public BlueDisplayAlertEvent(Builder source) {
super(source);
}
}
}

View File

@ -1,11 +0,0 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu.Builder;
public class BlueDisplayAlertEvent extends DeviceAlertEvent<Rtu.Builder> {
public BlueDisplayAlertEvent(Builder source) {
super(source);
}
}

View File

@ -139,6 +139,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
String alertMsg = String.format("%s-%s-屏蔽门无法%s", stationName, wayType, openClose);
log.info("屏蔽门[{}] 线路[{}] 触发告警[{}] 车站[{}] 方向[{}]", platformBuild.getId(), lineId, customName, stationName, wayType);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), platformBuild, alertMsg,
AlertDeviceType.DEVICE_TYPE_PLATFORM,
false);
alertManager.emit(alertInfo);
}

View File

@ -1,11 +0,0 @@
package club.joylink.xiannccda.ats.warn;
import com.google.protobuf.GeneratedMessageV3;
import com.google.protobuf.GeneratedMessageV3.Builder;
public class SwitchAndTrackLedAlertEvent extends DeviceAlertEvent<GeneratedMessageV3.Builder> {
public SwitchAndTrackLedAlertEvent(Builder source) {
super(source);
}
}

View File

@ -1,11 +0,0 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch.Builder;
public class SwitchLostAlertEvent extends DeviceAlertEvent<Switch.Builder> {
public SwitchLostAlertEvent(Builder source) {
super(source);
}
}

View File

@ -1,7 +1,9 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener.SwitchLostAlertEvent;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch.Builder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -24,4 +26,11 @@ public class SwitchLostAlertListener implements AlertSourceEventListener<SwitchL
}
}
public static class SwitchLostAlertEvent extends DeviceAlertEvent<Switch.Builder> {
public SwitchLostAlertEvent(Builder source) {
super(source);
}
}
}

View File

@ -5,6 +5,7 @@ import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.warn.SwitchLostMostAlertListener.SwitchLostMostEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch.Builder;
@ -48,19 +49,10 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
public void removeSwitch(Switch.Builder switchBuilder) {
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(switchBuilder.getLineId(), switchBuilder.getId(), Turnout.class);
Optional<DeviceAreaConfig> alertInfoOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
switchBuilder.getLineId());
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
switchBuilder.getLineId());
log.info("线路[{}] 道岔[{}] 从监控中移除... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
deviceMap.remove(switchBuilder.getId());
String alertInfoName = alertInfoOpt.map(DeviceAreaConfig::getAreaName).orElse(this.getName());
String mostName = alertInfoMostOpt.map(DeviceAreaConfig::getAreaName).orElse(null);
alertManager.removeAlterDevice(switchBuilder.getLineId(), alertInfoName, switchBuilder.getId());
if (StringUtils.isNotEmpty(mostName)) {
alertManager.removeAlterDevice(switchBuilder.getLineId(), mostName, switchBuilder.getId());
}
alertManager.removeAlterDevice(switchBuilder.getLineId(), this.getName(), switchBuilder.getId());
alertManager.emit(new SwitchLostMostEvent(switchBuilder, false, turnout));
}
@Override
@ -71,30 +63,20 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
private void checkDevice(Turnout turnout, Builder savedSwitchBuild) {
int lineId = savedSwitchBuild.getLineId();
GuardConfig guardConfig = configService.getGuardConfig(lineId);
Optional<DeviceAreaConfig> alertInfoOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
savedSwitchBuild.getLineId());
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
savedSwitchBuild.getLineId());
boolean saveIsLost = savedSwitchBuild.getIpSingleSwitchStusLostIndication();
if (saveIsLost && this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 对应地图设备id[{}]", lineId, savedSwitchBuild.getId(), savedSwitchBuild.getReceiveTime(), turnout.getCommon().getId());
String alertInfoName = alertInfoOpt.map(DeviceAreaConfig::getAreaName).orElse(this.getName());
//失表超时
if (alertManager.putAlterDevice(lineId, alertInfoName, savedSwitchBuild.getId())) {
if (alertManager.putAlterDevice(lineId, this.getName(), savedSwitchBuild.getId())) {
String alertMsg = String.format("设备[%s]失表", savedSwitchBuild.getId());
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(),
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
alertManager.emit(alertInfo);
alertManager.emit(new SwitchLostMostEvent(savedSwitchBuild, true, turnout));
this.deviceMap.remove(savedSwitchBuild.getId());
}
String mostName = alertInfoMostOpt.map(DeviceAreaConfig::getAreaName).orElse(null);
//检测大面积失表
if (StringUtils.isNotEmpty(mostName) && alertManager.needMostShow(lineId, mostName, guardConfig.getSwitchLostMostNums())) {
String warnDevices = alertManager.findAllWarnDevice(lineId, mostName);
String alertMsg = String.format("%s-大面积失表设备[%s]", mostName, warnDevices);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
alertManager.emit(alertInfo);
}
} else if (!saveIsLost) {
this.removeSwitch(savedSwitchBuild);
}
}
@ -103,42 +85,10 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
for (Builder savedSwitchBuild : this.deviceMap.values()) {
Integer lineId = savedSwitchBuild.getLineId();
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, savedSwitchBuild.getId(), Turnout.class);
log.info("道岔失表检测 线路[{}] 设备[{}] 查找对应的地图道岔id[{}]", lineId, savedSwitchBuild.getId(), turnout.getCommon().getId());
// log.info("道岔失表检测 线路[{}] 设备[{}] 查找对应的地图道岔id[{}]", lineId, savedSwitchBuild.getId(), turnout.getCommon().getId());
this.checkDevice(turnout, savedSwitchBuild);
/* Optional<DeviceAreaConfig> alertInfoOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
savedSwitchBuild.getLineId());
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
savedSwitchBuild.getLineId());
String customName = this.getCustomName(alertInfoOpt, alertInfoMostOpt);
boolean saveIsLost = savedSwitchBuild.getIpSingleSwitchStusLostIndication();
if (saveIsLost && this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 对应地图设备id[{}]", lineId, savedSwitchBuild.getId(), savedSwitchBuild.getReceiveTime(), turnout.getCommon().getId());
//失表超时
if (alertManager.putAlterDevice(lineId, customName, savedSwitchBuild.getId())) {
String alertMsg = String.format("设备[%s]失表", savedSwitchBuild.getId());
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
alertManager.emit(alertInfo);
this.deviceMap.remove(savedSwitchBuild.getId());
}
//检测大面积失表
if (alertInfoMostOpt.isPresent() && alertManager.needMostShow(lineId, customName, guardConfig.getSwitchLostMostNums())) {
String warnDevices = alertManager.findAllWarnDevice(lineId, customName);
String alertMsg = String.format("%s-大面积失表设备[%s]", customName, warnDevices);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
alertManager.emit(alertInfo);
}
}*/
}
}
private String getCustomName(Optional<DeviceAreaConfig> alertInfoOpt, Optional<DeviceAreaConfig> alertInfoMostOpt) {
String customName = alertInfoMostOpt.map(DeviceAreaConfig::getAreaName).orElse(null);
if (StringUtils.isEmpty(customName)) {
customName = alertInfoOpt.map(DeviceAreaConfig::getAreaName).orElse(AlertType.SWITCH_LOST.name());
}
return customName;
}
}

View File

@ -0,0 +1,76 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.warn.SwitchLostMostAlertListener.SwitchLostMostEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch.Builder;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import java.util.Optional;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class SwitchLostMostAlertListener implements AlertSourceEventListener<SwitchLostMostEvent> {
private final AlertInfoService alertInfoService;
private final DeviceGuardConfigService configService;
public SwitchLostMostAlertListener(AlertInfoService alertInfoService, DeviceGuardConfigService configService) {
this.alertInfoService = alertInfoService;
this.configService = configService;
}
private final AlertManager alertManager = AlertManager.getDefault();
@Override
public void accept(SwitchLostMostEvent event) {
Switch.Builder switchBuild = event.getSource();
Integer lineId = switchBuild.getLineId();
Turnout turnout = event.turnout;
GuardConfig guardConfig = configService.getGuardConfig(lineId);
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
switchBuild.getLineId());
String mostName = alertInfoMostOpt.map(DeviceAreaConfig::getAreaName).orElse(null);
if (event.alert) {
//检测大面积失表
if (StringUtils.isNotEmpty(mostName)) {
alertManager.putAlterDevice(lineId, mostName, switchBuild.getId());
if (alertManager.needMostShow(lineId, mostName, guardConfig.getSwitchLostMostNums())) {
String warnDevices = alertManager.findAllWarnDevice(lineId, mostName);
String alertMsg = String.format("%s-大面积失表设备[%s]", mostName, warnDevices);
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, switchBuild, alertMsg, turnout.getCommon().getId(),
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
alertManager.emit(alertInfo);
}
}
} else if (StringUtils.isNotEmpty(mostName)) {
}
}
public static class SwitchLostMostEvent extends DeviceAlertEvent<Switch.Builder> {
private boolean alert;
private Turnout turnout;
public SwitchLostMostEvent(Builder source, boolean alert, Turnout turnout) {
super(source);
this.alert = alert;
this.turnout = turnout;
}
}
}

View File

@ -1,11 +0,0 @@
package club.joylink.xiannccda.ats.warn;
import com.google.protobuf.GeneratedMessageV3;
public class TrainAlertEvent extends DeviceAlertEvent<GeneratedMessageV3.Builder> {
public TrainAlertEvent(GeneratedMessageV3.Builder source) {
super(source);
}
}

View File

@ -104,7 +104,8 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
if (alertManager.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) {
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), section.getCode());
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, alertMsg, false);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, alertMsg,
AlertDeviceType.DEVICE_TYPE_TRAIN, false);
alertManager.emit(alertInfo);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
@ -43,4 +44,11 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
}
public static class TrainAlertEvent extends DeviceAlertEvent<GeneratedMessageV3.Builder> {
public TrainAlertEvent(GeneratedMessageV3.Builder source) {
super(source);
}
}
}

View File

@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.TrainTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener.TrainRecordAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
import org.springframework.stereotype.Component;
@ -26,4 +27,12 @@ public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainR
}
}
}
public static class TrainRecordAlertEvent extends DeviceAlertEvent<TrainRecord.Builder> {
public TrainRecordAlertEvent(TrainRecord.Builder source) {
super(source);
}
}
}

View File

@ -1,11 +0,0 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
public class TrainRecordAlertEvent extends DeviceAlertEvent<TrainRecord.Builder> {
public TrainRecordAlertEvent(TrainRecord.Builder source) {
super(source);
}
}

View File

@ -40,6 +40,10 @@ public class AlertRecord {
private Long alertTipId;
private Integer alarmStatus;
private String alertDeviceType;
private String alertDeviceId;
public static final String ID = "id";
public static final String ALERT_TYPE = "alert_type";
@ -54,4 +58,7 @@ public class AlertRecord {
public static final String ALERT_LOCATION_ID = "alert_location_id";
public static final String ALERT_TIP_ID = "alert_tip_id";
public static final String ALARM_STATUS = "alarm_status";
public static final String ALERT_DEVICE_TYPE = "alert_device_type";
public static final String ALERT_DEVICE_ID = "alert_device_id";
}

View File

@ -21,5 +21,5 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AlertRecordMapper extends BaseMapper<AlertRecord> {
List<AlertRecordReportResponseDTO> report(AlertRecordReportDTO dto, @Param("lineId") Integer lineId);
List<AlertRecordReportResponseDTO> report(@Param("dto") AlertRecordReportDTO dto, @Param("lineId") Integer lineId);
}

View File

@ -26,7 +26,6 @@ public class AlertInfoService {
private final DeviceAreaConfigService deviceAreaConfigService;
public AlertInfoService(DeviceAreaConfigService deviceAreaConfigService) {
this.deviceAreaConfigService = deviceAreaConfigService;
}
@ -38,41 +37,41 @@ public class AlertInfoService {
return areaConfigList.stream().filter(d -> d.findAlertTypes(alertType)).toList();
}
public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String alertMsg, boolean mockData) {
public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String alertMsg, AlertDeviceType deviceType, boolean mockData) {
Integer lineId = DeviceStatusDataOperate.findFieldVal(mb, "lineId", Integer.class);
Optional<DeviceAreaConfig> areaConfigOptional = this.findAreaDevice(alertType, dt, layoutId, lineId);
return this.createAlert2(areaConfigOptional, alertType, mb, alertMsg, layoutId, mockData);
return this.createAlert2(areaConfigOptional, alertType, mb, alertMsg, layoutId, deviceType, mockData);
}
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String alertMsg, String layoutId, boolean mockData) {
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String alertMsg, String layoutId, AlertDeviceType deviceType, boolean mockData) {
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"));
Long areaConfigId = areaConfigOpt.map(DeviceAreaConfig::getId).orElse(null);
return new NccAlertInfo(createTime, alertType, lineId, alertMsg, layoutId, areaConfigId, mockData);
return new NccAlertInfo(createTime, alertType, lineId, alertMsg, layoutId, areaConfigId, deviceType, mockData);
}
public Optional<DeviceAreaConfig> findAreaDevice(AlertType alertType, AlertDeviceType dt, String layoutId, int lineId) {
List<DeviceAreaConfig> areaConfigList = this.findDevice(alertType, dt, lineId);
DeviceAreaConfig areaConfig = this.findAreaDevice(areaConfigList, dt, layoutId);
return Optional.ofNullable(areaConfig);
return this.findAreaDevice(areaConfigList, dt, layoutId);
}
private DeviceAreaConfig findAreaDevice(List<DeviceAreaConfig> areaConfigList, AlertDeviceType dt, String layoutId) {
private Optional<DeviceAreaConfig> findAreaDevice(List<DeviceAreaConfig> areaConfigList, AlertDeviceType dt, String layoutId) {
if (CollectionUtils.isEmpty(areaConfigList)) {
//TODO
return null;
return Optional.empty();
}
for (DeviceAreaConfig areaConfig : areaConfigList) {
if (areaConfig.getDeviceType() == dt) {
if (Splitter.on(",").splitToStream(areaConfig.getData()).anyMatch(d -> StringUtils.equalsIgnoreCase(d, layoutId))) {
return areaConfig;
}
return areaConfigList.stream()
.filter(areaConfig -> areaConfig.getDeviceType() == dt && Splitter.on(",").splitToStream(areaConfig.getData()).anyMatch(d -> StringUtils.equalsIgnoreCase(d, layoutId))).findAny();
/*for (DeviceAreaConfig areaConfig : areaConfigList) {
if (areaConfig.getDeviceType() == dt && ) {
return areaConfig;
}
}
return null;
return null;*/
}

View File

@ -73,7 +73,7 @@ public class AlertMockService {
bb.setTimestamp(System.currentTimeMillis() / 1000);
bb.setId(dto.getFrist());
bb.setIpRtuStusDown(true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(), bb, station.getName(), true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(), bb, station.getName(), AlertDeviceType.DEVICE_TYPE_RTU, true);
}
case PLATFORM_DOOR_CANNOT_OPEN -> {
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
@ -83,7 +83,8 @@ public class AlertMockService {
platform.setLineId(dto.getLineId());
platform.setTimestamp(System.currentTimeMillis() / 1000);
Platform pf = pfOptional.orElse(null);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
true);
}
case PLATFORM_DOOR_CANNOT_CLOSE -> {
Optional<Platform> pfOptional = LineGraphicDataRepository.getDevices(lineId, Platform.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
@ -94,7 +95,8 @@ public class AlertMockService {
platform.setLineId(dto.getLineId());
platform.setTimestamp(System.currentTimeMillis() / 1000);
Platform pf = pfOptional.orElse(null);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_PLATFORM, pf.getCommon().getId(), platform, platform.getId(), AlertDeviceType.DEVICE_TYPE_PLATFORM,
true);
}
/* case SWITCH_LOST -> {
Optional<Turnout> turnoutOptional = LineGraphicDataRepository.getDevices(lineId, Turnout.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
@ -116,7 +118,7 @@ public class AlertMockService {
switchs.setReceiveTime(System.currentTimeMillis());
switchs.setIpSingleSwitchStusLostIndication(true);
Turnout turnout = turnoutOptional.orElse(null);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, dto.getAll(), true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchs, dto.getAll(), AlertDeviceType.DEVICE_TYPE_SWITCH, true);
}
case AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST -> {
Optional<LogicSection> lsOptional = LineGraphicDataRepository.getDevices(lineId, LogicSection.class).filter(d -> dto.getDeviceCodes().contains(d.getCode())).findAny();
@ -125,7 +127,7 @@ public class AlertMockService {
track.setLineId(dto.getLineId());
track.setTimestamp(System.currentTimeMillis() / 1000);
LogicSection ls = lsOptional.orElse(null);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_TRACK, ls.getCommon().getId(), track, dto.getAll(), true);
return this.alertInfoService.createAlert(dto.getAlertType(), AlertDeviceType.DEVICE_TYPE_TRACK, ls.getCommon().getId(), track, dto.getAll(), AlertDeviceType.DEVICE_TYPE_TRACK, true);
}
case TRAIN_EB_ATP -> {
@ -137,7 +139,7 @@ public class AlertMockService {
track.setTimestamp(System.currentTimeMillis() / 1000);
LogicSection ls = lsOptional.orElse(null);
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, ls.getCommon().getId(), track, "测试车组号", true);
return this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, ls.getCommon().getId(), track, "测试车组号", AlertDeviceType.DEVICE_TYPE_TRAIN, true);
}
default -> throw new IllegalStateException("Unexpected value: " + dto.getAlertType());
@ -200,7 +202,8 @@ public class AlertMockService {
switchBuild.setIpSingleSwitchStusLocked(true);
switchBuild.setReceiveTime(System.currentTimeMillis());
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, switchBuild.getId(), Turnout.class);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchBuild, switchBuild.getId(), true);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(), switchBuild, switchBuild.getId(),
AlertDeviceType.DEVICE_TYPE_SWITCH, true);
alertInfo.setMock(true);
return alertInfo;
}
@ -212,7 +215,8 @@ public class AlertMockService {
track.setLineId(lineId);
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A");
Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, section.getCommon().getId(), track, track.getId(), true);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, section.getCommon().getId(), track, track.getId(),
AlertDeviceType.DEVICE_TYPE_TRACK, true);
alertInfo.setMock(true);
return alertInfo;
}
@ -225,7 +229,8 @@ public class AlertMockService {
track.setLineId(lineId);
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A");
Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.AXLE_LED_ORANGE, AlertDeviceType.DEVICE_TYPE_TRACK, section.getCommon().getId(), track, track.getId(), true);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.AXLE_LED_ORANGE, AlertDeviceType.DEVICE_TYPE_TRACK, section.getCommon().getId(), track, track.getId(),
AlertDeviceType.DEVICE_TYPE_TRACK, true);
alertInfo.setMock(true);
return alertInfo;
}
@ -234,7 +239,8 @@ public class AlertMockService {
platform.setLineId(lineId);
platform.setId("PF02301").setReceiveTime(System.currentTimeMillis()).setTrainberth(true);
LayoutGraphicsProto.Platform platform2 = LineGraphicDataRepository.getDeviceByCode(lineId, platform.getId(), LayoutGraphicsProto.Platform.class);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(), true);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(),
AlertDeviceType.DEVICE_TYPE_PLATFORM, true);
alertInfo.setMock(true);
return alertInfo;
}
@ -243,7 +249,8 @@ public class AlertMockService {
platform.setLineId(lineId);
platform.setId("PF02301").setReceiveTime(System.currentTimeMillis()).setTrainberth(true).setPsdOpen(true);
LayoutGraphicsProto.Platform platform2 = LineGraphicDataRepository.getDeviceByCode(lineId, platform.getId(), LayoutGraphicsProto.Platform.class);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(), true);
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform2.getCommon().getId(), platform, platform.getId(),
AlertDeviceType.DEVICE_TYPE_PLATFORM, true);
alertInfo.setMock(true);
return alertInfo;
}