蓝显及代码调整
This commit is contained in:
parent
0a87420003
commit
7446eed3d0
@ -104,7 +104,7 @@ public class NccAlertInfo implements AlertInfo {
|
||||
}
|
||||
case BLUE_DISPLAY, PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_DOOR_CANNOT_OPEN,
|
||||
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, TRAIN_DELAY_10, SWITCH_LOST,
|
||||
SWITCH_LOST_MOST, AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST, TRAIN_EB_ATP -> {
|
||||
SWITCH_LOST_MOST, AXLE_LED_RED, AXLE_LED_ORANGE, AXLE_LED_ORANGE_MOST, AXLE_LED_RED_MOST, TRAIN_EB_ATP, ALL_LINE_BLUE_DISPLAY -> {
|
||||
return "I";
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + alertType);
|
||||
|
@ -34,7 +34,7 @@ public class AlertManager extends EventEmitter {
|
||||
* <p>
|
||||
* val = 设备code
|
||||
*/
|
||||
private static final Table<String, String, AlertTableDetail> DEVICE_ALTER_TABLE = Tables.synchronizedTable(HashBasedTable.create());
|
||||
private static final Table<Integer, String, AlertTableDetail> DEVICE_ALTER_TABLE = Tables.synchronizedTable(HashBasedTable.create());
|
||||
/**
|
||||
* 报警监控任务(循环监测式报警)
|
||||
*/
|
||||
@ -56,7 +56,7 @@ public class AlertManager extends EventEmitter {
|
||||
}
|
||||
|
||||
|
||||
public boolean putAlterDevice(String lineId, String customName, String deviceName) {
|
||||
public boolean putAlterDevice(Integer lineId, String customName, String deviceName) {
|
||||
AlertTableDetail detail = DEVICE_ALTER_TABLE.get(lineId, customName);
|
||||
if (Objects.isNull(detail)) {
|
||||
detail = new AlertTableDetail(false);
|
||||
@ -65,7 +65,7 @@ public class AlertManager extends EventEmitter {
|
||||
return detail.add(deviceName);
|
||||
}
|
||||
|
||||
public void removeAlterDevice(String lineId, String customName, String deviceName) {
|
||||
public void removeAlterDevice(Integer lineId, String customName, String deviceName) {
|
||||
AlertTableDetail detail = DEVICE_ALTER_TABLE.get(lineId, customName);
|
||||
if (Objects.isNull(detail)) {
|
||||
detail = new AlertTableDetail(false);
|
||||
@ -74,7 +74,7 @@ public class AlertManager extends EventEmitter {
|
||||
detail.remove(deviceName);
|
||||
}
|
||||
|
||||
public boolean needMostShow(String lineId, String customName, int val) {
|
||||
public boolean needMostShow(Integer lineId, String customName, int val) {
|
||||
if (StringUtils.isEmpty(customName)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -105,18 +105,18 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
|
||||
String ledMostName = alertInfoMostOptional.map(DeviceAreaConfig::getAreaName).orElse(null);
|
||||
|
||||
if (light) {
|
||||
if (alertManager.putAlterDevice(lineId.toString(), ledName, id)) {
|
||||
if (alertManager.putAlterDevice(lineId, ledName, id)) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode());
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
if (Objects.nonNull(ledMostName) && alertManager.needMostShow(lineId.toString(), ledMostName, overNums)) {
|
||||
if (Objects.nonNull(ledMostName) && alertManager.needMostShow(lineId, ledMostName, overNums)) {
|
||||
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(alertInfoOptional, alertType, build, section.getCode());
|
||||
alertManager.emit(alertInfoMost);
|
||||
}
|
||||
} else {
|
||||
alertManager.removeAlterDevice(lineId.toString(), ledName, id);
|
||||
alertManager.removeAlterDevice(lineId, ledName, id);
|
||||
if (StringUtils.isNotEmpty(ledMostName)) {
|
||||
alertManager.removeAlterDevice(lineId.toString(), ledMostName, id);
|
||||
alertManager.removeAlterDevice(lineId, ledMostName, id);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,85 @@
|
||||
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.AlertSourceEventListener;
|
||||
import club.joylink.xiannccda.alert.util.AlertUtil;
|
||||
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
|
||||
import club.joylink.xiannccda.entity.DeviceAreaConfig;
|
||||
import club.joylink.xiannccda.service.AlertInfoService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
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.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class BlueAlertListener implements AlertSourceEventListener<BlueDisplayAlertEvent> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private AlertDetailFactory alertDetailFactory;
|
||||
private AlertInfoService alertInfoService;
|
||||
private final static String BLUE_DISPLAY_NAME = Rtu.getDescriptor().getName();
|
||||
private final static String ALL_BLUE_DISPLAY_VAL = "全线蓝显";
|
||||
private final static AlertManager alertManager = AlertManager.getDefault();
|
||||
|
||||
private final static Map<Integer, List<Station>> CONTROL_STATION_MAPER = new ConcurrentHashMap<>();
|
||||
|
||||
private final static String DEVICE_TYPE_NAME = Rtu.getDescriptor().getName();
|
||||
|
||||
private NccAlertInfo createAlterTip(Rtu.Builder rtuBuild, String lineId, MessageOrBuilder mb) {
|
||||
|
||||
LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(rtuBuild.getTimestamp()), ZoneId.of("+8"));
|
||||
|
||||
NccAlertInfo alertInfo = this.alertDetailFactory.getAlertDetail(createTime, AlertType.BLUE_DISPLAY, Integer.valueOf(lineId), false, mb);
|
||||
// alertInfo.setAlertLocation(AlertUtil.findLocationByRtuCode(rtuBuild.getId()).orElse(null));
|
||||
return alertInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(BlueDisplayAlertEvent event) {
|
||||
Rtu.Builder rtu = event.getSource();
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
String lineId = String.valueOf(rtu.getLineId());
|
||||
Station station = findAllStation(rtu.getLineId(), rtu.getId());
|
||||
if (Objects.isNull(station)) {
|
||||
//TODO logs
|
||||
return;
|
||||
}
|
||||
|
||||
if (rtu.getIpRtuStusDown()) {
|
||||
if (alertManager.putAlterDevice(String.valueOf(rtu.getLineId()), DEVICE_TYPE_NAME, rtu.getId())) {
|
||||
String rtuName = Strings.padStart(rtu.getId(), 2, '0');
|
||||
Stream<Station> stream = LineGraphicDataRepository.getDevices(rtu.getLineId(), Station.class);
|
||||
Station station = stream.filter(Station::getConcentrationStations).filter(d -> StringUtils.equals(d.getCode(), rtuName)).findFirst().get();
|
||||
NccAlertInfo alertInfo = this.createAlterTip(rtu, lineId, station);
|
||||
if (alertManager.putAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, rtu.getId())) {
|
||||
Optional<DeviceAreaConfig> alertInfoOpt = this.alertInfoService.findAreaDevice(AlertType.BLUE_DISPLAY, AlertDeviceType.DEVICE_TYPE_RTU, station.getCommon().getId(),
|
||||
rtu.getLineId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.BLUE_DISPLAY, rtu, station.getName());
|
||||
alertManager.emit(alertInfo);
|
||||
|
||||
}
|
||||
int allControlStationSize = CONTROL_STATION_MAPER.get(rtu.getLineId()).size();
|
||||
if (alertManager.needMostShow(rtu.getLineId(), BLUE_DISPLAY_NAME, 1)
|
||||
&& 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);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertManager.removeAlterDevice(lineId, DEVICE_TYPE_NAME, rtu.getId());
|
||||
alertManager.removeAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, rtu.getId());
|
||||
alertManager.removeAlterDevice(rtu.getLineId(), BLUE_DISPLAY_NAME, ALL_BLUE_DISPLAY_VAL);
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized Station findAllStation(int lineId, String rtuId) {
|
||||
if (CollectionUtils.isEmpty(CONTROL_STATION_MAPER)) {
|
||||
Stream<Station> stream = LineGraphicDataRepository.getDevices(lineId, Station.class);
|
||||
List<Station> stationList = stream.filter(Station::getConcentrationStations).toList();
|
||||
CONTROL_STATION_MAPER.put(lineId, stationList);
|
||||
}
|
||||
List<Station> stationList = CONTROL_STATION_MAPER.get(lineId);
|
||||
if (CollectionUtils.isEmpty(stationList)) {
|
||||
return null;
|
||||
}
|
||||
String rtuName = Strings.padStart(rtuId, 2, '0');
|
||||
Optional<Station> optionalStation = stationList.stream().filter(d -> StringUtils.equalsIgnoreCase(d.getCode(), rtuName)).findAny();
|
||||
return optionalStation.orElse(null);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
|
||||
public void removeSwitch(Platform.Builder platformBuild) {
|
||||
platformMap.remove(platformBuild.getId());
|
||||
alertManager.removeAlterDevice(String.valueOf(platformBuild.getLineId()), CUSTOM_NAME, platformBuild.getId());
|
||||
alertManager.removeAlterDevice(platformBuild.getLineId(), CUSTOM_NAME, platformBuild.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,17 +66,16 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Platform.Builder build : platformMap.values()) {
|
||||
String lineId = String.valueOf(build.getLineId());
|
||||
GuardConfig guardConfig = configService.getGuardConfig(build.getLineId());
|
||||
AlertType alertType = AlertType.PLATFORM_DOOR_CANNOT_OPEN;
|
||||
int timeOut = guardConfig.getCanNotOpenTimes();
|
||||
if (build.getPsdOpen()) {
|
||||
alertType = AlertType.PLATFORM_DOOR_CANNOT_CLOSE;
|
||||
timeOut = guardConfig.getCanNotCloseTimes();
|
||||
alertManager.removeAlterDevice(String.valueOf(build.getLineId()), CUSTOM_NAME, build.getId());
|
||||
alertManager.removeAlterDevice(build.getLineId(), CUSTOM_NAME, build.getId());
|
||||
}
|
||||
if (this.timeOver(build.getReceiveTime(), timeOut)
|
||||
&& alertManager.putAlterDevice(lineId, CUSTOM_NAME, build.getId())) {
|
||||
&& alertManager.putAlterDevice(build.getLineId(), 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, platform.getCode());
|
||||
alertManager.emit(alertInfo);
|
||||
|
@ -59,7 +59,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
public void removeSwitch(Switch.Builder switchBuilder) {
|
||||
AlertManager alertManager = AlertManager.getDefault();
|
||||
deviceMap.remove(switchBuilder.getId());
|
||||
alertManager.removeAlterDevice(String.valueOf(switchBuilder.getLineId()), DEVICE_TYPE_NAME, switchBuilder.getId());
|
||||
alertManager.removeAlterDevice(switchBuilder.getLineId(), DEVICE_TYPE_NAME, switchBuilder.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +71,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Builder savedSwitchBuild : this.deviceMap.values()) {
|
||||
String lineIdStr = String.valueOf(savedSwitchBuild.getLineId());
|
||||
// String lineIdStr = String.valueOf(savedSwitchBuild.getLineId());
|
||||
GuardConfig guardConfig = configService.getGuardConfig(savedSwitchBuild.getLineId());
|
||||
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(savedSwitchBuild.getLineId(), savedSwitchBuild.getId(), Turnout.class);
|
||||
|
||||
@ -83,7 +83,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
boolean saveIsLost = savedSwitchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (saveIsLost && this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
//失表超时
|
||||
if (alertManager.putAlterDevice(lineIdStr, oneName, savedSwitchBuild.getId())) {
|
||||
if (alertManager.putAlterDevice(savedSwitchBuild.getLineId(), oneName, savedSwitchBuild.getId())) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoOpt, AlertType.SWITCH_LOST, savedSwitchBuild, savedSwitchBuild.getId());
|
||||
alertManager.emit(alertInfo);
|
||||
this.deviceMap.remove(savedSwitchBuild.getId());
|
||||
@ -91,7 +91,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||
Optional<DeviceAreaConfig> alertInfoMostOpt = this.alertInfoService.findAreaDevice(AlertType.SWITCH_LOST_MOST, AlertDeviceType.DEVICE_TYPE_SWITCH, turnout.getCommon().getId(),
|
||||
savedSwitchBuild.getLineId());
|
||||
//检测大面积失表
|
||||
if (alertInfoMostOpt.isPresent() && alertManager.needMostShow(lineIdStr, alertInfoMostOpt.get().getAreaName(), guardConfig.getSwitchLostMostNums())) {
|
||||
if (alertInfoMostOpt.isPresent() && alertManager.needMostShow(savedSwitchBuild.getLineId(), alertInfoMostOpt.get().getAreaName(), guardConfig.getSwitchLostMostNums())) {
|
||||
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(alertInfoMostOpt, AlertType.SWITCH_LOST_MOST, savedSwitchBuild, savedSwitchBuild.getId());
|
||||
alertManager.emit(alertInfo);
|
||||
|
@ -31,7 +31,6 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
public void accept(TrainAlertEvent event) {
|
||||
TrainInfo.Builder trainInfo = event.getSource();
|
||||
TrainMode trainMode = trainInfo.getMode();
|
||||
String lineIdStr = String.valueOf(trainInfo.getLineId());
|
||||
if (trainMode.getIpModeTrainAtpCut() && trainMode.getIpModeTrainEbAlarm()) {
|
||||
|
||||
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName());
|
||||
@ -39,12 +38,12 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
|
||||
return;
|
||||
}
|
||||
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode, Section.class);
|
||||
if (alertManager.putAlterDevice(lineIdStr, CUSTOM_NAME, trainInfo.getGroupId())) {
|
||||
if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId())) {
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, trainInfo.getGroupId());
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertManager.removeAlterDevice(lineIdStr, CUSTOM_NAME, trainInfo.getGroupId());
|
||||
alertManager.removeAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b44f47754df86082bc6402be4899475ad0d4ffff
|
||||
Subproject commit a65253b7a3685dabe0376caa36bda8b47d675ff7
|
Loading…
Reference in New Issue
Block a user