From 5790fd2cfb2c49fc8664f960053c3807c15a2ad2 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Thu, 14 Nov 2024 17:41:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E6=B7=BB=E5=8A=A04?= =?UTF-8?q?=E5=8F=B7=E7=BA=BF=E8=AE=BE=E5=A4=87=E5=90=8D=E7=A7=B0=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ats/cache/LineGraphicDataManage.java | 2 +- .../ats/cache/LineGraphicDataRepository.java | 198 +++++++++++++----- .../ats/message/OccMessageManage.java | 2 + .../changer/DeviceNameChangerManage.java | 47 ++++- .../ats/message/changer/NameChanger.java | 17 ++ .../ats/message/changer/NameChangerEnum.java | 2 +- .../message/changer/line4/Line4NameUtil.java | 25 +++ .../message/changer/line4/SignalChanger.java | 30 +++ .../message/changer/line4/SwitchChanger.java | 61 ++++++ .../message/changer/line4/TrackChanger.java | 30 +++ .../changer/universal/SignalChanger.java | 4 + .../changer/universal/SwitchChanger.java | 5 + .../changer/universal/TrackChanger.java | 6 + .../collect/convertor/TrainInitConvertor.java | 2 +- .../convertor/TrainRemoveConvertor.java | 2 +- .../convertor/TrainUpdateConvertor.java | 2 +- .../line3/rep/DeviceStatusChangeResponse.java | 2 +- .../TrainAtpCutAlertMonitoringTask.java | 40 +++- .../TrainModeAlertListener.java | 7 +- .../xiannccda/dto/event/EventLogPageDTO.java | 2 + .../dto/mock/show/SwitchJammedMockDTO.java | 20 ++ .../xiannccda/dto/protos/AlertConstProto.java | 101 ++++++++- .../joylink/xiannccda/entity/EventLog.java | 2 + .../mock/message/occ/MockOccServer.java | 5 + .../xiannccda/service/AlertMockService.java | 4 + .../xiannccda/ws/msg/SystemWarnListener.java | 32 +++ src/main/resources/application-dev.yml | 8 +- src/main/resources/application-local.yml | 2 +- src/main/resources/application-master.yml | 2 +- src/main/resources/application-prod.yml | 2 +- ...l.java => LineRoleConfigGenerateUtil.java} | 11 +- .../device/DeviceStatusCheckTest.java | 12 ++ .../xiannccda/protocal/x/TestUtil.java | 56 +++-- 33 files changed, 639 insertions(+), 104 deletions(-) create mode 100644 src/main/java/club/joylink/xiannccda/ats/message/changer/NameChanger.java create mode 100644 src/main/java/club/joylink/xiannccda/ats/message/changer/line4/Line4NameUtil.java create mode 100644 src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SignalChanger.java create mode 100644 src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SwitchChanger.java create mode 100644 src/main/java/club/joylink/xiannccda/ats/message/changer/line4/TrackChanger.java rename src/main/java/club/joylink/xiannccda/ats/warn/{atp => train}/TrainAtpCutAlertMonitoringTask.java (77%) rename src/main/java/club/joylink/xiannccda/ats/warn/{atp => train}/TrainModeAlertListener.java (89%) create mode 100644 src/main/java/club/joylink/xiannccda/dto/mock/show/SwitchJammedMockDTO.java rename src/test/java/club/joylink/xiannccda/{LineConfigGenerateUtil.java => LineRoleConfigGenerateUtil.java} (82%) diff --git a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataManage.java b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataManage.java index 13a68d4..0f87d8a 100644 --- a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataManage.java +++ b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataManage.java @@ -30,7 +30,7 @@ public class LineGraphicDataManage implements ApplicationRunner { list.forEach(d -> { LineGraphicDataRepository.putLineGraph(d); if (!SystemContext.getMasterEnv()) { - LineGraphicDataRepository.initDeviceStationCenter(); + LineGraphicDataRepository.initDeviceStationCenter(d.getLineId()); } }); } diff --git a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java index a12cabe..8465a83 100644 --- a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java +++ b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java @@ -12,10 +12,12 @@ import club.joylink.xiannccda.dto.protos.DeviceInfoProto; import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer; import club.joylink.xiannccda.dto.protos.DeviceInfoProto.Turnout; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.AxleCounting; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.KilometerSystem; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RelatedRef.DeviceType; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.RtssGraphicStorage; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section; @@ -24,6 +26,7 @@ import club.joylink.xiannccda.entity.PublishedGi; import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Lists; import com.google.common.collect.Table; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.GeneratedMessageV3; @@ -56,7 +59,7 @@ public class LineGraphicDataRepository { */ private static final Map>> lineGraphMap = new ConcurrentHashMap<>(); - + /** * 线路各坐标系转换关系 */ @@ -146,45 +149,43 @@ public class LineGraphicDataRepository { } - public static void initDeviceStationCenter() { + public static void initDeviceStationCenter(Integer lineId) { log.info("开始初始化地图中设备集中站的归属。。。"); - for (Integer lineId : line_code_table.rowKeySet()) { - DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE); - InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK); - ; + DeviceStatusData dsd = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.DEVICE); + InterLockData interLock = DeviceDataRepository.findDataSouce(lineId.toString(), DataTypeEnum.INTER_LOCK); + ; // for (MessageOrBuilder mb : line_code_table.values()) { - for (MessageOrBuilder mb : line_code_table.row(lineId).values()) { - String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class); - Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class); - if (Objects.isNull(deviceId) || deviceId == 0) { - continue; - } - Integer rtuId = getStationCenterById(lineId, deviceId.toString()); - if (Objects.isNull(rtuId)) { - continue; - } + for (MessageOrBuilder mb : line_code_table.row(lineId).values()) { + String deviceCode = DeviceStatusDataOperate.findFieldVal(mb, "code", String.class); + Integer deviceId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class); + if (Objects.isNull(deviceId) || deviceId == 0) { + continue; + } + Integer rtuId = getStationCenterById(lineId, deviceId.toString()); + if (Objects.isNull(rtuId)) { + continue; + } // List builders = Lists.newArrayList(); - if (mb instanceof LayoutGraphicsProto.Turnout) { - List sl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SWITCH, deviceCode, rtuId.shortValue()); - List tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue()); - dsd.addDevice(sl); - dsd.addDevice(tl); - interLock.addDevice(sl); - }/* else if (mb instanceof LogicSection logicSection) { + if (mb instanceof LayoutGraphicsProto.Turnout) { + List sl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SWITCH, deviceCode, rtuId.shortValue()); + List tl = createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue()); + dsd.addDevice(sl); + dsd.addDevice(tl); + interLock.addDevice(sl); + }/* else if (mb instanceof LogicSection logicSection) { builders.addAll(this.createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode, rtuId.shortValue())); }*/ else if (mb instanceof LayoutGraphicsProto.Section section) { - if (section.getSectionType() == SectionType.Physical) { - for (Integer childId : section.getChildrenList()) { - MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString()); - String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class); - dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); - interLock.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); - } + if (section.getSectionType() == SectionType.Physical) { + for (Integer childId : section.getChildrenList()) { + MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString()); + String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class); + dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); + interLock.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); } - } else if (mb instanceof LayoutGraphicsProto.Signal) { - dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SIGNAL, deviceCode, rtuId.shortValue())); } + } else if (mb instanceof LayoutGraphicsProto.Signal) { + dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SIGNAL, deviceCode, rtuId.shortValue())); } } } @@ -413,7 +414,17 @@ public class LineGraphicDataRepository { Map convertorMap = lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>()); Map cacheSwitchMap = new HashMap<>(storage.getTurnoutsList().size()); - storage.getTurnoutsList().stream() + for (LayoutGraphicsProto.Turnout t : storage.getTurnoutsList()) { + List systemList = t.getKilometerSystemList().stream().filter(k -> StringUtils.isNotEmpty(k.getCoordinateSystem())).toList(); + DeviceInfoProto.Turnout.Builder turnoutBuilder = DeviceInfoProto.Turnout.newBuilder(); + turnoutBuilder.setId(t.getCommon().getId()); + turnoutBuilder.setCode(t.getCode()); + turnoutBuilder.setKilometer(initKilometer(systemList)); + cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder); + convertorCoordinateByTurnoutKM(convertorMap, systemList); + } + dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap); +/* storage.getTurnoutsList().stream() .forEach( t -> { List systemList = @@ -427,7 +438,7 @@ public class LineGraphicDataRepository { cacheSwitchMap.put(t.getCommon().getId(), turnoutBuilder); convertorCoordinateByTurnoutKM(convertorMap, systemList); }); - dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap); + dataMap.put(DeviceType.Turnout.name(), cacheSwitchMap);*/ } /** @@ -484,7 +495,40 @@ public class LineGraphicDataRepository { initConvertorCoordinate(lineId, dataMap, storage); Map sectionMap = dataMap.getOrDefault(DeviceType.Section.name(), Map.of()); Map turnoutMap = dataMap.getOrDefault(DeviceType.Turnout.name(), Map.of()); - storage.getAxleCountingsList().stream() + for (AxleCounting ac : storage.getAxleCountingsList()) { + if (StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem())) { + long mainLineCoordinate = doConvertorCoordinate(lineId, ac.getKilometerSystem()); + for (RelatedRef ref : ac.getAxleCountingRefList()) { + if (Objects.equals(DeviceType.Section, ref.getDeviceType())) { + DeviceInfoProto.Section.Builder b = findSection(sectionMap, ref.getId()); + if (b != null) { + DeviceInfoProto.DeviceKilometer.Builder k = b.getKilometerBuilder(); + updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate); + } + } else if (Objects.equals(DeviceType.Turnout, ref.getDeviceType())) { + DeviceInfoProto.Turnout.Builder b = findTurnout(turnoutMap, ref.getId()); + if (b != null) { + DeviceInfoProto.DeviceKilometer.Builder k = b.getKilometerBuilder(); + // 更新道岔自身的公里标数据 + for (KilometerSystem s : k.getKilometerSystemList()) { + long mc = doConvertorCoordinate(lineId, s); + updateMinAndMaxKilometer(k, mc); + } + // 放入当前计轴信息 +/* updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate); + k.getKilometerSystemList() + .forEach( + s -> + updateMinAndMaxKilometer( + k, doConvertorCoordinate(lineId, s))); + // 放入当前计轴信息 + updateKilometer(k, ac.getKilometerSystem(), mainLineCoordinate);*/ + } + } + } + } + } +/* storage.getAxleCountingsList().stream() .filter(ac -> StringUtils.isNotEmpty(ac.getKilometerSystem().getCoordinateSystem())) .forEach( ac -> { @@ -513,7 +557,7 @@ public class LineGraphicDataRepository { } } }); - }); + });*/ } /** @@ -523,19 +567,76 @@ public class LineGraphicDataRepository { * @param dataMap 设备集合 * @param storage 地图信息 */ - private static void initConvertorCoordinate( - Integer lineId, - Map> dataMap, - LayoutGraphicsProto.RtssGraphicStorage storage) { + private static void initConvertorCoordinate(Integer lineId, Map> dataMap, LayoutGraphicsProto.RtssGraphicStorage storage) { // 强制转换道岔 Map turnoutMap = dataMap.get(DeviceType.Turnout.name()); if (CollectionUtils.isEmpty(turnoutMap)) { return; } - Map convertorMap = - lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>()); + + Map convertorMap = lineCoordinateMain.computeIfAbsent(lineId, id -> new HashMap<>()); // 从计轴中转换信息 - storage + for (AxleCounting axle : storage.getAxleCountingsList()) { + +// 筛选出道岔的公里标坐标系 + List kilometerSystemList = Lists.newArrayList(); + for (RelatedRef ref : axle.getAxleCountingRefList()) { + if (DeviceType.Turnout.equals(ref.getDeviceType()) && turnoutMap.containsKey(ref.getId())) { + DeviceInfoProto.Turnout.Builder t = (DeviceInfoProto.Turnout.Builder) turnoutMap.get(ref.getId()); + if (t.getKilometer().getKilometerSystemCount() > 0) { + kilometerSystemList.add(t.getKilometer().getKilometerSystemList().get(0)); + } + } + } +/* List kilometerSystemList = + axle.getAxleCountingRefList().stream() + .filter( + ref -> + DeviceType.Turnout.equals(ref.getDeviceType()) + && turnoutMap.containsKey(ref.getId())) + .map(ref -> (DeviceInfoProto.Turnout.Builder) turnoutMap.get(ref.getId())) + .filter(t -> t.getKilometer().getKilometerSystemCount() > 0) + .map(t -> t.getKilometer().getKilometerSystemList().get(0)) + .toList();*/ + // 如果关联多个道岔 + if (kilometerSystemList.size() > 1) { + KilometerSystem axleSystem = axle.getKilometerSystem(); + KilometerSystem sameSystem = + kilometerSystemList.stream() + .filter( + k -> + Objects.equals( + k.getCoordinateSystem(), axleSystem.getCoordinateSystem())) + .findFirst() + .orElse(null); + KilometerSystem diffSystem = + kilometerSystemList.stream() + .filter( + k -> + !Objects.equals( + k.getCoordinateSystem(), axleSystem.getCoordinateSystem())) + .findFirst() + .orElse(null); + // 存在不同的坐标系再做处理 + if (sameSystem != null && diffSystem != null) { + String convertorKey = + CoordinateConvertor.generateConvertorKey( + axleSystem.getCoordinateSystem(), diffSystem.getCoordinateSystem()); + if (!convertorMap.containsKey(convertorKey)) { + // 计轴与相同坐标系岔心之间差值 + long diffValue = axleSystem.getKilometer() - sameSystem.getKilometer(); + // 俩岔心到计轴的距离相同,所以另一坐标系的公里标相减差值就是计轴在另一个坐标系的位置 + // a - x = y - b (x,y为计轴在两坐标系上的坐标) + long convertKilometer = diffSystem.getKilometer() - diffValue; + // 求出坐标系0点位置 + CoordinateConvertor convertor = + CoordinateConvertor.generate(axleSystem, diffSystem.getCoordinateSystem(), convertKilometer); + convertorMap.put(convertorKey, convertor); + } + } + } + } + /* storage .getAxleCountingsList() .forEach( axle -> { @@ -582,13 +683,12 @@ public class LineGraphicDataRepository { long convertKilometer = diffSystem.getKilometer() - diffValue; // 求出坐标系0点位置 CoordinateConvertor convertor = - CoordinateConvertor.generate( - axleSystem, diffSystem.getCoordinateSystem(), convertKilometer); + CoordinateConvertor.generate(axleSystem, diffSystem.getCoordinateSystem(), convertKilometer); convertorMap.put(convertorKey, convertor); } } } - }); + });*/ } /** @@ -645,11 +745,9 @@ public class LineGraphicDataRepository { return kilometer.getKilometer(); } Map convertorMap = lineCoordinateMain.get(lineId); - String convertorKey = - CoordinateConvertor.generateConvertorKey( - kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE); + String convertorKey = CoordinateConvertor.generateConvertorKey(kilometer.getCoordinateSystem(), CoordinateEnum.MAIN_LINE); if (CollectionUtils.isEmpty(convertorMap) || !convertorMap.containsKey(convertorKey)) { - log.error("无坐标转换规则" + convertorKey); + log.error("无坐标转换规则 lineId:{},规则:{}", lineId, convertorKey); return kilometer.getKilometer(); } return convertorMap.get(convertorKey).convertorKilometer(kilometer, CoordinateEnum.MAIN_LINE); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/OccMessageManage.java b/src/main/java/club/joylink/xiannccda/ats/message/OccMessageManage.java index 961704b..1586484 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/OccMessageManage.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/OccMessageManage.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; /** @@ -24,6 +25,7 @@ import org.springframework.stereotype.Component; @Slf4j @Component @Setter +@Order(1) public class OccMessageManage implements ApplicationRunner { @Autowired diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java index 93a7c0c..4037dcb 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java @@ -10,6 +10,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; @@ -90,17 +91,55 @@ public class DeviceNameChangerManage { public static void init() throws Exception { - List classes = getClassFQName("club.joylink.xiannccda.ats.message.changer.universal", NameChangerFilter.class); - List filters = Lists.newArrayList(); + List classes = getClassFQName("club.joylink.xiannccda.ats.message.changer", NameChangerFilter.class); +// List classes = getClassFQName("club.joylink.xiannccda.ats.message.changer.universal", NameChangerFilter.class); + Map> nameChnageFilterMapList = Maps.newHashMap(); + + for (Class clazz : classes) { + NameChanger nc = (NameChanger) clazz.getDeclaredAnnotation(NameChanger.class); + if (Objects.nonNull(nc)) { + for (NameChangerEnum ncVal : nc.value()) { + List filterList = nameChnageFilterMapList.computeIfAbsent(ncVal, d -> Lists.newArrayList()); + Object obj = clazz.getDeclaredConstructor().newInstance(); + filterList.add((NameChangerFilter) obj); + } + } else { + log.error("没有找到对应的配置信息 class:{}", clazz.getName()); + } + } + for (Entry> entry : nameChnageFilterMapList.entrySet()) { + Map> deviceTypeListMap = entry.getValue().stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType)); + deviceTypeListMap.forEach((k, v) -> { + Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex)); + CHANGER_TABLE2.put(entry.getKey(), k, v); + }); + } + +/* List filters = Lists.newArrayList(); for (Class clazz : classes) { Object obj = clazz.getDeclaredConstructor().newInstance(); filters.add((NameChangerFilter) obj); } + Map> filteMaper = filters.stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType)); filteMaper.forEach((k, v) -> { Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex)); - CHANGER_TABLE2.put(NameChangerEnum.UNIVERSAL, k, v); - }); + for (NameChangerFilter ncf : v) { + NameChanger nc = ncf.getClass().getDeclaredAnnotation(NameChanger.class); + if (Objects.isNull(nc)) { + log.error("class:{} 没有找到对应的名称处理注解", ncf.getClass().getName()); + continue; + } + for (NameChangerEnum nameChangerEnum : nc.value()) { + List tmpList = CHANGER_TABLE2.get(nameChangerEnum, k); + if (Objects.isNull(tmpList)) { + tmpList = Lists.newArrayList(); + CHANGER_TABLE2.put(nameChangerEnum, k, tmpList); + } + tmpList.add(ncf); + } + } + });*/ } public static void initLineIdNameCHanger(Integer lineId, NameChangerEnum nameChanger) { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChanger.java new file mode 100644 index 0000000..5af0825 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChanger.java @@ -0,0 +1,17 @@ +package club.joylink.xiannccda.ats.message.changer; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface NameChanger { + + NameChangerEnum[] value() default {}; +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerEnum.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerEnum.java index 1f2b833..d6af3bf 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerEnum.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerEnum.java @@ -4,5 +4,5 @@ public enum NameChangerEnum { NONE, //通用 UNIVERSAL, - ; + LINE_4 } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/Line4NameUtil.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/Line4NameUtil.java new file mode 100644 index 0000000..0c93d8c --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/Line4NameUtil.java @@ -0,0 +1,25 @@ +package club.joylink.xiannccda.ats.message.changer.line4; + +public class Line4NameUtil { + + public static String convertLine4Name(String line4Name) { + + try { + StringBuilder sb = new StringBuilder(); + byte[] bb = line4Name.getBytes("ISO-8859-1"); + for (int i = 0; i < bb.length; i++) { + byte b = bb[i]; + if (i + 1 < bb.length) { + if (b == 0 && bb[i + 1] == 63) { + break; + } + } + sb.append((char) b); + } + return sb.toString(); + } catch (Exception e) { + e.printStackTrace(); + return line4Name; + } + } +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SignalChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SignalChanger.java new file mode 100644 index 0000000..eaee5c1 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SignalChanger.java @@ -0,0 +1,30 @@ +package club.joylink.xiannccda.ats.message.changer.line4; + +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; +import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; +import club.joylink.xiannccda.ats.message.line3.device.DeviceType; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; + +public class SignalChanger { + + /** + * X10301 /XR + */ + @NameChanger(value = {NameChangerEnum.LINE_4}) + public static class Signal1Changer implements NameChangerFilter { + + @Override + public DeviceType deviceType() { + return DeviceType.DEVICE_TYPE_SIGNAL; + } + + @Override + public String changeDeviceName(String sourceName) { + return Line4NameUtil.convertLine4Name(sourceName); + } + } + +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SwitchChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SwitchChanger.java new file mode 100644 index 0000000..71cc18d --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/SwitchChanger.java @@ -0,0 +1,61 @@ +package club.joylink.xiannccda.ats.message.changer.line4; + +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; +import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; +import club.joylink.xiannccda.ats.message.line3.device.DeviceType; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * P09301 + */ +public class SwitchChanger { + + + /** + * 道岔物理区段转换 + */ + @NameChanger(value = {NameChangerEnum.LINE_4}) + public static class SwitchDGChanger implements NameChangerFilter { + + @Override + public DeviceType deviceType() { + return DeviceType.DEVICE_TYPE_SWITCH; + } + + @Override + public String changeDeviceName(String sourceName) { + return Line4NameUtil.convertLine4Name(sourceName); + + } + } + + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) + + public static class Switch1Changer implements NameChangerFilter { + + @Override + public int filterIndex() { + return 1; + } + + @Override + public DeviceType deviceType() { + return DeviceType.DEVICE_TYPE_SWITCH; + } + + @Override + public String changeDeviceName(String sourceName) { + Pattern regex = Pattern.compile("^([A-Za-z]{1,2})(\\d{2})3(.*?)$"); + Matcher matcher = regex.matcher(sourceName); + if (matcher.find()) { + String head = matcher.group(2); + String tail = matcher.group(3); + return "P" + tail + head; + } + return null; + } + } + +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/TrackChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/TrackChanger.java new file mode 100644 index 0000000..e5114f8 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/line4/TrackChanger.java @@ -0,0 +1,30 @@ +package club.joylink.xiannccda.ats.message.changer.line4; + +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; +import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; +import club.joylink.xiannccda.ats.message.line3.device.DeviceType; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TrackChanger { + + + /** + * 处理 3号线 区段位 T06301A 这样类似的格式 + */ + @NameChanger(value = {NameChangerEnum.LINE_4}) + public static class Track1Changer implements NameChangerFilter { + + @Override + public DeviceType deviceType() { + return DeviceType.DEVICE_TYPE_TRACK; + } + + @Override + public String changeDeviceName(String sourceName) { + return Line4NameUtil.convertLine4Name(sourceName); + } + } + +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java index fb50c18..030e7f6 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java @@ -1,5 +1,7 @@ package club.joylink.xiannccda.ats.message.changer.universal; +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import java.util.regex.Matcher; @@ -11,6 +13,7 @@ public class SignalChanger { /** * X10301 /XR */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class Signal1Changer implements NameChangerFilter { @Override @@ -38,6 +41,7 @@ public class SignalChanger { /** * X1506_L2 */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class Signal2Changer implements NameChangerFilter { @Override diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java index 257054b..4bfbe72 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java @@ -1,5 +1,7 @@ package club.joylink.xiannccda.ats.message.changer.universal; +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import java.util.regex.Matcher; @@ -14,6 +16,7 @@ public class SwitchChanger { /** * 道岔物理区段转换 */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class SwitchDGChanger implements NameChangerFilter { @Override @@ -35,6 +38,8 @@ public class SwitchChanger { } } + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) + public static class Switch1Changer implements NameChangerFilter { @Override diff --git a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java index 29f122c..b9b720e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java @@ -1,5 +1,7 @@ package club.joylink.xiannccda.ats.message.changer.universal; +import club.joylink.xiannccda.ats.message.changer.NameChanger; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import java.util.regex.Matcher; @@ -11,6 +13,7 @@ public class TrackChanger { /** * 处理 3号线 区段位 T06301A 这样类似的格式 */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class Track1Changer implements NameChangerFilter { @Override @@ -33,6 +36,7 @@ public class TrackChanger { } } + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) /** * 处理区段 T11301 这样类似的格式 */ @@ -64,6 +68,7 @@ public class TrackChanger { /** * 处理区段 TP_D33G 这样类似的格式 */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class Track2Changer implements NameChangerFilter { @Override @@ -85,6 +90,7 @@ public class TrackChanger { /** * 处理区段 T150406 这样类似的格式 */ + @NameChanger(value = {NameChangerEnum.UNIVERSAL}) public static class Track3Changer implements NameChangerFilter { @Override diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java index bde7c9c..2f953c2 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java index f5a68f7..6f2959b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java index 9d37ea4..959e175 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java index 44bbd16..3aaf775 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusChangeResponse.java @@ -108,7 +108,7 @@ public class DeviceStatusChangeResponse extends MessageResponse { DeviceStatusConvertor.convertForTrack(this.deviceStatus, builder); DeviceStatusConvertor.convertForPlatform(this.deviceStatus, 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); } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/train/TrainAtpCutAlertMonitoringTask.java similarity index 77% rename from src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java rename to src/main/java/club/joylink/xiannccda/ats/warn/train/TrainAtpCutAlertMonitoringTask.java index afebf4d..62f0e86 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/train/TrainAtpCutAlertMonitoringTask.java @@ -1,4 +1,4 @@ -package club.joylink.xiannccda.ats.warn.atp; +package club.joylink.xiannccda.ats.warn.train; import club.joylink.xiannccda.alert.NccAlertInfo; import club.joylink.xiannccda.alert.core.AlertDeviceStatusRepository; @@ -19,9 +19,11 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo.Builder; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; import club.joylink.xiannccda.service.AlertInfoService; import club.joylink.xiannccda.service.config.DeviceGuardConfigService; +import club.joylink.xiannccda.vo.AreaConfigVO; import com.google.protobuf.MessageOrBuilder; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -62,6 +64,35 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask { } } + private final static String TRAIN_INTEGRITY_NAME = "TRAIN_INTEGRITY"; + + public void trainIntegrityAlarm(TrainInfo.Builder trainInfo) { + if (trainInfo.getMode().getIpModeTrainIntegrityAlarm()) { + if (alertDataSource.putAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId())) { + + MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName()); +// CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class); + String layoutDeviceId = null; + if (mb instanceof LogicSection) { + String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName()); + Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class); + layoutDeviceId = String.valueOf(section.getCommon().getId()); + } else if (mb instanceof Turnout) { + String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName()); + Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class); + layoutDeviceId = String.valueOf(section.getCommon().getId()); + } + + String alertMsg = String.format("列车[%s] 丢失完整性所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName()); + NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.TRAIN_INTEGRITY_ALARM, trainInfo, alertMsg, layoutDeviceId, + AlertDeviceType.DEVICE_TYPE_TRACK, false); + alertManager.emit(alertInfo); + } + } else { + alertDataSource.removeAlterDevice(trainInfo.getLineId(), TRAIN_INTEGRITY_NAME, trainInfo.getGroupId()); + } + } + /** * 判断紧致后发生atp切除并恢复 *

@@ -116,13 +147,6 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask { Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class); layoutDeviceId = section.getCommon().getId(); } - /* if (mb instanceof Section section) { - if (section.getSectionType() == SectionType.Physical) { - - } else { - - } - }*/ if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) { log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName()); diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/train/TrainModeAlertListener.java similarity index 89% rename from src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java rename to src/main/java/club/joylink/xiannccda/ats/warn/train/TrainModeAlertListener.java index e188b73..2235d00 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/train/TrainModeAlertListener.java @@ -1,8 +1,8 @@ -package club.joylink.xiannccda.ats.warn.atp; +package club.joylink.xiannccda.ats.warn.train; import club.joylink.xiannccda.alert.core.AlertSourceEventListener; import club.joylink.xiannccda.ats.warn.DeviceAlertEvent; -import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.train.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; @@ -20,7 +20,6 @@ public class TrainModeAlertListener implements AlertSourceEventListener { + return 40; + } + case ALERT -> { + return 261; + } + } + return 0; + } +} diff --git a/src/main/java/club/joylink/xiannccda/dto/protos/AlertConstProto.java b/src/main/java/club/joylink/xiannccda/dto/protos/AlertConstProto.java index 56760e9..deb3151 100644 --- a/src/main/java/club/joylink/xiannccda/dto/protos/AlertConstProto.java +++ b/src/main/java/club/joylink/xiannccda/dto/protos/AlertConstProto.java @@ -391,6 +391,46 @@ public final class AlertConstProto { * SWITCH_JAMMED = 25; */ SWITCH_JAMMED(25), + /** + *

+     *zc联锁故障
+     * 
+ * + * INTERLOCKED_ZC_FAULT = 26; + */ + INTERLOCKED_ZC_FAULT(26), + /** + *
+     *列车定位丢失
+     * 
+ * + * TRAIN_LOST_LOCATION = 27; + */ + TRAIN_LOST_LOCATION(27), + /** + *
+     *列车完整性
+     * 
+ * + * TRAIN_INTEGRITY_ALARM = 28; + */ + TRAIN_INTEGRITY_ALARM(28), + /** + *
+     *列车故障救援
+     * 
+ * + * TRAIN_FAULT_HELP = 29; + */ + TRAIN_FAULT_HELP(29), + /** + *
+     *ats卡滞
+     * 
+ * + * INTERLOCKED_ATS_STUCK = 30; + */ + INTERLOCKED_ATS_STUCK(30), UNRECOGNIZED(-1), ; @@ -582,6 +622,46 @@ public final class AlertConstProto { * SWITCH_JAMMED = 25; */ public static final int SWITCH_JAMMED_VALUE = 25; + /** + *
+     *zc联锁故障
+     * 
+ * + * INTERLOCKED_ZC_FAULT = 26; + */ + public static final int INTERLOCKED_ZC_FAULT_VALUE = 26; + /** + *
+     *列车定位丢失
+     * 
+ * + * TRAIN_LOST_LOCATION = 27; + */ + public static final int TRAIN_LOST_LOCATION_VALUE = 27; + /** + *
+     *列车完整性
+     * 
+ * + * TRAIN_INTEGRITY_ALARM = 28; + */ + public static final int TRAIN_INTEGRITY_ALARM_VALUE = 28; + /** + *
+     *列车故障救援
+     * 
+ * + * TRAIN_FAULT_HELP = 29; + */ + public static final int TRAIN_FAULT_HELP_VALUE = 29; + /** + *
+     *ats卡滞
+     * 
+ * + * INTERLOCKED_ATS_STUCK = 30; + */ + public static final int INTERLOCKED_ATS_STUCK_VALUE = 30; public final int getNumber() { @@ -632,6 +712,11 @@ public final class AlertConstProto { case 23: return INTERLOCK_LEVEL_ONE; case 24: return PLATFORM_EMERG_STOP; case 25: return SWITCH_JAMMED; + case 26: return INTERLOCKED_ZC_FAULT; + case 27: return TRAIN_LOST_LOCATION; + case 28: return TRAIN_INTEGRITY_ALARM; + case 29: return TRAIN_FAULT_HELP; + case 30: return INTERLOCKED_ATS_STUCK; default: return null; } } @@ -875,7 +960,7 @@ public final class AlertConstProto { "\n\020alertConst.proto\022\005alert*g\n\rAlertLocati" + "on\022\032\n\026ALERT_LOCATION_UNKNOWN\020\000\022\006\n\002QX\020\001\022\013" + "\n\007YHZ_LSQ\020\002\022\013\n\007HJM_LSQ\020\003\022\013\n\007BCT_LSQ\020\004\022\013\n" + - "\007BSQ_LSQ\020\005*\327\004\n\tAlertType\022\026\n\022ALERT_TYPE_U" + + "\007BSQ_LSQ\020\005*\326\005\n\tAlertType\022\026\n\022ALERT_TYPE_U" + "NKNOWN\020\000\022\020\n\014BLUE_DISPLAY\020\001\022\021\n\rTRAIN_DELA" + "Y_2\020\002\022\022\n\016TRAIN_DELAY_10\020\003\022\'\n#PLATFORM_DO" + "OR_WITHOUT_LOCKED_SIGNAL\020\004\022\035\n\031PLATFORM_D" + @@ -890,11 +975,15 @@ public final class AlertConstProto { "XLE_LED_ORANGE_INTERLOCK_AREA\020\025\022\036\n\032SWITC" + "H_LOST_INTERLOCK_AREA\020\026\022\027\n\023INTERLOCK_LEV" + "EL_ONE\020\027\022\027\n\023PLATFORM_EMERG_STOP\020\030\022\021\n\rSWI" + - "TCH_JAMMED\020\031*x\n\rTipTimeConfig\022\026\n\022HOLIDAY" + - "S_MORN_PEAK\020\000\022\031\n\025HOLIDAYS_EVENING_PEAK\020\001" + - "\022\r\n\tMORN_PEAK\020\002\022\021\n\rEVENING_PEARK\020\003\022\022\n\016NO" + - "RMAL_UNPEARK\020\004B4\n!club.joylink.xiannccda" + - ".dto.protosB\017AlertConstProtob\006proto3" + "TCH_JAMMED\020\031\022\030\n\024INTERLOCKED_ZC_FAULT\020\032\022\027" + + "\n\023TRAIN_LOST_LOCATION\020\033\022\031\n\025TRAIN_INTEGRI" + + "TY_ALARM\020\034\022\024\n\020TRAIN_FAULT_HELP\020\035\022\031\n\025INTE" + + "RLOCKED_ATS_STUCK\020\036*x\n\rTipTimeConfig\022\026\n\022" + + "HOLIDAYS_MORN_PEAK\020\000\022\031\n\025HOLIDAYS_EVENING" + + "_PEAK\020\001\022\r\n\tMORN_PEAK\020\002\022\021\n\rEVENING_PEARK\020" + + "\003\022\022\n\016NORMAL_UNPEARK\020\004B4\n!club.joylink.xi" + + "annccda.dto.protosB\017AlertConstProtob\006pro" + + "to3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, diff --git a/src/main/java/club/joylink/xiannccda/entity/EventLog.java b/src/main/java/club/joylink/xiannccda/entity/EventLog.java index 49ed130..8d8d81b 100644 --- a/src/main/java/club/joylink/xiannccda/entity/EventLog.java +++ b/src/main/java/club/joylink/xiannccda/entity/EventLog.java @@ -32,6 +32,8 @@ public class EventLog { private CommonLogTypeEnum eventType; private CommonLogTypeEnum.SubEventType subEventType; private String faceName; + private Integer lineId; + private String uri; private String method; private String parameters; diff --git a/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java b/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java index 7849749..59245c7 100644 --- a/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java +++ b/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java @@ -189,6 +189,11 @@ public class MockOccServer { System.out.println(mb); Integer stationId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class); return this.findRtuStation(lineId, stationId); + } else if (alertType == AlertType.SWITCH_JAMMED) { + MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCode(lineId, deviceName); + System.out.println(mb); + Integer stationId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class); + return this.findRtuStation(lineId, stationId); } return null; } diff --git a/src/main/java/club/joylink/xiannccda/service/AlertMockService.java b/src/main/java/club/joylink/xiannccda/service/AlertMockService.java index 7a12e5b..28c53de 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertMockService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertMockService.java @@ -17,6 +17,7 @@ import club.joylink.xiannccda.constants.SystemContext; import club.joylink.xiannccda.dto.mock.show.BlueAlertMockDTO; import club.joylink.xiannccda.dto.mock.show.NewAlertMockDTO.DeviceNameInfo; import club.joylink.xiannccda.dto.mock.show.PlatformEBDTO; +import club.joylink.xiannccda.dto.mock.show.SwitchJammedMockDTO; import club.joylink.xiannccda.dto.mock.test.AlertMockDTO; import club.joylink.xiannccda.dto.mock.show.NewAlertMockDTO; import club.joylink.xiannccda.dto.mock.show.OrangeAlertMockDTO; @@ -148,6 +149,9 @@ public class AlertMockService { case PLATFORM_EMERG_STOP -> { return PlatformEBDTO.class; } + case SWITCH_JAMMED -> { + return SwitchJammedMockDTO.class; + } default -> throw new IllegalStateException("Unexpected value: " + alertType); } } diff --git a/src/main/java/club/joylink/xiannccda/ws/msg/SystemWarnListener.java b/src/main/java/club/joylink/xiannccda/ws/msg/SystemWarnListener.java index 6612351..aca8980 100644 --- a/src/main/java/club/joylink/xiannccda/ws/msg/SystemWarnListener.java +++ b/src/main/java/club/joylink/xiannccda/ws/msg/SystemWarnListener.java @@ -1,10 +1,16 @@ package club.joylink.xiannccda.ws.msg; import club.joylink.xiannccda.ats.message.OccTcpClientConnection; +import club.joylink.xiannccda.constants.common.CommonLogTypeEnum; import club.joylink.xiannccda.dto.protos.SystemWarnMsgProto; import club.joylink.xiannccda.dto.protos.SystemWarnMsgProto.WarnMessage; import club.joylink.xiannccda.dto.protos.SystemWarnMsgProto.WarnMessage.Builder; +import club.joylink.xiannccda.entity.EventLog; +import club.joylink.xiannccda.repository.IEventLogRepository; import club.joylink.xiannccda.ws.msg.SystemWarnEvent.SystemWarnConnStateEvent; +import jakarta.annotation.Resource; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -15,6 +21,9 @@ import org.springframework.stereotype.Component; @Component public class SystemWarnListener implements ApplicationListener { + @Resource + private IEventLogRepository eventLogRepository; + private final static Map SYSTEM_MSG_MAP = new ConcurrentHashMap<>(); @Override @@ -25,9 +34,32 @@ public class SystemWarnListener implements ApplicationListener builder.setLineId(k); return builder; }); + List events = new ArrayList<>(); + if (!build.getOccRealConned()) { + events.add(this.createLogObj(lineId, true)); + } + if (!build.getOccUnrealConned()) { + events.add(this.createLogObj(lineId, false)); + } + this.eventLogRepository.saveBatch(events); this.connedHandle(event, build); } + + private EventLog createLogObj(Integer lineId, boolean real) { + EventLog eventLog = new EventLog(); + eventLog.setLineId(lineId); + eventLog.setEventType(CommonLogTypeEnum.WARN); + eventLog.setFaceName("实时接口"); + eventLog.setCreateDateTime(LocalDateTime.now()); + eventLog.setMethod("tcp"); + if (!real) { + eventLog.setFaceName("非实时接口"); + } + eventLog.setRequestSuccess(0); + return eventLog; + } + private void connedHandle(SystemWarnEvent event, SystemWarnMsgProto.WarnMessage.Builder build) { if (event instanceof SystemWarnConnStateEvent) { OccTcpClientConnection clientConnection = (OccTcpClientConnection) event.getSource(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8c59d96..078a247 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -32,11 +32,11 @@ occ-client: - OCC - NCC 4: - nameChanger: NONE - server-host: 10.254.12.45 - real-port: 3604 + nameChanger: LINE_4 + server-host: 127.0.0.1 + real-port: 2603 un-real-port: 3704 - collector-data: true + collector-data: false monitor-handware-change: false receiveMsgTimeout: 6 filterRtuIds: diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 9b67b68..86c67e2 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -32,7 +32,7 @@ occ-client: - OCC - NCC 4: - nameChanger: NONE + nameChanger: LINE_4 server-host: 10.254.12.45 real-port: 3604 un-real-port: 3704 diff --git a/src/main/resources/application-master.yml b/src/main/resources/application-master.yml index fdb9895..357efe4 100644 --- a/src/main/resources/application-master.yml +++ b/src/main/resources/application-master.yml @@ -39,7 +39,7 @@ occ-client: - OCC - NCC 4: - nameChanger: NONE + nameChanger: LINE_4 server-host: 10.254.12.45 real-port: 3604 un-real-port: 3704 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a2dde28..3b168aa 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -33,7 +33,7 @@ occ-client: - OCC - NCC 4: - nameChanger: NONE + nameChanger: LINE_4 server-host: 10.254.12.45 real-port: 3604 un-real-port: 3704 diff --git a/src/test/java/club/joylink/xiannccda/LineConfigGenerateUtil.java b/src/test/java/club/joylink/xiannccda/LineRoleConfigGenerateUtil.java similarity index 82% rename from src/test/java/club/joylink/xiannccda/LineConfigGenerateUtil.java rename to src/test/java/club/joylink/xiannccda/LineRoleConfigGenerateUtil.java index 276b77d..2ad4141 100644 --- a/src/test/java/club/joylink/xiannccda/LineConfigGenerateUtil.java +++ b/src/test/java/club/joylink/xiannccda/LineRoleConfigGenerateUtil.java @@ -6,16 +6,15 @@ import club.joylink.xiannccda.constants.common.LineTypeEnum; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import com.alibaba.fastjson2.JSON; import java.util.List; -import java.util.Map; import org.junit.jupiter.api.Test; -public class LineConfigGenerateUtil { +public class LineRoleConfigGenerateUtil { @Test public void genJson4() { LineConfig lc = new LineConfig(); - WarnConfig nccWc = new WarnConfig(LineTypeEnum.NCC, List.of(AlertType.INTERLOCK_LEVEL_ONE)); - WarnConfig occWc = new WarnConfig(LineTypeEnum.OCC, List.of(AlertType.INTERLOCK_LEVEL_ONE)); + WarnConfig nccWc = new WarnConfig(LineTypeEnum.NCC, List.of(AlertType.INTERLOCK_LEVEL_ONE, AlertType.TRAIN_INTEGRITY_ALARM)); + WarnConfig occWc = new WarnConfig(LineTypeEnum.OCC, List.of(AlertType.INTERLOCK_LEVEL_ONE, AlertType.TRAIN_INTEGRITY_ALARM)); lc.setWarnConfig(List.of(nccWc, occWc)); String json = JSON.toJSONString(lc); @@ -28,8 +27,8 @@ public class LineConfigGenerateUtil { @Test public void genJson3() { LineConfig lc = new LineConfig(); - WarnConfig nccWc = new WarnConfig(LineTypeEnum.NCC, List.of(AlertType.SWITCH_JAMMED, AlertType.PLATFORM_EMERG_STOP)); - WarnConfig occWc = new WarnConfig(LineTypeEnum.OCC, List.of(AlertType.SWITCH_JAMMED)); + WarnConfig nccWc = new WarnConfig(LineTypeEnum.NCC, List.of(AlertType.PLATFORM_EMERG_STOP)); + WarnConfig occWc = new WarnConfig(LineTypeEnum.OCC, List.of(AlertType.SWITCH_JAMMED, AlertType.TRAIN_INTEGRITY_ALARM)); lc.setWarnConfig(List.of(nccWc, occWc)); String json = JSON.toJSONString(lc); diff --git a/src/test/java/club/joylink/xiannccda/device/DeviceStatusCheckTest.java b/src/test/java/club/joylink/xiannccda/device/DeviceStatusCheckTest.java index 6797136..783a243 100644 --- a/src/test/java/club/joylink/xiannccda/device/DeviceStatusCheckTest.java +++ b/src/test/java/club/joylink/xiannccda/device/DeviceStatusCheckTest.java @@ -9,6 +9,7 @@ import club.joylink.xiannccda.ats.warn.bule.BuleDisplayMonitoringTask.RtuWarnVO; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Platform; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Rtu; +import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch; import club.joylink.xiannccda.vo.AreaConfigVO; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -101,6 +102,17 @@ public class DeviceStatusCheckTest { } } + @Test + public void switchJammed() { + for (int i = 0; i < 999999999; i++) { + Switch.Builder p1 = DeviceStatusConvertor.convert(DeviceStatus.SWITCH.class, i); + if (p1.getIpSingleSwitchStusJammed()) { + System.out.println(i); + } + } + } + + @Test public void platformTest() { diff --git a/src/test/java/club/joylink/xiannccda/protocal/x/TestUtil.java b/src/test/java/club/joylink/xiannccda/protocal/x/TestUtil.java index fdee146..2afb930 100644 --- a/src/test/java/club/joylink/xiannccda/protocal/x/TestUtil.java +++ b/src/test/java/club/joylink/xiannccda/protocal/x/TestUtil.java @@ -2,25 +2,53 @@ package club.joylink.xiannccda.protocal.x; import club.joylink.xiannccda.ats.message.line3.MessageCons; +import com.alibaba.fastjson2.JSON; import java.nio.charset.Charset; +import java.util.Map; +import lombok.SneakyThrows; public class TestUtil { - /** - * 将src通过charset编码后填充到to - */ - public static void fill(final String src, final Charset charset, final byte[] to) { - final byte[] srcBuf = src.getBytes(charset); - if (to.length < srcBuf.length) throw new RuntimeException("to.length