逻辑调整,添加数据处理日志
This commit is contained in:
parent
25ac77925b
commit
039a6162d3
@ -12,6 +12,7 @@ import club.joylink.xiannccda.ats.warn.SwitchLostAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.SwitchLostAlertListener;
|
||||
import club.joylink.xiannccda.ats.warn.SwitchLostAlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
|
||||
import club.joylink.xiannccda.ats.warn.TrainAtpCutAlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.warn.TrainModeAlertListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@ -38,6 +39,8 @@ public class AlertEmitJob implements ApplicationRunner {
|
||||
private PlatformAlertListener platformAlertListener;
|
||||
@Autowired
|
||||
private TrainModeAlertListener trainModeAlertListener;
|
||||
@Autowired
|
||||
private TrainAtpCutAlertMonitoringTask trainAtpCutAlertMonitoringTask;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
@ -48,6 +51,7 @@ public class AlertEmitJob implements ApplicationRunner {
|
||||
// alertManager.on(this.axleSwitchTrackAlertListener2, DeviceAlertEvent.class);
|
||||
alertManager.addTask(this.lostAlertMonitoringTask2);
|
||||
alertManager.addTask(this.platformAlertMonitoringTask);
|
||||
alertManager.addTask(this.trainAtpCutAlertMonitoringTask);
|
||||
alertManager.on(this.axleSwitchTrackLedAlertListener2, SwitchAndTrackLedAlertEvent.class);
|
||||
alertManager.on(this.blueAlertListener2, BlueDisplayAlertEvent.class);
|
||||
alertManager.on(this.switchLostAlertListener, SwitchLostAlertEvent.class);
|
||||
|
@ -66,6 +66,15 @@ public class AlertManager extends EventEmitter {
|
||||
return detail.add(deviceName);
|
||||
}
|
||||
|
||||
public boolean deviceIsExist(Integer lineId, String customName, String deviceName) {
|
||||
AlertTableDetail detail = DEVICE_ALTER_TABLE.get(lineId, customName);
|
||||
if (Objects.isNull(detail)) {
|
||||
return false;
|
||||
}
|
||||
return detail.contains(deviceName);
|
||||
|
||||
}
|
||||
|
||||
public void removeAlterDevice(Integer lineId, String customName, String deviceName) {
|
||||
AlertTableDetail detail = DEVICE_ALTER_TABLE.get(lineId, customName);
|
||||
if (Objects.isNull(detail)) {
|
||||
|
@ -36,11 +36,11 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor {
|
||||
|
||||
@Override
|
||||
public void run(List<MessageData> messageDataList) {
|
||||
ConvertorUtil cu = SystemContext.getAppContext().getBean(ConvertorUtil.class);
|
||||
Map<Short, List<MessageResponse>> lineMapper = this.groupByLineId(messageDataList);
|
||||
lineMapper.forEach((k, v) -> {
|
||||
List<GeneratedMessageV3.Builder> builders = v.stream().map(MessageResponse::generateProto)
|
||||
.flatMap(Collection::stream).filter(d -> {
|
||||
ConvertorUtil cu = SystemContext.getAppContext().getBean(ConvertorUtil.class);
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class);
|
||||
Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class);
|
||||
return cu.notMatchHandle(lineId, rtuId);
|
||||
|
@ -24,11 +24,13 @@ 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 AxleSwitchTrackLedAlertListener implements AlertSourceEventListener<SwitchAndTrackLedAlertEvent> {
|
||||
|
||||
|
||||
@ -45,12 +47,12 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
|
||||
@Override
|
||||
public void accept(SwitchAndTrackLedAlertEvent event) {
|
||||
GeneratedMessageV3.Builder o = event.getSource();
|
||||
String receiveBuildType = o.getDescriptorForType().getName();
|
||||
|
||||
Integer lineId = DeviceStatusDataOperate.findFieldVal(o, "lineId", Integer.class);
|
||||
String id = DeviceStatusDataOperate.findFieldVal(o, "id", String.class);
|
||||
if (Objects.isNull(lineId)) {
|
||||
return;
|
||||
}
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, id);
|
||||
log.info("区段光带检测 线路[{}] 设备[{}] 查找对应的物理区段code[{}] 接受类型[{}]", lineId, id, sectionCode, receiveBuildType);
|
||||
if (StringUtils.isEmpty(sectionCode)) {
|
||||
return;
|
||||
}
|
||||
@ -98,16 +100,18 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
|
||||
String customName = this.getCustomName(alertInfoOptional, alertInfoMostOptional, alertType);
|
||||
String ledName = alertType == AlertType.AXLE_LED_RED ? "红光带" : "橙光带";
|
||||
if (light) {
|
||||
log.info("光带检测到[{}] 线路[{}] 设备[{}] 告警[{}] 自定义名称[{}]", ledName, lineId, id, alertType.name(), customName);
|
||||
if (alertManager.putAlterDevice(lineId, customName, id)) {
|
||||
String alertMsg = String.format("出现%s设备[%s]", ledName, id);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, alertMsg, false);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, alertMsg, section.getCommon().getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
|
||||
if (alertInfoMostOptional.isPresent() && alertManager.needMostShow(lineId, customName, overNums)) {
|
||||
|
||||
String warnDevices = alertManager.findAllWarnDevice(lineId, customName);
|
||||
String alertMsg = String.format("%s-出现大面积%s设备[%s]", alertInfoMostOptional.get().getAreaName(), ledName, warnDevices);
|
||||
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, mostType, build, alertMsg, false);
|
||||
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, mostType, build, alertMsg, section.getCommon().getId(), false);
|
||||
alertManager.emit(alertInfoMost);
|
||||
}
|
||||
} else {
|
||||
@ -124,7 +128,7 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
|
||||
if (StringUtils.isNotEmpty(customName)) {
|
||||
return String.format("%s_%s", customName, alertType.name());
|
||||
}
|
||||
return alertInfoOpt.isPresent() ? alertInfoOpt.get().getAreaName() : alertType.name();
|
||||
return alertInfoOpt.map(DeviceAreaConfig::getAreaName).orElse(alertType.name());
|
||||
}
|
||||
|
||||
private String findSectionId(int lineId, Section section, String deviceCode) {
|
||||
|
@ -61,24 +61,25 @@ public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAl
|
||||
rtu.getLineId());
|
||||
|
||||
if (alertInfoOpt.isEmpty()) {
|
||||
log.error("rtu[{}] 地图车站id[{}] 线路Id[{}]未找到对应的区域配置,无法蓝显", rtu.getId(), station.getCommon().getId(), rtu.getLineId());
|
||||
log.error("线路[{}] rtu[{}] 地图车站id[{}] 线路Id[{}]未找到对应的区域配置,无法蓝显", rtu.getLineId(), rtu.getId(), station.getCommon().getId(), rtu.getLineId());
|
||||
return;
|
||||
}
|
||||
DeviceAreaConfig areaConfig = alertInfoOpt.get();
|
||||
if (rtu.getIpRtuStusDown()) {
|
||||
log.info("线路[{}] 车站[{}] rtu[{}] 通信中断", rtu.getLineId(), station.getName(), rtu.getId());
|
||||
//保存出现蓝显的集中站
|
||||
alertManager.putAlterDevice(rtu.getLineId(), COLL_RTU_NAME, rtu.getId());
|
||||
//保存蓝显联锁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, false);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, alertMsg, station.getCommon().getId(), 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, false);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.ALL_LINE_BLUE_DISPLAY, rtu, ALL_BLUE_DISPLAY_VAL, station.getCommon().getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,37 +1,16 @@
|
||||
package club.joylink.xiannccda.ats.warn;
|
||||
|
||||
import club.joylink.xiannccda.alert.AlertDetailFactory;
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||
import club.joylink.xiannccda.alert.util.AlertUtil;
|
||||
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.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class PlatformAlertListener implements AlertSourceEventListener<PlatformAlertEvent> {
|
||||
|
||||
private AlertDetailFactory alertDetailFactory;
|
||||
private PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||
|
||||
public PlatformAlertListener(AlertDetailFactory alertDetailFactory, PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||
this.alertDetailFactory = alertDetailFactory;
|
||||
public PlatformAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.warn;
|
||||
|
||||
import club.joylink.xiannccda.alert.AlertDetailFactory;
|
||||
import club.joylink.xiannccda.alert.NccAlertInfo;
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||
@ -13,7 +12,6 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -41,22 +39,33 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
private final static String CUSTOM_NAME = AlertDeviceType.DEVICE_TYPE_PLATFORM.name();
|
||||
|
||||
public void putSwitchIfNotExist(Platform.Builder platformBuild) {
|
||||
|
||||
Platform.Builder saveBuilder = this.platformMap.get(platformBuild.getId());
|
||||
|
||||
if (Objects.isNull(saveBuilder)) {
|
||||
platformMap.put(platformBuild.getId(), platformBuild);
|
||||
} else {
|
||||
// this.removeSwitch(saveBuilder);
|
||||
saveBuilder.setPsdOpen(platformBuild.getPsdOpen());
|
||||
//重新计算时间
|
||||
if (platformBuild.getPsdOpen()) {
|
||||
saveBuilder.setTimestamp(platformBuild.getTimestamp());
|
||||
}
|
||||
platformMap.put(platformBuild.getId(), platformBuild);
|
||||
}
|
||||
AlertType alertType = AlertType.PLATFORM_DOOR_CANNOT_CLOSE;
|
||||
if (platformBuild.getPsdOpen()) {
|
||||
alertType = AlertType.PLATFORM_DOOR_CANNOT_OPEN;
|
||||
}
|
||||
alertManager.removeAlterDevice(platformBuild.getLineId(), alertType.name(), platformBuild.getId());
|
||||
log.info("线路[{}] 站台门[{}] 是否打开[{}] ,添加到监控中...", platformBuild.getLineId(), platformBuild.getId(), platformBuild.getPsdOpen());
|
||||
}
|
||||
|
||||
public void removeSwitch(Platform.Builder platformBuild) {
|
||||
log.info("线路[{}] 站台门[{}] 是否打开[{}] ,从监控中移除...", platformBuild.getLineId(), platformBuild.getId(), platformBuild.getPsdOpen());
|
||||
platformMap.remove(platformBuild.getId());
|
||||
alertManager.removeAlterDevice(platformBuild.getLineId(), CUSTOM_NAME, platformBuild.getId());
|
||||
alertManager.removeAlterDevice(platformBuild.getLineId(), AlertType.PLATFORM_DOOR_CANNOT_OPEN.name(), platformBuild.getId());
|
||||
alertManager.removeAlterDevice(platformBuild.getLineId(), AlertType.PLATFORM_DOOR_CANNOT_CLOSE.name(), platformBuild.getId());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,17 +88,20 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
if (build.getPsdOpen()) {
|
||||
alertType = AlertType.PLATFORM_DOOR_CANNOT_CLOSE;
|
||||
timeOut = guardConfig.getCanNotCloseTimes();
|
||||
alertManager.removeAlterDevice(build.getLineId(), CUSTOM_NAME, build.getId());
|
||||
}
|
||||
if (this.timeOver(build.getReceiveTime(), timeOut)
|
||||
&& alertManager.putAlterDevice(build.getLineId(), CUSTOM_NAME, build.getId())) {
|
||||
LayoutGraphicsProto.Platform platform = LineGraphicDataRepository.getDeviceByCode(build.getLineId(), build.getId(), LayoutGraphicsProto.Platform.class);
|
||||
String stationName = this.findRefStationName(build.getLineId(), platform.getRefStation());
|
||||
if (this.timeOver(build.getReceiveTime(), timeOut)
|
||||
&& alertManager.putAlterDevice(build.getLineId(), alertType.name(), build.getId())) {
|
||||
String openClose = alertType == AlertType.PLATFORM_DOOR_CANNOT_OPEN ? "打开" : "关闭";
|
||||
String alertMsg = String.format("%s-%s-屏蔽门无法%s", stationName, platform.getUp() ? "上行" : "下行", openClose);
|
||||
String wayType = platform.getUp() ? "上行" : "下行";
|
||||
String stationName = this.findRefStationName(build.getLineId(), platform.getRefStation());
|
||||
String alertMsg = String.format("%s-%s-屏蔽门无法%s", stationName, wayType, openClose);
|
||||
log.info("屏蔽门[{}] 线路[{}] 触发告警[{}] 车站[{}] 方向[{}]", build.getId(), build.getLineId(), alertType.name(), stationName, wayType);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(alertType, AlertDeviceType.DEVICE_TYPE_PLATFORM, platform.getCommon().getId(), build, alertMsg, false);
|
||||
alertManager.emit(alertInfo);
|
||||
platformMap.remove(build.getId());
|
||||
} else if (this.timeOver(build.getReceiveTime(), timeOut) && alertManager.deviceIsExist(build.getLineId(), alertType.name(), build.getId())) {
|
||||
platformMap.remove(build.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.warn;
|
||||
|
||||
import club.joylink.xiannccda.alert.AlertDetailFactory;
|
||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -10,8 +9,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class SwitchLostAlertListener implements AlertSourceEventListener<SwitchLostAlertEvent> {
|
||||
|
||||
@Autowired
|
||||
private AlertDetailFactory alertDetailFactory;
|
||||
@Autowired
|
||||
private SwitchLostAlertMonitoringTask monitoringTask2;
|
||||
|
||||
@ -19,7 +16,7 @@ public class SwitchLostAlertListener implements AlertSourceEventListener<SwitchL
|
||||
@Override
|
||||
public void accept(SwitchLostAlertEvent event) {
|
||||
Switch.Builder switchBuild = event.getSource();
|
||||
boolean isLost = /*switchBuild.getIpSingleSwitchStusLocked() &&*/ switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost) {
|
||||
this.monitoringTask2.putSwitchIfNotExist(switchBuild);
|
||||
} else {
|
||||
|
@ -1,29 +1,19 @@
|
||||
package club.joylink.xiannccda.ats.warn;
|
||||
|
||||
import club.joylink.xiannccda.alert.AlertDetailFactory;
|
||||
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.AlertMonitoringTask;
|
||||
import club.joylink.xiannccda.alert.util.AlertUtil;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import club.joylink.xiannccda.dto.config.DeviceGuardConfigDto.GuardUnit;
|
||||
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.entity.DeviceGuardConfig;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import club.joylink.xiannccda.service.config.Operator;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -44,15 +34,15 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
|
||||
private final static String DEVICE_TYPE_NAME = Switch.getDescriptor().getName();
|
||||
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
private AlertManager alertManager = AlertManager.getDefault();
|
||||
|
||||
Map<String, Switch.Builder> deviceMap = new ConcurrentHashMap<>();
|
||||
|
||||
public void putSwitchIfNotExist(Switch.Builder switchBuilder) {
|
||||
if (!deviceMap.containsKey(switchBuilder.getId())) {
|
||||
deviceMap.put(switchBuilder.getId(), switchBuilder);
|
||||
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +53,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
|
||||
switchBuilder.getLineId());
|
||||
String customName = this.getCustomName(alertInfoOpt, alertInfoMostOpt);
|
||||
|
||||
log.info("线路[{}] 道岔[{}] 从监控中移除... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
||||
deviceMap.remove(switchBuilder.getId());
|
||||
alertManager.removeAlterDevice(switchBuilder.getLineId(), customName, switchBuilder.getId());
|
||||
}
|
||||
@ -80,6 +70,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
Integer lineId = savedSwitchBuild.getLineId();
|
||||
GuardConfig guardConfig = configService.getGuardConfig(lineId);
|
||||
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, savedSwitchBuild.getId(), Turnout.class);
|
||||
log.info("道岔失表检测 线路[{}] 设备[{}] 查找对应的地图道岔id[{}]", lineId, savedSwitchBuild.getId(), turnout.getCommon().getId());
|
||||
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(),
|
||||
@ -88,10 +79,11 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
|
||||
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, false);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
this.deviceMap.remove(savedSwitchBuild.getId());
|
||||
}
|
||||
@ -100,7 +92,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
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, false);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, alertMsg, turnout.getCommon().getId(), false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
@ -110,7 +102,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
private String getCustomName(Optional<DeviceAreaConfig> alertInfoOpt, Optional<DeviceAreaConfig> alertInfoMostOpt) {
|
||||
String customName = alertInfoMostOpt.map(DeviceAreaConfig::getAreaName).orElse(null);
|
||||
if (StringUtils.isEmpty(customName)) {
|
||||
customName = alertInfoOpt.isPresent() ? alertInfoOpt.get().getAreaName() : AlertType.SWITCH_LOST.name();
|
||||
customName = alertInfoOpt.map(DeviceAreaConfig::getAreaName).orElse(AlertType.SWITCH_LOST.name());
|
||||
}
|
||||
return customName;
|
||||
}
|
||||
|
@ -0,0 +1,93 @@
|
||||
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.AlertMonitoringTask;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
|
||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo.Builder;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
|
||||
|
||||
private final DeviceGuardConfigService configService;
|
||||
private final AlertInfoService alertInfoService;
|
||||
|
||||
public TrainAtpCutAlertMonitoringTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
this.configService = configService;
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
|
||||
private final AlertManager alertManager = AlertManager.getDefault();
|
||||
|
||||
private Map<String, TrainInfo.Builder> trainInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void putTrainInfoMonitor(TrainInfo.Builder train) {
|
||||
log.info("线路[{}] 车组号[{}] 列车状态[{}] 加入ATP检测中...", train.getLineId(), train.getGroupId(), train.getMode());
|
||||
this.trainInfoMap.put(train.getGroupId(), train);
|
||||
}
|
||||
|
||||
public void removeTrainInfo(TrainInfo.Builder train) {
|
||||
this.trainInfoMap.remove(train.getGroupId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TRAIN_EB_WITH_ATP_CUT_ALTER";
|
||||
}
|
||||
|
||||
private final static String CUSTOM_NAME = AlertType.TRAIN_EB_ATP.name();
|
||||
|
||||
|
||||
protected void trainAlert(TrainInfo.Builder trainInfo) {
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
if (StringUtils.isEmpty(sectionCode)) {
|
||||
return;
|
||||
}
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode, Section.class);
|
||||
if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, 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);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (TrainInfo.Builder trainInfo : this.trainInfoMap.values()) {
|
||||
Integer lineId = trainInfo.getLineId();
|
||||
GuardConfig guardConfig = configService.getGuardConfig(lineId);
|
||||
TrainMode trainMode = trainInfo.getMode();
|
||||
boolean timeOver = this.timeOver(trainInfo.getReceiveTime(), guardConfig.getTrainAtpCutTimes());
|
||||
if (Objects.equals(false, timeOver) && trainMode.getIpModeTrainAtpCut()) {
|
||||
//列车时间ATP切除且时间没有到告警
|
||||
this.trainAlert(trainInfo);
|
||||
} else if (timeOver) {
|
||||
this.removeTrainInfo(trainInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -10,40 +10,35 @@ import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TrainModeAlertListener implements AlertSourceEventListener<TrainAlertEvent> {
|
||||
|
||||
private final AlertInfoService alertInfoService;
|
||||
private final TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask;
|
||||
|
||||
public TrainModeAlertListener(AlertInfoService alertInfoService) {
|
||||
this.alertInfoService = alertInfoService;
|
||||
public TrainModeAlertListener(TrainAtpCutAlertMonitoringTask atpCutAlertMonitoringTask) {
|
||||
|
||||
this.atpCutAlertMonitoringTask = atpCutAlertMonitoringTask;
|
||||
}
|
||||
|
||||
private AlertManager alertManager = AlertManager.getDefault();
|
||||
|
||||
private final static String CUSTOM_NAME = AlertType.TRAIN_EB_ATP.name();
|
||||
|
||||
@Override
|
||||
public void accept(TrainAlertEvent event) {
|
||||
TrainInfo.Builder trainInfo = event.getSource();
|
||||
TrainMode trainMode = trainInfo.getMode();
|
||||
if (trainMode.getIpModeTrainAtpCut() && trainMode.getIpModeTrainEbAlarm()) {
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
if (StringUtils.isEmpty(sectionCode)) {
|
||||
return;
|
||||
}
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode, Section.class);
|
||||
if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId())) {
|
||||
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);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
|
||||
trainMode.getIpModeTrainAtpCut(),
|
||||
trainMode.getIpModeTrainEbAlarm());
|
||||
if (trainMode.getIpModeTrainEbAlarm()) {
|
||||
//列车紧急制动
|
||||
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
|
||||
} else {
|
||||
alertManager.removeAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId());
|
||||
//列车回复
|
||||
this.atpCutAlertMonitoringTask.removeTrainInfo(trainInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,16 @@ public class AlertInfoService {
|
||||
public NccAlertInfo createAlert(AlertType alertType, AlertDeviceType dt, String layoutId, MessageOrBuilder mb, String alertMsg, 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, mockData);
|
||||
return this.createAlert2(areaConfigOptional, alertType, mb, alertMsg, layoutId, mockData);
|
||||
}
|
||||
|
||||
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String alertMsg, boolean mockData) {
|
||||
public NccAlertInfo createAlert2(Optional<DeviceAreaConfig> areaConfigOpt, AlertType alertType, MessageOrBuilder mb, String alertMsg, String layoutId, 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);
|
||||
// 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, deviceCode, areaConfigId, mockData);
|
||||
return new NccAlertInfo(createTime, alertType, lineId, alertMsg, layoutId, areaConfigId, mockData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a65253b7a3685dabe0376caa36bda8b47d675ff7
|
||||
Subproject commit 7aebba13bf04bf2c59df3595c5650a96e616bef4
|
Loading…
Reference in New Issue
Block a user