diff --git a/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java b/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java index 5fcc89e..be2ad25 100644 --- a/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java +++ b/src/main/java/club/joylink/xiannccda/aop/SystemEventAspect.java @@ -50,7 +50,6 @@ public class SystemEventAspect { Jwt jwt = jwtDecoder.decode(obj.toString()); String userId = jwt.getClaimAsString("sub"); oe.setUserId(Long.parseLong(userId)); - } SystemContext.publishEvent(oe); } @@ -61,7 +60,6 @@ public class SystemEventAspect { OperateEvent oe = this.parseOperateEvent(joinPoint); if (Objects.nonNull(oe)) { oe.setRequestSuccess(0); - } SystemContext.publishEvent(oe); } 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 423d923..fdac036 100644 --- a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java +++ b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java @@ -1,6 +1,7 @@ package club.joylink.xiannccda.ats.cache; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; 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; @@ -195,7 +196,7 @@ public class LineGraphicDataRepository { statusChange.setType(dt); statusChange.setDeviceStatus(0); statusChange.setRtuId(rtuId); - return statusChange.generateProto(); + return statusChange.generateProto(DeviceNameChangerManage.findNameChanger(lineId)); } public static Integer getStationCenterById(Integer lineId, String deviceId) { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/MessageData.java b/src/main/java/club/joylink/xiannccda/ats/message/MessageData.java index 1047d94..5dffc5c 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/MessageData.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/MessageData.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.ats.message; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; import com.alibaba.fastjson2.annotation.JSONField; import com.google.common.collect.Lists; @@ -92,7 +93,7 @@ public abstract class MessageData { */ public abstract void decode2(ByteBuf buf) throws Exception; - public abstract List generateProto(); + public abstract List generateProto(NameChangerEnum nameChanger); public void encode(ByteBuf buf) { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/MessageRequest.java b/src/main/java/club/joylink/xiannccda/ats/message/MessageRequest.java index 3324dc9..e58563b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/MessageRequest.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/MessageRequest.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.ats.message; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.util.List; @@ -18,7 +19,7 @@ public abstract class MessageRequest extends MessageData { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { return null; } } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/MessageResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/MessageResponse.java index eabd7d1..f77ad1f 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/MessageResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/MessageResponse.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.ats.message; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.util.Collections; @@ -13,8 +14,9 @@ public abstract class MessageResponse extends MessageData { public abstract Short getLineId(); + @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { return Collections.emptyList(); } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/OccMessageHandler.java b/src/main/java/club/joylink/xiannccda/ats/message/OccMessageHandler.java index 71b25dd..7497bdc 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/OccMessageHandler.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/OccMessageHandler.java @@ -40,7 +40,7 @@ public class OccMessageHandler extends SimpleChannelInboundHandler clientInfoMap; Map clientMap = new HashMap<>(); public void sendMsg(Integer lineId, MessageData md, boolean isRealTime) { @@ -48,6 +36,20 @@ public class OccMessageManage implements ApplicationRunner { client.send(md, isRealTime); } + public boolean notMatchHandle(Integer lineId, Integer rtuId) { + OccClientMessage clientMessage = this.clientInfoMap.get(lineId); + if (Objects.isNull(clientMessage)) { + return true; + } + if (CollectionUtils.isEmpty(clientMessage.filterRtuIds)) { + return true; + } + if (clientMessage.filterRtuIds.contains(rtuId)) { + return false; + } + return true; + } + public void registerClient(XianOccMessagingClient client) { clientMap.put(client.lineId, client); @@ -61,13 +63,36 @@ public class OccMessageManage implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - log.info("初始化 occ tcp连接.... 是否监控cpu,内存信息:{}", this.monitorHandwareChange); DeviceNameChangerManage.init(); - // 读取数据配置,创建客户端 - this.registerClient(new XianOccMessagingClient(this.lineId, this.realPort, this.unRealPort, this.serverHost, this.collectorData, receiveMsgTimeout)); - for (XianOccMessagingClient client : this.clientMap.values()) { - client.connect(this.monitorHandwareChange); - } + + this.clientInfoMap.forEach((k, v) -> { + log.info("初始化 occ tcp连接.... 是否监控cpu,lineId:{} 内存信息:{}", k, v.monitorHandwareChange); + DeviceNameChangerManage.initLineIdNameCHanger(k, v.getNameChanger()); + XianOccMessagingClient client = new XianOccMessagingClient(k, v); + this.registerClient(client); + client.connect(v.monitorHandwareChange); + + }); + + } + + @Data + public static class OccClientMessage { + + private String serverHost; + + private Integer realPort; + + private Integer unRealPort; + + private Boolean collectorData; + + private Integer receiveMsgTimeout; + + private boolean monitorHandwareChange; + + private List filterRtuIds; + private NameChangerEnum nameChanger; } } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/OccTcpClientConnection.java b/src/main/java/club/joylink/xiannccda/ats/message/OccTcpClientConnection.java index cbf6b47..c754ca1 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/OccTcpClientConnection.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/OccTcpClientConnection.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.ats.message; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.constants.SystemContext; import club.joylink.xiannccda.ws.msg.SystemWarnEvent; import club.joylink.xiannccda.ws.msg.SystemWarnEvent.SystemWarnConnStateEvent; @@ -54,13 +55,16 @@ public class OccTcpClientConnection { @Getter final boolean isRealPort; + @Getter + final NameChangerEnum nameChanger; + public void write(MessageData messageData) { if (Objects.nonNull(this.channel)) { this.channel.writeAndFlush(List.of(messageData)); } } - public OccTcpClientConnection(XianOccMessagingClient client, String host, int port, boolean collectorData, boolean isRealPort) { + public OccTcpClientConnection(XianOccMessagingClient client, String host, int port, boolean collectorData, boolean isRealPort, NameChangerEnum nameChanger) { this.client = client; this.host = host; @@ -68,6 +72,7 @@ public class OccTcpClientConnection { this.group = new NioEventLoopGroup(1); this.bootstrap = new Bootstrap(); this.isRealPort = isRealPort; + this.nameChanger = nameChanger; OccTcpClientConnection self = this; bootstrap.group(group) .channel(NioSocketChannel.class) @@ -117,7 +122,6 @@ public class OccTcpClientConnection { this.connected = false; this.channel = null; this.client.resetRequestBaseDataFlag(); - } SystemContext.publishEvent(new SystemWarnConnStateEvent(this.client.getLineId(), this)); this.reconnectState.resetState(); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/XianOccMessagingClient.java b/src/main/java/club/joylink/xiannccda/ats/message/XianOccMessagingClient.java index f0ec8c4..7341c04 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/XianOccMessagingClient.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/XianOccMessagingClient.java @@ -1,5 +1,6 @@ package club.joylink.xiannccda.ats.message; +import club.joylink.xiannccda.ats.message.OccMessageManage.OccClientMessage; import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest; import club.joylink.xiannccda.ats.message.line3.req.LoadHistoryTGDataRequest.ApplyTypeEnum; import java.time.LocalDateTime; @@ -21,8 +22,6 @@ import oshi.hardware.GlobalMemory; @Slf4j public class XianOccMessagingClient { - // final int realTimePortBase = 2600; - // final int nonRealTimePortBase = 2700; /** * 线路号 实时信息的侦听端口号为2600+line_id,非实时信息的侦听端口号为2700+line_id。 (如对于地铁1号线来说,实时信息的侦听端口号为2601,非实时信息的侦听端口号为2701) */ @@ -58,7 +57,7 @@ public class XianOccMessagingClient { } - public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) { +/* public XianOccMessagingClient(int lineId, Integer realPort, Integer unRealPort, String host, boolean collectorData, Integer receiveMsgTimeout) { this.host = host; this.lineId = lineId; this.requestBaseTime = TimeUnit.HOURS.toMillis(receiveMsgTimeout); @@ -67,6 +66,17 @@ public class XianOccMessagingClient { this.nrtConnection = new OccTcpClientConnection(this, host, unRealPort, false, false); this.timeOutHandler.addConnection(this.rtConnection); this.timeOutHandler.addConnection(this.nrtConnection); + }*/ + + public XianOccMessagingClient(Integer lineId, OccClientMessage clientMessage) { + this.host = clientMessage.getServerHost(); + this.lineId = lineId; + this.requestBaseTime = TimeUnit.HOURS.toMillis(clientMessage.getReceiveMsgTimeout()); + // 创建实时和非实时消息连接 + this.rtConnection = new OccTcpClientConnection(this, host, clientMessage.getRealPort(), clientMessage.getCollectorData(), true, clientMessage.getNameChanger()); + this.nrtConnection = new OccTcpClientConnection(this, host, clientMessage.getUnRealPort(), false, false, clientMessage.getNameChanger()); + this.timeOutHandler.addConnection(this.rtConnection); + this.timeOutHandler.addConnection(this.nrtConnection); } @@ -164,20 +174,6 @@ public class XianOccMessagingClient { } return null; -/* GlobalMemory memory = systemInfo.getHardware().getMemory(); - long totalMemory = memory.getTotal(); - long availableMemory = memory.getAvailable(); - long usedMemory = totalMemory - availableMemory; - if (Objects.isNull(this.osProcess)) { - return String.format("内存总内存:%s(MB) 使用:%s(MB) 可用:%s(MB)", (totalMemory / 1024 / 1024), (usedMemory / 1024 / 1024), - (availableMemory / 1024 / 1024)); - } else { - OSProcess osp = this.systemInfo.getOperatingSystem().getProcess(this.processId); - - double d2 = this.osProcess.getProcessCpuLoadBetweenTicks(osp); - return String.format("当前CPU使用:%d%% 内存总内存:%s(MB) 使用:%s(MB) 可用:%s(MB)", Math.round(d2 * 100), (totalMemory / 1024 / 1024), (usedMemory / 1024 / 1024), - (availableMemory / 1024 / 1024)); - }*/ } public void start() { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/DeviceNameChangerManage.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java similarity index 65% rename from src/main/java/club/joylink/xiannccda/ats/message/line3/changer/DeviceNameChangerManage.java rename to src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java index 2f2be89..28b3153 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/DeviceNameChangerManage.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/DeviceNameChangerManage.java @@ -1,8 +1,9 @@ -package club.joylink.xiannccda.ats.message.line3.changer; +package club.joylink.xiannccda.ats.message.changer; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import com.google.common.collect.HashBasedTable; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.google.common.collect.Table; import java.util.ArrayList; import java.util.Collections; @@ -24,10 +25,11 @@ import org.springframework.util.CollectionUtils; @Slf4j public class DeviceNameChangerManage { - final static Table> CHANGER_TABLE = HashBasedTable.create(); - private final static Integer TMP_DEFAULT_LINEID = 3; + final static Table> CHANGER_TABLE2 = HashBasedTable.create(); + final static Map LINEID_NAMECHANGER_MAP = Maps.newHashMap(); - public static String findMatch(DeviceType deviceType, String occName) { + + public static String findMatch(NameChangerEnum nameChanger, DeviceType deviceType, String occName) { if (Objects.isNull(deviceType)) { log.debug("错误的设备类型 type[{}]", deviceType); return occName; @@ -36,7 +38,7 @@ public class DeviceNameChangerManage { log.debug("错误的设备名称 occName[{}]", occName); return occName; } - List filters = CHANGER_TABLE.get(TMP_DEFAULT_LINEID, deviceType); + List filters = CHANGER_TABLE2.get(nameChanger, deviceType); if (CollectionUtils.isEmpty(filters)) { log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType); return occName; @@ -51,8 +53,41 @@ public class DeviceNameChangerManage { return occName; } + public static NameChangerEnum findNameChanger(Integer lineId) { + NameChangerEnum nameChanger = LINEID_NAMECHANGER_MAP.get(lineId); + if (Objects.isNull(nameChanger)) { + + return NameChangerEnum.UNIVERSAL; + } + return nameChanger; + } + + public static String findMatch(Integer lineId, DeviceType deviceType, String occName) { + NameChangerEnum nameChanger = LINEID_NAMECHANGER_MAP.get(lineId); + if (Objects.isNull(nameChanger)) { + log.debug("错误的设备类型 type[{}]", deviceType); + return occName; + } + + List filters = CHANGER_TABLE2.get(nameChanger, deviceType); + if (CollectionUtils.isEmpty(filters)) { + log.debug("未找到对应的转换的occName:[{}] deviceType[{}]", occName, deviceType); + return occName; + } + for (NameChangerFilter filter : filters) { + String newName = filter.changeDeviceName(occName); + if (Objects.nonNull(newName)) { + return newName; + } + } + log.debug("不能转换的occName:[{}] deviceType[{}]", occName, deviceType); + + return occName; + } + + public static void init() throws Exception { - List classes = getClassFQName("club.joylink.xiannccda.ats.message.line3.changer", NameChangerFilter.class); + List classes = getClassFQName("club.joylink.xiannccda.ats.message.changer.universal", NameChangerFilter.class); List filters = Lists.newArrayList(); for (Class clazz : classes) { Object obj = clazz.getDeclaredConstructor().newInstance(); @@ -61,10 +96,14 @@ public class DeviceNameChangerManage { Map> filteMaper = filters.stream().collect(Collectors.groupingBy(NameChangerFilter::deviceType)); filteMaper.forEach((k, v) -> { Collections.sort(v, Comparator.comparingInt(NameChangerFilter::filterIndex)); - CHANGER_TABLE.put(TMP_DEFAULT_LINEID, k, v); + CHANGER_TABLE2.put(NameChangerEnum.UNIVERSAL, k, v); }); } + public static void initLineIdNameCHanger(Integer lineId, NameChangerEnum nameChanger) { + LINEID_NAMECHANGER_MAP.put(lineId, nameChanger); + } + private static List getClassFQName(String packgeName, Class clz) { // final String BASE_PACKAGE = packgeName; final String RESOURCE_PATTERN = "/**/*.class"; @@ -101,18 +140,18 @@ public class DeviceNameChangerManage { public static void main(String[] args) throws Exception { DeviceNameChangerManage.init(); - String d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T13301C"); + String d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T13301C"); System.out.println(d); - d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T06301C"); + d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T06301C"); System.out.println(d); - d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "T04325G"); + d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_TRACK, "T04325G"); System.out.println(d); /*d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, "TD_2DG"); System.out.println(d); d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, "P02309"); System.out.println(d);*/ - d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "S03305"); + d = DeviceNameChangerManage.findMatch(NameChangerEnum.UNIVERSAL, DeviceType.DEVICE_TYPE_SIGNAL, "S03305"); System.out.println(d); /* d = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, "XR"); System.out.println(d); 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 new file mode 100644 index 0000000..ad88a02 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerEnum.java @@ -0,0 +1,7 @@ +package club.joylink.xiannccda.ats.message.changer; + +public enum NameChangerEnum { + //通用 + UNIVERSAL, + ; +} diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/NameChangerFilter.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerFilter.java similarity index 80% rename from src/main/java/club/joylink/xiannccda/ats/message/line3/changer/NameChangerFilter.java rename to src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerFilter.java index 5891629..f91a312 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/NameChangerFilter.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/NameChangerFilter.java @@ -1,4 +1,4 @@ -package club.joylink.xiannccda.ats.message.line3.changer; +package club.joylink.xiannccda.ats.message.changer; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SignalChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java similarity index 92% rename from src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SignalChanger.java rename to src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java index 5677bf0..fb50c18 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SignalChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SignalChanger.java @@ -1,5 +1,6 @@ -package club.joylink.xiannccda.ats.message.line3.changer; +package club.joylink.xiannccda.ats.message.changer.universal; +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; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SwitchChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java similarity index 91% rename from src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SwitchChanger.java rename to src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java index 8857fda..257054b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/SwitchChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/SwitchChanger.java @@ -1,5 +1,6 @@ -package club.joylink.xiannccda.ats.message.line3.changer; +package club.joylink.xiannccda.ats.message.changer.universal; +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; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/TrackChanger.java b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java similarity index 95% rename from src/main/java/club/joylink/xiannccda/ats/message/line3/changer/TrackChanger.java rename to src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java index d282ad1..29f122c 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/changer/TrackChanger.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/changer/universal/TrackChanger.java @@ -1,5 +1,6 @@ -package club.joylink.xiannccda.ats.message.line3.changer; +package club.joylink.xiannccda.ats.message.changer.universal; +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; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertor.java index f2db93d..500809c 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertor.java @@ -2,9 +2,13 @@ package club.joylink.xiannccda.ats.message.collect; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; +import club.joylink.xiannccda.ats.message.changer.NameChangerFilter; import java.util.List; -/** 消息数据额外转换时间,比如:线路的数据转换为线网数据 */ +/** + * 消息数据额外转换时间,比如:线路的数据转换为线网数据 + */ public abstract class DeviceStatusConvertor { /** @@ -14,6 +18,8 @@ public abstract class DeviceStatusConvertor { */ public abstract MessageId getMessageId(); - /** 任务执行逻辑 */ - public abstract void run(List messageDataList); + /** + * 任务执行逻辑 + */ + public abstract void run(NameChangerEnum nameChanger, List messageDataList); } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertorManager.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertorManager.java index 8ef6497..3b11518 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertorManager.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusConvertorManager.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import java.util.Collections; import java.util.List; import java.util.Map; @@ -48,14 +49,14 @@ public class DeviceStatusConvertorManager { * * @param dataList 消息数据列表 */ - public static void doConvertor(List dataList) { + public static void doConvertor(NameChangerEnum nameChanger, List dataList) { dataList.stream() .filter(m -> CONVERTOR_MAP.containsKey(m.getMsgId())) .collect(Collectors.groupingBy(MessageData::getMsgId)) - .forEach((k, v) -> CONVERTOR_MAP.get(k).values().forEach(c -> c.run(v))); + .forEach((k, v) -> CONVERTOR_MAP.get(k).values().forEach(c -> c.run(nameChanger, v))); } - public static void doConvertor(MessageData md) { - doConvertor(Collections.singletonList(md)); + public static void doConvertor(NameChangerEnum nameChanger, MessageData md) { + doConvertor(nameChanger, Collections.singletonList(md)); } } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusDataOperate.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusDataOperate.java index cb18fcd..f54371e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusDataOperate.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/DeviceStatusDataOperate.java @@ -60,22 +60,20 @@ public abstract class DeviceStatusDataOperate { .forEach( (k, v) -> { // 当前的设备状态 - Map deviceStatusMap = - allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size())); + Map deviceStatusMap = allDeviceMap.computeIfAbsent(k, key -> new ConcurrentHashMap<>(v.size())); // 新的设备状态 - Map newDeviceMap = - v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> { - Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class); - Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class); - if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) { - if (collTime >= curTime) { - return v2; - } else { - return v1; - } - } + Map newDeviceMap = v.stream().collect(Collectors.toMap(DeviceStatusDataOperate::getIdVal, b -> b, (v1, v2) -> { + Long curTime = DeviceStatusDataOperate.findFieldVal(v1, "timestamp", Long.class); + Long collTime = DeviceStatusDataOperate.findFieldVal(v2, "timestamp", Long.class); + if (Objects.nonNull(curTime) && Objects.nonNull(collTime)) { + if (collTime >= curTime) { return v2; - })); + } else { + return v1; + } + } + return v2; + })); // 对比结果 Map compareMap = compare(deviceStatusMap, newDeviceMap); if (!CollectionUtils.isEmpty(compareMap) && (!(data instanceof DeviceStatusData))) { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DefaultConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DefaultConvertor.java index 846c851..249b81a 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DefaultConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/DefaultConvertor.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor; @@ -46,10 +47,10 @@ public abstract class DefaultConvertor extends DeviceStatusConvertor { } @Override - public void run(List messageDataList) { + public void run(NameChangerEnum nameChanger, List messageDataList) { Map> lineMapper = this.groupByLineId(messageDataList); lineMapper.forEach((k, v) -> { - List builders = v.stream().map(MessageResponse::generateProto) + List builders = v.stream().map(d -> d.generateProto(nameChanger)) .flatMap(Collection::stream).filter(d -> { Integer lineId = DeviceStatusDataOperate.findFieldVal(d, "lineId", Integer.class); Integer rtuId = DeviceStatusDataOperate.findFieldVal(d, "rtuId", Integer.class); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainComMethod.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainComMethod.java index f202e81..e021a8b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainComMethod.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainComMethod.java @@ -1,10 +1,11 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataRepository; import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.dto.protos.DeviceInfoProto; import club.joylink.xiannccda.dto.protos.DeviceInfoProto.DeviceKilometer; @@ -56,10 +57,10 @@ public abstract class LineNetTrainComMethod { * @param type 所在设备类型 * @param deviceName 设备名称 */ - public static void setUpKilometerCode( + public static void setUpKilometerCode(NameChangerEnum nameChanger, WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj, DeviceType type, String deviceName) { // 获取到当前区段公里标 - DeviceKilometer.Builder km = getDeviceKM(obj.getLineId(), type, deviceName); + DeviceKilometer.Builder km = getDeviceKM(nameChanger, obj.getLineId(), type, deviceName); if (km != null) { obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), km)); } else { @@ -76,14 +77,14 @@ public abstract class LineNetTrainComMethod { * @param type 设备类型 * @param name 设备名称 */ - public static void setTrainDirectionAndKilometerCode( + public static void setTrainDirectionAndKilometerCode(NameChangerEnum nameChanger, WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj, String globalId, String destinationCode, DeviceType type, String name) { TrainRunDirection direction = null; - DeviceKilometer.Builder deviceKm = getDeviceKM(obj.getLineId(), type, name); + DeviceKilometer.Builder deviceKm = getDeviceKM(nameChanger, obj.getLineId(), type, name); if (deviceKm != null && StringUtils.isNoneEmpty(destinationCode)) { DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode); // 目的地最大公里标大于设备最大公里标,上行 @@ -120,13 +121,13 @@ public abstract class LineNetTrainComMethod { * @param name 设备名称 * @return 公里标列表 */ - private static DeviceKilometer.Builder getDeviceKM(int lineId, DeviceType type, String name) { + private static DeviceKilometer.Builder getDeviceKM(NameChangerEnum nameChanger, int lineId, DeviceType type, String name) { // 非区段、道岔直接返回 if (!DeviceType.DEVICE_TYPE_TRACK.equals(type) && !DeviceType.DEVICE_TYPE_SWITCH.equals(type)) { return null; } // 转换成程序中的名称 - String convertName = DeviceNameChangerManage.findMatch(type, name); + String convertName = DeviceNameChangerManage.findMatch(nameChanger, type, name); // 获取到当前区段公里标 return LineGraphicDataRepository.getKilometerCodeList(lineId, convertName); } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainInitConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainInitConvertor.java index 8fceb2e..0fbb1e1 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainInitConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainInitConvertor.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse; @@ -13,16 +14,19 @@ import java.util.List; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -/** 接收列车初始化消息,就收转换线网的列车数据 */ +/** + * 接收列车初始化消息,就收转换线网的列车数据 + */ @Slf4j public class LineNetTrainInitConvertor extends DeviceStatusConvertor { + @Override public MessageId getMessageId() { return MessageId.TRAIN_INDICATION_INIT; } @Override - public void run(List messageDataList) { + public void run(NameChangerEnum nameChanger, List messageDataList) { List buildList = Lists.newArrayList(); try { for (MessageData data : messageDataList) { @@ -35,7 +39,7 @@ public class LineNetTrainInitConvertor extends DeviceStatusConvertor { offset.setLineId(response.getLineId()); // 线路id offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一 offset.setGroupId(trainCell.getGroupId()); // 车组号 - LineNetTrainComMethod.setTrainDirectionAndKilometerCode( + LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger, offset, trainCell.getGlobalId(), trainCell.getDestinationId(), diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRecordConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRecordConvertor.java index 66b683c..0577fa2 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRecordConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRecordConvertor.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; @@ -23,7 +24,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor { } @Override - public void run(List messageDataList) { + public void run(NameChangerEnum nameChanger, List messageDataList) { try { List buildList = Lists.newArrayList(); // 已存在的设备信息 @@ -37,7 +38,7 @@ public class LineNetTrainRecordConvertor extends DeviceStatusConvertor { LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据 offset.setDir(response.getDirection().getValue()); // 初始设置无运行方向 // 设置公里标信息 - LineNetTrainComMethod.setUpKilometerCode( + LineNetTrainComMethod.setUpKilometerCode(nameChanger, offset, DeviceType.DEVICE_TYPE_TRACK, response.getTrackName()); offset.setShow(offset.getKilometerCode() != 0); buildList.add(offset); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRemoveConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRemoveConvertor.java index aa1b1c0..d02a1e4 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRemoveConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainRemoveConvertor.java @@ -3,6 +3,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; @@ -17,7 +18,9 @@ import java.util.List; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -/** 列车信息移除时,线网信息处理 */ +/** + * 列车信息移除时,线网信息处理 + */ @Slf4j public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor { @@ -27,7 +30,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor { } @Override - public void run(List messageDataList) { + public void run(NameChangerEnum nameChanger, List messageDataList) { try { List buildList = Lists.newArrayList(); for (MessageData data : messageDataList) { @@ -39,7 +42,7 @@ public class LineNetTrainRemoveConvertor extends DeviceStatusConvertor { offset.setGroupId(response.getGroupId()); offset.setTrainIndex(response.getTrainIndex()); LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据 - LineNetTrainComMethod.setUpKilometerCode( + LineNetTrainComMethod.setUpKilometerCode(nameChanger, offset, response.getDevType(), response.getDevName()); offset.setShow(false); buildList.add(offset); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainUpdateConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainUpdateConvertor.java index 5332d58..12c17e1 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainUpdateConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/LineNetTrainUpdateConvertor.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.collect.convertor; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse; @@ -12,7 +13,9 @@ import java.util.List; import java.util.Objects; import lombok.extern.slf4j.Slf4j; -/** 列车信息更新时,信息转换 */ +/** + * 列车信息更新时,信息转换 + */ @Slf4j public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor { @@ -22,7 +25,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor { } @Override - public void run(List messageDataList) { + public void run(NameChangerEnum nameChanger, List messageDataList) { try { List buildList = Lists.newArrayList(); for (MessageData data : messageDataList) { @@ -34,7 +37,7 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor { offset.setTrainIndex(response.getTrainIndex()); // 列车标示号,全线唯一 offset.setGroupId(response.getGroupId()); // 车组号 LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据 - LineNetTrainComMethod.setTrainDirectionAndKilometerCode( + LineNetTrainComMethod.setTrainDirectionAndKilometerCode(nameChanger, offset, response.getGlobalId(), response.getDestinationId(), diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/TrainDataSource.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/TrainDataSource.java index 09e9ef9..94ee794 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/TrainDataSource.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/TrainDataSource.java @@ -39,6 +39,12 @@ public class TrainDataSource extends AbstractData { /** * 增量的设备更新信息 + *

+ * k1 数据类型 + *

+ * k2 车组号 + *

+ * v 列车数据 */ private Table trainUpdate = Tables.synchronizedTable(HashBasedTable.create()); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/HeartBeatMsg.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/HeartBeatMsg.java index cd2699f..c2df065 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/HeartBeatMsg.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/HeartBeatMsg.java @@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.line3; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.util.List; @@ -18,7 +19,7 @@ public class HeartBeatMsg extends MessageData { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { return null; } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusBitmapResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusBitmapResponse.java index 313453d..69df59f 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusBitmapResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/DeviceStatusBitmapResponse.java @@ -2,8 +2,9 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; @@ -69,14 +70,14 @@ public class DeviceStatusBitmapResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { List msgBuildList = Lists.newArrayList(); for (DeviceTypeEntity deviceTypeEntity : this.entityList) { DeviceType dt = deviceTypeEntity.getType(); for (DeviceEntity deviceEntity : deviceTypeEntity.deviceList) { GeneratedMessageV3.Builder builder = DeviceStatusConvertor.convert(dt, deviceEntity.status); // DeviceStatusConvertor.fillField(builder, "id", deviceEntity.devName); - String newOccName = DeviceNameChangerManage.findMatch(dt, deviceEntity.devName); + String newOccName = DeviceNameChangerManage.findMatch(nameChanger, dt, deviceEntity.devName); DeviceStatusConvertor.fillField(builder, "id", newOccName); DeviceStatusConvertor.fillField(builder, "rtuId", this.rtuId); DeviceStatusConvertor.fillField(builder, "timestamp", this.getTime()); 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 7dd0111..44bbd16 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 @@ -2,25 +2,21 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; -import club.joylink.xiannccda.dto.protos.DeviceStatusProto; import com.alibaba.fastjson2.JSON; -import com.google.common.collect.Lists; -import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Optional; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; /** * 2.7.5 设备状态变化消息 @@ -91,12 +87,12 @@ public class DeviceStatusChangeResponse extends MessageResponse { @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { if (Objects.isNull(this.type)) { log.error("设备变更状态类型为空:{}", JSON.toJSONString(this)); return Collections.emptyList(); } - String occName = DeviceNameChangerManage.findMatch(this.type, this.devName); + String occName = DeviceNameChangerManage.findMatch(nameChanger, this.type, this.devName); // if (this.type == DeviceType.DEVICE_TYPE_SWITCH && StringUtils.startsWith(occName, "DG")) { // this.type = DeviceType.DEVICE_TYPE_TRACK; // } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java index cb0d491..b57d990 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/InusedScheduleResponse.java @@ -1,6 +1,7 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.device.ScheduleSubIdType; import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData; @@ -83,7 +84,7 @@ public class InusedScheduleResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { List planBuilds = Lists.newArrayList(); if (CollectionUtils.isEmpty(this.entityList)) { Plan.Builder planBuild = Plan.newBuilder(); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainBlockInfoResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainBlockInfoResponse.java index 3da4641..9fd155b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainBlockInfoResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainBlockInfoResponse.java @@ -1,6 +1,7 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.line3.MessageCons; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; @@ -48,7 +49,7 @@ public class TrainBlockInfoResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { List builders = Lists.newArrayList(); for (TrainCell train : this.trains) { TrainBlock.Builder builder = TrainBlock.newBuilder(); diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationInitResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationInitResponse.java index 21e3e7e..5e5295d 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationInitResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationInitResponse.java @@ -1,10 +1,11 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.MessageCons; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; @@ -54,7 +55,7 @@ public class TrainIndicationInitResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { List msgBuildList = Lists.newArrayList(); for (TrainCell trainCell : this.trains) { TrainInfo.Builder builder = TrainInfo.newBuilder(); @@ -75,7 +76,7 @@ public class TrainIndicationInitResponse extends MessageResponse { } // builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), "")); - String occName = DeviceNameChangerManage.findMatch(trainCell.getDevType(), trainCell.getDevName()); + String occName = DeviceNameChangerManage.findMatch(nameChanger, trainCell.getDevType(), trainCell.getDevName()); builder.setDevName(occName); if (trainCell.devType == DeviceType.DEVICE_TYPE_SWITCH) { //车辆在道岔时,转换对应的设备类型 diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationRemoveResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationRemoveResponse.java index e614f8b..0aa0748 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationRemoveResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationRemoveResponse.java @@ -1,8 +1,9 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.line3.MessageCons; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow; @@ -79,7 +80,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { TrainRemove.Builder trainRemove = TrainRemove.newBuilder(); trainRemove.setReceiveTime(System.currentTimeMillis()); if (Objects.nonNull(this.lineId)) { @@ -100,7 +101,7 @@ public class TrainIndicationRemoveResponse extends MessageResponse { trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal())); } // trainRemove.setDevName(StringUtils.defaultString(this.devName, "")); - String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName); + String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName); trainRemove.setDevName(occName); if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) { //车辆在道岔时,转换对应的设备类型 diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationUpdateResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationUpdateResponse.java index 12f614e..8b4631b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationUpdateResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationUpdateResponse.java @@ -1,10 +1,11 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.MessageCons; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto; @@ -20,7 +21,6 @@ import java.util.List; import java.util.Objects; import lombok.Getter; import lombok.Setter; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; /** @@ -127,7 +127,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse { } @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder(); train.setReceiveTime(System.currentTimeMillis()); @@ -148,7 +148,7 @@ public class TrainIndicationUpdateResponse extends MessageResponse { } // train.setDevName(StringUtils.defaultString(this.devName, "")); - String occName = DeviceNameChangerManage.findMatch(this.devType, this.devName); + String occName = DeviceNameChangerManage.findMatch(nameChanger, this.devType, this.devName); train.setDevName(occName); if (this.devType == DeviceType.DEVICE_TYPE_SWITCH) { //车辆在道岔时,转换对应的设备类型 diff --git a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainRecordResponse.java b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainRecordResponse.java index f7ba3b0..4add69e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainRecordResponse.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainRecordResponse.java @@ -1,16 +1,13 @@ package club.joylink.xiannccda.ats.message.line3.rep; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.line3.DateTimeUtil; import club.joylink.xiannccda.ats.message.line3.MessageCons; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; -import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse.TrainCell; -import club.joylink.xiannccda.dto.protos.DeviceStatusProto; -import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRecord; import com.google.common.collect.Lists; -import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.GeneratedMessageV3.Builder; import io.netty.buffer.ByteBuf; import java.time.ZoneOffset; @@ -133,7 +130,7 @@ public class TrainRecordResponse extends MessageResponse { @Override - public List generateProto() { + public List generateProto(NameChangerEnum nameChanger) { TrainRecord.Builder builder = TrainRecord.newBuilder(); builder.setReceiveTime(System.currentTimeMillis()); @@ -164,7 +161,7 @@ public class TrainRecordResponse extends MessageResponse { builder.setSideId(this.getSideId()); } builder.setTrackName(StringUtils.defaultString(this.trackName, "")); - String deviceName = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, builder.getTrackName()); + String deviceName = DeviceNameChangerManage.findMatch(nameChanger, DeviceType.DEVICE_TYPE_TRACK, builder.getTrackName()); builder.setTrackName(deviceName); if (this.getRecordType() != null) { builder.setRecordType(this.getRecordType()); diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/platform/TrainReacrdAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/platform/TrainReacrdAlertListener.java index a1cd1cd..d5f5304 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/platform/TrainReacrdAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/platform/TrainReacrdAlertListener.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertSourceEventListener; import club.joylink.xiannccda.ats.message.line3.rep.TrainRecordResponse.DirectionEnum; import club.joylink.xiannccda.ats.warn.DeviceAlertEvent; import club.joylink.xiannccda.ats.warn.platform.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.Builder; import lombok.extern.slf4j.Slf4j; @@ -17,8 +17,7 @@ import org.springframework.stereotype.Component; public class TrainReacrdAlertListener implements AlertSourceEventListener { private final PlatformAlertMonitoringTask platformAlertMonitoringTask; - @Autowired - private OccNotHandlePros notHandlePros; + public TrainReacrdAlertListener(PlatformAlertMonitoringTask platformAlertMonitoringTask) { this.platformAlertMonitoringTask = platformAlertMonitoringTask; diff --git a/src/main/java/club/joylink/xiannccda/configuration/pros/OccNotHandlePros.java b/src/main/java/club/joylink/xiannccda/configuration/pros/OccNotHandlePros.java deleted file mode 100644 index 5ee4e92..0000000 --- a/src/main/java/club/joylink/xiannccda/configuration/pros/OccNotHandlePros.java +++ /dev/null @@ -1,33 +0,0 @@ -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 filterRtuIds; - private Map> 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; - } - -} diff --git a/src/main/java/club/joylink/xiannccda/constants/SystemContext.java b/src/main/java/club/joylink/xiannccda/constants/SystemContext.java index a97410b..194dc31 100644 --- a/src/main/java/club/joylink/xiannccda/constants/SystemContext.java +++ b/src/main/java/club/joylink/xiannccda/constants/SystemContext.java @@ -1,6 +1,6 @@ package club.joylink.xiannccda.constants; -import club.joylink.xiannccda.configuration.pros.OccNotHandlePros; +import club.joylink.xiannccda.ats.message.OccMessageManage; import club.joylink.xiannccda.ws.msg.SystemWarnEvent; import lombok.Getter; import org.springframework.beans.BeansException; @@ -26,7 +26,7 @@ public class SystemContext implements ApplicationContextAware { } public static boolean notMatchRtu(Integer lineId, Integer rtuId) { - OccNotHandlePros cu = SystemContext.getAppContext().getBean(OccNotHandlePros.class); + OccMessageManage cu = SystemContext.getAppContext().getBean(OccMessageManage.class); return cu.notMatchHandle(lineId, rtuId); } diff --git a/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java b/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java index 8f1bccd..19d0215 100644 --- a/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java +++ b/src/main/java/club/joylink/xiannccda/mock/message/MockLoadData.java @@ -3,6 +3,7 @@ package club.joylink.xiannccda.mock.message; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertorManager; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -64,7 +65,7 @@ public class MockLoadData implements ApplicationRunner { // .ne(NccMockData::getIsDelete, 1) .orderBy(true, true, NccMockData::getId); List dataList = this.nccMockDataService.loadALLData(wrapper); - DeviceStatusConvertorManager.doConvertor(dataList.stream().map(d -> (MessageData) d).collect(Collectors.toList())); + DeviceStatusConvertorManager.doConvertor(NameChangerEnum.UNIVERSAL, dataList.stream().map(d -> (MessageData) d).collect(Collectors.toList())); } catch (Exception e) { log.error(e.getMessage(), e); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 33bcb5a..f42d42b 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -14,12 +14,22 @@ logging: com.zaxxer.hikari: debug file: path: /usr/local/joylink/logs/xianncc -occ: - host: localhost - realPort: 2603 - unRealPort: 123 - lineId: 3 - collectorData: false + +occ-client: + clientInfoMap: + 3: + server-host: 127.0.0.1 + real-port: 2603 + un-real-port: 5703 + line-id: 3 + collector-data: false + monitor-handware-change: false + receiveMsgTimeout: 6 + filterRtuIds: + - 81 + - 82 + nameChanger: UNIVERSAL + #故障测试 mock-alert-test: false #加载历史模拟数据 diff --git a/src/main/resources/application-local-test.yml b/src/main/resources/application-local-test.yml index c60a814..8e89e23 100644 --- a/src/main/resources/application-local-test.yml +++ b/src/main/resources/application-local-test.yml @@ -13,11 +13,19 @@ logging: file: path: /usr/local/joylink/logs/xianncc occ: - host: localhost - realPort: 2603 - unRealPort: 123 - lineId: 3 - collectorData: false + clientInfoMap: + 3: + nameChanger: UNIVERSAL + server-host: 127.0.0.1 + real-port: 2603 + un-real-port: 5703 + line-id: 3 + collector-data: false + monitor-handware-change: false + receiveMsgTimeout: 6 + filterRtuIds: + - 81 + - 82 #故障测试 mock-alert-test: true #加载历史模拟数据 diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 616def4..07e0386 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -15,14 +15,22 @@ logging: path: /usr/xianncc max-size: 40MB -occ: - host: 127.0.0.1 - realPort: 2603 - # host: 10.255.11.15 - # realPort: 5603 - unRealPort: 5703 - lineId: 3 - collectorData: false +occ-client: + clientInfoMap: + 3: + server-host: 127.0.0.1 + real-port: 2603 + un-real-port: 5703 + line-id: 3 + collector-data: false + monitor-handware-change: false + receiveMsgTimeout: 6 + filterRtuIds: + - 81 + - 82 + nameChanger: UNIVERSAL + + mock-alert-test: true load-mock-history-data: false #延时加载告警处理 diff --git a/src/main/resources/application-master.yml b/src/main/resources/application-master.yml index 56262d4..b8a138f 100644 --- a/src/main/resources/application-master.yml +++ b/src/main/resources/application-master.yml @@ -19,12 +19,20 @@ logging: club.joylink.xiannccda.ats.message.line3.rep: debug club.joylink.xiannccda.mapper: debug com.zaxxer.hikari: debug -occ: - host: 10.255.11.15 - realPort: 5603 - unRealPort: 5703 - lineId: 3 - collectorData: false +occ-client: + clientInfoMap: + 3: + nameChanger: UNIVERSAL + server-host: 10.255.11.15 + real-port: 5603 + un-real-port: 5703 + collector-data: false + monitor-handware-change: false + receiveMsgTimeout: 6 + filterRtuIds: + - 81 + - 82 + mock-alert-test: false load-mock-history-data: false #延时加载告警处理 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index adcc38e..ae03e08 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -16,12 +16,20 @@ logging: level: root: "info" -occ: - host: 10.255.11.15 - realPort: 5603 - unRealPort: 5703 - lineId: 3 - collectorData: false +occ-client: + clientInfoMap: + 3: + nameChanger: UNIVERSAL + server-host: 10.255.11.15 + real-port: 5603 + un-real-port: 5703 + collector-data: false + monitor-handware-change: false + receiveMsgTimeout: 6 + filterRtuIds: + - 81 + - 82 + mock-alert-test: false load-mock-history-data: false #延时加载告警处理 diff --git a/src/test/java/club/joylink/xiannccda/device/DeviceStatusTest.java b/src/test/java/club/joylink/xiannccda/device/DeviceStatusTest.java index 0bf370e..613fa85 100644 --- a/src/test/java/club/joylink/xiannccda/device/DeviceStatusTest.java +++ b/src/test/java/club/joylink/xiannccda/device/DeviceStatusTest.java @@ -3,6 +3,7 @@ package club.joylink.xiannccda.device; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate; import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataRepository; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; @@ -136,7 +137,7 @@ public class DeviceStatusTest { Set rtuSet = new HashSet<>(); for (MessageResponse messageDatum : messageData) { - List msgs = messageDatum.generateProto(); + List msgs = messageDatum.generateProto(NameChangerEnum.UNIVERSAL); for (Builder msg : msgs) { Integer rtuId = DeviceStatusDataOperate.findFieldVal(msg, "rtuId", Integer.class); rtuSet.add(rtuId); diff --git a/src/test/java/club/joylink/xiannccda/device/TrainDataTest.java b/src/test/java/club/joylink/xiannccda/device/TrainDataTest.java index 6c0236d..4919b53 100644 --- a/src/test/java/club/joylink/xiannccda/device/TrainDataTest.java +++ b/src/test/java/club/joylink/xiannccda/device/TrainDataTest.java @@ -3,6 +3,7 @@ package club.joylink.xiannccda.device; import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.MessageResponse; +import club.joylink.xiannccda.ats.message.changer.NameChangerEnum; import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus; import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus.PLATFORM; @@ -205,9 +206,9 @@ public class TrainDataTest { List messageData = this.dataService.loadALLData(wrapper); for (MessageResponse messageDatum : messageData) { - List msgs = messageDatum.generateProto(); + List msgs = messageDatum.generateProto(NameChangerEnum.UNIVERSAL); System.out.println(messageDatum); - System.out.println(messageDatum.generateProto()); + System.out.println(messageDatum.generateProto(NameChangerEnum.UNIVERSAL)); } } diff --git a/src/test/java/club/joylink/xiannccda/util/Device.java b/src/test/java/club/joylink/xiannccda/util/Device.java index 8bd52f8..3799983 100644 --- a/src/test/java/club/joylink/xiannccda/util/Device.java +++ b/src/test/java/club/joylink/xiannccda/util/Device.java @@ -1,6 +1,6 @@ package club.joylink.xiannccda.util; -import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.changer.DeviceNameChangerManage; import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; @@ -86,7 +86,7 @@ public abstract class Device { @Override public String changeDeviceName(String nccDeviceName) { - return DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, nccDeviceName); + return DeviceNameChangerManage.findMatch(3, DeviceType.DEVICE_TYPE_SWITCH, nccDeviceName); } } @@ -114,10 +114,8 @@ public abstract class Device { @Override String changeDeviceName(String nccDeviceName) { - if (StringUtils.equals(nccDeviceName, "T13301C")) { - System.out.println("aaaaaaaaaaaaaa"); - } - return DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_TRACK, nccDeviceName); + + return DeviceNameChangerManage.findMatch(3, DeviceType.DEVICE_TYPE_TRACK, nccDeviceName); } } @@ -131,7 +129,7 @@ public abstract class Device { @Override String changeDeviceName(String nccDeviceName) { - return DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SIGNAL, nccDeviceName); + return DeviceNameChangerManage.findMatch(3, DeviceType.DEVICE_TYPE_SIGNAL, nccDeviceName); } }