区段,道岔报警调整
This commit is contained in:
parent
5aeb856082
commit
4b92f68541
@ -1,9 +1,10 @@
|
|||||||
package club.joylink.xiannccda.alert;
|
package club.joylink.xiannccda.alert;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertManager;
|
import club.joylink.xiannccda.alert.core.AlertManager;
|
||||||
import club.joylink.xiannccda.ats.warn.AxleTrackAlertListener;
|
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedAlertListener;
|
||||||
import club.joylink.xiannccda.ats.warn.BlueAlertListener;
|
import club.joylink.xiannccda.ats.warn.BlueAlertListener;
|
||||||
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
import club.joylink.xiannccda.ats.warn.DeviceAlertEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
@ -13,32 +14,26 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class AlertEmitJob implements ApplicationRunner {
|
public class AlertEmitJob implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private TrainDelayAlertMonitoringTask trainDelayAlertMonitoringTask;
|
private TrainDelayAlertMonitoringTask trainDelayAlertMonitoringTask;
|
||||||
|
@Autowired
|
||||||
private BlueAlertListener blueAlertListener;
|
private BlueAlertListener blueAlertListener;
|
||||||
|
@Autowired
|
||||||
private PlatformDoorAlertMonitoringTask platformDoorAlertMonitoringTask;
|
private PlatformDoorAlertMonitoringTask platformDoorAlertMonitoringTask;
|
||||||
|
@Autowired
|
||||||
|
private SwitchLostAlertMonitoringTask switchAlertMonitoringTask;
|
||||||
|
|
||||||
private SwitchAlertMonitoringTask switchAlertMonitoringTask;
|
@Autowired
|
||||||
|
private AxleSwitchTrackLedAlertListener axleSwitchTrackAlertListener2;
|
||||||
private AxleTrackAlertListener axleTrackAlertListener;
|
|
||||||
|
|
||||||
public AlertEmitJob(TrainDelayAlertMonitoringTask trainDelayAlertMonitoringTask, BlueAlertListener blueAlertListener,
|
|
||||||
PlatformDoorAlertMonitoringTask platformDoorAlertMonitoringTask, SwitchAlertMonitoringTask switchAlertMonitoringTask, AxleTrackAlertListener axleTrackAlertListener) {
|
|
||||||
this.trainDelayAlertMonitoringTask = trainDelayAlertMonitoringTask;
|
|
||||||
this.blueAlertListener = blueAlertListener;
|
|
||||||
this.platformDoorAlertMonitoringTask = platformDoorAlertMonitoringTask;
|
|
||||||
this.switchAlertMonitoringTask = switchAlertMonitoringTask;
|
|
||||||
this.axleTrackAlertListener = axleTrackAlertListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
AlertManager alertManager = AlertManager.getDefault();
|
AlertManager alertManager = AlertManager.getDefault();
|
||||||
//报警源
|
//报警源
|
||||||
alertManager.addTask(trainDelayAlertMonitoringTask);
|
// alertManager.addTask(trainDelayAlertMonitoringTask);
|
||||||
// alertManager.addTask(blueDisplayAlertMonitoringTask);
|
// alertManager.addTask(platformDoorAlertMonitoringTask);
|
||||||
alertManager.addTask(platformDoorAlertMonitoringTask);
|
|
||||||
alertManager.addTask(this.switchAlertMonitoringTask);
|
alertManager.addTask(this.switchAlertMonitoringTask);
|
||||||
alertManager.on(this.axleTrackAlertListener, DeviceAlertEvent.class);
|
|
||||||
alertManager.on(this.blueAlertListener, DeviceAlertEvent.class);
|
alertManager.on(this.blueAlertListener, DeviceAlertEvent.class);
|
||||||
|
alertManager.on(this.axleSwitchTrackAlertListener2, DeviceAlertEvent.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
|||||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch;
|
||||||
import club.joylink.xiannccda.repository.IAlertTipRepository;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -21,13 +20,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SwitchAlertMonitoringTask implements AlertMonitoringTask {
|
public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||||
|
|
||||||
private IAlertTipRepository alertTipRepository;
|
|
||||||
private AlertDetailFactory alertDetailFactory;
|
private AlertDetailFactory alertDetailFactory;
|
||||||
|
|
||||||
public SwitchAlertMonitoringTask(IAlertTipRepository alertTipRepository, AlertDetailFactory alertDetailFactory) {
|
public SwitchLostAlertMonitoringTask(AlertDetailFactory alertDetailFactory) {
|
||||||
this.alertTipRepository = alertTipRepository;
|
|
||||||
this.alertDetailFactory = alertDetailFactory;
|
this.alertDetailFactory = alertDetailFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +36,7 @@ public class SwitchAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "SWITCH_ALTER";
|
return "SWITCH_LOST_ALTER";
|
||||||
}
|
}
|
||||||
|
|
||||||
private NccAlertInfo createAlterTip(Switch.Builder switchBuild, String lineId) {
|
private NccAlertInfo createAlterTip(Switch.Builder switchBuild, String lineId) {
|
@ -101,14 +101,21 @@ public class LineGraphicDataRepository {
|
|||||||
if (CollectionUtils.isEmpty(tmpMaper)) {
|
if (CollectionUtils.isEmpty(tmpMaper)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Map<String, Builder> turnoutMap = tmpMaper.get(DeviceType.Turnout.name());
|
||||||
|
|
||||||
Map<String, Builder> builderMap = tmpMaper.get(DeviceType.Section.name());
|
Map<String, Builder> builderMap = tmpMaper.get(DeviceType.Section.name());
|
||||||
if (CollectionUtils.isEmpty(builderMap)) {
|
/*if (CollectionUtils.isEmpty(builderMap)) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
for (Section section : storage.getSectionList()) {
|
for (Section section : storage.getSectionList()) {
|
||||||
if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
if (section.getSectionType() == SectionType.TurnoutPhysical) {
|
||||||
LOGIC_SECTION_TO_SECTION_TABLE.put(publishGi.getLineId(), section.getCode(), section.getCode());
|
for (String s : section.getChildrenList()) {
|
||||||
|
Builder b = turnoutMap.get(s);
|
||||||
|
if (b instanceof DeviceInfoProto.Turnout.Builder logicSection) {
|
||||||
|
LOGIC_SECTION_TO_SECTION_TABLE.put(publishGi.getLineId(), logicSection.getCode(), section.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String s : section.getChildrenList()) {
|
for (String s : section.getChildrenList()) {
|
||||||
Builder b = builderMap.get(s);
|
Builder b = builderMap.get(s);
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
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.Switch;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener<DeviceAlertEvent<List<Builder>>> {
|
||||||
|
|
||||||
|
private AlertDetailFactory alertDetailFactory;
|
||||||
|
|
||||||
|
public AxleSwitchTrackLedAlertListener(AlertDetailFactory alertDetailFactory) {
|
||||||
|
this.alertDetailFactory = alertDetailFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(DeviceAlertEvent<List<Builder>> event) {
|
||||||
|
List<Builder> listBuild = event.getSource();
|
||||||
|
for (Builder o : listBuild) {
|
||||||
|
boolean isSwitchOrTrack = (o instanceof Switch.Builder || o instanceof Track.Builder);
|
||||||
|
if (isSwitchOrTrack) {
|
||||||
|
Integer lineId = DeviceStatusDataOperate.findFieldVal(o, "lineId", Integer.class);
|
||||||
|
String id = DeviceStatusDataOperate.findFieldVal(o, "id", String.class);
|
||||||
|
if (Objects.isNull(lineId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, id);
|
||||||
|
if (StringUtils.isEmpty(sectionCode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class);
|
||||||
|
if (section.getTurning()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TrainDataSource trainDataSource = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.TRAIN);
|
||||||
|
String trainGroupId = trainDataSource.findTrainForDeviceName(id);
|
||||||
|
if (o instanceof Switch.Builder switchBuilder) {
|
||||||
|
this.switchHandle(switchBuilder, trainGroupId, section);
|
||||||
|
} else if (o instanceof Track.Builder trackBuilder) {
|
||||||
|
this.trackHandle(trackBuilder, trainGroupId, section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchHandle(Switch.Builder switchBuilder, String trainGroupId, Section section) {
|
||||||
|
boolean ledRed = switchBuilder.getIpSingleSwitchStusCiOccupied() && !switchBuilder.getIpSingleSwitchStusCbtcOccupied() && Objects.isNull(trainGroupId);
|
||||||
|
boolean orange = switchBuilder.getIpSingleSwitchStusAtcInvalid();
|
||||||
|
this.emit(ledRed, switchBuilder, section, AlertType.AXLE_LED_RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void trackHandle(Track.Builder trackBuild, String trainGroupId, Section section) {
|
||||||
|
boolean ledRed = trackBuild.getCiOccupied() && !trackBuild.getCbtcOccupied() && Objects.isNull(trainGroupId);
|
||||||
|
boolean orange = trackBuild.getAtcInvalid();
|
||||||
|
this.emit(ledRed, trackBuild, section, AlertType.AXLE_LED_RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void emit(boolean light, GeneratedMessageV3.Builder build, Section section, AlertType alertType) {
|
||||||
|
AlertManager alertManager = AlertManager.getDefault();
|
||||||
|
Integer lineId = DeviceStatusDataOperate.findFieldVal(build, "lineId", Integer.class);
|
||||||
|
String id = DeviceStatusDataOperate.findFieldVal(build, "id", String.class);
|
||||||
|
Long timestemp = DeviceStatusDataOperate.findFieldVal(build, "timestamp", Long.class);
|
||||||
|
if (light) {
|
||||||
|
if (alertManager.putAlterDevice(lineId.toString(), alertType.name(), id)) {
|
||||||
|
LocalDateTime createTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestemp), ZoneId.of("+8"));
|
||||||
|
NccAlertInfo alertInfo = this.alertDetailFactory.getAlertDetail(createTime, alertType, lineId, false, section);
|
||||||
|
alertInfo.setAlertLocation(AlertUtil.findLocationByRtuCode(id).orElse(null));
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alertManager.removeAlterDevice(lineId.toString(), alertType.name(), id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user