From 8da937e941842d8d39dfe67f35effefccfceaf0a Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 11 Mar 2021 13:26:48 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E4=BB=BF=E7=9C=9F=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E2=80=94=E2=80=94=E8=99=9A=E6=8B=9F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=80=BB=E8=BE=91=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/Simulation.java | 37 +++----- .../rtss/simulation/rt/srd/SrdService.java | 87 +++++++++++++++++-- .../rtss/simulation/rt/srd/bo/SrAXC.java | 15 ++++ .../rtss/simulation/rt/srd/bo/SrDevice.java | 21 +++++ .../rtss/simulation/rt/srd/bo/SrPSD.java | 49 +++++++++-- .../rtss/simulation/rt/srd/bo/SrSignal.java | 75 +++++++++++++--- .../rtss/simulation/rt/srd/bo/SrTrack.java | 14 ++- .../rtss/simulation/rt/srd/bo/SrTrain.java | 12 ++- .../rtss/simulation/rt/srd/bo/SrTurnout.java | 47 +++++++++- .../simulation/rt/srd/bo/SrdRepository.java | 12 +++ .../simulation/rt/srd/bo/TrackPosition.java | 3 + .../SessionAuthHandshakeInterceptor.java | 3 + .../client/SimulationSessionHandler.java | 38 ++++++++ .../websocket/client/StompClientManager.java | 27 ++++++ 14 files changed, 374 insertions(+), 66 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/websocket/client/SimulationSessionHandler.java create mode 100644 src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index a3a5bec3b..9f0ffc592 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -42,7 +42,7 @@ public abstract class Simulation { - log.info("logic"); - }, 500); - simulation.addFixedRateJob("c", () -> { - log.warn("fixed"); - }, 1000); - simulation.updateSpeed(5); - simulation.start(); - } private void runAsSpeed() { if (this.future == null) { -// if (!this.future.cancel(false)) { -// log.error(String.format("仿真旧主线程无法取消")); -// } ScheduledFuture scheduledFuture = EXECUTOR.scheduleAtFixedRate(()->this.logic(), this.SYSTEM_TIME_RATE, this.SYSTEM_TIME_RATE, TimeUnit.MILLISECONDS); this.future = scheduledFuture; @@ -119,7 +101,7 @@ public abstract class Simulation this.srTrainRun(rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class)), TRAIN_RUN_RATE); + rtSimulation.addJob("srDeviceLogic", + () -> this.srDeviceLogic(rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class), rtSimulation.getSystemTime()), + DEVICE_RUN_RATE); + } + + private void srDeviceLogic(SrdRepository repository, LocalDateTime systemTime) { + // 道岔转动 + List turnoutList = repository.getTurnoutList(); + for (SrTurnout turnout : turnoutList) { + if (turnout.isControlByReal()) { + continue; + } + if (turnout.isTurning()) { + turnout.tryFinishTurning(systemTime); + } + } + // 屏蔽门开/闭 + List psdList = repository.getPsdList(); + for (SrPSD psd : psdList) { + if (psd.isControlByReal()) { + continue; + } + if (psd.isTurning()) { + psd.tryFinishTurning(systemTime); + } + } + // 信号机控制 + List signalList = repository.getSignalList(); + for (SrSignal signal : signalList) { + if (signal.isControlByReal()) { + continue; + } + if (signal.isTurning()) { + signal.tryFinishTurning(systemTime); + } + } } public void srTrainRun(SrdRepository repository) { @@ -31,20 +71,35 @@ public class SrdService { if (!srTrain.isUsing()) { continue; } - TrackPosition position = srTrain.getHeadPosition(); + // 计算列车加速度,更新列车速度,计算列车运行距离,更新列车位置 boolean right = srTrain.isRight(); + TrackPosition position = srTrain.getHeadPosition(); int cv = this.calculateSpeed(srTrain); - int s = this.calculateLen(cv, TRAIN_RUN_RATE); - TrackPosition np = calculatePosition(position, s, right); + int s = this.calculateLen(srTrain, cv, TRAIN_RUN_RATE); + TrackPosition np = calculatePosition(position, s, right, new HashSet<>()); if (np.equals(position) && cv != 0) { cv = 0; } - srTrain.updatePositionAndSpeed(np, cv); + Set occupiedTrackSet = new HashSet<>(); + TrackPosition tailPosition = this.calculatePosition(np, srTrain.getLen(), !right, occupiedTrackSet); + srTrain.updatePositionAndSpeed(np, tailPosition, cv); + // 更新计轴占用 + Set oldOccupiedTrackSet = new HashSet<>(); + this.calculatePosition(position, srTrain.getLen(), !right, oldOccupiedTrackSet); + Set clearList = new HashSet<>(oldOccupiedTrackSet); + clearList.removeAll(occupiedTrackSet); + for (SrTrack srTrack : clearList) { + srTrack.getAxc().clear(); + } + for (SrTrack srTrack : occupiedTrackSet) { + srTrack.getAxc().occupy(); + } } } - private int calculateLen(int cv, int time) { - return cv * time; + private int calculateLen(SrTrain srTrain, int cv, int time) { + int s = cv * time; + return s * srTrain.getGear(); } private int calculateSpeed(SrTrain srTrain) { @@ -61,10 +116,21 @@ public class SrdService { if (cv < 0) { cv = 0; } + if (srTrain.isNeutralGear() && cv > 0) { // 空档位 + cv = 0; + } return cv; } - private TrackPosition calculatePosition(TrackPosition position, int s, boolean right) { + /** + * + * @param position 起始位置 + * @param s 距离 + * @param right 方向 + * @param trackSet 从position往方向[right]经过距离[s]所经过的轨道列表 + * @return + */ + private TrackPosition calculatePosition(TrackPosition position, int s, boolean right, Set trackSet) { if (s == 0) { return position; } @@ -76,7 +142,11 @@ public class SrdService { offset -= s; } SrTrack base = track; + trackSet.add(base); + int iter = 0; while (offset < 0 || offset > base.getLen()) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(iter < 10); + ++iter; SrTrack nextTrack = base.queryNextTrack(right); if (nextTrack == null) { // 下一区段为空,到达尽头或道岔失表处 log.debug(String.format("区段[%s][%s]区段不存在",base.debugStr(), right?"右向":"左向")); @@ -95,6 +165,7 @@ public class SrdService { offset += nextTrack.getLen(); } base = nextTrack; + trackSet.add(nextTrack); } } return new TrackPosition(base, offset); diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java index b1f73be6c..26847f177 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java @@ -14,4 +14,19 @@ public class SrAXC extends SrDevice { public SrAXC(String id) { super(id, DeviceType.AXC); } + + public void clear() { + this.state.set(OFF); + } + + public void occupy() { + if (this.state.get() != ON) { + this.state.set(ON); + } + } + + @Override + public void applyState(int state) { + + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java index eb7a251f2..8f2c07115 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java @@ -3,6 +3,8 @@ package club.joylink.rtss.simulation.rt.srd.bo; import club.joylink.rtss.simulation.Debug; import lombok.Getter; +import java.util.Objects; + /** * 虚拟真实设备抽象父类 */ @@ -10,6 +12,10 @@ import lombok.Getter; public abstract class SrDevice implements Debug { String id; DeviceType deviceType; + /** + * 是否由真实设备控制 + */ + boolean controlByReal; public SrDevice() {} @@ -18,8 +24,23 @@ public abstract class SrDevice implements Debug { this.deviceType = deviceType; } + public abstract void applyState(int state); + @Override public String debugStr() { return String.format("%s:%s", this.deviceType, this.id); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SrDevice srDevice = (SrDevice) o; + return Objects.equals(id, srDevice.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java index e72bc664f..371e83363 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java @@ -1,5 +1,7 @@ package club.joylink.rtss.simulation.rt.srd.bo; +import java.time.LocalDateTime; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** @@ -11,19 +13,56 @@ public class SrPSD extends SrDevice { AtomicInteger state = new AtomicInteger(CLOSE_LOCK); public static final int CLOSE_LOCK = 1;//关闭且锁闭 public static final int CLOSED = 2;//关闭未锁闭 - public static final int OPEN = 3;//打开未到位 + public static final int TURNING = 3;//转换中 public static final int OPEN_FINISH = 4;//打开到位 AtomicInteger command = new AtomicInteger(NONE); public static final int NONE = 0;//无动作 - public static final int C_OPEN = 1;//控制开门 - public static final int C_CLOSE = 2;//控制关门 /** - * 剩余动作时间 + * 转换完成时间 */ - int remain; + LocalDateTime finishTime; public SrPSD(String id) { super(id, DeviceType.PSD); } + + public boolean isTurning() { + return NONE != this.command.get(); + } + + public void open(LocalDateTime systemTime) { + this.startTurn(systemTime, OPEN_FINISH); + } + + public void close(LocalDateTime systemTime) { + this.startTurn(systemTime, CLOSE_LOCK); + } + + private void startTurn(LocalDateTime systemTime, int command) { + this.finishTime = systemTime.plusNanos(TimeUnit.MILLISECONDS.toNanos(turnTime)); + this.command.set(command); + this.state.set(TURNING); + } + + public void tryFinishTurning(LocalDateTime systemTime) { + if (this.finishTime != null && systemTime.compareTo(this.finishTime) >= 0) { + this.turnFinish(); + } + } + + public void turnFinish() { + this.state.set(this.command.get()); + this.command.set(NONE); + this.finishTime = null; + } + + @Override + public void applyState(int state) { + if (CLOSE_LOCK == state || CLOSED == state || TURNING == state || OPEN_FINISH == state) { + this.state.set(state); + } else { + throw new IllegalArgumentException(String.format("无效的屏蔽门状态:[%s]", state)); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java index f61cf334f..2e3eb7516 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java @@ -2,6 +2,8 @@ package club.joylink.rtss.simulation.rt.srd.bo; import lombok.Getter; +import java.time.LocalDateTime; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** @@ -9,6 +11,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ @Getter public class SrSignal extends SrDevice { + public static final int turnTime = 500; // 默认转换时间,单位ms /** * 所在区段 @@ -20,19 +23,18 @@ public class SrSignal extends SrDevice { int offset; AtomicInteger state = new AtomicInteger(CLOSE); - public static final int CLOSE = 1; - public static final int RED = 2; - public static final int GREEN = 3; - public static final int YELLOW = 4; - public static final int RED_YELLOW = 5; + public static final int CLOSE = 1; // 关闭 + public static final int RED = 2; // 红灯信号(禁止信号) + public static final int GREEN = 3; // 绿灯信号(直向通行) + public static final int YELLOW = 4; // 黄灯信号(侧向通行) + public static final int GUIDE = 5; // 引导信号(正线为黄红) - AtomicInteger command = new AtomicInteger(C_NONE); - public static final int C_NONE = 0; - public static final int C_CLOSE = 1; - public static final int C_RED = 2; - public static final int C_GREEN = 3; - public static final int C_YELLOW = 4; - public static final int C_RED_YELLOW = 5; + AtomicInteger command = new AtomicInteger(NONE); + public static final int NONE = 0; + /** + * 转换完成时间 + */ + LocalDateTime finishTime; public SrSignal(String id) { super(id, DeviceType.SIGNAL); @@ -42,4 +44,53 @@ public class SrSignal extends SrDevice { this.track = srTrack; this.offset = offset; } + + public boolean isTurning() { + return NONE != this.command.get(); + } + + public void close(LocalDateTime systemTime) { + this.startTurn(systemTime, CLOSE); + } + + public void openRed(LocalDateTime systemTime) { + this.startTurn(systemTime, RED); + } + + public void openGreen(LocalDateTime systemTime) { + this.startTurn(systemTime, GREEN); + } + + public void openYellow(LocalDateTime systemTime) { + this.startTurn(systemTime, YELLOW); + } + + public void openGuide(LocalDateTime systemTime) { + this.startTurn(systemTime, GUIDE); + } + + private void startTurn(LocalDateTime systemTime, int command) { + this.finishTime = systemTime.plusNanos(TimeUnit.MILLISECONDS.toNanos(turnTime)); + this.command.set(command); + } + + public void tryFinishTurning(LocalDateTime systemTime) { + if (this.finishTime != null && systemTime.compareTo(this.finishTime) >= 0) { + this.turnFinish(); + } + } + + public void turnFinish() { + this.state.set(this.command.get()); + this.command.set(NONE); + this.finishTime = null; + } + @Override + public void applyState(int state) { + if (CLOSE == state || RED == state || GREEN == state || YELLOW == state || GUIDE == state) { + this.state.set(state); + } else { + throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java index d8e2c5250..1aa38c7a9 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java @@ -14,14 +14,6 @@ public class SrTrack extends SrDevice implements Debug { * 轨道长度,单位mm */ int len; - /** - * 左停车点,单位mm - */ - int leftPs; - /** - * 右停车点,单位mm - */ - int rightPs; /** * 计轴器 */ @@ -104,8 +96,14 @@ public class SrTrack extends SrDevice implements Debug { return null; } + @Override + public void applyState(int state) { + + } + @Override public String debugStr() { return String.format("%s(%s)", this.name, this.id); } + } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java index 7633794d7..a1e187d9a 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java @@ -51,7 +51,7 @@ public class SrTrain extends SrDevice { /** * 档位 */ - int gear = NEUTRAL; + int gear; public static final int NEUTRAL = 0; //空挡 public static final int FORWARD = 1; //前进挡 public static final int REVERSE = -1; //后退档 @@ -72,8 +72,14 @@ public class SrTrain extends SrDevice { return NEUTRAL == this.gear; } - public void updatePositionAndSpeed(TrackPosition position, int v) { - this.headPosition = position; + public void updatePositionAndSpeed(TrackPosition headPosition, TrackPosition tailPosition, int v) { + this.headPosition = headPosition; + this.tailPosition = tailPosition; this.speed = v; } + + @Override + public void applyState(int state) { + + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java index a2aa90b8e..dff30455c 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java @@ -1,5 +1,7 @@ package club.joylink.rtss.simulation.rt.srd.bo; +import java.time.LocalDateTime; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /** @@ -19,12 +21,10 @@ public class SrTurnout extends SrDevice { AtomicInteger command = new AtomicInteger(NONE); public static final int NONE = 0; - public static final int TN = 1; // 定操/转动到定位 - public static final int TR = 2; // 反操/转动到反位 /** - * 转换剩余时间,单位ms + * 转换完成时间 */ - int remain; + LocalDateTime finishTime; public SrTurnout(String id) { super(id, DeviceType.TURNOUT); @@ -53,4 +53,43 @@ public class SrTurnout extends SrDevice { public boolean isReversePosition() { return REVERSE == this.state.get(); } + + public boolean isTurning() { + return NONE != this.command.get(); + } + + public void turnToNormal(LocalDateTime systemTime) { + this.startTurn(systemTime, NORMAL); + } + + public void turnToReverse(LocalDateTime systemTime) { + this.startTurn(systemTime, REVERSE); + } + + private void startTurn(LocalDateTime systemTime, int command) { + this.finishTime = systemTime.plusNanos(TimeUnit.MILLISECONDS.toNanos(turnTime)); + this.command.set(command); + this.state.set(TURNING); + } + + public void tryFinishTurning(LocalDateTime systemTime) { + if (this.finishTime != null && systemTime.compareTo(this.finishTime) >= 0) { + this.turnFinish(); + } + } + + public void turnFinish() { + this.state.set(this.command.get()); + this.command.set(NONE); + this.finishTime = null; + } + + @Override + public void applyState(int state) { + if (NORMAL == state || REVERSE == state || TURNING == state) { + this.state.set(state); + } else { + throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java index 607ee244e..80db54bba 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java @@ -31,6 +31,18 @@ public class SrdRepository extends SimulationRepository { return new ArrayList<>(this.trainMap.values()); } + public List getTurnoutList() { + return new ArrayList<>(this.turnoutMap.values()); + } + + public List getPsdList() { + return new ArrayList<>(this.psdMap.values()); + } + + public List getSignalList() { + return new ArrayList<>(this.signalMap.values()); + } + @Override public void initState() { diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/TrackPosition.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/TrackPosition.java index 087442a85..963d22def 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/TrackPosition.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/TrackPosition.java @@ -2,6 +2,9 @@ package club.joylink.rtss.simulation.rt.srd.bo; public class TrackPosition { SrTrack track; + /** + * 轨道偏移量,单位mm + */ int offset; public TrackPosition(SrTrack track, int offset) { diff --git a/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java b/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java index e3544a319..c1c77af67 100644 --- a/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java +++ b/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java @@ -5,6 +5,7 @@ import club.joylink.rtss.services.LoginSessionManager; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.util.StringUtils; @@ -34,6 +35,7 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor { } catch (Throwable e) { log.error("未登录或登陆已过期", e); } + response.setStatusCode(HttpStatus.UNAUTHORIZED); return false; } @@ -71,5 +73,6 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor { @Override public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { + } } diff --git a/src/main/java/club/joylink/rtss/websocket/client/SimulationSessionHandler.java b/src/main/java/club/joylink/rtss/websocket/client/SimulationSessionHandler.java new file mode 100644 index 000000000..76aa57332 --- /dev/null +++ b/src/main/java/club/joylink/rtss/websocket/client/SimulationSessionHandler.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.websocket.client; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.simp.stomp.StompCommand; +import org.springframework.messaging.simp.stomp.StompHeaders; +import org.springframework.messaging.simp.stomp.StompSession; +import org.springframework.messaging.simp.stomp.StompSessionHandler; + +import java.lang.reflect.Type; + +@Slf4j +public class SimulationSessionHandler implements StompSessionHandler { + @Override + public void afterConnected(StompSession session, StompHeaders connectedHeaders) { + log.debug(String.format("stomp websocket connected")); + } + + @Override + public void handleException(StompSession session, StompCommand command, StompHeaders headers, byte[] payload, Throwable exception) { + log.error("stomp handle exception", exception); + } + + @Override + public void handleTransportError(StompSession session, Throwable exception) { + log.error("stomp handle transport error", exception); + } + + @Override + public Type getPayloadType(StompHeaders headers) { + return String.class; + } + + @Override + public void handleFrame(StompHeaders headers, Object payload) { + String json = (String) payload; + log.debug(String.format("receive frame:%s", json)); + } +} diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java new file mode 100644 index 000000000..79881a579 --- /dev/null +++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.websocket.client; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.messaging.simp.stomp.StompSession; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.socket.client.standard.StandardWebSocketClient; +import org.springframework.web.socket.messaging.WebSocketStompClient; + +import java.util.concurrent.ExecutionException; + +@Slf4j +public class StompClientManager { + +// private static final Map stompClientMap = new ConcurrentHashMap<>(); + + public static void main(String[] args) throws ExecutionException, InterruptedException { + StandardWebSocketClient socketClient = new StandardWebSocketClient(); + WebSocketStompClient stompClient = new WebSocketStompClient(socketClient); + SimulationSessionHandler handler = new SimulationSessionHandler(); + ListenableFuture future = stompClient + .connect("ws://192.168.8.129:9000/joylink-websocket?token=aaa", + handler, "null"); + StompSession stompSession = future.get(); + stompSession.subscribe("/user/queue/simulation/1/", handler); + } + +} From 7c72507527c170ce88e4e414159975b1e41bbecf Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Fri, 12 Mar 2021 18:54:14 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=96=B0=E4=BB=BF=E7=9C=9F=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E2=80=94=E2=80=94=E8=AE=A1=E7=AE=97=E6=9C=BA=E8=81=94?= =?UTF-8?q?=E9=94=81=E6=A8=A1=E5=9D=97=E5=BC=80=E5=8F=91=20=E4=BB=BF?= =?UTF-8?q?=E7=9C=9F=E5=8F=91=E5=B8=83=E6=B6=88=E6=81=AF=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/Simulation.java | 21 ++++++++++---- .../simulation/rt/CIL/CilLogicService.java | 10 +++++++ .../simulation/rt/CIL/bo/CilAutoSignal.java | 8 ++++++ .../rtss/simulation/rt/CIL/bo/CilDevice.java | 22 +++++++++++++++ .../rtss/simulation/rt/CIL/bo/CilEsp.java | 8 ++++++ .../rtss/simulation/rt/CIL/bo/CilFls.java | 24 ++++++++++++++++ .../rtss/simulation/rt/CIL/bo/CilPath.java | 15 ++++++++++ .../rtss/simulation/rt/CIL/bo/CilPsd.java | 8 ++++++ .../simulation/rt/CIL/bo/CilRepository.java | 26 +++++++++++++++++ .../rt/CIL/bo/CilRepositoryBuilder.java | 28 +++++++++++++++++++ .../rtss/simulation/rt/CIL/bo/CilRoute.java | 14 ++++++++++ .../rtss/simulation/rt/CIL/bo/CilSection.java | 17 +++++++++++ .../rtss/simulation/rt/CIL/bo/CilServer.java | 10 +++++++ .../rtss/simulation/rt/CIL/bo/CilSignal.java | 17 +++++++++++ .../rtss/simulation/rt/CIL/bo/CilStand.java | 8 ++++++ .../rtss/simulation/rt/CIL/bo/CilSwitch.java | 19 +++++++++++++ .../rt/CIL/bo/CilSwitchPosition.java | 8 ++++++ .../simulation/rt/RtSimulationService.java | 8 +++--- .../{SrdService.java => SrdLogicService.java} | 9 ++++-- .../rtss/simulation/rt/srd/bo/SrAXC.java | 14 ++++------ .../rtss/simulation/rt/srd/bo/SrPSD.java | 8 +++--- .../rtss/simulation/rt/srd/bo/SrSignal.java | 6 ++-- .../srd/bo/{SrTurnout.java => SrSwitch.java} | 21 ++++++++------ .../rtss/simulation/rt/srd/bo/SrTrack.java | 12 ++++---- .../simulation/rt/srd/bo/SrdRepository.java | 4 +-- .../rt/srd/bo/SrdRepositoryBuilder.java | 10 +++---- 26 files changed, 306 insertions(+), 49 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilAutoSignal.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilDevice.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilEsp.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilFls.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPath.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilServer.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilStand.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitchPosition.java rename src/main/java/club/joylink/rtss/simulation/rt/srd/{SrdService.java => SrdLogicService.java} (97%) rename src/main/java/club/joylink/rtss/simulation/rt/srd/bo/{SrTurnout.java => SrSwitch.java} (84%) diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 9f0ffc592..633435d01 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -58,9 +58,9 @@ public abstract class Simulation delayJobMap = new ConcurrentHashMap<>(); /** - * 执行线程池,核心线程数量默认4(后需改为配置),所有仿真共享 + * 执行线程池,核心线程数量默认4(后可改为配置),所有仿真共享 */ - public static final ScheduledExecutorService EXECUTOR = Executors.newScheduledThreadPool(4); + private static final ScheduledExecutorService EXECUTOR = Executors.newScheduledThreadPool(4); public static final String MESSAGE_SUB_PREFIX = "/queue/simulation/{id}"; public static final String PATH_SEPARATOR = "/"; @@ -68,6 +68,10 @@ public abstract class Simulation subscribeMessageServiceList; private SimulationMessagePublisher publisher; + /** + * 消息推送线程池 + */ + private static final ExecutorService Message_Executor = Executors.newSingleThreadExecutor(); private Map repositoryMap = new ConcurrentHashMap<>(); private Map simulationMemberMap = new ConcurrentHashMap<>(); @@ -90,7 +94,7 @@ public abstract class Simulation scheduledFuture = EXECUTOR.scheduleAtFixedRate(()->this.logic(), - this.SYSTEM_TIME_RATE, this.SYSTEM_TIME_RATE, TimeUnit.MILLISECONDS); + SYSTEM_TIME_RATE, SYSTEM_TIME_RATE, TimeUnit.MILLISECONDS); this.future = scheduledFuture; } this.updateTimeUpdateSpeed(this.speed); @@ -104,6 +108,7 @@ public abstract class Simulation this.publisher.publishToUser(userId, destination, message)); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java new file mode 100644 index 000000000..2a6defd27 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java @@ -0,0 +1,10 @@ +package club.joylink.rtss.simulation.rt.CIL; + +import org.springframework.stereotype.Component; + +/** + * 计算机连锁逻辑 + */ +@Component +public class CilLogicService { +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilAutoSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilAutoSignal.java new file mode 100644 index 000000000..ee3ec492d --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilAutoSignal.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilAutoSignal extends CilDevice { + + public CilAutoSignal(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilDevice.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilDevice.java new file mode 100644 index 000000000..88cb5e312 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilDevice.java @@ -0,0 +1,22 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilDevice { + public static final int OFF = 0; + public static final int ON = 1; + + String id; + String name; + + public CilDevice(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilEsp.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilEsp.java new file mode 100644 index 000000000..4d8b00921 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilEsp.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilEsp extends CilDevice { + + public CilEsp(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilFls.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilFls.java new file mode 100644 index 000000000..3bb35e771 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilFls.java @@ -0,0 +1,24 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +import java.util.List; + +/** + * 侧防 + */ +public class CilFls { + String id; + + String name; + + CilSwitchPosition target; + + List firstLevelList; + + List secondLevelList; + + public static class FlsElement { + CilSwitchPosition pp; // 防护道岔 + CilSignal ps; // 防护信号 + CilSwitchPosition pae; // 侧防区域元件 + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPath.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPath.java new file mode 100644 index 000000000..e84efe7da --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPath.java @@ -0,0 +1,15 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +import java.util.List; + +public class CilPath { + + boolean right; + + List sectionList; + + List logicSectionList; + + List switchPositionList; + +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java new file mode 100644 index 000000000..85d93f56b --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilPsd extends CilDevice { + + public CilPsd(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java new file mode 100644 index 000000000..b14a91da7 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java @@ -0,0 +1,26 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +import club.joylink.rtss.simulation.SimulationRepository; + +import java.util.HashMap; +import java.util.Map; + +public class CilRepository extends SimulationRepository { + public static final String NAME = "CIL"; + + Map sectionMap; + Map switchMap; + Map signalMap; + + public CilRepository() { + super(NAME); + this.sectionMap = new HashMap<>(); + this.switchMap = new HashMap<>(); + this.signalMap = new HashMap<>(); + } + + @Override + public void initState() { + + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java new file mode 100644 index 000000000..281423407 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java @@ -0,0 +1,28 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.client.map.MapVO; +import club.joylink.rtss.vo.client.map.newmap.MapGraphDataNewVO; +import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO; + +import java.util.List; +import java.util.Map; + +public class CilRepositoryBuilder { + + public static CilRepository buildFrom(MapVO mapVO) { + CilRepository cilRepository = new CilRepository(); + MapGraphDataNewVO graphDataNew = mapVO.getGraphDataNew(); + buildSections(graphDataNew.getSectionList(), cilRepository.sectionMap); + return cilRepository; + } + + private static void buildSections(List sectionList, Map sectionMap) { + for (MapSectionNewVO sectionNewVO : sectionList) { + BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(sectionMap.containsKey(sectionNewVO.getCode()), + String.format("存在重复的区段id:[%s]", sectionNewVO.getCode())); + CilSection cilSection = new CilSection(sectionNewVO.getCode(), sectionNewVO.getName()); + sectionMap.put(cilSection.getId(), cilSection); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java new file mode 100644 index 000000000..6fad0bbc4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java @@ -0,0 +1,14 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilRoute extends CilDevice { + + CilSignal start; + + CilSignal end; + + CilPath path; + + public CilRoute(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java new file mode 100644 index 000000000..31870db9e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java @@ -0,0 +1,17 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +import java.util.List; + +public class CilSection extends CilDevice { + + CilSection parent; + List logicList; + CilSwitch belongSwitch; + + int axcOccupy; + + + public CilSection(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilServer.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilServer.java new file mode 100644 index 000000000..8039b4d15 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilServer.java @@ -0,0 +1,10 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilServer extends CilDevice { + + int state; + + public CilServer(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java new file mode 100644 index 000000000..e41c56c62 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java @@ -0,0 +1,17 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilSignal extends CilDevice { + + int state; + int logic; + int blockade; + int forceLight; + int level; + public static final int LEVEL_1 = 1; //关闭/非监控级 + public static final int LEVEL_2 = 2; //引导级 + public static final int LEVEL_3 = 3; //主信号级 + + public CilSignal(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilStand.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilStand.java new file mode 100644 index 000000000..5dc00ce6c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilStand.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilStand extends CilDevice { + + public CilStand(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java new file mode 100644 index 000000000..0a6350716 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java @@ -0,0 +1,19 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilSwitch extends CilDevice { + + int position; + public static final int LOST = 0; // 失表 + public static final int NORMAL = 1; // 定位 + public static final int REVERSE = 2; // 反位 + + int singleLock; + int blockade; + int routeLock; + int overlapLock; + int fpLock; + + public CilSwitch(String id, String name) { + super(id, name); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitchPosition.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitchPosition.java new file mode 100644 index 000000000..850d2c6bf --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitchPosition.java @@ -0,0 +1,8 @@ +package club.joylink.rtss.simulation.rt.CIL.bo; + +public class CilSwitchPosition { + + CilSwitch cilSwitch; + int position; + +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java index ff565df1e..74f00c6ef 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java @@ -2,7 +2,7 @@ package club.joylink.rtss.simulation.rt; import club.joylink.rtss.services.MapService; import club.joylink.rtss.simulation.SimulationManager; -import club.joylink.rtss.simulation.rt.srd.SrdService; +import club.joylink.rtss.simulation.rt.srd.SrdLogicService; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; @@ -19,14 +19,14 @@ public class RtSimulationService { private SimulationManager simulationManager; @Autowired - private SrdService srdService; + private SrdLogicService srdLogicService; public RtSimulation create(UserVO userVO, Long mapId) { Objects.requireNonNull(mapId); MapVO mapVO = this.mapService.getMapDetail(mapId); RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId()); this.loadData(rtSimulation, mapVO); - this.srdService.addJobs(rtSimulation); + this.srdLogicService.addJobs(rtSimulation); this.simulationManager.save(rtSimulation); return rtSimulation; } @@ -37,6 +37,6 @@ public class RtSimulationService { * @param mapVO */ private void loadData(RtSimulation rtSimulation, MapVO mapVO) { - this.srdService.buildRepository(rtSimulation, mapVO); + this.srdLogicService.buildRepository(rtSimulation, mapVO); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdLogicService.java similarity index 97% rename from src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java rename to src/main/java/club/joylink/rtss/simulation/rt/srd/SrdLogicService.java index ad41f467e..c41565a02 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdLogicService.java @@ -12,9 +12,12 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +/** + * 虚拟真实设备运行逻辑 + */ @Slf4j @Component -public class SrdService { +public class SrdLogicService { public static final int TRAIN_RUN_RATE = 20; // 列车运行逻辑频率 public static final int DEVICE_RUN_RATE = 500; // 其他设备逻辑频率 @@ -34,8 +37,8 @@ public class SrdService { private void srDeviceLogic(SrdRepository repository, LocalDateTime systemTime) { // 道岔转动 - List turnoutList = repository.getTurnoutList(); - for (SrTurnout turnout : turnoutList) { + List turnoutList = repository.getTurnoutList(); + for (SrSwitch turnout : turnoutList) { if (turnout.isControlByReal()) { continue; } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java index 26847f177..dd99273b8 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrAXC.java @@ -1,27 +1,25 @@ package club.joylink.rtss.simulation.rt.srd.bo; -import java.util.concurrent.atomic.AtomicBoolean; - /** * 虚拟真实计轴器(Axle counter) */ public class SrAXC extends SrDevice { - AtomicBoolean state = new AtomicBoolean(OFF); - public static final boolean OFF = false;//出清 - public static final boolean ON = true;//占用 + int state = OFF; + public static final int OFF = 0;//出清 + public static final int ON = 1;//占用 public SrAXC(String id) { super(id, DeviceType.AXC); } public void clear() { - this.state.set(OFF); + this.state = OFF; } public void occupy() { - if (this.state.get() != ON) { - this.state.set(ON); + if (this.state != ON) { + this.state=ON; } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java index 371e83363..8d84b2571 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java @@ -10,7 +10,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class SrPSD extends SrDevice { public static final int turnTime = 3000; // 默认开关门时间,单位ms - AtomicInteger state = new AtomicInteger(CLOSE_LOCK); + int state = CLOSE_LOCK; public static final int CLOSE_LOCK = 1;//关闭且锁闭 public static final int CLOSED = 2;//关闭未锁闭 public static final int TURNING = 3;//转换中 @@ -42,7 +42,7 @@ public class SrPSD extends SrDevice { private void startTurn(LocalDateTime systemTime, int command) { this.finishTime = systemTime.plusNanos(TimeUnit.MILLISECONDS.toNanos(turnTime)); this.command.set(command); - this.state.set(TURNING); + this.state = TURNING; } public void tryFinishTurning(LocalDateTime systemTime) { @@ -52,7 +52,7 @@ public class SrPSD extends SrDevice { } public void turnFinish() { - this.state.set(this.command.get()); + this.state = this.command.get(); this.command.set(NONE); this.finishTime = null; } @@ -60,7 +60,7 @@ public class SrPSD extends SrDevice { @Override public void applyState(int state) { if (CLOSE_LOCK == state || CLOSED == state || TURNING == state || OPEN_FINISH == state) { - this.state.set(state); + this.state = state; } else { throw new IllegalArgumentException(String.format("无效的屏蔽门状态:[%s]", state)); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java index 2e3eb7516..3a979d534 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSignal.java @@ -22,7 +22,7 @@ public class SrSignal extends SrDevice { */ int offset; - AtomicInteger state = new AtomicInteger(CLOSE); + int state = CLOSE; public static final int CLOSE = 1; // 关闭 public static final int RED = 2; // 红灯信号(禁止信号) public static final int GREEN = 3; // 绿灯信号(直向通行) @@ -81,14 +81,14 @@ public class SrSignal extends SrDevice { } public void turnFinish() { - this.state.set(this.command.get()); + this.state = this.command.get(); this.command.set(NONE); this.finishTime = null; } @Override public void applyState(int state) { if (CLOSE == state || RED == state || GREEN == state || YELLOW == state || GUIDE == state) { - this.state.set(state); + this.state = state; } else { throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSwitch.java similarity index 84% rename from src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java rename to src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSwitch.java index dff30455c..491ae796a 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTurnout.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrSwitch.java @@ -7,14 +7,14 @@ import java.util.concurrent.atomic.AtomicInteger; /** * 虚拟真实道岔 */ -public class SrTurnout extends SrDevice { +public class SrSwitch extends SrDevice { public static final int turnTime = 3000; // 默认转换时间 SrTrack a; SrTrack b; SrTrack c; - AtomicInteger state = new AtomicInteger(NORMAL); + int state = NORMAL; public static final int NORMAL = 1; // 定位 public static final int REVERSE = 2; // 反位 public static final int TURNING = 0; // 失表 @@ -26,14 +26,17 @@ public class SrTurnout extends SrDevice { */ LocalDateTime finishTime; - public SrTurnout(String id) { + public SrSwitch(String id) { super(id, DeviceType.TURNOUT); } - public void setTracks(SrTrack a, SrTrack b, SrTrack c) { + void setTracks(SrTrack a, SrTrack b, SrTrack c) { this.a = a; this.b = b; this.c = c; + a.setSrSwitch(this); + b.setSrSwitch(this); + c.setSrSwitch(this); if (this.a.leftTrack == null && this.a.rightTrack == null) { throw new IllegalStateException("道岔a区段两端都没有关联的区段"); } @@ -47,11 +50,11 @@ public class SrTurnout extends SrDevice { } public boolean isNormalPosition() { - return NORMAL == this.state.get(); + return NORMAL == this.state; } public boolean isReversePosition() { - return REVERSE == this.state.get(); + return REVERSE == this.state; } public boolean isTurning() { @@ -69,7 +72,7 @@ public class SrTurnout extends SrDevice { private void startTurn(LocalDateTime systemTime, int command) { this.finishTime = systemTime.plusNanos(TimeUnit.MILLISECONDS.toNanos(turnTime)); this.command.set(command); - this.state.set(TURNING); + this.state = TURNING; } public void tryFinishTurning(LocalDateTime systemTime) { @@ -79,7 +82,7 @@ public class SrTurnout extends SrDevice { } public void turnFinish() { - this.state.set(this.command.get()); + this.state = this.command.get(); this.command.set(NONE); this.finishTime = null; } @@ -87,7 +90,7 @@ public class SrTurnout extends SrDevice { @Override public void applyState(int state) { if (NORMAL == state || REVERSE == state || TURNING == state) { - this.state.set(state); + this.state = state; } else { throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java index 1aa38c7a9..d90cc329d 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java @@ -37,7 +37,7 @@ public class SrTrack extends SrDevice implements Debug { /** * 关联的道岔(是道岔区段才会关联,否则为null) */ - SrTurnout turnout; + SrSwitch srSwitch; public SrTrack(String id) { super(id, DeviceType.TRACK); @@ -67,15 +67,15 @@ public class SrTrack extends SrDevice implements Debug { rightFlank.setLeftTrack(this); } - public void setTurnout(SrTurnout turnout) { - this.turnout = turnout; + public void setSrSwitch(SrSwitch srSwitch) { + this.srSwitch = srSwitch; } public SrTrack queryNextTrack(boolean right) { - if (this.turnout != null) { - if (this.turnout.isNormalPosition()) { + if (this.srSwitch != null) { + if (this.srSwitch.isNormalPosition()) { return right ? this.rightTrack : this.leftTrack; - } else if (this.turnout.isReversePosition()) { + } else if (this.srSwitch.isReversePosition()) { if (right) { if (this.rightFlankTrack != null) { return this.rightFlankTrack; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java index 80db54bba..1b46e6419 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepository.java @@ -12,7 +12,7 @@ public class SrdRepository extends SimulationRepository { Map trackMap; Map axcMap; - Map turnoutMap; + Map turnoutMap; Map signalMap; Map psdMap; Map trainMap; @@ -31,7 +31,7 @@ public class SrdRepository extends SimulationRepository { return new ArrayList<>(this.trainMap.values()); } - public List getTurnoutList() { + public List getTurnoutList() { return new ArrayList<>(this.turnoutMap.values()); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepositoryBuilder.java index da737e772..692ea3653 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrdRepositoryBuilder.java @@ -78,7 +78,7 @@ public class SrdRepositoryBuilder { } private static void buildRelationOfTurnoutAndTrack(List switchList, - Map turnoutMap, + Map turnoutMap, Map trackMap) { for (MapSwitchVO switchVO : switchList) { SrTrack a = trackMap.get(switchVO.getSectionACode()); @@ -90,7 +90,7 @@ public class SrdRepositoryBuilder { String.format("道岔[%s]关联区段B[%s]不存在", switchVO.getCode(), switchVO.getSectionBCode())); BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(c, String.format("道岔[%s]关联区段C[%s]不存在", switchVO.getCode(), switchVO.getSectionCCode())); - SrTurnout turnout = turnoutMap.get(switchVO.getCode()); + SrSwitch turnout = turnoutMap.get(switchVO.getCode()); turnout.setTracks(a, b, c); } } @@ -121,10 +121,10 @@ public class SrdRepositoryBuilder { } } - private static void buildTurnout(List switchList, Map turnoutMap) { + private static void buildTurnout(List switchList, Map turnoutMap) { for (MapSwitchVO switchVO : switchList) { - SrTurnout srTurnout = new SrTurnout(switchVO.getCode()); - turnoutMap.put(srTurnout.getId(), srTurnout); + SrSwitch srSwitch = new SrSwitch(switchVO.getCode()); + turnoutMap.put(srSwitch.getId(), srSwitch); } } From e7ab43038aaa038d48168042ecee6f69cdada846 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Mon, 15 Mar 2021 16:53:39 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/configuration/WebConfig.java | 2 + .../controller/ProjectServerController.java | 50 ++ .../joylink/rtss/dao/ProjectServerDAO.java | 14 + .../joylink/rtss/entity/ProjectServer.java | 35 + .../rtss/entity/ProjectServerExample.java | 663 ++++++++++++++++++ .../rtss/services/project/ServerService.java | 17 + .../services/project/ServerServiceImpl.java | 81 +++ .../rtss/vo/project/ProjectServerQueryVO.java | 15 + .../rtss/vo/project/ProjectServerVO.java | 66 ++ .../mybatis/mapper/ProjectServerDAO.xml | 245 +++++++ 10 files changed, 1188 insertions(+) create mode 100644 src/main/java/club/joylink/rtss/controller/ProjectServerController.java create mode 100644 src/main/java/club/joylink/rtss/dao/ProjectServerDAO.java create mode 100644 src/main/java/club/joylink/rtss/entity/ProjectServer.java create mode 100644 src/main/java/club/joylink/rtss/entity/ProjectServerExample.java create mode 100644 src/main/java/club/joylink/rtss/services/project/ServerService.java create mode 100644 src/main/java/club/joylink/rtss/services/project/ServerServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/project/ProjectServerQueryVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/project/ProjectServerVO.java create mode 100644 src/main/resources/mybatis/mapper/ProjectServerDAO.xml diff --git a/src/main/java/club/joylink/rtss/configuration/WebConfig.java b/src/main/java/club/joylink/rtss/configuration/WebConfig.java index 3c90b176c..b98cf7eb2 100644 --- a/src/main/java/club/joylink/rtss/configuration/WebConfig.java +++ b/src/main/java/club/joylink/rtss/configuration/WebConfig.java @@ -58,6 +58,8 @@ public class WebConfig implements WebMvcConfigurer { whiteList.add("/api/learn/cgy/updateMessageTime"); // 成都工业使用记录 whiteList.add("/api/cgy/**"); + //项目域名查询 + whiteList.add("/api/projectServer/project/{project}"); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); } diff --git a/src/main/java/club/joylink/rtss/controller/ProjectServerController.java b/src/main/java/club/joylink/rtss/controller/ProjectServerController.java new file mode 100644 index 000000000..dd172583d --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/ProjectServerController.java @@ -0,0 +1,50 @@ +package club.joylink.rtss.controller; + +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.constants.RoleEnum; +import club.joylink.rtss.controller.advice.AuthenticateInterceptor; +import club.joylink.rtss.controller.advice.Role; +import club.joylink.rtss.services.project.ServerService; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectServerQueryVO; +import club.joylink.rtss.vo.project.ProjectServerVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@Slf4j +@RestController +@RequestMapping("/api/projectServer") +public class ProjectServerController { + + @Autowired + private ServerService serverService; + + @GetMapping("/project/{project}") + public ProjectServerVO getByProject(@PathVariable Project project) { + return this.serverService.getByProject(project); + } + + @Role(RoleEnum.SuperAdmin) + @GetMapping("/paging") + public PageVO pagingQuery(ProjectServerQueryVO queryVO) { + return this.serverService.pagingQuery(queryVO); + } + + @Role(RoleEnum.SuperAdmin) + @PostMapping("") + public String create(@RequestBody ProjectServerVO vo, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) UserVO userVO) { + return this.serverService.create(vo, userVO); + } + + @Role(RoleEnum.SuperAdmin) + @PutMapping("/{id}") + public void update(@PathVariable Long id, + @RequestBody ProjectServerVO vo, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) UserVO userVO) { + this.serverService.update(id, vo, userVO); + } + +} diff --git a/src/main/java/club/joylink/rtss/dao/ProjectServerDAO.java b/src/main/java/club/joylink/rtss/dao/ProjectServerDAO.java new file mode 100644 index 000000000..b80d623b5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/dao/ProjectServerDAO.java @@ -0,0 +1,14 @@ +package club.joylink.rtss.dao; + +import club.joylink.rtss.entity.ProjectServer; +import club.joylink.rtss.entity.ProjectServerExample; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** + * ProjectServerDAO继承基类 + */ +@Mapper +@Repository +public interface ProjectServerDAO extends MyBatisBaseDao { +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/ProjectServer.java b/src/main/java/club/joylink/rtss/entity/ProjectServer.java new file mode 100644 index 000000000..13a7ebfcd --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/ProjectServer.java @@ -0,0 +1,35 @@ +package club.joylink.rtss.entity; + +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @author + * 项目服务器域名表 + */ +@Data +public class ProjectServer implements Serializable { + private Long id; + + /** + * 项目编码 + */ + private String project; + + /** + * 域名 + */ + private String domainName; + + private Long createUserId; + + private LocalDateTime createTime; + + private Long updateUserId; + + private LocalDateTime updateTime; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/ProjectServerExample.java b/src/main/java/club/joylink/rtss/entity/ProjectServerExample.java new file mode 100644 index 000000000..d93e2c34c --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/ProjectServerExample.java @@ -0,0 +1,663 @@ +package club.joylink.rtss.entity; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class ProjectServerExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public ProjectServerExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andProjectIsNull() { + addCriterion("project is null"); + return (Criteria) this; + } + + public Criteria andProjectIsNotNull() { + addCriterion("project is not null"); + return (Criteria) this; + } + + public Criteria andProjectEqualTo(String value) { + addCriterion("project =", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectNotEqualTo(String value) { + addCriterion("project <>", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectGreaterThan(String value) { + addCriterion("project >", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectGreaterThanOrEqualTo(String value) { + addCriterion("project >=", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectLessThan(String value) { + addCriterion("project <", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectLessThanOrEqualTo(String value) { + addCriterion("project <=", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectLike(String value) { + addCriterion("project like", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectNotLike(String value) { + addCriterion("project not like", value, "project"); + return (Criteria) this; + } + + public Criteria andProjectIn(List values) { + addCriterion("project in", values, "project"); + return (Criteria) this; + } + + public Criteria andProjectNotIn(List values) { + addCriterion("project not in", values, "project"); + return (Criteria) this; + } + + public Criteria andProjectBetween(String value1, String value2) { + addCriterion("project between", value1, value2, "project"); + return (Criteria) this; + } + + public Criteria andProjectNotBetween(String value1, String value2) { + addCriterion("project not between", value1, value2, "project"); + return (Criteria) this; + } + + public Criteria andDomainNameIsNull() { + addCriterion("domain_name is null"); + return (Criteria) this; + } + + public Criteria andDomainNameIsNotNull() { + addCriterion("domain_name is not null"); + return (Criteria) this; + } + + public Criteria andDomainNameEqualTo(String value) { + addCriterion("domain_name =", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameNotEqualTo(String value) { + addCriterion("domain_name <>", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameGreaterThan(String value) { + addCriterion("domain_name >", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameGreaterThanOrEqualTo(String value) { + addCriterion("domain_name >=", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameLessThan(String value) { + addCriterion("domain_name <", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameLessThanOrEqualTo(String value) { + addCriterion("domain_name <=", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameLike(String value) { + addCriterion("domain_name like", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameNotLike(String value) { + addCriterion("domain_name not like", value, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameIn(List values) { + addCriterion("domain_name in", values, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameNotIn(List values) { + addCriterion("domain_name not in", values, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameBetween(String value1, String value2) { + addCriterion("domain_name between", value1, value2, "domainName"); + return (Criteria) this; + } + + public Criteria andDomainNameNotBetween(String value1, String value2) { + addCriterion("domain_name not between", value1, value2, "domainName"); + return (Criteria) this; + } + + public Criteria andCreateUserIdIsNull() { + addCriterion("create_user_id is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIdIsNotNull() { + addCriterion("create_user_id is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserIdEqualTo(Long value) { + addCriterion("create_user_id =", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdNotEqualTo(Long value) { + addCriterion("create_user_id <>", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdGreaterThan(Long value) { + addCriterion("create_user_id >", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("create_user_id >=", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdLessThan(Long value) { + addCriterion("create_user_id <", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdLessThanOrEqualTo(Long value) { + addCriterion("create_user_id <=", value, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdIn(List values) { + addCriterion("create_user_id in", values, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdNotIn(List values) { + addCriterion("create_user_id not in", values, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdBetween(Long value1, Long value2) { + addCriterion("create_user_id between", value1, value2, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateUserIdNotBetween(Long value1, Long value2) { + addCriterion("create_user_id not between", value1, value2, "createUserId"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(LocalDateTime value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(LocalDateTime value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(LocalDateTime value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(LocalDateTime value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdIsNull() { + addCriterion("update_user_id is null"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdIsNotNull() { + addCriterion("update_user_id is not null"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdEqualTo(Long value) { + addCriterion("update_user_id =", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdNotEqualTo(Long value) { + addCriterion("update_user_id <>", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdGreaterThan(Long value) { + addCriterion("update_user_id >", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("update_user_id >=", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdLessThan(Long value) { + addCriterion("update_user_id <", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdLessThanOrEqualTo(Long value) { + addCriterion("update_user_id <=", value, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdIn(List values) { + addCriterion("update_user_id in", values, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdNotIn(List values) { + addCriterion("update_user_id not in", values, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdBetween(Long value1, Long value2) { + addCriterion("update_user_id between", value1, value2, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateUserIdNotBetween(Long value1, Long value2) { + addCriterion("update_user_id not between", value1, value2, "updateUserId"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(LocalDateTime value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(LocalDateTime value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(LocalDateTime value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(LocalDateTime value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(LocalDateTime value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(LocalDateTime value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/services/project/ServerService.java b/src/main/java/club/joylink/rtss/services/project/ServerService.java new file mode 100644 index 000000000..bacd6b951 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/project/ServerService.java @@ -0,0 +1,17 @@ +package club.joylink.rtss.services.project; + +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectServerQueryVO; +import club.joylink.rtss.vo.project.ProjectServerVO; + +public interface ServerService { + public ProjectServerVO getByProject(Project project); + + PageVO pagingQuery(ProjectServerQueryVO queryVO); + + String create(ProjectServerVO vo, UserVO userVO); + + void update(Long id, ProjectServerVO vo, UserVO userVO); +} diff --git a/src/main/java/club/joylink/rtss/services/project/ServerServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/ServerServiceImpl.java new file mode 100644 index 000000000..fd9a56f49 --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/project/ServerServiceImpl.java @@ -0,0 +1,81 @@ +package club.joylink.rtss.services.project; + +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.dao.ProjectServerDAO; +import club.joylink.rtss.entity.ProjectServer; +import club.joylink.rtss.entity.ProjectServerExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectServerQueryVO; +import club.joylink.rtss.vo.project.ProjectServerVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; + +@Slf4j +@Service +public class ServerServiceImpl implements ServerService { + + @Autowired + private ProjectServerDAO projectServerDAO; + + @Override + public ProjectServerVO getByProject(Project project) { + ProjectServerExample example = new ProjectServerExample(); + example.createCriteria() + .andProjectEqualTo(project.name()); + List projectServerList = this.projectServerDAO.selectByExample(example); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(projectServerList); + return new ProjectServerVO(projectServerList.get(0)); + } + + @Override + public PageVO pagingQuery(ProjectServerQueryVO queryVO) { + ProjectServerExample example = new ProjectServerExample(); + if (queryVO.getProject() != null) { + example.createCriteria() + .andProjectEqualTo(queryVO.getProject().name()); + } + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + Page projectServerList = (Page) this.projectServerDAO.selectByExample(example); + List voList = ProjectServerVO.convert2VOList(projectServerList.getResult()); + return PageVO.convert(projectServerList, voList); + } + + @Override + public String create(ProjectServerVO vo, UserVO userVO) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(vo.getProject(),"项目不能为null"); + BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertNotTrue(this.isProjectDataExist(vo.getProject()), + String.format("项目[%s]的域名数据已经存在", vo.getProject())); + ProjectServer db = vo.toDB(); + db.setCreateUserId(userVO.getId()); + db.setCreateTime(LocalDateTime.now()); + this.projectServerDAO.insert(db); + return db.getId().toString(); + } + + private boolean isProjectDataExist(Project project) { + ProjectServerExample example = new ProjectServerExample(); + example.createCriteria() + .andProjectEqualTo(project.name()); + return this.projectServerDAO.countByExample(example) > 0; + } + + @Override + public void update(Long id, ProjectServerVO vo, UserVO userVO) { + ProjectServer projectServer = this.projectServerDAO.selectByPrimaryKey(id); + if (!Objects.equals(vo.getDomainName(), projectServer.getDomainName())) { + projectServer.setDomainName(vo.getDomainName()); + projectServer.setUpdateUserId(userVO.getId()); + projectServer.setUpdateTime(LocalDateTime.now()); + this.projectServerDAO.updateByPrimaryKey(projectServer); + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectServerQueryVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectServerQueryVO.java new file mode 100644 index 000000000..d130a911b --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectServerQueryVO.java @@ -0,0 +1,15 @@ +package club.joylink.rtss.vo.project; + +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.vo.client.PageQueryVO; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class ProjectServerQueryVO extends PageQueryVO { + private Project project; + +} diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectServerVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectServerVO.java new file mode 100644 index 000000000..b139bbf5d --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectServerVO.java @@ -0,0 +1,66 @@ +package club.joylink.rtss.vo.project; + +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.entity.ProjectServer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.util.CollectionUtils; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +public class ProjectServerVO { + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + private Project project; + + /** + * 域名 + */ + private String domainName; + + @JsonSerialize(using = ToStringSerializer.class) + private Long createUserId; + + private LocalDateTime createTime; + + @JsonSerialize(using = ToStringSerializer.class) + private Long updateUserId; + + private LocalDateTime updateTime; + + public ProjectServerVO(ProjectServer projectServer) { + this.id = projectServer.getId(); + this.project = Project.valueOf(projectServer.getProject()); + this.domainName = projectServer.getDomainName(); + this.createUserId = projectServer.getCreateUserId(); + this.createTime = projectServer.getCreateTime(); + this.updateUserId = projectServer.getUpdateUserId(); + this.updateTime = projectServer.getUpdateTime(); + } + + public static List convert2VOList(List projectServerList) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(projectServerList)) { + for (ProjectServer projectServer : projectServerList) { + voList.add(new ProjectServerVO(projectServer)); + } + } + return voList; + } + + public ProjectServer toDB() { + ProjectServer db = new ProjectServer(); + db.setProject(this.project.name()); + db.setDomainName(this.domainName); + return db; + } +} diff --git a/src/main/resources/mybatis/mapper/ProjectServerDAO.xml b/src/main/resources/mybatis/mapper/ProjectServerDAO.xml new file mode 100644 index 000000000..80d68e2ce --- /dev/null +++ b/src/main/resources/mybatis/mapper/ProjectServerDAO.xml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, project, domain_name, create_user_id, create_time, update_user_id, update_time + + + + + delete from project_server + where id = #{id,jdbcType=BIGINT} + + + delete from project_server + + + + + + insert into project_server (project, domain_name, create_user_id, + create_time, update_user_id, update_time + ) + values (#{project,jdbcType=VARCHAR}, #{domainName,jdbcType=VARCHAR}, #{createUserId,jdbcType=BIGINT}, + #{createTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP} + ) + + + insert into project_server + + + project, + + + domain_name, + + + create_user_id, + + + create_time, + + + update_user_id, + + + update_time, + + + + + #{project,jdbcType=VARCHAR}, + + + #{domainName,jdbcType=VARCHAR}, + + + #{createUserId,jdbcType=BIGINT}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateUserId,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + + + + update project_server + + + id = #{record.id,jdbcType=BIGINT}, + + + project = #{record.project,jdbcType=VARCHAR}, + + + domain_name = #{record.domainName,jdbcType=VARCHAR}, + + + create_user_id = #{record.createUserId,jdbcType=BIGINT}, + + + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + + + update_user_id = #{record.updateUserId,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=TIMESTAMP}, + + + + + + + + update project_server + set id = #{record.id,jdbcType=BIGINT}, + project = #{record.project,jdbcType=VARCHAR}, + domain_name = #{record.domainName,jdbcType=VARCHAR}, + create_user_id = #{record.createUserId,jdbcType=BIGINT}, + create_time = #{record.createTime,jdbcType=TIMESTAMP}, + update_user_id = #{record.updateUserId,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=TIMESTAMP} + + + + + + update project_server + + + project = #{project,jdbcType=VARCHAR}, + + + domain_name = #{domainName,jdbcType=VARCHAR}, + + + create_user_id = #{createUserId,jdbcType=BIGINT}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_user_id = #{updateUserId,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=BIGINT} + + + update project_server + set project = #{project,jdbcType=VARCHAR}, + domain_name = #{domainName,jdbcType=VARCHAR}, + create_user_id = #{createUserId,jdbcType=BIGINT}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_user_id = #{updateUserId,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file From 9dbdbc0a95c5a8f1f389cc9cc704bceacaacd04f Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Mon, 15 Mar 2021 18:18:50 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9F=9F=E5=90=8Dsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20210315-sheng-project-server.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 sql/20210315-sheng-project-server.sql diff --git a/sql/20210315-sheng-project-server.sql b/sql/20210315-sheng-project-server.sql new file mode 100644 index 000000000..776d20a26 --- /dev/null +++ b/sql/20210315-sheng-project-server.sql @@ -0,0 +1,12 @@ +DROP TABLE IF EXISTS `project_server`; +CREATE TABLE `project_server` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `project` varchar(32) NOT NULL COMMENT '项目编码', + `domain_name` varchar(255) NOT NULL COMMENT '域名', + `create_user_id` bigint(20) NOT NULL, + `create_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP, + `update_user_id` bigint(20) DEFAULT NULL, + `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `project_server_project_1` (`project`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='项目服务器域名表'; \ No newline at end of file From 413a9c1c3727f579d4f3f4a48173d261717ae770 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Tue, 16 Mar 2021 13:30:25 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9ATS=E8=BF=9B=E8=B7=AF?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=8E=A5=E8=BF=91=E5=8C=BA=E6=AE=B5=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E9=80=BB=E8=BE=91=E9=97=AE=E9=A2=98=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BD=BF=E7=94=A8=E5=88=97=E8=BD=A6=E6=89=80=E5=9C=A8?= =?UTF-8?q?=E7=89=A9=E7=90=86=E5=8C=BA=E6=AE=B5=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ATS/service/AtsRouteSettingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index e68d29479..f7dcf00ac 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -748,7 +748,7 @@ public class AtsRouteSettingService { continue; } // 信号机存在,判定信号关闭、接近区段 - if (signal.isApproachSection(train.getSection())) { + if (signal.isApproachSection(train.getPhysicalSection())) { target = signal; } break; From 3f86f1fc6ccd1dd8fed08e128ab027b8c9474ef2 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 17 Mar 2021 16:02:05 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=81=94=E9=94=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E2=80=94=E2=80=94=E4=BF=AE=E6=94=B9=E4=BA=A4=E8=B7=AF=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91=E9=97=AE=E9=A2=98=EF=BC=8C=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E7=AB=99=E5=8F=B0=E8=BD=A8=E6=97=A0=E5=87=BA=E7=AB=99?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DraftMapCiDataGeneratorImpl.java | 51 +++++++++++++++---- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 646b979dc..36ac91c46 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -873,7 +873,11 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } // 找指定方向的站台轨 Signal signal = lastSection.getSignalOf(right); - this.queryNormalStandTracksOnDirectionFromSignal(signal, right, nstdList); + if (signal == null) { + this.queryNormalStandTracksOnDirectionFromSection(lastSection, right, nstdList); + } else { + this.queryNormalStandTracksOnDirectionFromSignal(signal, right, nstdList); + } // 站前折返情况处理 if (!CollectionUtils.isEmpty(nstdList) && end.isNormalStandTrack() && @@ -903,6 +907,21 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } } + private void queryNormalStandTracksOnDirectionFromSection(Section lastSection, boolean right, List
nstdList) { + Signal signal = lastSection.getSignalOf(right); + if (signal != null) { + this.queryNormalStandTracksOnDirectionFromSignal(signal, right, nstdList); + } else { + Section nextSection = lastSection.getSectionOf(right); + if (nextSection.isNormalStandTrack() && nextSection.getStandList().get(0).isRight() == right) { + nstdList.add(nextSection); + return; + } else { + this.queryNormalStandTracksOnDirectionFromSection(nextSection, right, nstdList); + } + } + } + private boolean canArriveOppositeStandTrack(Section start, Section end, boolean right) { Signal signal = start.getSignalOf(right); List
nstdList = new ArrayList<>(); @@ -1137,27 +1156,37 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { Set signals = new HashSet<>(); for (Route route : routeList) { boolean containOppositeStandTrack = false; + boolean contains = false; for (Section section : route.getSectionList()) { - if (section.isNormalStandTrack() && - !Objects.equals(section.getStandList().get(0).isRight(), standRight)) { - containOppositeStandTrack = true; + if (section.isNormalStandTrack()) { + if (!Objects.equals(section.getStandList().get(0).isRight(), standRight)) { + containOppositeStandTrack = true; + } else { + contains = true; + nstdList.add(section); + } break; } } if (containOppositeStandTrack) { continue; } - Section lastRouteSection = route.getLastRouteSection(); - if (lastRouteSection.isNormalStandTrack()) { - if (Objects.equals(lastRouteSection.getStandList().get(0).isRight(), standRight)) { - if (!nstdList.contains(lastRouteSection)) { - nstdList.add(lastRouteSection); - } - } + if (contains) { continue; } else { signals.add(route.getDestination()); } +// Section lastRouteSection = route.getLastRouteSection(); +// if (lastRouteSection.isNormalStandTrack()) { +// if (Objects.equals(lastRouteSection.getStandList().get(0).isRight(), standRight)) { +// if (!nstdList.contains(lastRouteSection)) { +// nstdList.add(lastRouteSection); +// } +// } +// continue; +// } else { +// signals.add(route.getDestination()); +// } } if (!CollectionUtils.isEmpty(signals)) { for (Signal end : signals) {