开关门逻辑,失表逻辑调整
This commit is contained in:
parent
ce81921022
commit
3ea0d08ca6
@ -7,6 +7,7 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
|||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
|
||||||
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RtssGraphicStorage;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RtssGraphicStorage;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
|
||||||
@ -27,6 +28,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -137,6 +139,18 @@ public class LineGraphicDataRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<Platform> findLayoutPlatformFromSection(Integer lineId, String sectionName) {
|
||||||
|
MessageOrBuilder sectionMsg = LineGraphicDataRepository.getDeviceByCodeNotException(lineId, sectionName);
|
||||||
|
if (Objects.isNull(sectionMsg)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
if (sectionMsg instanceof Section section) {
|
||||||
|
Stream<LayoutGraphicsProto.Platform> platformStream = LineGraphicDataRepository.getDevices(lineId, LayoutGraphicsProto.Platform.class);
|
||||||
|
return platformStream.filter(d -> StringUtils.equals(d.getRefSectionId(), section.getCommon().getId())).findFirst();
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
public static String findAxleCodeFromLogicCode(int lineId, String logicCode) {
|
public static String findAxleCodeFromLogicCode(int lineId, String logicCode) {
|
||||||
return LOGIC_SECTION_TO_AXLE_TABLE.get(lineId, logicCode);
|
return LOGIC_SECTION_TO_AXLE_TABLE.get(lineId, logicCode);
|
||||||
|
|
||||||
@ -195,6 +209,14 @@ public class LineGraphicDataRepository {
|
|||||||
return LOGIC_SECTION_TO_SECTION_TABLE.get(lineId, code);
|
return LOGIC_SECTION_TO_SECTION_TABLE.get(lineId, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> Optional<T> getDeviceOptByCode(int lineId, String code, Class<T> cls) {
|
||||||
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
|
if (Objects.isNull(mob)) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of((T) mob);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> T getDeviceByCode(int lineId, String code, Class<T> cls) {
|
public static <T> T getDeviceByCode(int lineId, String code, Class<T> cls) {
|
||||||
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
MessageOrBuilder mob = line_code_table.get(lineId, code);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mob,
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package club.joylink.xiannccda.ats.message.collect.convertor;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ConvertorUtil {
|
|
||||||
|
|
||||||
@Value("#{${occ-not-handle-rtu}}")
|
|
||||||
// @Value("${occ-not-handle-rtu}")
|
|
||||||
private Map<Integer, String> mapList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 过滤需要处理的rtu消息
|
|
||||||
*
|
|
||||||
* @param lineId
|
|
||||||
* @param rtuId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
|
||||||
if (Objects.isNull(lineId) || Objects.isNull(rtuId)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String rtuIds = mapList.get(lineId);
|
|
||||||
if (StringUtils.isEmpty(rtuIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
List<String> rtuList = Splitter.on(StringPool.COMMA).splitToList(rtuIds);
|
|
||||||
if (rtuList.contains(rtuId.toString())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -45,13 +45,13 @@ public class InUsedScheduleData extends AbstractData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Plan.Builder> findPlan(String trainId, String globalId, Integer stationId, boolean upDownWay) {
|
public Optional<Plan.Builder> findPlan(String trainId, String globalId, Integer stationId, boolean upDownWay, Integer platformId) {
|
||||||
List<Plan.Builder> plans = trainSchedule.get(trainId, globalId);
|
List<Plan.Builder> plans = trainSchedule.get(trainId, globalId);
|
||||||
if (CollectionUtils.isEmpty(plans)) {
|
if (CollectionUtils.isEmpty(plans)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Plan.Builder> optional = plans.stream().filter(d -> d.getStationId() == stationId && Objects.equals(d.getUpWay(), upDownWay)).findAny();
|
Optional<Plan.Builder> optional = plans.stream().filter(d -> d.getStationId() == stationId && Objects.equals(d.getUpWay(), upDownWay) && d.getPlatformId() == platformId).findAny();
|
||||||
/* if (optional.isEmpty()) {
|
/* if (optional.isEmpty()) {
|
||||||
System.out.println("aaaaaaaaaaaaa");
|
System.out.println("aaaaaaaaaaaaa");
|
||||||
}*/
|
}*/
|
||||||
|
@ -112,7 +112,7 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
|||||||
DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder);
|
DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder);
|
||||||
DeviceStatusConvertor.convertForPlatform(this.deviceStatus, Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
DeviceStatusConvertor.convertForPlatform(this.deviceStatus, Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
||||||
DeviceStatusConvertor.convertForSwitch(Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
DeviceStatusConvertor.convertForSwitch(Objects.isNull(this.spare) ? 0 : this.spare, builder);
|
||||||
log.info("接受全量状态设备类型[{}] 对应状态[{}]", this.type.name(), builder);
|
log.info("接受设备状态设备类型[{}] 对应状态[{}]", this.type.name(), builder);
|
||||||
return List.of(builder);
|
return List.of(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,16 @@ import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository;
|
|||||||
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
import club.joylink.xiannccda.ats.message.collect.datasource.InUsedScheduleData;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||||
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.Platform;
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track;
|
||||||
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
|
||||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
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.LayoutGraphicsProto.Station;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord.Builder;
|
||||||
@ -24,6 +28,7 @@ import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.protobuf.GeneratedMessageV3;
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -80,10 +85,18 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
return stationOptional.map(Station::getName).orElse(null);
|
return stationOptional.map(Station::getName).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
private Platform.Builder parsePlatform(TrainRecord.Builder record, boolean isUpWay) {
|
||||||
Integer stationId = record.getStationId();
|
|
||||||
|
/*Integer stationId = record.getStationId();
|
||||||
String stationCode = Strings.padStart(stationId.toString(), 2, '0');
|
String stationCode = Strings.padStart(stationId.toString(), 2, '0');
|
||||||
String platformCode = String.format("PF%s3%s", (isUpWay ? "01" : "02"), stationCode);
|
String platformCode = String.format("PF%s3%s", (isUpWay ? "01" : "02"), stationCode);*/
|
||||||
|
String newTrackName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, record.getTrackName());
|
||||||
|
Optional<LayoutGraphicsProto.Platform> layoutPlatformOpt = LineGraphicDataRepository.findLayoutPlatformFromSection(record.getLineId(), newTrackName);
|
||||||
|
String platformCode = layoutPlatformOpt.map(LayoutGraphicsProto.Platform::getCode).orElse(null);
|
||||||
|
if (StringUtils.isEmpty(platformCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.DEVICE);
|
DeviceStatusData deviceStatusData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.DEVICE);
|
||||||
Map<String, GeneratedMessageV3.Builder> builderMap = deviceStatusData.getAllDeviceMap().get(DeviceStatusProto.Platform.getDescriptor().getName());
|
Map<String, GeneratedMessageV3.Builder> builderMap = deviceStatusData.getAllDeviceMap().get(DeviceStatusProto.Platform.getDescriptor().getName());
|
||||||
if (CollectionUtils.isNotEmpty(builderMap)) {
|
if (CollectionUtils.isNotEmpty(builderMap)) {
|
||||||
@ -147,9 +160,11 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Builder record : this.trainRecordMap.values()) {
|
for (Builder record : this.trainRecordMap.values()) {
|
||||||
|
|
||||||
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
|
boolean isUpWay = record.getDir() == DirectionEnum.Up.getValue();
|
||||||
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
Platform.Builder platformBuild = this.parsePlatform(record, isUpWay);
|
||||||
int lineId = record.getLineId();
|
int lineId = record.getLineId();
|
||||||
@ -159,7 +174,7 @@ public class PlatformAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
InUsedScheduleData scheduleData = DeviceDataRepository.findDataSouce(String.valueOf(record.getLineId()), DataTypeEnum.TRAIN_PLAN);
|
||||||
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay);
|
Optional<Plan.Builder> planBuildOpt = scheduleData.findPlan(record.getTrainId(), record.getGlobalId(), record.getStationId(), isUpWay, record.getSideId());
|
||||||
if (planBuildOpt.isEmpty()) {
|
if (planBuildOpt.isEmpty()) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
|
log.info("未找到对应的行车计划,线路[{}] 列车表号[{}] 列车车次号[{}] 车站id[{}] 站台门id[{}] 上下行[{}] 解析屏蔽门code[{}]"
|
||||||
|
@ -12,7 +12,8 @@ import org.springframework.stereotype.Component;
|
|||||||
public class SwitchLostAlertListener implements AlertSourceEventListener<SwitchLostAlertEvent> {
|
public class SwitchLostAlertListener implements AlertSourceEventListener<SwitchLostAlertEvent> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SwitchLostAlertMonitoringTask monitoringTask2;
|
// private SwitchLostAlertMonitoringTask monitoringTask2;
|
||||||
|
private SwitchLostAlertMonitoringTask2 monitoringTask2;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,13 +14,19 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
|||||||
import club.joylink.xiannccda.service.AlertInfoService;
|
import club.joylink.xiannccda.service.AlertInfoService;
|
||||||
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||||
import com.google.protobuf.MessageOrBuilder;
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
//@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
||||||
|
|
||||||
@ -40,21 +46,24 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
private final Map<String, Switch.Builder> deviceMap = new ConcurrentHashMap<>();
|
private final Map<String, Switch.Builder> deviceMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void putSwitchIfNotExist(Switch.Builder switchBuilder) {
|
public void putSwitchIfNotExist(Switch.Builder switchBuilder) {
|
||||||
if (!deviceMap.containsKey(switchBuilder.getId())) {
|
/*if (!deviceMap.containsKey(switchBuilder.getId())) {
|
||||||
|
deviceMap.put(switchBuilder.getId(), switchBuilder);
|
||||||
|
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder.getIpSingleSwitchStusLostIndication());
|
||||||
|
}*/
|
||||||
deviceMap.put(switchBuilder.getId(), switchBuilder);
|
deviceMap.put(switchBuilder.getId(), switchBuilder);
|
||||||
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder.getIpSingleSwitchStusLostIndication());
|
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder.getIpSingleSwitchStusLostIndication());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSwitch(Switch.Builder switchBuilder) {
|
public void removeSwitch(Switch.Builder switchBuilder) {
|
||||||
MessageOrBuilder turnoutBuild = LineGraphicDataRepository.getDeviceByCode(switchBuilder.getLineId(), switchBuilder.getId());
|
|
||||||
if (turnoutBuild instanceof Turnout turnout) {
|
|
||||||
String switchPutName = this.getDefaultName(AlertType.SWITCH_LOST, switchBuilder.getLineId(), switchBuilder.getRtuId());
|
String switchPutName = this.getDefaultName(AlertType.SWITCH_LOST, switchBuilder.getLineId(), switchBuilder.getRtuId());
|
||||||
log.info("线路[{}] 道岔[{}] 从监控中移除... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
log.info("线路[{}] 道岔[{}] 从监控中移除... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
||||||
deviceMap.remove(switchBuilder.getId());
|
deviceMap.remove(switchBuilder.getId());
|
||||||
alertManager.removeAlterDevice(switchBuilder.getLineId(), switchPutName, switchBuilder.getId());
|
alertManager.removeAlterDevice(switchBuilder.getLineId(), switchPutName, switchBuilder.getId());
|
||||||
|
|
||||||
|
MessageOrBuilder turnoutBuild = LineGraphicDataRepository.getDeviceByCodeNotException(switchBuilder.getLineId(), switchBuilder.getId());
|
||||||
|
if (Objects.nonNull(turnoutBuild) && turnoutBuild instanceof Turnout turnout) {
|
||||||
|
//大面积失表移除
|
||||||
alertManager.emit(new SwitchLostMostEvent(switchBuilder, false, turnout));
|
alertManager.emit(new SwitchLostMostEvent(switchBuilder, false, turnout));
|
||||||
// alertManager.emit(new SwitchLostMostInterLockL2Event(switchBuilder, false, turnout));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +76,9 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
return String.format("%s-%s-%s", alertType.name(), lineId, rtuId);
|
return String.format("%s-%s-%s", alertType.name(), lineId, rtuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDevice(Turnout turnout, Builder savedSwitchBuild) {
|
private void checkDevice(Builder savedSwitchBuild) {
|
||||||
int lineId = savedSwitchBuild.getLineId();
|
int lineId = savedSwitchBuild.getLineId();
|
||||||
|
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, savedSwitchBuild.getId(), Turnout.class);
|
||||||
GuardConfig guardConfig = configService.getGuardConfig(lineId);
|
GuardConfig guardConfig = configService.getGuardConfig(lineId);
|
||||||
boolean saveIsLost = savedSwitchBuild.getIpSingleSwitchStusLostIndication();
|
boolean saveIsLost = savedSwitchBuild.getIpSingleSwitchStusLostIndication();
|
||||||
boolean timeOver = this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes());
|
boolean timeOver = this.timeOver(savedSwitchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes());
|
||||||
@ -94,10 +104,8 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Builder savedSwitchBuild : this.deviceMap.values()) {
|
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);
|
this.checkDevice(savedSwitchBuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,146 @@
|
|||||||
|
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.ats.message.collect.DeviceDataRepository;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
|
||||||
|
import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData;
|
||||||
|
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.service.AlertInfoService;
|
||||||
|
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import com.google.protobuf.MessageOrBuilder;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class SwitchLostAlertMonitoringTask2 implements AlertMonitoringTask {
|
||||||
|
|
||||||
|
private DeviceGuardConfigService configService;
|
||||||
|
|
||||||
|
private AlertInfoService alertInfoService;
|
||||||
|
|
||||||
|
public SwitchLostAlertMonitoringTask2(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||||
|
|
||||||
|
this.configService = configService;
|
||||||
|
this.alertInfoService = alertInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final AlertManager alertManager = AlertManager.getDefault();
|
||||||
|
|
||||||
|
private final Map<String, Integer> deviceCodeMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public void putSwitchIfNotExist(Builder switchBuilder) {
|
||||||
|
if (!this.deviceCodeMap.containsKey(switchBuilder.getId())) {
|
||||||
|
log.info("线路[{}] 道岔[{}] 添加到道岔失表监控中... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder.getIpSingleSwitchStusLostIndication());
|
||||||
|
deviceCodeMap.put(switchBuilder.getId(), switchBuilder.getLineId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSwitch(Builder switchBuilder) {
|
||||||
|
String switchPutName = this.getDefaultName(AlertType.SWITCH_LOST, switchBuilder.getLineId(), switchBuilder.getRtuId());
|
||||||
|
log.info("线路[{}] 道岔[{}] 从监控中移除... 设备状态参数[{}]", switchBuilder.getLineId(), switchBuilder.getId(), switchBuilder);
|
||||||
|
deviceCodeMap.remove(switchBuilder.getId());
|
||||||
|
alertManager.removeAlterDevice(switchBuilder.getLineId(), switchPutName, switchBuilder.getId());
|
||||||
|
|
||||||
|
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuilder.getLineId(), switchBuilder.getId(), Turnout.class);
|
||||||
|
Turnout turnout = turnoutOpt.orElse(null);
|
||||||
|
if (Objects.nonNull(turnout)) {
|
||||||
|
log.info("道岔失表未找到地图对应的设备 线路[{}],道岔code[{}]", switchBuilder.getLineId(), switchBuilder.getId());
|
||||||
|
|
||||||
|
//大面积失表移除
|
||||||
|
alertManager.emit(new SwitchLostMostEvent(switchBuilder, false, turnout));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "SWITCH_LOST_ALTER";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDefaultName(AlertType alertType, Integer lineId, Integer rtuId) {
|
||||||
|
return String.format("%s-%s-%s", alertType.name(), lineId, rtuId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Switch.Builder findSwitchDevice(String deviceCode, Integer lineId) {
|
||||||
|
DeviceStatusData deviceDataSource = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE);
|
||||||
|
Map<String, GeneratedMessageV3.Builder> switchBuildMap = deviceDataSource.getAllDeviceMap().get(Switch.getDescriptor().getName());
|
||||||
|
if (CollectionUtils.isEmpty(switchBuildMap)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GeneratedMessageV3.Builder msgBuild = switchBuildMap.get(deviceCode);
|
||||||
|
if (msgBuild instanceof Switch.Builder switchs) {
|
||||||
|
return switchs;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkDevice(Switch.Builder switchBuild, Turnout turnout, Integer lineId, GuardConfig guardConfig) {
|
||||||
|
|
||||||
|
boolean saveIsLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||||
|
boolean timeOver = this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes());
|
||||||
|
String switchPutName = this.getDefaultName(AlertType.SWITCH_LOST, lineId, switchBuild.getRtuId());
|
||||||
|
if (saveIsLost && timeOver) {
|
||||||
|
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||||
|
, lineId, switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), turnout.getCommon().getId());
|
||||||
|
//失表超时
|
||||||
|
if (alertManager.putAlterDevice(lineId, switchPutName, switchBuild.getId())) {
|
||||||
|
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||||
|
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, turnout.getCommon().getId(),
|
||||||
|
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||||
|
alertManager.emit(alertInfo);
|
||||||
|
alertManager.emit(new SwitchLostMostEvent(switchBuild, true, turnout));
|
||||||
|
}
|
||||||
|
this.deviceCodeMap.remove(switchBuild.getId());
|
||||||
|
} else if (!saveIsLost) {
|
||||||
|
this.removeSwitch(switchBuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (Entry<String, Integer> entry : this.deviceCodeMap.entrySet()) {
|
||||||
|
String deviceCode = entry.getKey();
|
||||||
|
Integer lineId = entry.getValue();
|
||||||
|
Switch.Builder switchBuild = this.findSwitchDevice(deviceCode, lineId);
|
||||||
|
if (Objects.isNull(switchBuild)) {
|
||||||
|
this.deviceCodeMap.remove(deviceCode);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(lineId, deviceCode, Turnout.class);
|
||||||
|
Turnout turnout = turnoutOpt.orElse(null);
|
||||||
|
if (Objects.isNull(turnout)) {
|
||||||
|
log.info("道岔失表未找到地图对应的设备 线路[{}],道岔code[{}]", lineId, deviceCode);
|
||||||
|
this.deviceCodeMap.remove(deviceCode);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GuardConfig guardConfig = configService.getGuardConfig(lineId);
|
||||||
|
this.checkDevice(switchBuild, turnout, lineId, guardConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,16 @@
|
|||||||
package club.joylink.xiannccda.ats.warn;
|
package club.joylink.xiannccda.ats.warn;
|
||||||
|
|
||||||
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage;
|
||||||
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.TrainTypeEnum;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.TrainTypeEnum;
|
||||||
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener.TrainRecordAlertEvent;
|
import club.joylink.xiannccda.ats.warn.TrainReacrdAlertListener.TrainRecordAlertEvent;
|
||||||
|
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
||||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
@ -15,6 +19,8 @@ import org.springframework.stereotype.Component;
|
|||||||
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
|
public class TrainReacrdAlertListener implements AlertSourceEventListener<TrainRecordAlertEvent> {
|
||||||
|
|
||||||
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
private final PlatformAlertMonitoringTask platformAlertMonitoringTask;
|
||||||
|
@Autowired
|
||||||
|
private OccNotHandlePros notHandlePros;
|
||||||
|
|
||||||
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) {
|
||||||
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
this.platformAlertMonitoringTask = platformAlertMonitoringTask;
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package club.joylink.xiannccda.configuration.pros;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "occ-not-handle")
|
||||||
|
public class OccNotHandlePros {
|
||||||
|
|
||||||
|
private Integer lineId;
|
||||||
|
private List<Integer> filterRtuIds;
|
||||||
|
private Map<Integer, List<String>> trainRecordStation;
|
||||||
|
|
||||||
|
public boolean notMatchHandle(Integer lineId, Integer rtuId) {
|
||||||
|
if (Objects.isNull(lineId) || Objects.isNull(rtuId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(this.filterRtuIds)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.filterRtuIds.contains(rtuId)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
package club.joylink.xiannccda.constants;
|
package club.joylink.xiannccda.constants;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.convertor.ConvertorUtil;
|
import club.joylink.xiannccda.configuration.pros.OccNotHandlePros;
|
||||||
import java.util.Objects;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -27,7 +25,7 @@ public class SystemContext implements ApplicationContextAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean notMatchRtu(Integer lineId, Integer rtuId) {
|
public static boolean notMatchRtu(Integer lineId, Integer rtuId) {
|
||||||
ConvertorUtil cu = SystemContext.getAppContext().getBean(ConvertorUtil.class);
|
OccNotHandlePros cu = SystemContext.getAppContext().getBean(OccNotHandlePros.class);
|
||||||
return cu.notMatchHandle(lineId, rtuId);
|
return cu.notMatchHandle(lineId, rtuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user