From b2894c960b2ed2c5529acbff2841df263095635e Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 22 Dec 2023 11:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=85=E9=9A=9C=E6=B5=8B=E8=AF=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mock/message/occ/MockOccServer.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) 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 1d5705e..1102be8 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 @@ -16,6 +16,7 @@ import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Track; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout; import club.joylink.xiannccda.mock.message.occ.req.MockDeviceStatusReq; import club.joylink.xiannccda.mock.message.occ.req.MockTrainRecordReq; import club.joylink.xiannccda.mock.message.occ.req.MockTrainUpdateReq; @@ -149,13 +150,17 @@ public class MockOccServer { private Integer findDeviceRtuId(Integer lineId, DeviceType dt, String deviceName, AlertType alertType) { if (alertType == AlertType.AXLE_LED_RED || alertType == AlertType.AXLE_LED_ORANGE) { - String axleSectionCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, deviceName); - MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, axleSectionCode); - Integer stationId = DeviceStatusDataOperate.findFieldVal(section, "centralizedStationId", Integer.class); -// LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(lineId, stationId.toString(), LayoutGraphicsProto.Station.class); -// System.out.println(section); -// return Integer.parseInt(station.getCode()); - return this.findRtuStation(lineId, stationId); + MessageOrBuilder t = LineGraphicDataRepository.getDeviceByCodeNotException(lineId, deviceName); + + if (t instanceof Turnout) { + Integer stationId = DeviceStatusDataOperate.findFieldVal(t, "centralizedStationId", Integer.class); + return this.findRtuStation(lineId, stationId); + } else { + String axleSectionCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(lineId, deviceName); + MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, axleSectionCode); + Integer stationId = DeviceStatusDataOperate.findFieldVal(section, "centralizedStationId", Integer.class); + return this.findRtuStation(lineId, stationId); + } } else if (alertType == AlertType.BLUE_DISPLAY) { Optional stationOptional = LineGraphicDataRepository.getDevices(lineId, LayoutGraphicsProto.Station.class).filter(d -> StringUtils.equals(d.getCode(), deviceName)) .findFirst(); @@ -163,12 +168,9 @@ public class MockOccServer { return this.findRtuStation(lineId, stationOptional.get().getCommon().getId()); } } else if (alertType == AlertType.SWITCH_LOST) { - String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, deviceName); - MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode); - Integer stationId = DeviceStatusDataOperate.findFieldVal(section, "centralizedStationId", Integer.class); - System.out.println(section); -// LayoutGraphicsProto.Station station = LineGraphicDataRepository.getDeviceByCode(lineId, stationId.toString(), LayoutGraphicsProto.Station.class); -// return Integer.parseInt(station.getCode()); + MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCode(lineId, deviceName); + Integer stationId = DeviceStatusDataOperate.findFieldVal(mb, "centralizedStationId", Integer.class); + System.out.println(mb); return this.findRtuStation(lineId, stationId); } return null;