From 67be44750ae4baaea8a1ddd48e3f2a176b5def68 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 17:15:54 +0800
Subject: [PATCH 01/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 14 +-
.../rtss/constants/MapPrdTypeEnum.java | 1 +
.../ATS/service/NewAtsTrainLoadService.java | 133 ++++++++++++++++++
.../ATS/service/TrainPositionService.java | 124 ++++++++++++++++
.../cbtc/build/SimulationBuilder.java | 3 +-
.../rtss/websocket/WebSocketController.java | 13 +-
.../rtss/websocket/WebsocketConfig.java | 4 +-
.../websocket/client/StompClientManager.java | 55 +++++++-
8 files changed, 333 insertions(+), 14 deletions(-)
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
diff --git a/pom.xml b/pom.xml
index 5d42be2c3..0ca8c3bd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,13 +102,13 @@
0.2.1
-
- com.huawei.sis
- huaweicloud-java-sdk-sis
- 1.3.2
- system
- ${project.basedir}/libs/huaweicloud-java-sdk-sis-1.3.2.jar
-
+
+
+
+
+
+
+
com.huawei.apigateway
diff --git a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
index 3e093ca1b..b5f2b4b42 100644
--- a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
+++ b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
@@ -13,6 +13,7 @@ public enum MapPrdTypeEnum {
BIG_SCREEN("07", "大屏工作站", null),
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
DEPOT_IL("09", "车辆段联锁工作站", null),
+ BIG_SCREEN_TRAIN_POSITION("10", "大屏车辆真实工作站", null),
// CTC("10", "CTC工作站")
;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
new file mode 100644
index 000000000..4b58317b2
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -0,0 +1,133 @@
+package club.joylink.rtss.simulation.cbtc.ATS.service;
+
+import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
+import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
+import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService;
+import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
+import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
+import club.joylink.rtss.simulation.cbtc.Simulation;
+import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
+import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
+import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
+import club.joylink.rtss.simulation.cbtc.data.CalculateService;
+import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
+import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
+import club.joylink.rtss.simulation.cbtc.data.map.Route;
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
+import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
+import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
+import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
+import club.joylink.rtss.simulation.cbtc.data.support.TrainLoadParam2;
+import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
+import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
+import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
+import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
+import club.joylink.rtss.simulation.cbtc.event.SimulationRunAsPlanEvent;
+import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
+import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
+import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
+import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
+import club.joylink.rtss.vo.ws.TrainPosition;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class NewAtsTrainLoadService extends AtsTrainLoadService {
+
+ @Resource
+ private VRTrainRunningService vrTrainRunningService;
+
+
+
+
+
+ public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
+ SimulationDataRepository repository = simulation.getRepository();
+ String tripNumber = tp.getTrainTripNum();
+ TrainInfo trainInfo = repository.getTrainInfoMap().values().stream().filter(train -> tripNumber.equals(train.getTripNumber())).findFirst().orElse(null);
+
+// List allVrTrain = repository.getAllVrTrain();
+
+ if(Objects.nonNull(trainInfo)){
+ //存在列车需要更新位置
+ Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream().filter(d->Objects.equals(d.getTripNumber(),tripNumber)).findFirst();
+ VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
+ trainOnline(simulation, section, tp, virtualRealityTrain);
+// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
+ }else{
+
+ Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream()
+ .filter(vrTrain -> !repository.isVrTrainOnline(vrTrain.getGroupNumber()))
+ .findFirst();
+ VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
+ // 设置列车车次
+ virtualRealityTrain.setTripNumber(tripNumber);
+ trainOnline(simulation, section, tp, virtualRealityTrain);
+// SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
+// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
+ }
+
+ }
+
+
+ /**
+ * 列车上线并构建ATS监控列车信息
+ * @param simulation
+ * @param section
+ * @param tp
+ * @param train
+ */
+ private void trainOnline(Simulation simulation, Section section, TrainPosition tp, VirtualRealityTrain train) {
+ boolean right = tp.isRight();
+ if (!section.isPhysical()) {
+ section = section.getParent();
+ }
+ BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(section.isPhysical(), "列车需加载到物理区段上");
+ //重叠检测
+ SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
+// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
+ SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
+ boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
+ BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
+ // 列车上线并构建ATS监控列车信息
+ manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
+ }
+
+ /**
+ * 人工车上线并监控
+ */
+ private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right) {
+ train.initManualTrain(headPosition, right);
+ SimulationDataRepository repository = simulation.getRepository();
+ //设置列车预选模式、驾驶模式、运行级别
+ if (!headPosition.getSection().anyZcWorking()) {
+ train.initAsRM();
+ } else {
+ MapConfig config = repository.getConfig();
+ if (RunLevel.ITC.equals(config.getRunMode())) {
+ train.initAsAM_I();
+ } else if (RunLevel.IL.equals(config.getRunMode())) {
+ train.initAsRM();
+ }
+ }
+ if (!repository.getConfig().isHandleDepot()) {
+ TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
+ trainInfo.tracking(train);
+ repository.addOnlineTrain(train);
+ repository.addTrainInfo(trainInfo);
+ }
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
new file mode 100644
index 000000000..a83cb1c57
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -0,0 +1,124 @@
+package club.joylink.rtss.simulation.cbtc.ATS.service;
+
+
+import club.joylink.rtss.constants.MapPrdTypeEnum;
+import club.joylink.rtss.simulation.SimulationManager;
+import club.joylink.rtss.simulation.cbtc.Simulation;
+import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import club.joylink.rtss.util.JsonUtils;
+import club.joylink.rtss.vo.ws.TrainPosition;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class TrainPositionService {
+ @Resource
+ private NewAtsTrainLoadService newAtsTrainLoadService;
+ @Resource
+ private SimulationManager simulationManager;
+ /**
+ * 数据过期时间
+ */
+ private final static long EXPIRE_SECTION_TIME_MIN = 10;
+ /**
+ * 区段的缓存
+ * key 对应的方向类型
+ * EXPIRE_SECTION_TIME_MIN 数据过期时间
+ */
+ private final static Cache> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
+
+ /**
+ * 初始化或更新列车的位置
+ * @param mapName
+ * @param json
+ */
+ public void initTrainOrUpdate(String mapName,String json){
+ TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
+ List simulationList = this.findSimulationList(mapName);
+ if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
+ log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
+ return;
+ }
+
+ List sectionList = findDirectionAllSection(simulationList.get(0),tp.getRoadType());
+ Section section = this.findSecion(sectionList,tp);
+ if(Objects.isNull(section)){
+ log.error("未找到对应的区段 param:{}",json);
+ return;
+ }
+ for (Simulation sim : simulationList) {
+ this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
+ }
+ }
+
+ /**
+ * 根据传入的参数 定位对应的所在的区段
+ * @param sectionList
+ * @param tp
+ * @return
+ */
+ private Section findSecion(List sectionList,TrainPosition tp){
+ int i = 0;
+// Section findSection;
+ for (Section section : sectionList) {
+ if(tp.isRight()){
+ if(tp.getLocation() <= section.getKmMax()){
+ return section;
+ }
+ }else{
+ if(tp.getLocation() <= section.getKmMax() && tp.getLocation() >= section.getKmMin()){
+ return section;
+ }
+ }
+ i++;
+ }
+ return null;
+ }
+
+
+ /**
+ * 根据车辆方向获取对应的区段并升序排序
+ * @param sim
+ * @param roadType
+ * @return
+ */
+ private static synchronized List findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
+ List list = ROAD_TYPE_CACHE.getIfPresent(roadType);
+ if(Objects.equals(true,CollectionUtils.isEmpty(list))){
+ list = sim.getRepository().getSectionList();
+ list = list.stream().filter(d->d.getRoadType() == roadType)
+ .sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
+ ROAD_TYPE_CACHE.put(roadType,list);
+ }
+ return list;
+ }
+
+ /**
+ * 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION
+ * @param mapName
+ * @return
+ */
+ private List findSimulationList(String mapName){
+ return this.simulationManager.getSimulationList().stream().filter(d->{
+ if(d instanceof Simulation){
+ Simulation sim = (Simulation) d;
+ SimulationBuildParams params = sim.getBuildParams();
+ boolean same = Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION;
+ return same;
+ }
+ return false;
+ }).map(d->(Simulation) d).collect(Collectors.toList());
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
index 8ac858ea5..94eb3a7c0 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
@@ -379,9 +379,10 @@ public class SimulationBuilder {
rep.save(ts);
}
}
- //复制编辑区的股道,出入口到生效,编辑区
+ //复制编辑区的股道数据到生效,编辑区
copyEditToTargetForStationTrack(stationTrackRepositoryMap,effectStationTrackMap);
copyEditToTargetForStationTrack(stationTrackRepositoryMap,updateStationTrackMap);
+ //复制编辑区的出入口数据到生效,编辑区
copyEditToTargetForDoor(doorRepository,effectDoorMap);
copyEditToTargetForDoor(doorRepository,updateDoorMap);
}
diff --git a/src/main/java/club/joylink/rtss/websocket/WebSocketController.java b/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
index a3076b8fc..d4b711d26 100644
--- a/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
+++ b/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
@@ -1,15 +1,20 @@
package club.joylink.rtss.websocket;
+import club.joylink.rtss.simulation.cbtc.ATS.service.TrainPositionService;
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
import club.joylink.rtss.simulation.cbtc.Simulation;
+
+import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
+import club.joylink.rtss.vo.ws.TrainPosition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.DestinationVariable;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.stereotype.Controller;
+import javax.annotation.Resource;
import java.security.Principal;
@Controller
@@ -21,11 +26,17 @@ public class WebSocketController {
@Autowired
private GroupSimulationCache groupSimulationCache;
-
+ @Resource
+ private TrainPositionService trainPositionService;
@MessageMapping("/simulation/{group}/vr")
public void routingData(Principal user, String json, @DestinationVariable String group) {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
SocketMessageVO message = SocketMessageFactory.buildVrMessage(group, json);
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
+
+ @MessageMapping("/{mapName}/trainPosition")
+ public void mlbs( String json,@DestinationVariable String mapName) {
+ this.trainPositionService.initTrainOrUpdate(mapName,json);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java b/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
index 78ffde9aa..3de9ee643 100644
--- a/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
+++ b/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
@@ -43,13 +43,11 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
registry.addEndpoint("/joylink-websocket")
.addInterceptors(new SessionAuthHandshakeInterceptor(loginSessionManager))
.setHandshakeHandler(new DefaultHandshakeHandler() {
-
@Override
protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
Map attributes) {
return new MyPrincipal((LoginUserInfoVO) attributes.get(SessionAuthHandshakeInterceptor.ATTR_USER_KEY));
}
-
})
.setAllowedOrigins("*");
registry.addEndpoint("/joylink-wm-websocket")
@@ -64,6 +62,8 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
})
.setAllowedOrigins("*");
+ registry.addEndpoint("/joylink-tbi-websocket")
+ .setAllowedOrigins("*");
}
/**
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index bca561755..87a43bbc6 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -1,12 +1,18 @@
package club.joylink.rtss.websocket.client;
+import club.joylink.rtss.util.JsonUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
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.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
@Slf4j
public class StompClientManager {
@@ -18,10 +24,53 @@ public class StompClientManager {
WebSocketStompClient stompClient = new WebSocketStompClient(socketClient);
SimulationSessionHandler handler = new SimulationSessionHandler();
ListenableFuture future = stompClient
- .connect("ws://192.168.3.120:9000/joylink-websocket?token=cc789dc2b2f003b2593f5eafbf4763bd",
- handler, "null");
+ .connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
StompSession stompSession = future.get();
- stompSession.subscribe("/user/queue/simulation/11/ats", handler);
+
+ runToLeft(stompSession,"train001");
+// runToRight(stompSession,"train002");
+
+ }
+
+ public static void runToLeft(StompSession stompSession,String tripNum){
+ int step = 80;
+ int location = 40000;
+ while(true){
+ location -= step;
+ Map dataMap = new HashMap<>();
+ dataMap.put("trainTripNum",tripNum);
+// dataMap.put("direction",1);
+ dataMap.put("direction",0);
+ dataMap.put("location",location);
+ String val = JsonUtils.writeValueNullableFieldAsString(dataMap);
+ System.out.println(val);
+ stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
+ try {
+ TimeUnit.MILLISECONDS.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ public static void runToRight(StompSession stompSession,String tripNum){
+ int step = 20;
+ int location = 0;
+ while(true){
+ location += step;
+ Map dataMap = new HashMap<>();
+ dataMap.put("trainTripNum",tripNum);
+ dataMap.put("direction",1);
+// dataMap.put("direction",0);
+ dataMap.put("location",location);
+ String val = JsonUtils.writeValueNullableFieldAsString(dataMap);
+ System.out.println(val);
+ stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
+ try {
+ TimeUnit.MILLISECONDS.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
}
}
From 4df36e6ccfa058b14def882c5d0fad9cd8855d1d Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 17:17:35 +0800
Subject: [PATCH 02/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../joylink/rtss/vo/ws/TrainPosition.java | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
new file mode 100644
index 000000000..a9d5e8c5a
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -0,0 +1,27 @@
+package club.joylink.rtss.vo.ws;
+
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class TrainPosition {
+ private String trainTripNum;
+ /**
+ * 方向1=上行(向右),0=下行(向左)
+ */
+ private int direction;
+ private float location;
+
+ public Section.SectionRoadType getRoadType(){
+ Section.SectionRoadType type = Section.SectionRoadType.LEFT;
+ if(this.direction == 1){
+ return Section.SectionRoadType.RIGHT;
+ }
+ return type;
+ }
+ public boolean isRight(){
+ return this.direction == 1;
+ }
+}
From caf12a6cee181ada1e3c004fb0e03575a08826e1 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 17:20:12 +0800
Subject: [PATCH 03/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0ca8c3bd6..5d42be2c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,13 +102,13 @@
0.2.1
-
-
-
-
-
-
-
+
+ com.huawei.sis
+ huaweicloud-java-sdk-sis
+ 1.3.2
+ system
+ ${project.basedir}/libs/huaweicloud-java-sdk-sis-1.3.2.jar
+
com.huawei.apigateway
From 5916cd765e638e061f56c63d30e22b89ef78a07c Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 18:12:32 +0800
Subject: [PATCH 04/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/simulation/cbtc/ATS/service/TrainPositionService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index a83cb1c57..fa27dd591 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -98,7 +98,7 @@ public class TrainPositionService {
List list = ROAD_TYPE_CACHE.getIfPresent(roadType);
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
- list = list.stream().filter(d->d.getRoadType() == roadType)
+ list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
ROAD_TYPE_CACHE.put(roadType,list);
}
From d3aea82953cfec42faab1dd19f291085a7c6b730 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 18:30:19 +0800
Subject: [PATCH 05/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/simulation/cbtc/ATS/service/TrainPositionService.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index fa27dd591..a01c7b00c 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -98,6 +98,8 @@ public class TrainPositionService {
List list = ROAD_TYPE_CACHE.getIfPresent(roadType);
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
+ List list1 = list.stream().filter(d->d.getRoadType() == roadType && Objects.isNull(d.getKmMin())).map(d->d.getCode() + "-->" + d.getName()).collect(Collectors.toList());
+ System.out.println(list1);
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
ROAD_TYPE_CACHE.put(roadType,list);
From 01947496106b2a87cfac4d2bfa536586215b8715 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 7 Sep 2022 18:35:17 +0800
Subject: [PATCH 06/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/simulation/cbtc/ATS/service/TrainPositionService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index a01c7b00c..fe9a4b9f3 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -99,7 +99,7 @@ public class TrainPositionService {
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
List list1 = list.stream().filter(d->d.getRoadType() == roadType && Objects.isNull(d.getKmMin())).map(d->d.getCode() + "-->" + d.getName()).collect(Collectors.toList());
- System.out.println(list1);
+ log.info(list1.toString());
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
ROAD_TYPE_CACHE.put(roadType,list);
From 9565b2f31a1ff154080f3b7c21e54f85f44a2187 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 8 Sep 2022 13:13:59 +0800
Subject: [PATCH 07/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/simulation/SimulationManager.java | 29 +++++++++++
.../ATS/service/NewAtsTrainLoadService.java | 48 ++++++++++++-------
.../ATS/service/TrainPositionService.java | 32 +++++--------
.../cbtc/SimulationLifeCycleServiceImpl.java | 12 ++++-
.../joylink/rtss/vo/ws/TrainPosition.java | 4 +-
.../websocket/client/StompClientManager.java | 8 ++--
6 files changed, 89 insertions(+), 44 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java
index caea255e8..371d89d54 100644
--- a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java
+++ b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java
@@ -1,12 +1,15 @@
package club.joylink.rtss.simulation;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.event.SimulationDestroyEvent;
import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent;
import club.joylink.rtss.simulation.event.SimulationFaultRemoveEvent;
import club.joylink.rtss.simulation.event.SimulationMemberPlayChangeEvent;
import club.joylink.rtss.simulation.messaging.websocket.DefaultMessageSender;
import club.joylink.rtss.simulation.vo.SimulationFaultVO;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -20,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@@ -31,6 +35,19 @@ public class SimulationManager {
public static final Map simulationCache = new ConcurrentHashMap<>();
+ /**
+ * 数据过期时间
+ */
+ private final static long EXPIRE_SECTION_TIME_MIN = 10;
+ /**
+ * 区段的缓存
+ * key 对应的方向类型
+ * EXPIRE_SECTION_TIME_MIN 数据过期时间
+ */
+ private final static Cache> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
+// private final static Cache> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
+
+
public static final int Destroy_Time = 180; // RtSimulation无用户时销毁时间,单位s
@Scheduled(fixedRate = 5000)
public void cleanUselessRtSimulation() {
@@ -61,6 +78,15 @@ public class SimulationManager {
});
}
+
+ public void putSectionDirCache(String type,List list){
+ ROAD_TYPE_CACHE.put(type,list);
+ }
+
+ public List getSectionDir(String type){
+ return ROAD_TYPE_CACHE.getIfPresent(type);
+
+ }
/**
* 保存仿真
* @return 需要销毁的仿真
@@ -113,8 +139,11 @@ public class SimulationManager {
}
public Simulation destroy(String id) {
+
Simulation simulation = simulationCache.remove(id);
if (simulation != null) {
+ ROAD_TYPE_CACHE.invalidate(simulation.getId() + "-" + Section.SectionRoadType.LEFT.name());
+ ROAD_TYPE_CACHE.invalidate(simulation.getId() + "-" + Section.SectionRoadType.RIGHT.name());
if (simulation instanceof club.joylink.rtss.simulation.cbtc.Simulation) {
this.applicationContext.publishEvent(new SimulationDestroyEvent(this, (club.joylink.rtss.simulation.cbtc.Simulation) simulation));
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 4b58317b2..7b4574f02 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -1,12 +1,14 @@
package club.joylink.rtss.simulation.cbtc.ATS.service;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
+import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
+import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
@@ -29,17 +31,20 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
import club.joylink.rtss.vo.ws.TrainPosition;
+import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
+import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -49,35 +54,44 @@ public class NewAtsTrainLoadService extends AtsTrainLoadService {
@Resource
private VRTrainRunningService vrTrainRunningService;
+ @Resource
+ private SimulationManager simulationManager;
-
-
+ private final static AtomicLong TRIP_NUM = new AtomicLong(0);
+ private String createTripNum(String groupNum){
+ String tripNum = Strings.padStart(TRIP_NUM.incrementAndGet() + "",4,'0');
+ return String.join(groupNum,"-",tripNum);
+ }
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository();
- String tripNumber = tp.getTrainTripNum();
- TrainInfo trainInfo = repository.getTrainInfoMap().values().stream().filter(train -> tripNumber.equals(train.getTripNumber())).findFirst().orElse(null);
-// List allVrTrain = repository.getAllVrTrain();
+ Map trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(d->d.getGroupNumber(),Function.identity()));
- if(Objects.nonNull(trainInfo)){
+ if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
+ log.error("没有找到对应车组号 param:{}",tp);
+ return;
+ }
+ VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
+ if(Objects.nonNull(virtualRealityTrain)){
//存在列车需要更新位置
- Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream().filter(d->Objects.equals(d.getTripNumber(),tripNumber)).findFirst();
- VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
trainOnline(simulation, section, tp, virtualRealityTrain);
-// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
+ virtualRealityTrain.setDriveMode(DriveMode.CM);
}else{
- Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream()
+ /*Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream()
.filter(vrTrain -> !repository.isVrTrainOnline(vrTrain.getGroupNumber()))
.findFirst();
- VirtualRealityTrain virtualRealityTrain = virtualRealityTrainOptional.get();
+ if(virtualRealityTrainOptional.isEmpty()){
+ log.error("没有更多的车组可以使用 param:{}",tp);
+ return;
+ }*/
+ virtualRealityTrain = trainMap.get(tp.getGroupNum());
+ virtualRealityTrain.setDriveMode(DriveMode.CM);
// 设置列车车次
- virtualRealityTrain.setTripNumber(tripNumber);
+ virtualRealityTrain.setTripNumber(this.createTripNum(tp.getGroupNum()));
trainOnline(simulation, section, tp, virtualRealityTrain);
-// SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
-// virtualRealityTrain.initManualTrain(headPosition, tp.isRight());
}
}
@@ -99,9 +113,9 @@ public class NewAtsTrainLoadService extends AtsTrainLoadService {
//重叠检测
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
- SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
- boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
- BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
+// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
+// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
+// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index fe9a4b9f3..6eeb589f7 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -28,16 +28,6 @@ public class TrainPositionService {
private NewAtsTrainLoadService newAtsTrainLoadService;
@Resource
private SimulationManager simulationManager;
- /**
- * 数据过期时间
- */
- private final static long EXPIRE_SECTION_TIME_MIN = 10;
- /**
- * 区段的缓存
- * key 对应的方向类型
- * EXPIRE_SECTION_TIME_MIN 数据过期时间
- */
- private final static Cache> ROAD_TYPE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_SECTION_TIME_MIN, TimeUnit.MINUTES).build();
/**
* 初始化或更新列车的位置
@@ -52,13 +42,13 @@ public class TrainPositionService {
return;
}
- List sectionList = findDirectionAllSection(simulationList.get(0),tp.getRoadType());
- Section section = this.findSecion(sectionList,tp);
- if(Objects.isNull(section)){
- log.error("未找到对应的区段 param:{}",json);
- return;
- }
for (Simulation sim : simulationList) {
+ List sectionList = findDirectionAllSection(sim,tp.getRoadType());
+ Section section = this.findSecion(sectionList,tp);
+ if(Objects.isNull(section)){
+ log.error("未找到对应的区段 param:{}",json);
+ return;
+ }
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
}
}
@@ -94,15 +84,15 @@ public class TrainPositionService {
* @param roadType
* @return
*/
- private static synchronized List findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
- List list = ROAD_TYPE_CACHE.getIfPresent(roadType);
+ private synchronized List findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
+ String key = sim.getId() + "-" + roadType.name();
+ List list = simulationManager.getSectionDir(key);
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
- List list1 = list.stream().filter(d->d.getRoadType() == roadType && Objects.isNull(d.getKmMin())).map(d->d.getCode() + "-->" + d.getName()).collect(Collectors.toList());
- log.info(list1.toString());
+
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
- ROAD_TYPE_CACHE.put(roadType,list);
+ simulationManager.putSectionDirCache(key,list);
}
return list;
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
index 26e6fca67..b9b6d8f75 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
@@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc;
+import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.services.IVoiceCommandService;
@@ -179,6 +180,14 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
}
private void addJobs(Simulation simulation) {
+ if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION){
+ //非武汉大屏车辆定位
+ atsLogicLoop.addJobs(simulation);
+ atsMessageCollectAndDispatcher.addJobs(simulation);
+ vrDeviceLogicLoop.addJobs(simulation);
+ ciLogic.addJobs(simulation);
+ return;
+ }
if (simulation.getRepository().getConfig().isRailway()) {
ctcLogicLoop.addJobs(simulation);
} else {
@@ -192,13 +201,14 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
}
atpLogicLoop.addJobs(simulation);
atsLogicLoop.addJobs(simulation);
+ simulationRobotService.addJobs(simulation);
vrTrainRunningService.addJobs(simulation);
ciLogic.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
joylink3DMessageService.addJobs(simulation);
faultGenerator.addJobs(simulation);
- simulationRobotService.addJobs(simulation);
+
}
@Override
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index a9d5e8c5a..f71b8eee4 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -3,11 +3,13 @@ package club.joylink.rtss.vo.ws;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import lombok.Data;
import lombok.NoArgsConstructor;
+import lombok.ToString;
@Data
@NoArgsConstructor
+@ToString
public class TrainPosition {
- private String trainTripNum;
+ private String groupNum;
/**
* 方向1=上行(向右),0=下行(向左)
*/
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index 87a43bbc6..c67a4c0c0 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -27,8 +27,8 @@ public class StompClientManager {
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
StompSession stompSession = future.get();
- runToLeft(stompSession,"train001");
-// runToRight(stompSession,"train002");
+ runToLeft(stompSession,"001");
+ runToRight(stompSession,"002");
}
@@ -38,7 +38,7 @@ public class StompClientManager {
while(true){
location -= step;
Map dataMap = new HashMap<>();
- dataMap.put("trainTripNum",tripNum);
+ dataMap.put("groupNum",tripNum);
// dataMap.put("direction",1);
dataMap.put("direction",0);
dataMap.put("location",location);
@@ -58,7 +58,7 @@ public class StompClientManager {
while(true){
location += step;
Map dataMap = new HashMap<>();
- dataMap.put("trainTripNum",tripNum);
+ dataMap.put("groupNum",tripNum);
dataMap.put("direction",1);
// dataMap.put("direction",0);
dataMap.put("location",location);
From 45ac71635554fe3146eb5cda685c32ff89e4d94a Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 8 Sep 2022 13:44:55 +0800
Subject: [PATCH 08/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ATS/service/NewAtsTrainLoadService.java | 19 +++----------------
.../websocket/client/StompClientManager.java | 2 +-
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 7b4574f02..e6781f9e0 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -50,12 +50,7 @@ import java.util.stream.Collectors;
@Slf4j
@Component
-public class NewAtsTrainLoadService extends AtsTrainLoadService {
-
- @Resource
- private VRTrainRunningService vrTrainRunningService;
- @Resource
- private SimulationManager simulationManager;
+public class NewAtsTrainLoadService {
private final static AtomicLong TRIP_NUM = new AtomicLong(0);
private String createTripNum(String groupNum){
@@ -76,19 +71,11 @@ public class NewAtsTrainLoadService extends AtsTrainLoadService {
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
if(Objects.nonNull(virtualRealityTrain)){
//存在列车需要更新位置
+ virtualRealityTrain.setRunLevel(RunLevel.IL);
trainOnline(simulation, section, tp, virtualRealityTrain);
- virtualRealityTrain.setDriveMode(DriveMode.CM);
}else{
-
- /*Optional virtualRealityTrainOptional = repository.getAllVrTrain().stream()
- .filter(vrTrain -> !repository.isVrTrainOnline(vrTrain.getGroupNumber()))
- .findFirst();
- if(virtualRealityTrainOptional.isEmpty()){
- log.error("没有更多的车组可以使用 param:{}",tp);
- return;
- }*/
virtualRealityTrain = trainMap.get(tp.getGroupNum());
- virtualRealityTrain.setDriveMode(DriveMode.CM);
+ virtualRealityTrain.setRunLevel(RunLevel.IL);
// 设置列车车次
virtualRealityTrain.setTripNumber(this.createTripNum(tp.getGroupNum()));
trainOnline(simulation, section, tp, virtualRealityTrain);
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index c67a4c0c0..77a18e9c7 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -33,7 +33,7 @@ public class StompClientManager {
}
public static void runToLeft(StompSession stompSession,String tripNum){
- int step = 80;
+ int step = 20;
int location = 40000;
while(true){
location -= step;
From 1363355e8f10633d620b9db446c161821e15e364 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 8 Sep 2022 15:36:26 +0800
Subject: [PATCH 09/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4=EF=BC=8C=E8=B0=83=E6=95=B4=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../club/joylink/rtss/constants/MapPrdTypeEnum.java | 2 +-
.../cbtc/ATS/service/NewAtsTrainLoadService.java | 11 +----------
.../cbtc/ATS/service/TrainPositionService.java | 5 ++---
.../cbtc/SimulationLifeCycleServiceImpl.java | 2 +-
.../java/club/joylink/rtss/vo/client/TreeNode.java | 6 ++++--
5 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
index b5f2b4b42..9b47f383e 100644
--- a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
+++ b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java
@@ -13,7 +13,7 @@ public enum MapPrdTypeEnum {
BIG_SCREEN("07", "大屏工作站", null),
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
DEPOT_IL("09", "车辆段联锁工作站", null),
- BIG_SCREEN_TRAIN_POSITION("10", "大屏车辆真实工作站", null),
+ YJDDZH("10", "应急调度指挥系统", null),
// CTC("10", "CTC工作站")
;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index e6781f9e0..a6f19394f 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -52,17 +52,10 @@ import java.util.stream.Collectors;
@Component
public class NewAtsTrainLoadService {
- private final static AtomicLong TRIP_NUM = new AtomicLong(0);
- private String createTripNum(String groupNum){
- String tripNum = Strings.padStart(TRIP_NUM.incrementAndGet() + "",4,'0');
- return String.join(groupNum,"-",tripNum);
- }
-
-
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository();
- Map trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(d->d.getGroupNumber(),Function.identity()));
+ Map trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
log.error("没有找到对应车组号 param:{}",tp);
@@ -76,8 +69,6 @@ public class NewAtsTrainLoadService {
}else{
virtualRealityTrain = trainMap.get(tp.getGroupNum());
virtualRealityTrain.setRunLevel(RunLevel.IL);
- // 设置列车车次
- virtualRealityTrain.setTripNumber(this.createTripNum(tp.getGroupNum()));
trainOnline(simulation, section, tp, virtualRealityTrain);
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index 6eeb589f7..275c26031 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -98,7 +98,7 @@ public class TrainPositionService {
}
/**
- * 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION
+ * 获取对应线路的仿真,并且地图类型为 MapPrdTypeEnum.YJDDZH
* @param mapName
* @return
*/
@@ -107,8 +107,7 @@ public class TrainPositionService {
if(d instanceof Simulation){
Simulation sim = (Simulation) d;
SimulationBuildParams params = sim.getBuildParams();
- boolean same = Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION;
- return same;
+ return Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.YJDDZH;
}
return false;
}).map(d->(Simulation) d).collect(Collectors.toList());
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
index b9b6d8f75..6550bc565 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
@@ -180,7 +180,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
}
private void addJobs(Simulation simulation) {
- if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION){
+ if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位
atsLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
diff --git a/src/main/java/club/joylink/rtss/vo/client/TreeNode.java b/src/main/java/club/joylink/rtss/vo/client/TreeNode.java
index 1aa721749..2bebb8e72 100644
--- a/src/main/java/club/joylink/rtss/vo/client/TreeNode.java
+++ b/src/main/java/club/joylink/rtss/vo/client/TreeNode.java
@@ -267,7 +267,8 @@ public class TreeNode {
if (!CollectionUtils.isEmpty(mapSystemVOList)) {
Map> listMap = mapSystemVOList.stream()
.filter(mapSystemVO -> mapSystemVO.getMapId().equals(mapVO.getId())
- && !MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType()))
+ && !MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
+ && !MapPrdTypeEnum.YJDDZH.getCode().equals(mapSystemVO.getPrdType()))
.collect(Collectors.groupingBy(MapSystemVO::getType));
listMap.forEach((type, list) -> {
TreeNode systemNode = buildSystemNode(type, "");
@@ -275,7 +276,8 @@ public class TreeNode {
list.forEach(mapSystemVO -> systemNode.addChild(buildMapSystemNode(mapSystemVO)));
});
List collect = mapSystemVOList.stream()
- .filter(mapSystemVO -> MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
+ .filter(mapSystemVO -> (MapPrdTypeEnum.JOINT.getCode().equals(mapSystemVO.getPrdType())
+ || MapPrdTypeEnum.YJDDZH.getCode().equals(mapSystemVO.getPrdType()))
&& mapSystemVO.getMapId().equals(mapVO.getId()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
From a13eaceeeea82218ef75ec141c7934da69d7be28 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 8 Sep 2022 17:09:31 +0800
Subject: [PATCH 10/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/club/joylink/rtss/constants/Project.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/constants/Project.java b/src/main/java/club/joylink/rtss/constants/Project.java
index 34319eb25..c1e5e2648 100644
--- a/src/main/java/club/joylink/rtss/constants/Project.java
+++ b/src/main/java/club/joylink/rtss/constants/Project.java
@@ -61,7 +61,8 @@ public enum Project {
/** 哈盈达-铁路 */
HYD_RAILWAY,
/** 武汉8号线 */
- WH
+ WH,
+ YJDDZH
;
public static boolean isDefault(Project project) {
From 5d66e5ae098cf9b5a71be54466949665b6e2bd28 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 8 Sep 2022 18:04:05 +0800
Subject: [PATCH 11/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/club/joylink/rtss/constants/Project.java | 3 ++-
.../simulation/cbtc/ATS/service/TrainPositionService.java | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/constants/Project.java b/src/main/java/club/joylink/rtss/constants/Project.java
index c1e5e2648..a26e82c2f 100644
--- a/src/main/java/club/joylink/rtss/constants/Project.java
+++ b/src/main/java/club/joylink/rtss/constants/Project.java
@@ -61,7 +61,8 @@ public enum Project {
/** 哈盈达-铁路 */
HYD_RAILWAY,
/** 武汉8号线 */
- WH,
+// WH,
+ /** 武汉8号线 应急调度指挥系统*/
YJDDZH
;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index 275c26031..2cdeae904 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -60,7 +60,7 @@ public class TrainPositionService {
* @return
*/
private Section findSecion(List sectionList,TrainPosition tp){
- int i = 0;
+// int i = 0;
// Section findSection;
for (Section section : sectionList) {
if(tp.isRight()){
@@ -72,7 +72,7 @@ public class TrainPositionService {
return section;
}
}
- i++;
+// i++;
}
return null;
}
@@ -92,7 +92,7 @@ public class TrainPositionService {
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
- simulationManager.putSectionDirCache(key,list);
+// simulationManager.putSectionDirCache(key,list);
}
return list;
}
From 52625cce1d0d9394371372cfadc733ac83b6cf64 Mon Sep 17 00:00:00 2001
From: thesai <1021828630@qq.com>
Date: Thu, 8 Sep 2022 23:23:10 +0800
Subject: [PATCH 12/31] =?UTF-8?q?=E7=BA=A2=E6=B2=B3=E8=B4=A2=E7=BB=8F?=
=?UTF-8?q?=E7=8E=B0=E5=9C=BA=E9=83=A8=E7=BD=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/MapDataHandleController.java | 14 +++-
.../services/VirtualRealityIbpService.java | 10 +--
.../services/project/DeviceServiceImpl.java | 11 +++
.../publishData/PublishMapDataHandler.java | 66 ++++++++++++++++--
.../ThirdAccountDataSyncService.java | 4 ++
.../ProjectJointSimulationServiceImpl.java | 7 +-
.../cbtc/data/vr/ControllableVrDevice.java | 4 ++
.../data/vr/VirtualRealityScreenDoor.java | 40 +++++++----
.../modbustcp/hhcj/HhcjIbpServiceImpl.java | 10 ++-
.../real/modbustcp/hhcj/HhcjPsdConfig.java | 21 ++++++
.../modbustcp/hhcj/HhcjPsdServiceImpl.java | 68 +++++++++++++++++++
.../{richor => zjd}/ZjdIbpConfig.java | 2 +-
.../{richor => zjd}/ZjdIbpServiceImpl.java | 2 +-
.../{richor => zjd}/ZjdPsdConfig.java | 2 +-
.../{richor => zjd}/ZjdPsdServiceImpl.java | 2 +-
.../{richor => zjd}/ZjdPslConfig.java | 2 +-
.../{richor => zjd}/ZjdPslServiceImpl.java | 2 +-
.../vo/client/project/ProjectDeviceVO.java | 10 ++-
.../client/project/hhcj/HhcjIbpConfigVO.java | 15 ++++
.../client/project/hhcj/HhcjPsdConfigVO.java | 25 +++++++
src/main/resources/application.yml | 8 +--
21 files changed, 284 insertions(+), 41 deletions(-)
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjPsdConfig.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjPsdServiceImpl.java
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdIbpConfig.java (98%)
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdIbpServiceImpl.java (99%)
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdPsdConfig.java (98%)
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdPsdServiceImpl.java (99%)
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdPslConfig.java (98%)
rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/{richor => zjd}/ZjdPslServiceImpl.java (99%)
create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjPsdConfigVO.java
diff --git a/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java b/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java
index edf332143..b0be90cdd 100644
--- a/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java
+++ b/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java
@@ -4,9 +4,9 @@ import club.joylink.rtss.services.draftData.DraftMapDataHandleService;
import club.joylink.rtss.services.publishData.PublishMapDataHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.LinkedHashMap;
/**
* 地图数据处理
@@ -35,4 +35,12 @@ public class MapDataHandleController {
public void signalShowDirection() {
this.publishMapDataHandler.signalShowDirection();
}
+
+ /**
+ * 批量修改线路数据和ISCS的车站名
+ */
+ @PutMapping("/{mapId}/stationName/mapAndIscs")
+ public void changeStationName(@PathVariable long mapId, @RequestBody LinkedHashMap nameMap) {
+ this.publishMapDataHandler.changeStationName(mapId, nameMap);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java
index 9f7b33c36..edc6323dd 100644
--- a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java
+++ b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java
@@ -126,13 +126,15 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
break;
}
case XXYS: {
- List czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false);
- czLights.forEach(light -> light.orderTo(true));
+// List czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false);
+// czLights.forEach(light -> light.orderTo(true));
+ ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false).orderTo(true);
break;
}
case SXYS: {
- List czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true);
- czLights.forEach(light -> light.orderTo(true));
+// List czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true);
+// czLights.forEach(light -> light.orderTo(true));
+ ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true).orderTo(true);
break;
}
// case PSD_HSJC: {
diff --git a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java
index cd82289ef..90519eef7 100644
--- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java
@@ -15,6 +15,7 @@ import club.joylink.rtss.vo.client.project.*;
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO;
import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO;
+import club.joylink.rtss.vo.client.project.hhcj.HhcjPsdConfigVO;
import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO;
import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
@@ -486,6 +487,16 @@ public class DeviceServiceImpl implements DeviceService {
HhcjIbpConfigVO ibpConfigVO = new HhcjIbpConfigVO();
ibp.setConfig(ibpConfigVO.toJson());
list.add(ibp);
+ // PSD
+ ProjectDevice psd = new ProjectDevice();
+ psd.setProjectCode(Project.RICHOR_HHCJ.name());
+ psd.setCode("hhcj-psd");
+ psd.setType(ProjectDeviceType.PSD.name());
+ psd.setCreator(accountVO.getId());
+ psd.setCreateTime(now);
+ HhcjPsdConfigVO psdConfigVO = new HhcjPsdConfigVO();
+ psd.setConfig(psdConfigVO.toJson());
+ list.add(psd);
return list;
}
diff --git a/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java b/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java
index 05f04469d..1dd3298b2 100644
--- a/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java
+++ b/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java
@@ -1,12 +1,14 @@
package club.joylink.rtss.services.publishData;
+import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.MapStatus;
+import club.joylink.rtss.dao.IscsDAO;
import club.joylink.rtss.dao.MapDataDAO;
import club.joylink.rtss.dao.MapInfoDAO;
-import club.joylink.rtss.entity.MapDataWithBLOBs;
-import club.joylink.rtss.entity.MapInfo;
-import club.joylink.rtss.entity.MapInfoExample;
+import club.joylink.rtss.entity.*;
+import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
+import club.joylink.rtss.services.cache.ICacheService;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
@@ -21,14 +23,12 @@ import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
-import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
@Service
public class PublishMapDataHandler {
@@ -38,6 +38,10 @@ public class PublishMapDataHandler {
private MapInfoDAO mapInfoDAO;
@Autowired
private MapDataDAO mapDataDAO;
+ @Autowired
+ private IscsDAO iscsDAO;
+ @Autowired
+ private ICacheService iCacheService;
public List queryMapInfos() {
MapInfoExample example = new MapInfoExample();
@@ -207,4 +211,54 @@ public class PublishMapDataHandler {
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
}
+
+ public void changeStationName(long mapId, Map nameMap) {
+ // 修改地图数据
+ MapDataWithBLOBs mapData = getMapDataEntity(mapId);
+ String graphData = mapData.getGraphData();
+ for (Map.Entry entry : nameMap.entrySet()) {
+ String k = entry.getKey();
+ String v = entry.getValue();
+ graphData = graphData.replace(k, v);
+ }
+ mapData.setGraphData(graphData);
+ mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData);
+ // 修改ISCS数据
+ IscsExample iscsExample = new IscsExample();
+ iscsExample.createCriteria().andMapIdEqualTo(mapId);
+ List iscsList = iscsDAO.selectByExampleWithBLOBs(iscsExample);
+ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(iscsList);
+ for (Iscs iscs : iscsList) {
+ String iscsGraphData = iscs.getGraphData();
+ for (Map.Entry entry : nameMap.entrySet()) {
+ String k = entry.getKey();
+ String v = entry.getValue();
+ iscsGraphData = iscsGraphData.replace(k, v);
+ }
+ iscs.setGraphData(iscsGraphData);
+ iscsDAO.updateByPrimaryKeyWithBLOBs(iscs);
+ }
+ // 刷新缓存
+ iCacheService.remove(BusinessConsts.CachePrefix.Map + mapId);
+ iMapService.getMapDetail(mapId);
+ }
+
+ private MapDataWithBLOBs getMapDataEntity(long mapId) {
+ MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(mapId);
+ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapInfo);
+ return getMapDataEntity(mapId, mapInfo.getVersion());
+ }
+
+ private MapDataWithBLOBs findMapDataEntity(long mapId, String version) {
+ MapDataExample example = new MapDataExample();
+ example.createCriteria().andMapIdEqualTo(mapId).andVersionEqualTo(version);
+ List list = mapDataDAO.selectByExampleWithBLOBs(example);
+ return CollectionUtils.isEmpty(list) ? null : list.get(0);
+ }
+
+ private MapDataWithBLOBs getMapDataEntity(long mapId, String version) {
+ MapDataWithBLOBs entity = findMapDataEntity(mapId, version);
+ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity);
+ return entity;
+ }
}
diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java
index ff82d852e..34a28838b 100644
--- a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java
+++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountDataSyncService.java
@@ -10,6 +10,7 @@ import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.http.HttpEntity;
@@ -26,6 +27,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+@Slf4j
@Service
public class ThirdAccountDataSyncService {
@@ -88,6 +90,8 @@ public class ThirdAccountDataSyncService {
String body = JsonUtils.writeValueAsString(syncRecordData);
HttpEntity httpEntity = new HttpEntity<>(body, headers);
ResponseEntity responseEntity = this.restTemplate.postForEntity(url, httpEntity, String.class);
+ log.info("向第三方发送数据:" + body);
+ log.info("第三方同步数据接口Response:" + responseEntity);
}
private Map buildSyncUserSimulationRecordData(AccountVO accountVO, UserSimulationStats record) {
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
index 78f67f22d..59fda98f5 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
@@ -15,9 +15,10 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1Ib
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjIbpConfig;
-import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
-import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdIbpConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceThread;
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSignalConfig;
@@ -171,6 +172,8 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
switch (config.getDeviceType()) {
case IBP:
return ((HhcjIbpConfig) config).getConfigVO().getIbpCode();
+ case PSD:
+ return ((HhcjPsdConfig) config).getConfigVO().getPsdCode();
}
}
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java
index 25313b82b..c02f2d199 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java
@@ -91,4 +91,8 @@ public abstract class ControllableVrDevice extends VirtualRealityDevice {
* @param command
*/
protected abstract void doFinish(C command);
+
+ void setRemain(int remain) {
+ this.remain = remain;
+ }
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java
index d385f3879..6a8b7d0db 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java
@@ -69,28 +69,44 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice 0) {
+ vrPsd.turning(SimulationModule.VRD.getRateMs());
+ }
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpConfig.java
similarity index 98%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpConfig.java
index 1bdf7b076..d2d52db27 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpConfig.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java
similarity index 99%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java
index d1a96ce30..d11c80ecd 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdConfig.java
similarity index 98%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdConfig.java
index 03f40d844..f54cd2a98 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdConfig.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java
similarity index 99%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java
index 99a5af0ac..5b4d19de7 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslConfig.java
similarity index 98%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslConfig.java
index 27e18ec14..55490904c 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslConfig.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java
similarity index 99%
rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java
rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java
index 4b3adc3a5..eac446b87 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
+package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
diff --git a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java
index 729059b08..7eb70181d 100644
--- a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java
+++ b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java
@@ -10,12 +10,13 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConf
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjIbpConfig;
-import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig;
-import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPsdConfig;
-import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdIbpConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPsdConfig;
+import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig;
@@ -136,6 +137,9 @@ public class ProjectDeviceVO {
case IBP:
list.add(new HhcjIbpConfig(deviceVO));
break;
+ case PSD:
+ list.add(new HhcjPsdConfig(deviceVO));
+ break;
case PLC_GATEWAY:
list.add(new PlcGateway(deviceVO));
break;
diff --git a/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java
index 20a33b281..ee1238938 100644
--- a/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java
+++ b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjIbpConfigVO.java
@@ -532,6 +532,16 @@ public class HhcjIbpConfigVO extends RealConfigVO {
*/
private Integer w_sdtf_cthbm11M10 = 140;
+ /**
+ * 屏蔽门-实体-开门
+ */
+ private Integer w_psd_real_km = 144;
+
+ /**
+ * 屏蔽门-实体-关门
+ */
+ private Integer w_psd_real_gm = 145;
+
/**
* 车站环控-恢复正常按钮
*/
@@ -959,6 +969,11 @@ public class HhcjIbpConfigVO extends RealConfigVO {
*/
private Integer w_xfsb_dsw = 292;
+ /**
+ * 闸机-实体设备控制
+ */
+ private Integer w_zj_real = 296;
+
public HhcjIbpConfigVO() {
super(0, 304);
}
diff --git a/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjPsdConfigVO.java
new file mode 100644
index 000000000..670eceaee
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/vo/client/project/hhcj/HhcjPsdConfigVO.java
@@ -0,0 +1,25 @@
+package club.joylink.rtss.vo.client.project.hhcj;
+
+import club.joylink.rtss.vo.client.project.RealConfigVO;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class HhcjPsdConfigVO extends RealConfigVO {
+ private String psdCode = "Psd87821";
+
+ /**
+ * PLC网关的144
+ */
+ private Integer w_km = 144;
+
+ /**
+ * PLC网关的145
+ */
+ private Integer w_gm = 145;
+
+ public HhcjPsdConfigVO() {
+ super(0, 304);
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 403ddd9d1..4336a4092 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -95,9 +95,9 @@ springfox:
spring:
profiles: dev
datasource:
- url: jdbc:mysql://192.168.3.233:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+ url: jdbc:mysql://localhost:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
- password: joylink0503
+ password: root
tencent-cloud:
allow-send: false
@@ -190,9 +190,9 @@ common:
spring:
profiles: local
datasource:
- url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+ url: jdbc:mysql://192.168.0.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
- password: joylink0503
+ password: localdb
tencent-cloud:
allow-send: false
From eaf30840a1db2ed08da8803190dc6b90b0e53574 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 08:51:33 +0800
Subject: [PATCH 13/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cbtc/ATS/service/TrainPositionService.java | 4 +++-
src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java | 9 +++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index 2cdeae904..c0ba6839a 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -36,6 +36,8 @@ public class TrainPositionService {
*/
public void initTrainOrUpdate(String mapName,String json){
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
+ tp.setReceiveTime(System.currentTimeMillis());
+ log.info(tp.toString());
List simulationList = this.findSimulationList(mapName);
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
@@ -92,7 +94,7 @@ public class TrainPositionService {
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
-// simulationManager.putSectionDirCache(key,list);
+ simulationManager.putSectionDirCache(key,list);
}
return list;
}
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index f71b8eee4..9062b33e6 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -1,13 +1,14 @@
package club.joylink.rtss.vo.ws;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import club.joylink.rtss.util.JsonUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Data
@NoArgsConstructor
-@ToString
+
public class TrainPosition {
private String groupNum;
/**
@@ -15,7 +16,7 @@ public class TrainPosition {
*/
private int direction;
private float location;
-
+ private Long receiveTime;
public Section.SectionRoadType getRoadType(){
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
if(this.direction == 1){
@@ -26,4 +27,8 @@ public class TrainPosition {
public boolean isRight(){
return this.direction == 1;
}
+ @Override
+ public String toString(){
+ return JsonUtils.writeValueNullableFieldAsString(this);
+ }
}
From 4d0205f578bf0d6692aaccea0dbe430c1bb77de7 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 10:17:26 +0800
Subject: [PATCH 14/31] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=AB=99=E7=BB=86?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cbtc/CTC/data/CascoControl.java | 1 +
.../cbtc/CTC/service/CTCService.java | 1 +
.../cbtc/CTC/service/CascoControlService.java | 221 +++++++++++-------
3 files changed, 134 insertions(+), 89 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java
index 4dcc2f6aa..59d6c2178 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CascoControl.java
@@ -13,6 +13,7 @@ import java.util.Objects;
@Data
@NoArgsConstructor
public class CascoControl {
+
private Simulation simulation;
private Station station;
private Route route;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java
index 38f5a9562..ecf0602a0 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CTCService.java
@@ -186,6 +186,7 @@ public class CTCService {
CascoControl cc = new CascoControl(simulation,station,route,tripNumber);
List errCCMsg = this.cascoControl(cc,Objects.isNull(force) ? false:force.booleanValue());//站细卡控
if(Objects.equals(false,CollectionUtils.isEmpty(errCCMsg))){
+ //站细检测错误的信息
return errCCMsg;
}
if (StringUtils.hasText(tripNumber) && !Objects.equals(true, force)) { //列车进路防错办
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java
index b3b590d06..8e5274bfb 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/service/CascoControlService.java
@@ -1,27 +1,22 @@
package club.joylink.rtss.simulation.cbtc.CTC.service;
import club.joylink.rtss.exception.BusinessException;
-import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
-import club.joylink.rtss.simulation.cbtc.data.map.Station;
import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.annotations.Case;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
-import java.util.*;
-
-import static club.joylink.rtss.simulation.cbtc.CTC.data.TrackSection.DirectionType;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
@Service
@Slf4j
@@ -29,34 +24,54 @@ public class CascoControlService {
/**
*
- * @param cc
+ * @param cc 卡控参数
* @return
*/
public List checkCascoControlRoute(CascoControl cc){
- Station station = cc.getStation();
Simulation simulation = cc.getSimulation();
- String stationCode = station.getCode();
+ CheckData checkData = this.findCheckData(cc,simulation.getCtcRepository().getCtcEffectRepository());
+ if(checkData.isJustReturn()){
+ //说明没有行车计划需要立刻返回
+ return Collections.emptyList();
+ }
+ if(Objects.equals(false,CollectionUtils.isEmpty(cc.getErrorList()))){
+ return cc.getErrorList();
+ }
+ this.checkRegularTrainLine(checkData,cc.getErrorList());
+ this.doorCheckDetail(checkData,cc.getErrorList());
+ this.checkStationTrackDetail(checkData,cc.getErrorList());
+ return cc.getErrorList();
+ }
- CtcRepository ctcRepository = simulation.getCtcRepository();
- CtcEffectRepository effectRepository = ctcRepository.getCtcEffectRepository();
- List errMsgList = cc.getErrorList();
+
+ /**
+ * 获取检测固定径路,出入口,股道必要的参数数据
+ * @param cc
+ * @param effectRepository
+ * @return
+ */
+ private CheckData findCheckData(CascoControl cc,CtcEffectRepository effectRepository){
+ String stationCode = cc.getStation().getCode();
+ CheckData data = new CheckData();
boolean isDepart = cc.getRoute().getType() == Route.Type.DEPARTURE;
+ data.setDepart(isDepart);
CtcStationRunPlanLog runPlanLog;
try{
//在TDCS界面创建进路如果车次号没有在计划中就直接返回,先按照之前的逻辑运行
runPlanLog = this.checkForRunPlan(cc);
}catch (BusinessException e){
- log.error("站明检测失败 msg:" + e.getMessage(),e);
log.error(e.getMessage() + " errorCode:[{}]",e.getCode());
- return Collections.emptyList();
+ data.setJustReturn(true);
+ return data;
}
- CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog,errMsgList);
+
+ CtcStationRunPlanLog.RunPlanItem runPlan = this.findRunPlanFromPlan(isDepart,runPlanLog);
if(Objects.isNull(runPlan)){
- String depart = this.departToChar(isDepart);
+ String depart = data.departToChar();
String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
log.error(msg);
- errMsgList.add(msg);
- return errMsgList;
+ cc.addErrorMsg(msg);
+ return data;
}
CtcEffectRepository.StationDoorRepository doorRepository = effectRepository.getUpdateDoorMap().get(stationCode);
CtcEffectRepository.StationTrackSectionRepository stationTrackRepository = effectRepository.getUpdateStationTrackSectionMap().get(stationCode);
@@ -65,20 +80,22 @@ public class CascoControlService {
if(Objects.isNull(doorRepository)){
String msg = String.format("未找到对应的出入口站细数据,车站[%s]",stationCode);
log.error(msg);
- return Lists.newArrayList(msg);
+ cc.addErrorMsg(msg);
+ return data;
}
if(Objects.isNull(stationTrackRepository)){
String msg = String.format("未找到对应的股道站细数据,车站[%s]",stationCode);
log.error(msg);
- return Lists.newArrayList(msg);
+ cc.addErrorMsg(msg);
+ return data;
}
-
- this.checkRegularTrainLine(isDepart,runPlan,regularTrainLineRepository,runPlanLog,errMsgList);
- this.doorCheckDetail(isDepart,runPlan,doorRepository,runPlanLog,errMsgList);
- this.checkStationTrackDetail(isDepart,runPlan,stationTrackRepository,runPlanLog,errMsgList);
- return errMsgList;
+ data.setRunPlanLog(runPlanLog);
+ data.setRunPlan(runPlan);
+ data.setStationTrackRepository(stationTrackRepository);
+ data.setDoorRepository(doorRepository);
+ data.setRegularTrainLineRepository(regularTrainLineRepository);
+ return data;
}
-
private boolean trackAndDoor(Boolean d){
return Objects.isNull(d) ? false: d.booleanValue();
}
@@ -87,56 +104,59 @@ public class CascoControlService {
* 根据接发车获取行车计划的接发车计划
* @param isDepart
* @param runPlanLog
- * @param errMsgList
* @return
*/
- private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog,List errMsgList){
+ private CtcStationRunPlanLog.RunPlanItem findRunPlanFromPlan(boolean isDepart,CtcStationRunPlanLog runPlanLog){
CtcStationRunPlanLog.RunPlanItem runPlan = runPlanLog.getArriveRunPlan();
if(isDepart){
runPlan = runPlanLog.getDepartRunPlan();
}
- /*if(Objects.isNull(runPlan)){
- String msg = String.format("未找到行车计划的接发车计划 车站[%s] 车次[%s] [%s]", runPlanLog.getStation().getCode(), runPlanLog.getTripNumber(),depart);
- log.error(msg);
- errMsgList.add(msg);
- BusinessExceptionAssertEnum.STATION_DETAIL_NOT_FOUND_RD_PLAN_ITEM.assertNotNull(runPlan,msg);
- }*/
return runPlan;
}
+
/**
* 根据车辆计划(接发车,车次)查找对应更新区的车辆固定径路数据
- * @param isDepart
- * @param regularTrainLineRepository
- * @param runPlanLog
+ * @param checkData
* @param errMsg
*/
- private void checkRegularTrainLine(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository,CtcStationRunPlanLog runPlanLog,List errMsg){
- if(Objects.isNull(regularTrainLineRepository) || Objects.equals(true,CollectionUtils.isEmpty(errMsg))){
- log.error("");
+ private void checkRegularTrainLine(CheckData checkData,List errMsg){
+ CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository = checkData.getRegularTrainLineRepository();
+ if(Objects.isNull(regularTrainLineRepository) || Objects.equals(false,CollectionUtils.isEmpty(errMsg))){
+ log.error("未找到固定径路的数据车站[{}],车次[{}],方向[{}]",checkData.getRunPlanLog().getStation().getCode(),checkData.getRunPlan().getTripNumber(),checkData.departToChar());
return;
}
- final String tripNum = runPlan.getTripNumber();
+ //根据接发车获取对应的列车固定径路的数据
+ final String tripNum = checkData.runPlan.getTripNumber();
RegularTrainLine rtl = regularTrainLineRepository.getDataMap().values().stream().filter(d->{
String tmpNum = d.getArriveTipNum();
- if(isDepart){
+ if(checkData.isDepart()){
tmpNum = d.getLeaveTipNum();
}
return Objects.equals(tripNum,tmpNum);
}).findFirst().orElse(null);
if(Objects.isNull(rtl)){
+ log.error("未找到列车的固定径路 车站[{}],对应车次[{}],方向[{}]",checkData.runPlan.getStation().getCode(),tripNum,checkData.departToChar());
return;
}
StationDirection sd = rtl.getEnter();
- if(isDepart){
+ if(checkData.isDepart()){
sd = rtl.getOut();
}
- if(Objects.equals(false,trackAndDoor(runPlanLog.getTrackDiscordant())) && !Objects.equals(runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode())){
+ boolean trackSectionEQ = Objects.equals(checkData.runPlan.getTrackSection().getCode(),rtl.getMasterStand().getCode());
+ boolean doorEQ = Objects.equals(checkData.runPlan.getStationDirection().getCode(),sd.getCode());
+ //检测运行股道与固定径路是否一致
+ if(Objects.equals(false,trackAndDoor(checkData.runPlanLog.getTrackDiscordant())) && Objects.equals(false,trackSectionEQ)){
//股道不一致检测
- errMsg.add("股道固定径路不一致");
+ log.error("检测股道是否一致 计划车站[{}],计划股道[{}],径路车站[{}],径路股道[{}],车次[{}],方向[{}],固定径路[{}]",checkData.runPlan.getStation().getCode()
+ ,checkData.runPlan.getTrackSection().getCode(),rtl.getStation().getCode(),rtl.getMasterStand().getCode(),checkData.runPlan.getTripNumber(),checkData.departToChar(),rtl.getCode());
+ errMsg.add(String.format("运行股道固定径路[%s]不一致",rtl.getMasterStand().getName()));
}
- if(Objects.equals(false,trackAndDoor(runPlanLog.getEntryOutDiscordant())) && !Objects.equals(runPlan.getStationDirection().getCode(),sd.getCode())){
+ //检测出入口与固定径路是否一致
+ if(Objects.equals(false,trackAndDoor(checkData.runPlanLog.getEntryOutDiscordant())) && Objects.equals(false,doorEQ)){
//出入口不一致检测
- errMsg.add("出入口固定径路不一致");
+ log.error("检测出入口是否一致 计划车站[{}],计划股道[{}],径路车站[{}],径路股道[{}],车次[{}],方向[{}],固定径路[{}]",checkData.runPlan.getStation().getCode()
+ ,checkData.runPlan.getTrackSection().getCode(),rtl.getStation().getCode(),rtl.getMasterStand().getCode(),checkData.runPlan.getTripNumber(),checkData.departToChar(),rtl.getCode());
+ errMsg.add(String.format("运行出入口固定径路[%s]不一致",sd.getName()));
}
}
@@ -154,27 +174,25 @@ public class CascoControlService {
/**
* 检测接发计划与股道接发车方向是否一致
- * @param isDepart
- * @param stationTrackRepository
- * @param runPlanLog
+ * @param checkData
* @param errMsg
*/
- private void checkStationTrackDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationTrackSectionRepository stationTrackRepository,CtcStationRunPlanLog runPlanLog,List errMsg){
- if(!CollectionUtils.isEmpty(errMsg)){
+ private void checkStationTrackDetail(CheckData checkData,List errMsg){
+ if(Objects.equals(false,CollectionUtils.isEmpty(errMsg))){
return;
}
- String departChar = this.departToChar(isDepart);
- Section masterSection = runPlan.getTrackSection();
- TrackSection ts = stationTrackRepository.getDataMap().get(masterSection.getCode());
+ String departChar = checkData.departToChar();
+ Section masterSection = checkData.runPlan.getTrackSection();
+ TrackSection ts = checkData.stationTrackRepository.getDataMap().get(masterSection.getCode());
if(Objects.isNull(ts)){
- String d = String.format("未找到对应的股道[%s],车站[%s],车号[%s],股道[%s]",departChar,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),masterSection.getCode());
+ String d = String.format("未找到对应的股道 方向[%s],车站[%s],车号[%s],股道[%s]",departChar,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber(),masterSection.getCode());
log.error(d);
errMsg.add(d);
return;
}
- checkStationTrackForTransfinite(ts,runPlanLog,errMsg,departChar);
- checkStationTrackForTrainType(ts,runPlanLog,errMsg);
+ checkStationTrackForTransfinite(ts,checkData.runPlanLog,errMsg,departChar);
+ checkStationTrackForTrainType(ts,checkData.runPlanLog,errMsg);
}
/**
@@ -194,20 +212,24 @@ public class CascoControlService {
runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER);
//大于二级超限
boolean trainfiniteThanMoreTwo = runPlanLog.getTransfinite() == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_SUPER;
- String d = null;
+ String logMsg = null;
+ String msg = null;
if(sTT == CtcStationRunPlanLog.TransfiniteType.NO && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO){
//股道不能超限,但是计划超限
- d = String.format("股道[%s],车站[%s],车次[%s],[%s],不支持超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],不支持超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ msg = String.format("车站[%s],股道[%s] 不支持超限",runPlanLog.getStation().getName(),ts.getName());
}else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_ONE_LEVEL && transfiniteThanMoreOne){
//股道是一级超限,但是计划是二级或是超级
- d = String.format("股道[%s],车站[%s],车次[%s],[%s],一级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],一级超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ msg = String.format("车站[%s],股道[%s] 只支持一级超限",runPlanLog.getStation().getName(),ts.getName());
}else if(sTT == CtcStationRunPlanLog.TransfiniteType.TRANSFINITE_TWO_LEVEL && trainfiniteThanMoreTwo){
//股道是二级超限,但是计划是超级
- d = String.format("股道[%s],车站[%s],车次[%s],[%s],二级超限,但行车计划超限[%s]",ts.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ logMsg = String.format("车站[%s],股道[%s],车次[%s],方向[%s],二级超限,但行车计划超限[%s]",runPlanLog.getStation().getCode(),ts.getCode(),runPlanLog.getTripNumber(),departChar,runPlanLog.getTransfinite());
+ msg = String.format("车站[%s],股道[%s] 只支持二级超限",runPlanLog.getStation().getName(),ts.getName());
}
- if(Objects.equals(false,Strings.isNullOrEmpty(d))){
- log.error(d);
- errMsg.add(d);
+ if(Objects.equals(false,Strings.isNullOrEmpty(logMsg))){
+ log.error(logMsg);
+ errMsg.add(msg);
}
}
@@ -222,9 +244,11 @@ public class CascoControlService {
TrackSection.TrainType tt = ts.getTrainType();
switch (tt){
case PASSENGER:
+ //检测客车,但是计划中不是客车
trainTypeMatch = Objects.equals(false,runPlanLog.isPassengerTrain());
break;
case GOODS_VAN:
+ //检测货车,但是计划中不是货车
trainTypeMatch = Objects.equals(true,runPlanLog.isPassengerTrain());
break;
default:
@@ -232,53 +256,72 @@ public class CascoControlService {
}
if(trainTypeMatch){
String d = String.format("计划列车类型与股道类型不匹配,股道[%s] 股道区段[%s] 设置列车类型[%s],列车类型[%s]",ts.getCode(),ts.getSectionCode(),tt,runPlanLog.isPassengerTrain()?"客":"货");
- errMsg.add(d);
+ log.error(d);
+ errMsg.add(String.format("计划列车类型与股道类型不匹配"));
}
}
/**
* 计划与出入口检测明细
- * @param isDepart 是否是发车计划
- * @param doorRepository
- * @param runPlanLog
+ * @param checkData
+ * @param errMsgList
*/
- private void doorCheckDetail(boolean isDepart,CtcStationRunPlanLog.RunPlanItem runPlan,CtcEffectRepository.StationDoorRepository doorRepository,CtcStationRunPlanLog runPlanLog,List errMsgList){
+ private void doorCheckDetail(CheckData checkData,List errMsgList){
if(!CollectionUtils.isEmpty(errMsgList)){
return;
}
- String depart = this.departToChar(isDepart);
- StationDirection sd = runPlan.getStationDirection();
- StationDirection doorDir = doorRepository.getDataMap().get(sd.getCode());
+ String depart = checkData.departToChar();
+ StationDirection sd = checkData.runPlan.getStationDirection();
+ StationDirection doorDir = checkData.doorRepository.getDataMap().get(sd.getCode());
if(Objects.isNull(doorDir)){
- errMsgList.add(String.format("根据计划方向[%s] 没有找到出入口[%s]数据,车站[%s],车次[%s]"
- ,depart,sd.getCode(),runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
+ String d = String.format("根据计划方向[%s] 没有找到出入口数据 出入口[%s],车站[%s],车次[%s]"
+ ,depart,sd.getCode(),checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
+ log.error(d);
+ errMsgList.add("未找到计划方向对应的出入口数据");
}
- boolean isTransfinite = Objects.nonNull(runPlanLog.getTransfinite()) && runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO;
+ boolean isTransfinite = Objects.nonNull(checkData.runPlanLog.getTransfinite()) && checkData.runPlanLog.getTransfinite() != CtcStationRunPlanLog.TransfiniteType.NO;
if(!doorDir.isAllowOverrun() && isTransfinite){
// 出入口不能超限,但是计划超限
- errMsgList.add(String.format("出入口[%s],[%s]不允许超限,但是计划超限,车站[%s],车次[%s]"
- ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
+ String d = String.format("出入口方向[%s],车站[%s]不允许超限,但是计划超限,车站[%s],车次[%s]"
+ ,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
+ log.error(d);
+ errMsgList.add(String.format("出入口[%s]不允许超限",doorDir.getName()));
return;
}
- if(!doorDir.isTravelTrain() && Objects.equals(true,runPlanLog.isPassengerTrain())){
+ if(!doorDir.isTravelTrain() && Objects.equals(true,checkData.runPlanLog.isPassengerTrain())){
//出入口不支持客车,但是计划是客车
- errMsgList.add(String.format("出入口[%s],[%s]不允许客车,车站[%s],车次[%s]"
- ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
+ String d = String.format("出入口方向[%s],车站[%s]不允许客车,车站[%s],车次[%s]"
+ ,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
+ log.error(d);
+ errMsgList.add(String.format("出入口[%s]不支持接发客车",doorDir.getName()));
return;
}
- if(!doorDir.isGoodsTrain() && Objects.equals(false,runPlanLog.isPassengerTrain())){
+ if(!doorDir.isGoodsTrain() && Objects.equals(false,checkData.runPlanLog.isPassengerTrain())){
//出入口不支持货车,但是计划是货车
- errMsgList.add(String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]"
- ,sd.getCode(),depart,runPlanLog.getStation().getCode(),runPlanLog.getTripNumber()));
+ String d=String.format("出入口[%s],[%s]不允许货车,车站[%s],车次[%s]"
+ ,sd.getCode(),depart,checkData.runPlanLog.getStation().getCode(),checkData.runPlanLog.getTripNumber());
+ log.error(d);
+ errMsgList.add(String.format("出入口[%s]不支持接发货车",doorDir.getName()));
return;
}
}
- private String departToChar(boolean isDepart){
- return isDepart ? "发":"接";
- }
+ @Data
+ @NoArgsConstructor
+ public static class CheckData{
+ private CtcStationRunPlanLog runPlanLog;
+ private CtcStationRunPlanLog.RunPlanItem runPlan;
+ private CtcEffectRepository.StationDoorRepository doorRepository;
+ private CtcEffectRepository.StationTrackSectionRepository stationTrackRepository;
+ private CtcEffectRepository.RegularTrainLineRepository regularTrainLineRepository;
+ private boolean justReturn;
+ private boolean isDepart;
+ public String departToChar(){
+ return isDepart ? "发":"接";
+ }
+ }
}
From d57a288ae0168382cbf6c968b53e9277ca336ab5 Mon Sep 17 00:00:00 2001
From: joylink_zhangsai <1021828630@qq.com>
Date: Fri, 9 Sep 2022 11:03:33 +0800
Subject: [PATCH 15/31] =?UTF-8?q?=E8=BF=9B=E8=B7=AF=E9=A6=96=E5=8C=BA?=
=?UTF-8?q?=E6=AE=B5=E5=8D=A0=E7=94=A8=E6=97=B6=E8=81=94=E9=94=81=E7=AD=89?=
=?UTF-8?q?=E7=BA=A7=E5=8F=AA=E8=83=BD=E5=88=B0=E5=BC=95=E5=AF=BC=E7=BA=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../joylink/rtss/simulation/cbtc/CI/device/CiService.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java
index 27e459aa1..e9af22e76 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java
@@ -260,6 +260,11 @@ public class CiService {
return level;
}
}
+ //首区段占用
+ if (route.getFirstRouteSection().isOccupied()) {
+ return level;
+ }
+
if (signal.isCbtcMode()) {
level = Signal.LEVEL_Atp; // ATP级
}
From c6c26ff40a1a9fcfac16a8f257334d9414514836 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 13:33:29 +0800
Subject: [PATCH 16/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ATS/service/NewAtsTrainLoadService.java | 12 ++++--
.../ATS/service/TrainPositionService.java | 9 +++-
.../cbtc/SimulationLifeCycleServiceImpl.java | 2 +-
.../joylink/rtss/vo/ws/TrainPosition.java | 1 +
.../websocket/client/StompClientManager.java | 41 ++++++++++++++++++-
5 files changed, 56 insertions(+), 9 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index a6f19394f..5a2bdcb89 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -51,7 +51,8 @@ import java.util.stream.Collectors;
@Slf4j
@Component
public class NewAtsTrainLoadService {
-
+ @Autowired
+ private VRTrainRunningService vrTrainRunningService;
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository();
@@ -91,9 +92,12 @@ public class NewAtsTrainLoadService {
//重叠检测
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
-// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
-// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
-// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
+ SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
+ boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
+ if(willOverlap){
+ return;
+ }
+ BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index c0ba6839a..3861b6e25 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -37,16 +37,21 @@ public class TrainPositionService {
public void initTrainOrUpdate(String mapName,String json){
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
tp.setReceiveTime(System.currentTimeMillis());
- log.info(tp.toString());
+// log.info(tp.toString());
List simulationList = this.findSimulationList(mapName);
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
return;
}
-
+ boolean d = true;
for (Simulation sim : simulationList) {
List sectionList = findDirectionAllSection(sim,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
+ if(d){
+ tp.setSectionCode(section.getCode());
+ log.info(tp.toString());
+ d = false;
+ }
if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",json);
return;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
index 6550bc565..f8fb95827 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
@@ -182,7 +182,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位
- atsLogicLoop.addJobs(simulation);
+// atsLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation);
ciLogic.addJobs(simulation);
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index 9062b33e6..65e72ddb7 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -17,6 +17,7 @@ public class TrainPosition {
private int direction;
private float location;
private Long receiveTime;
+ private String sectionCode;
public Section.SectionRoadType getRoadType(){
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
if(this.direction == 1){
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index 77a18e9c7..01c880c37 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -1,6 +1,10 @@
package club.joylink.rtss.websocket.client;
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.util.JsonUtils;
+
+import club.joylink.rtss.util.test.LogTest;
+import club.joylink.rtss.vo.ws.TrainPosition;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompSession;
@@ -9,7 +13,12 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -26,10 +35,38 @@ public class StompClientManager {
ListenableFuture future = stompClient
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
StompSession stompSession = future.get();
+ LogTest lt = new LogTest();
+ List list = lt.readFile("d:\\spring.log2");
+// runToLeft(stompSession,"001");
+// runToRight(stompSession,"002");
+ list = lt.query(list,"004", Section.SectionRoadType.RIGHT);
+ send(stompSession,list);
+ }
- runToLeft(stompSession,"001");
- runToRight(stompSession,"002");
+ public static void send(StompSession stompSession,List list){
+ //48,55,56,65,75,121,127,138,150,155,162。。,183
+ //128
+ for (int i = 183; i < list.size(); i++) {
+ TrainPosition tp = list.get(i);
+ String val = JsonUtils.writeValueNullableFieldAsString(tp);
+ Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
+ ZoneId zone = ZoneId.systemDefault();
+ String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ System.out.println(d + " ->" + i +" ->" + val);
+ stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
+ if(i > 0){
+ TrainPosition old = list.get(i - 1);
+ try {
+ long sleepTime = tp.getReceiveTime() - old.getReceiveTime();
+ System.out.println("index:" + i + "sleep:"+sleepTime);
+ TimeUnit.MILLISECONDS.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
}
public static void runToLeft(StompSession stompSession,String tripNum){
From e24bfbcafe9f46c21ffdd4b13770a16b345fc74a Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 13:40:25 +0800
Subject: [PATCH 17/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../club/joylink/rtss/util/test/LogTest.java | 84 +++++++++++++++++++
1 file changed, 84 insertions(+)
create mode 100644 src/main/java/club/joylink/rtss/util/test/LogTest.java
diff --git a/src/main/java/club/joylink/rtss/util/test/LogTest.java b/src/main/java/club/joylink/rtss/util/test/LogTest.java
new file mode 100644
index 000000000..6d92fea4e
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/util/test/LogTest.java
@@ -0,0 +1,84 @@
+package club.joylink.rtss.util.test;
+
+import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import club.joylink.rtss.util.JsonUtils;
+import club.joylink.rtss.vo.ws.TrainPosition;
+import com.google.common.collect.Lists;
+
+import java.io.*;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+public class LogTest {
+
+
+ public static void main(String[] args) throws FileNotFoundException {
+ LogTest lt = new LogTest();
+ List list = lt.readFile("d:\\spring.log2");
+// lt.query(list,"024");
+ lt.queryAll(list);
+ }
+
+ public void queryAll(List list){
+ Map> mapList = list.stream()
+ .sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.groupingBy(d->d.getGroupNum() + "-" + d.getRoadType().name()));
+ mapList.forEach((k,v)->{
+
+ try(BufferedWriter writer = new BufferedWriter(new FileWriter("d:\\usr\\" + k))){
+ for (TrainPosition tp : v) {
+ Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
+ ZoneId zone = ZoneId.systemDefault();
+ String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ writer.write(d + "-->" + tp.toString() + "\n");
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ });
+ }
+ public List query(List list, String groupNum, Section.SectionRoadType roadType){
+ List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
+ return newList;
+ }
+ public List query(List list,String groupNum){
+ List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
+ return newList;
+ }
+ public List readFile(String file) {
+
+ List list = Lists.newArrayList();
+ try(BufferedReader reader = new BufferedReader(new FileReader(file))){
+// StringBuilder stringBuilder = new StringBuilder();
+ String content = null;
+ while((content = reader.readLine()) != null){
+ if(content.indexOf("TrainPositionService ") >= 0){
+// System.out.println(content);
+ TrainPosition tp = parseString(content);
+ if(Objects.nonNull(tp)){
+ list.add(tp);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+ private TrainPosition parseString(String d){
+ if(!d.contains("未找到")){
+ String t = d.substring(0,19);
+ int start = d.indexOf("{");
+ String json = d.substring(start);
+ TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
+ return tp;
+ }
+ return null;
+ }
+}
From b425e5b36bba5a2a467c6ee9e70f60933e2e1cca Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 13:45:04 +0800
Subject: [PATCH 18/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
index f8fb95827..6550bc565 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
@@ -182,7 +182,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位
-// atsLogicLoop.addJobs(simulation);
+ atsLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation);
ciLogic.addJobs(simulation);
From 114be10e1bc3acc4362e1ce429aae85ccb68dcc8 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 16:16:25 +0800
Subject: [PATCH 19/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ATS/service/NewAtsTrainLoadService.java | 12 +++++-----
.../club/joylink/rtss/util/test/LogTest.java | 24 ++++++++++++++++++-
.../joylink/rtss/vo/ws/TrainPosition.java | 11 +++++++++
.../websocket/client/StompClientManager.java | 12 +++++++---
4 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 5a2bdcb89..5a79bf45e 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -92,12 +92,12 @@ public class NewAtsTrainLoadService {
//重叠检测
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
- SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
- boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
- if(willOverlap){
- return;
- }
- BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
+// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
+// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
+// if(willOverlap){
+// return;
+// }
+// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
}
diff --git a/src/main/java/club/joylink/rtss/util/test/LogTest.java b/src/main/java/club/joylink/rtss/util/test/LogTest.java
index 6d92fea4e..21ce5b09d 100644
--- a/src/main/java/club/joylink/rtss/util/test/LogTest.java
+++ b/src/main/java/club/joylink/rtss/util/test/LogTest.java
@@ -23,7 +23,10 @@ public class LogTest {
LogTest lt = new LogTest();
List list = lt.readFile("d:\\spring.log2");
// lt.query(list,"024");
- lt.queryAll(list);
+ list = lt.query(list,"015",Section.SectionRoadType.RIGHT);
+ for (TrainPosition tp : list) {
+ System.out.println(tp.dateFormat() + " --->" + tp.toString());
+ }
}
public void queryAll(List list){
@@ -43,6 +46,11 @@ public class LogTest {
}
});
}
+
+ public List query(List list, List groups, Section.SectionRoadType roadType){
+ List newList = list.stream().filter(d->groups.contains(d.getGroupNum()) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
+ return newList;
+ }
public List query(List list, String groupNum, Section.SectionRoadType roadType){
List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
return newList;
@@ -51,6 +59,20 @@ public class LogTest {
List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
return newList;
}
+ public List readSource(String file){
+ List list = Lists.newArrayList();
+ try(BufferedReader reader = new BufferedReader(new FileReader(file))){
+// StringBuilder stringBuilder = new StringBuilder();
+ String content = null;
+ while((content = reader.readLine()) != null){
+ TrainPosition tp = JsonUtils.read(content, TrainPosition.class);
+ list.add(tp);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
public List readFile(String file) {
List list = Lists.newArrayList();
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index 65e72ddb7..e0ffc10b8 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -6,6 +6,11 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
@Data
@NoArgsConstructor
@@ -28,6 +33,12 @@ public class TrainPosition {
public boolean isRight(){
return this.direction == 1;
}
+
+ public String dateFormat(){
+ Instant instant = Instant.ofEpochMilli(this.receiveTime);
+ ZoneId zone = ZoneId.systemDefault();
+ return LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+ }
@Override
public String toString(){
return JsonUtils.writeValueNullableFieldAsString(this);
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index 01c880c37..b5f3a3f8e 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -6,6 +6,7 @@ import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.util.test.LogTest;
import club.joylink.rtss.vo.ws.TrainPosition;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.util.concurrent.ListenableFuture;
@@ -37,16 +38,18 @@ public class StompClientManager {
StompSession stompSession = future.get();
LogTest lt = new LogTest();
List list = lt.readFile("d:\\spring.log2");
+// List list = lt.readSource("d:\\t.txt");
// runToLeft(stompSession,"001");
// runToRight(stompSession,"002");
- list = lt.query(list,"004", Section.SectionRoadType.RIGHT);
+// list = lt.query(list,"042",Section.SectionRoadType.RIGHT);
+// list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT);
send(stompSession,list);
}
public static void send(StompSession stompSession,List list){
//48,55,56,65,75,121,127,138,150,155,162。。,183
//128
- for (int i = 183; i < list.size(); i++) {
+ for (int i = 0; i < list.size(); i++) {
TrainPosition tp = list.get(i);
String val = JsonUtils.writeValueNullableFieldAsString(tp);
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
@@ -58,7 +61,10 @@ public class StompClientManager {
if(i > 0){
TrainPosition old = list.get(i - 1);
try {
- long sleepTime = tp.getReceiveTime() - old.getReceiveTime();
+ long sleepTime = (tp.getReceiveTime() - old.getReceiveTime());
+ if(sleepTime > 10000){
+ sleepTime = sleepTime / 1000;
+ }
System.out.println("index:" + i + "sleep:"+sleepTime);
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
From 53c6aac14c20932e17d9030bb76d1d8a89ee858f Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 9 Sep 2022 16:42:54 +0800
Subject: [PATCH 20/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../club/joylink/rtss/util/test/LogTest.java | 19 ++++++++++++++-----
.../websocket/client/StompClientManager.java | 3 +--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/util/test/LogTest.java b/src/main/java/club/joylink/rtss/util/test/LogTest.java
index 21ce5b09d..b3ded7623 100644
--- a/src/main/java/club/joylink/rtss/util/test/LogTest.java
+++ b/src/main/java/club/joylink/rtss/util/test/LogTest.java
@@ -59,11 +59,16 @@ public class LogTest {
List newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
return newList;
}
+
+ /**
+ * 加载json源文件
+ * @param file
+ * @return
+ */
public List readSource(String file){
List list = Lists.newArrayList();
try(BufferedReader reader = new BufferedReader(new FileReader(file))){
-// StringBuilder stringBuilder = new StringBuilder();
- String content = null;
+ String content;
while((content = reader.readLine()) != null){
TrainPosition tp = JsonUtils.read(content, TrainPosition.class);
list.add(tp);
@@ -73,15 +78,19 @@ public class LogTest {
}
return list;
}
+
+ /**
+ * 加载日志
+ * @param file
+ * @return
+ */
public List readFile(String file) {
List list = Lists.newArrayList();
try(BufferedReader reader = new BufferedReader(new FileReader(file))){
-// StringBuilder stringBuilder = new StringBuilder();
- String content = null;
+ String content;
while((content = reader.readLine()) != null){
if(content.indexOf("TrainPositionService ") >= 0){
-// System.out.println(content);
TrainPosition tp = parseString(content);
if(Objects.nonNull(tp)){
list.add(tp);
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index b5f3a3f8e..e6e2ec606 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -47,8 +47,7 @@ public class StompClientManager {
}
public static void send(StompSession stompSession,List list){
- //48,55,56,65,75,121,127,138,150,155,162。。,183
- //128
+
for (int i = 0; i < list.size(); i++) {
TrainPosition tp = list.get(i);
String val = JsonUtils.writeValueNullableFieldAsString(tp);
From 3f7cb3645eb948c90daf89c2d3e97974689fba51 Mon Sep 17 00:00:00 2001
From: joylink_zhangsai <1021828630@qq.com>
Date: Tue, 13 Sep 2022 15:39:03 +0800
Subject: [PATCH 21/31] =?UTF-8?q?WS=E8=B7=AF=E5=BE=84=E7=BB=9F=E4=B8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../message/SimulationSubscribeTopic.java | 2 +
.../client/factory/SocketMessageFactory.java | 49 +++++++++----------
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
index f577055d2..33b93badf 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
@@ -16,6 +16,8 @@ public enum SimulationSubscribeTopic {
PassengerFlow("/queue/simulation/passenger/{id}"),
WeChatMini("/topic/simulation/assistant/{id}"),
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
+ Room("/queue/room/{id}"),
+ Wgu3d("/topic/simulation/wgu3d/{id}")
;
private String destPattern;
diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
index aa28e1047..a4f03a5d8 100644
--- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
+++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
@@ -66,23 +66,20 @@ public class SocketMessageFactory {
case BROADCAST:
case Order_Pay_Result:
case JointTraining_Room_Invite:
- case Be_Logged_Out: {
+ case Be_Logged_Out:
+ case Simulation_Invite: {
topicList.add(WebSocketSubscribeTopic.Common);
break;
}
case JointTraining_Room:
case JointTraining_Device:
case JointTraining_Chat: {
- topicList.add(String.format(WebSocketSubscribeTopic.Room, group));
+ topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
break;
}
case JointTraining_User: {
- topicList.add(String.format(WebSocketSubscribeTopic.Room, group));
- topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
- break;
- }
- case Simulation_Invite: {
- topicList.add(String.format(WebSocketSubscribeTopic.Common));
+ topicList.add(SimulationSubscribeTopic.Room.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
break;
}
case Simulation_Time_Sync:
@@ -107,7 +104,7 @@ public class SocketMessageFactory {
case Competition_Practical:
case SIMULATION_RAIL_TICKET:
case Simulation_Alarm: {
- topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
+ topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
break;
}
case SIMULATION_RAILWAY_RUN_PLAN_SEND: // 铁路局运行计划下发
@@ -138,9 +135,9 @@ public class SocketMessageFactory {
case Simulation_Driver_Change:
case Simulation_TrainSpeed:
case Simulation_Drive_Data_Routing: {
- topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
- topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
- topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
+ topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
break;
}
case STAND_PFI_NUM:
@@ -160,44 +157,44 @@ public class SocketMessageFactory {
case Device_Fault_Over_3D:
case VR_Sync_3D:
case SJL3D_TrainStatus: {
- topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
+ topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
break;
}
case Device_Load_Destroy_3D:
case DeviceCtrl_3D:
case TDT_3D:
case BeAbout2Arrive_3D: {
- topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
- topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
+ topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
break;
}
case Train_Position_3D:
case Train_Hmi_3D:
case Train_Position: {
- topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
+ topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
break;
}
case SDC:
case SDSQ:
case TPM: {
- topicList.add(String.format(WebSocketSubscribeTopic.WeiAngU3dSimulation, group));
+ topicList.add(SimulationSubscribeTopic.Wgu3d.buildDestination(group));
break;
}
case Simulation_Reset: {
- topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
- topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
+ topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
topicList.add(SimulationSubscribeTopic.PassengerFlow.buildDestination(group));
- topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
- topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
- topicList.add(String.format(WebSocketSubscribeTopic.WeiAngU3dSimulation, group));
+ topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.Wgu3d.buildDestination(group));
break;
}
case Simulation_Over: {
- topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
- topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));
+ topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.SandBox.buildDestination(group));
topicList.add(SimulationSubscribeTopic.PassengerFlow.buildDestination(group));
- topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group));
- topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
+ topicList.add(SimulationSubscribeTopic.Drive.buildDestination(group));
+ topicList.add(SimulationSubscribeTopic.WeChatMini.buildDestination(group));
}
}
return topicList;
From b863f2c87d65c221643ca82f01c5b0303bb0aa68 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Wed, 14 Sep 2022 14:41:05 +0800
Subject: [PATCH 22/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=94=AF=E6=8C=81=E8=AE=A2?=
=?UTF-8?q?=E9=98=85=E8=BF=94=E5=9B=9E=E6=B6=88=E6=81=AF=EF=BC=8C=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E5=90=8D=E5=AF=86=E7=A0=81=E7=9A=84=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sql/20220914-zhouyin.sql | 2 +
.../ATS/service/TrainPositionService.java | 13 ++++
.../message/SimulationSubscribeTopic.java | 3 +-
.../message/UserSimulationStatsManager.java | 2 +-
.../rtss/vo/client/WebSocketMessageType.java | 5 +-
.../client/factory/SocketMessageFactory.java | 4 ++
.../joylink/rtss/vo/ws/TrainPosition.java | 1 +
.../rtss/websocket/WebSocketController.java | 3 +
.../rtss/websocket/WebsocketConfig.java | 38 +++++++++++-
.../websocket/client/StompClientManager.java | 2 +-
.../websocket/client/StompClientManager2.java | 59 +++++++++++++++++++
.../interceptor/BaseInterceptor.java | 46 +++++++++++++++
.../PresenceChannelInterceptor.java | 58 ++++++++++++++++++
.../SessionAuthHandshakeInterceptor.java | 34 ++---------
.../interceptor/VSimpleInterceptor.java | 46 +++++++++++++++
15 files changed, 282 insertions(+), 34 deletions(-)
create mode 100644 sql/20220914-zhouyin.sql
create mode 100644 src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java
create mode 100644 src/main/java/club/joylink/rtss/websocket/interceptor/BaseInterceptor.java
create mode 100644 src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
rename src/main/java/club/joylink/rtss/websocket/{ => interceptor}/SessionAuthHandshakeInterceptor.java (64%)
create mode 100644 src/main/java/club/joylink/rtss/websocket/interceptor/VSimpleInterceptor.java
diff --git a/sql/20220914-zhouyin.sql b/sql/20220914-zhouyin.sql
new file mode 100644
index 000000000..0ea04f082
--- /dev/null
+++ b/sql/20220914-zhouyin.sql
@@ -0,0 +1,2 @@
+-- 武汉8号线添加第三方账号
+INSERT INTO `joylink`.`sys_account` ( `account`, `parent_account`, `type`, `org_id`, `name`, `nickname`, `avatar_path`, `password`, `mobile`, `nationcode`, `email`, `wx_id`, `wx_union_id`, `wm_open_id`, `status`, `roles`, `source`, `create_time`, `update_user_id`, `update_time`) VALUES ('yjddzh_train_place', NULL, '2', NULL, NULL, '武汉8号线_train_place', NULL, 'train_place', 'train_place', NULL, 'yjddzh@tests.com', NULL, NULL, NULL, '1', '01', NULL, '2022-09-14 10:00:14', NULL, NULL);
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index 3861b6e25..fb6cafb9b 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -7,7 +7,11 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.util.JsonUtils;
+import club.joylink.rtss.vo.client.SocketMessageVO;
+import club.joylink.rtss.vo.client.WebSocketMessageType;
+import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.ws.TrainPosition;
+import club.joylink.rtss.websocket.StompMessageService;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
@@ -28,6 +32,9 @@ public class TrainPositionService {
private NewAtsTrainLoadService newAtsTrainLoadService;
@Resource
private SimulationManager simulationManager;
+ @Resource
+ StompMessageService messageService;
+
/**
* 初始化或更新列车的位置
@@ -44,6 +51,8 @@ public class TrainPositionService {
return;
}
boolean d = true;
+ SocketMessageVO vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
+ this.messageService.send(vo);
for (Simulation sim : simulationList) {
List sectionList = findDirectionAllSection(sim,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
@@ -56,8 +65,12 @@ public class TrainPositionService {
log.error("未找到对应的区段 param:{}",json);
return;
}
+
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
+
}
+// SocketMessageVO messageVO = new SocketMessageVO(WebSocketMessageType.YJDDZH_RETURN_MSG,);
+// messageService.send();
}
/**
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
index 33b93badf..43be31392 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/SimulationSubscribeTopic.java
@@ -17,7 +17,8 @@ public enum SimulationSubscribeTopic {
WeChatMini("/topic/simulation/assistant/{id}"),
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
Room("/queue/room/{id}"),
- Wgu3d("/topic/simulation/wgu3d/{id}")
+ Wgu3d("/topic/simulation/wgu3d/{id}"),
+ YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition")
;
private String destPattern;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java
index c600207b1..52391a96f 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/message/UserSimulationStatsManager.java
@@ -117,7 +117,7 @@ public class UserSimulationStatsManager {
Set infos = userAndUseInfosMap.get(info.getUserId());
infos.removeIf(i -> group.equals(i.getGroup()));
});
- useInfos.forEach(info -> {
+ useInfos.stream().filter(d->Objects.nonNull(d.prdType)).forEach(info -> {
iUserSimulationStatService.addUserSimulationStats(info);
});
}
diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java
index 304009c24..a388c4704 100644
--- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java
+++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java
@@ -7,7 +7,10 @@ import lombok.Getter;
*/
@Getter
public enum WebSocketMessageType {
-
+ /**
+ * 应急调度指挥系统 返回前端的数据
+ */
+ YJDDZH_TRAIN_POSITION,
/**
* 订单支付结果
*/
diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
index a4f03a5d8..93b9120ab 100644
--- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
+++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java
@@ -63,6 +63,10 @@ public class SocketMessageFactory {
private static List getTopicsBy(WebSocketMessageType messageType, String group) {
List topicList = new ArrayList<>();
switch (messageType) {
+ case YJDDZH_TRAIN_POSITION:{
+ topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.getDestPattern());
+ break;
+ }
case BROADCAST:
case Order_Pay_Result:
case JointTraining_Room_Invite:
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index e0ffc10b8..3513844e9 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -43,4 +43,5 @@ public class TrainPosition {
public String toString(){
return JsonUtils.writeValueNullableFieldAsString(this);
}
+
}
diff --git a/src/main/java/club/joylink/rtss/websocket/WebSocketController.java b/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
index d4b711d26..07b31144c 100644
--- a/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
+++ b/src/main/java/club/joylink/rtss/websocket/WebSocketController.java
@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.DestinationVariable;
import org.springframework.messaging.handler.annotation.MessageMapping;
+import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
@@ -36,7 +37,9 @@ public class WebSocketController {
}
@MessageMapping("/{mapName}/trainPosition")
+// @SendTo("/topic/trainPosition")
public void mlbs( String json,@DestinationVariable String mapName) {
this.trainPositionService.initTrainOrUpdate(mapName,json);
+// return json;
}
}
diff --git a/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java b/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
index 3de9ee643..24b00dba1 100644
--- a/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
+++ b/src/main/java/club/joylink/rtss/websocket/WebsocketConfig.java
@@ -1,7 +1,12 @@
package club.joylink.rtss.websocket;
import club.joylink.rtss.services.LoginSessionManager;
+import club.joylink.rtss.services.SysUserService;
+import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
+import club.joylink.rtss.websocket.interceptor.PresenceChannelInterceptor;
+import club.joylink.rtss.websocket.interceptor.SessionAuthHandshakeInterceptor;
+import club.joylink.rtss.websocket.interceptor.VSimpleInterceptor;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -15,6 +20,7 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
+import javax.annotation.Resource;
import java.security.Principal;
import java.util.Map;
import java.util.Objects;
@@ -25,7 +31,10 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
@Autowired
private LoginSessionManager loginSessionManager;
-
+ @Resource
+ private SysUserService sysUserService;
+ @Resource
+ private PresenceChannelInterceptor presenceChannelInterceptor;
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
@@ -63,6 +72,16 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
})
.setAllowedOrigins("*");
registry.addEndpoint("/joylink-tbi-websocket")
+ .addInterceptors(new VSimpleInterceptor(this.sysUserService))
+ .setHandshakeHandler(new DefaultHandshakeHandler() {
+
+ @Override
+ protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
+ Map attributes) {
+ return new TrainPositionPrincipal((AccountVO) attributes.get(VSimpleInterceptor.ATT_USER_KEY));
+ }
+
+ })
.setAllowedOrigins("*");
}
@@ -73,6 +92,7 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.taskExecutor().corePoolSize(2) //设置消息输入通道的线程池线程数
.maxPoolSize(2); //最大线程数
+ registration.interceptors(presenceChannelInterceptor);
}
/**
@@ -107,4 +127,20 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
}
}
+ @Getter
+ public class TrainPositionPrincipal implements Principal {
+
+ private AccountVO user;
+
+ public TrainPositionPrincipal(AccountVO user) {
+ Objects.requireNonNull(user, "用户不能为null");
+ this.user = user;
+ }
+
+
+ @Override
+ public String getName() {
+ return this.user.getMobile();
+ }
+ }
}
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index e6e2ec606..9a0f15248 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -34,7 +34,7 @@ public class StompClientManager {
WebSocketStompClient stompClient = new WebSocketStompClient(socketClient);
SimulationSessionHandler handler = new SimulationSessionHandler();
ListenableFuture future = stompClient
- .connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
+ .connect("ws://127.0.0.1:9000/joylink-tbi-websocket?user_account=train_place&account_pwd=train_place",handler, "null");
StompSession stompSession = future.get();
LogTest lt = new LogTest();
List list = lt.readFile("d:\\spring.log2");
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java
new file mode 100644
index 000000000..aeb47834a
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager2.java
@@ -0,0 +1,59 @@
+package club.joylink.rtss.websocket.client;
+
+import club.joylink.rtss.util.JsonUtils;
+import club.joylink.rtss.util.test.LogTest;
+import club.joylink.rtss.vo.ws.TrainPosition;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.messaging.simp.stomp.StompFrameHandler;
+import org.springframework.messaging.simp.stomp.StompHeaders;
+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.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class StompClientManager2 {
+
+ 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://127.0.0.1:9000/joylink-websocket?token=6a8dbf62d3683844a6aa722b73b989f1",handler, "null");
+ StompSession stompSession = future.get();
+ stompSession.subscribe("/topic/yjddzh/trainPosition", new StompFrameHandler() {
+ @Override
+ public Type getPayloadType(StompHeaders stompHeaders) {
+ return byte[].class;
+ }
+
+ @Override
+ public void handleFrame(StompHeaders stompHeaders, Object o) {
+ String recv=null;
+ try {
+ recv = new String((byte[]) o,"UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ System.out.println(recv);
+ }
+ });
+ stompSession.setAutoReceipt(true);
+ TimeUnit.SECONDS.sleep(100);
+ }
+
+
+}
diff --git a/src/main/java/club/joylink/rtss/websocket/interceptor/BaseInterceptor.java b/src/main/java/club/joylink/rtss/websocket/interceptor/BaseInterceptor.java
new file mode 100644
index 000000000..b15643563
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/websocket/interceptor/BaseInterceptor.java
@@ -0,0 +1,46 @@
+package club.joylink.rtss.websocket.interceptor;
+
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.util.StringUtils;
+import org.springframework.web.socket.WebSocketHandler;
+import org.springframework.web.socket.server.HandshakeInterceptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class BaseInterceptor implements HandshakeInterceptor {
+ @Override
+ public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map map) throws Exception {
+ return false;
+ }
+
+ @Override
+ public void afterHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Exception e) {
+
+ }
+
+ public Map findQueryParams( ServerHttpRequest request){
+ String query = request.getURI().getQuery();
+ Map map = buildQueryMap(query);
+ return map;
+ }
+ private Map buildQueryMap(String query) {
+ Map map = new HashMap<>();
+ if (StringUtils.hasText(query)) {
+ String[] splits = query.split("&");
+ for (int i = 0; i < splits.length; ++i) {
+ String temp = splits[i];
+ int index = temp.indexOf("=");
+ if (index >= 0) {
+ String key = temp.substring(0, index);
+ String val = temp.substring(index + 1);
+ map.put(key, val);
+ } else {
+ map.put(temp, "");
+ }
+ }
+ }
+ return map;
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java b/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
new file mode 100644
index 000000000..14d934ec9
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
@@ -0,0 +1,58 @@
+package club.joylink.rtss.websocket.interceptor;
+
+import club.joylink.rtss.websocket.WebsocketConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
+import org.springframework.messaging.support.ChannelInterceptor;
+import org.springframework.stereotype.Component;
+
+import java.security.Principal;
+import java.util.Objects;
+
+@Slf4j
+@Component
+public class PresenceChannelInterceptor implements ChannelInterceptor {
+
+ @Override
+ public void postSend(Message> message, MessageChannel channel, boolean sent) {
+ StompHeaderAccessor sha = StompHeaderAccessor.wrap(message);
+ if(Objects.isNull(sha.getCommand())) {
+ return;
+ }
+ Principal principal = sha.getUser();
+
+ log.info(" STOMP " + sha.getCommand());
+ String wsSessionId = sha.getSessionId();
+ String dest = sha.getDestination();
+
+ switch(sha.getCommand()) {
+// case SUBSCRIBE:
+// case UNSUBSCRIBE:
+ case DISCONNECT:
+ this.unregister(wsSessionId,dest,principal);
+ break;
+ case CONNECT:
+ case CONNECTED:
+ this.register(wsSessionId,dest,principal);
+ default:
+ break;
+ }
+ }
+
+ private void register(String wsSessionId, String destination, Principal principal) {
+ if(Objects.equals(false,principal instanceof WebsocketConfig.TrainPositionPrincipal)){
+ return;
+ }
+ log.info("武汉8号线 创建stmop链接name:{}",principal.getName());
+ }
+
+
+ private void unregister(String wsSessionId, String destination, Principal principal) {
+ if(Objects.equals(false,principal instanceof WebsocketConfig.TrainPositionPrincipal)){
+ return;
+ }
+ log.info("武汉8号线 关闭stmop链接name:{}",principal.getName());
+ }
+}
diff --git a/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java b/src/main/java/club/joylink/rtss/websocket/interceptor/SessionAuthHandshakeInterceptor.java
similarity index 64%
rename from src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java
rename to src/main/java/club/joylink/rtss/websocket/interceptor/SessionAuthHandshakeInterceptor.java
index 6eea0548f..5026eac49 100644
--- a/src/main/java/club/joylink/rtss/websocket/SessionAuthHandshakeInterceptor.java
+++ b/src/main/java/club/joylink/rtss/websocket/interceptor/SessionAuthHandshakeInterceptor.java
@@ -1,4 +1,4 @@
-package club.joylink.rtss.websocket;
+package club.joylink.rtss.websocket.interceptor;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.LoginSessionManager;
@@ -15,7 +15,7 @@ import java.util.HashMap;
import java.util.Map;
@Slf4j
-public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
+public class SessionAuthHandshakeInterceptor extends BaseInterceptor {
private static final String Token_Key = "token";
public static final String ATTR_USER_KEY = "user";
private LoginSessionManager loginSessionManager;
@@ -39,9 +39,9 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
}
private LoginUserInfoVO getLoginUser(ServerHttpRequest request) {
- String query = request.getURI().getQuery();
- Map map = buildQueryMap(query);
- log.info(String.format("webSocket handshake query: [%s]", query));
+// String query = request.getURI().getQuery();
+ Map map = this.findQueryParams(request);
+ log.info(String.format("webSocket handshake query: [%s]", map));
BusinessExceptionAssertEnum.NOT_LOGIN.assertTrue(StringUtils.hasText(map.get(Token_Key)));
return this.loginSessionManager.getLoginInfoByToken(map.get(Token_Key));
// AccountVO accountVO = loginInfoVO.getAccountVO();
@@ -49,28 +49,4 @@ public class SessionAuthHandshakeInterceptor implements HandshakeInterceptor {
// return accountVO;
}
- private Map buildQueryMap(String query) {
- Map map = new HashMap<>();
- if (StringUtils.hasText(query)) {
- String[] splits = query.split("&");
- for (int i = 0; i < splits.length; ++i) {
- String temp = splits[i];
- int index = temp.indexOf("=");
- if (index >= 0) {
- String key = temp.substring(0, index);
- String val = temp.substring(index + 1);
- map.put(key, val);
- } else {
- map.put(temp, "");
- }
- }
- }
- return map;
- }
-
- @Override
- public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
- Exception exception) {
-
- }
}
diff --git a/src/main/java/club/joylink/rtss/websocket/interceptor/VSimpleInterceptor.java b/src/main/java/club/joylink/rtss/websocket/interceptor/VSimpleInterceptor.java
new file mode 100644
index 000000000..66b335610
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/websocket/interceptor/VSimpleInterceptor.java
@@ -0,0 +1,46 @@
+package club.joylink.rtss.websocket.interceptor;
+
+import club.joylink.rtss.constants.Project;
+import club.joylink.rtss.services.SysUserService;
+import club.joylink.rtss.vo.AccountVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.server.ServerHttpRequest;
+import org.springframework.http.server.ServerHttpResponse;
+import org.springframework.web.socket.WebSocketHandler;
+
+import java.util.Map;
+import java.util.Objects;
+
+@Slf4j
+public class VSimpleInterceptor extends BaseInterceptor {
+ private SysUserService sysUserService;
+
+ public VSimpleInterceptor(SysUserService sysUserService) {
+ this.sysUserService = sysUserService;
+ }
+
+
+ public final static String ATT_USER_KEY = "userVo";
+ @Override
+ public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map attributes) throws Exception {
+ Map map = this.findQueryParams(request);
+ log.info(String.format("webSocket handshake query: [%s]", map));
+ try{
+ AccountVO vo = this.checkUserInfo(map);
+ if(Objects.isNull(vo)){
+ return false;
+ }
+ attributes.put(ATT_USER_KEY,vo);
+ return true;
+ }catch (Exception e){
+ return false;
+ }
+ }
+
+ private final static String USER_ACCOUNT = "user_account";
+ private final static String ACCOUNT_PWD = "account_pwd";
+ private AccountVO checkUserInfo(Map dataMap){
+ AccountVO vo = this.sysUserService.findUserByAccountAndPassword(dataMap.get(USER_ACCOUNT),dataMap.get(ACCOUNT_PWD), Project.DEFAULT);
+ return vo;
+ }
+}
From a3f29142f8ab4ce82d98e45dfaaad6ff7060a7ab Mon Sep 17 00:00:00 2001
From: joylink_zhangsai <1021828630@qq.com>
Date: Thu, 15 Sep 2022 13:23:33 +0800
Subject: [PATCH 23/31] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81?=
=?UTF-8?q?=E3=80=81=E6=89=BE=E5=9B=9E=E5=AF=86=E7=A0=81=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/user/UserInfoController.java | 23 +++--
.../rtss/services/ISysUserService.java | 5 +-
.../joylink/rtss/services/SysUserService.java | 83 ++++++++++++++++++-
.../rtss/vo/client/user/RetrievePwdVO.java | 25 ++++++
.../rtss/vo/client/user/UpdatePasswordVO.java | 2 +
src/main/resources/application.yml | 4 +-
6 files changed, 129 insertions(+), 13 deletions(-)
create mode 100644 src/main/java/club/joylink/rtss/vo/client/user/RetrievePwdVO.java
diff --git a/src/main/java/club/joylink/rtss/controller/user/UserInfoController.java b/src/main/java/club/joylink/rtss/controller/user/UserInfoController.java
index 12661af8b..4beb236b5 100644
--- a/src/main/java/club/joylink/rtss/controller/user/UserInfoController.java
+++ b/src/main/java/club/joylink/rtss/controller/user/UserInfoController.java
@@ -4,13 +4,8 @@ import club.joylink.rtss.services.ISysUserService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.UserQueryVO;
import club.joylink.rtss.vo.client.PageVO;
-import club.joylink.rtss.vo.client.user.MobileInfoVO;
-import club.joylink.rtss.vo.client.user.UpdateEmailVO;
-import club.joylink.rtss.vo.client.user.UpdateMobileVO;
-import club.joylink.rtss.vo.client.user.UpdatePasswordVO;
+import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.user.AccountCreateVO;
-import club.joylink.rtss.vo.client.user.AccountRegisterQueryVO;
-import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
import club.joylink.rtss.vo.user.UserRegisterCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@@ -146,4 +141,20 @@ public class UserInfoController {
queryVO.setSource(source);
return this.iSysUserService.queryPagedUser(queryVO);
}
+
+ /**
+ * 超管重置用户密码
+ */
+ @PutMapping("/{id}/reset/pwd")
+ public void resetPwd(@PathVariable long id) {
+ iSysUserService.resetPwd(id);
+ }
+
+ /**
+ * 找回密码
+ */
+ @PutMapping("/retrieve/pwd")
+ public void retrievePwd(@RequestBody @Validated RetrievePwdVO vo) {
+ iSysUserService.retrievePwd(vo);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/services/ISysUserService.java b/src/main/java/club/joylink/rtss/services/ISysUserService.java
index c20c5e2b5..565af85d7 100644
--- a/src/main/java/club/joylink/rtss/services/ISysUserService.java
+++ b/src/main/java/club/joylink/rtss/services/ISysUserService.java
@@ -10,7 +10,6 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.user.*;
import club.joylink.rtss.vo.user.AccountCreateVO;
-import club.joylink.rtss.vo.client.user.AccountRegisterStatisticsVO;
import club.joylink.rtss.vo.wx.WmUserSession;
import lombok.NonNull;
@@ -325,4 +324,8 @@ public interface ISysUserService {
boolean isThirdParentAccountExist(String parentAccount);
List findEntitiesBySource(String source);
+
+ void resetPwd(long id);
+
+ void retrievePwd(RetrievePwdVO vo);
}
diff --git a/src/main/java/club/joylink/rtss/services/SysUserService.java b/src/main/java/club/joylink/rtss/services/SysUserService.java
index 5198c5086..2c3c97218 100644
--- a/src/main/java/club/joylink/rtss/services/SysUserService.java
+++ b/src/main/java/club/joylink/rtss/services/SysUserService.java
@@ -738,7 +738,7 @@ public class SysUserService implements ISysUserService {
@Override
public String sendMobileValidCode(MobileInfoVO mobileInfoVO) {
- BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate());
+ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(mobileInfoVO.validate(), "发送验证码请求未通过");
String code = RandomGenerator.getByLen(4);
long ts = System.currentTimeMillis();
List params = new ArrayList<>();
@@ -757,18 +757,44 @@ public class SysUserService implements ISysUserService {
public void updatePassword(Long id, UpdatePasswordVO updatePasswordVO) {
Objects.requireNonNull(id, "用户id不能为空");
SysAccount account = this.sysAccountDAO.selectByPrimaryKey(id);
+ updatePwdByMobileVdCode(updatePasswordVO, account);
+ }
+
+ private void updatePwdByMobileVdCode(UpdatePasswordVO updatePasswordVO, SysAccount account) {
if (Objects.nonNull(account)) {
VdCode vdCode = (VdCode) this.iCacheService.get(account.getNationcode() + account.getMobile());
BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
// 验证验证码
vdCode.isValidCode(updatePasswordVO.getVfCode());
// 验证码通过,修改密码
- account.setPassword(updatePasswordVO.getPassword());
- account.setUpdateTime(LocalDateTime.now());
- this.sysAccountDAO.updateByPrimaryKey(account);
+ updatePassword4Entity(account, updatePasswordVO.getPassword());
}
}
+ /**
+ * 通过邮箱验证码更新密码
+ * @param account 要更新密码的账号
+ * @param userVfCode 用户填写的验证码
+ * @param newPwd 新密码
+ */
+ private void updatePwdByEmailVdCode(SysAccount account, String userVfCode, String newPwd) {
+ if (Objects.nonNull(account)) {
+ VdCode vdCode = (VdCode) this.iCacheService.get(account.getEmail());
+ BusinessExceptionAssertEnum.INCORRECT_VERIFICATION_CODE.assertNotNull(vdCode);
+ // 验证验证码
+ vdCode.isValidCode(userVfCode);
+ // 验证码通过,修改密码
+ updatePassword4Entity(account, newPwd);
+ }
+ }
+
+ private void updatePassword4Entity(SysAccount account, String newPwd) {
+ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(newPwd, "新密码不能为空");
+ account.setPassword(newPwd);
+ account.setUpdateTime(LocalDateTime.now());
+ this.sysAccountDAO.updateByPrimaryKey(account);
+ }
+
@Override
public void updateUserPassword(Long id, String password) {
Objects.requireNonNull(id, "用户id不能为空");
@@ -991,6 +1017,55 @@ public class SysUserService implements ISysUserService {
return sysAccountDAO.selectByExample(example);
}
+ @Override
+ public void resetPwd(long id) {
+ String pwd = EncryptUtil.md5("123456");
+ SysAccount account = getEntity(id);
+ updatePassword4Entity(account, pwd);
+ }
+
+ @Override
+ public void retrievePwd(RetrievePwdVO vo) {
+ if (StringUtils.hasText(vo.getMobile())) {
+ SysAccount account = getEntityByMobile(vo.getMobile());
+ UpdatePasswordVO updatePasswordVO = new UpdatePasswordVO(vo.getVfCode(), vo.getNewPwd());
+ updatePwdByMobileVdCode(updatePasswordVO, account);
+ } else if (StringUtils.hasText(vo.getEmail())) {
+ SysAccount account = getEntityByEmail(vo.getEmail());
+ updatePwdByEmailVdCode(account, vo.getVfCode(), vo.getNewPwd());
+ } else {
+ throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("手机号和邮箱不能都为空");
+ }
+ }
+
+ private SysAccount getEntityByMobile(String mobile) {
+ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(mobile);
+ SysAccountExample example = new SysAccountExample();
+ example.createCriteria().andMobileEqualTo(mobile);
+ List accounts = sysAccountDAO.selectByExample(example);
+ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(accounts,
+ String.format("[手机号:%s]的账号不存在", mobile));
+ if (accounts.size() != 1) {
+ log.error("[手机号:%s]的账号有多个");
+ throw BusinessExceptionAssertEnum.DATA_ERROR.exception();
+ }
+ return accounts.get(0);
+ }
+
+ private SysAccount getEntityByEmail(String email) {
+ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(email);
+ SysAccountExample example = new SysAccountExample();
+ example.createCriteria().andEmailEqualTo(email);
+ List accounts = sysAccountDAO.selectByExample(example);
+ BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(accounts,
+ String.format("[邮箱:%s]的账号不存在", email));
+ if (accounts.size() != 1) {
+ log.error(String.format("[邮箱:%s]的账号有多个", email));
+ throw BusinessExceptionAssertEnum.DATA_ERROR.exception();
+ }
+ return accounts.get(0);
+ }
+
private boolean isSameEmailExist(String email) {
SysAccountExample example = new SysAccountExample();
example.createCriteria()
diff --git a/src/main/java/club/joylink/rtss/vo/client/user/RetrievePwdVO.java b/src/main/java/club/joylink/rtss/vo/client/user/RetrievePwdVO.java
new file mode 100644
index 000000000..bbdf89c31
--- /dev/null
+++ b/src/main/java/club/joylink/rtss/vo/client/user/RetrievePwdVO.java
@@ -0,0 +1,25 @@
+package club.joylink.rtss.vo.client.user;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * 找回密码
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+public class RetrievePwdVO {
+ private String mobile;
+
+ private String email;
+
+ @NotBlank(message = "验证码不能为空")
+ private String vfCode;
+
+ @NotBlank(message = "密码不能为空")
+ private String newPwd;
+}
diff --git a/src/main/java/club/joylink/rtss/vo/client/user/UpdatePasswordVO.java b/src/main/java/club/joylink/rtss/vo/client/user/UpdatePasswordVO.java
index 792f9c444..039786d3a 100644
--- a/src/main/java/club/joylink/rtss/vo/client/user/UpdatePasswordVO.java
+++ b/src/main/java/club/joylink/rtss/vo/client/user/UpdatePasswordVO.java
@@ -1,5 +1,6 @@
package club.joylink.rtss.vo.client.user;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -9,6 +10,7 @@ import javax.validation.constraints.NotBlank;
@Getter
@Setter
@NoArgsConstructor
+@AllArgsConstructor
public class UpdatePasswordVO {
/**
* 短信验证码
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 4336a4092..0c0134bca 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -24,8 +24,8 @@ spring:
mail:
host: smtp.exmail.qq.com
port: 465
- username: ServiceEmail@joylink.club
- password: wFHcZQFuigKPvpSr
+ username: serviceemai@joylink.club
+ password: Jiulian0503
properties:
mail:
smtp:
From 6741341601fa9a52eb6546e351261ceb87b5ca2c Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 15 Sep 2022 13:48:05 +0800
Subject: [PATCH 24/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../simulation/cbtc/ATS/ATSLogicLoop.java | 7 ++
.../ATS/service/AtsTrainMonitorService.java | 7 ++
.../ATS/service/NewAtsTrainLoadService.java | 78 ++++++++++---------
.../ATS/service/TrainPositionService.java | 23 +++---
.../rtss/simulation/cbtc/CI/CiLogic.java | 9 +++
.../cbtc/SimulationLifeCycleServiceImpl.java | 9 ++-
.../device/virtual/VRDeviceLogicLoop.java | 7 ++
.../joylink/rtss/vo/ws/TrainPosition.java | 33 ++++++++
.../websocket/client/StompClientManager.java | 9 ++-
9 files changed, 127 insertions(+), 55 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSLogicLoop.java
index c1c87b019..c27bc4dc6 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSLogicLoop.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSLogicLoop.java
@@ -30,7 +30,14 @@ public class ATSLogicLoop {
this.atsStationService.updateFieldThatChangeOverTime(simulation);
}
+ public void runForTrainPosition(Simulation simulation){
+ this.atsTrainMonitorService.monitorForTrainPosition(simulation);
+ }
public void addJobs(Simulation simulation) {
simulation.addJob(SimulationModule.ATS.name(), () -> this.run(simulation), SimulationConstants.ATS_LOOP_RATE);
}
+
+ public void addJobsForTrainPosition(Simulation simulation){
+ simulation.addJob(SimulationModule.ATS.name(), () -> this.runForTrainPosition(simulation), SimulationConstants.ATS_LOOP_RATE);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java
index f6d29d30a..42aa490d9 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java
@@ -51,6 +51,13 @@ public class AtsTrainMonitorService {
@Autowired
private OnBoardPisService onBoardPisService;
+
+ public void monitorForTrainPosition(Simulation simulation){
+ List trainList = simulation.getRepository().getSuperviseTrainList();
+ for (TrainInfo trainInfo : trainList) {
+ this.atsTrainTrackingService.track(simulation, trainInfo);
+ }
+ }
/**
* 列车监控逻辑
* @param simulation
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 5a79bf45e..ea3589c38 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -1,78 +1,82 @@
package club.joylink.rtss.simulation.cbtc.ATS.service;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
-import club.joylink.rtss.simulation.SimulationManager;
-import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
-import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService;
-import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
-import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.Simulation;
-import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
-import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
-import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
-import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
-import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
-import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
-import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
-import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
+import club.joylink.rtss.simulation.cbtc.data.map.Stand;
+import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
-import club.joylink.rtss.simulation.cbtc.data.support.TrainLoadParam2;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
-import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
-import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
-import club.joylink.rtss.simulation.cbtc.event.SimulationRunAsPlanEvent;
-import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
-import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
-import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
-import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
import club.joylink.rtss.vo.ws.TrainPosition;
-import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-import javax.annotation.Resource;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Component
public class NewAtsTrainLoadService {
- @Autowired
- private VRTrainRunningService vrTrainRunningService;
+
+ private void culStation(VirtualRealityTrain train , Section section, TrainPosition tp){
+
+ Station station = section.getStation();
+ if(Objects.isNull(station)){
+ return;
+ }
+ List stands = station.getLdStandList();
+ if(tp.isRight()){
+ stands = station.getRdStandList();
+ }
+ VirtualRealityTrain.Door door = train.getDoor1();
+ if(tp.isRight()){
+ door = train.getDoor2();
+ }
+ if(tp.isStop()){
+ /*for (Stand stand : stands) {
+ Section ss = stand.getSection();
+ System.out.println(ss.getCode());
+ stand.setTrainParking(true);
+ stand.getPsd().getVirtualScreenDoor().setClose(tp.isCloseDoor());
+ }*/
+ door.setClose(tp.isCloseDoor());
+ train.setSpeed(0);
+ }else{
+ /*for (Stand stand : stands) {
+ stand.setTrainParking(false);
+ }*/
+ door.setClose(tp.isCloseDoor());
+ train.setSpeed(99F);
+ }
+
+ }
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository();
-
Map trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
-
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
log.error("没有找到对应车组号 param:{}",tp);
return;
}
+
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
if(Objects.nonNull(virtualRealityTrain)){
//存在列车需要更新位置
+ culStation(virtualRealityTrain,section,tp);
virtualRealityTrain.setRunLevel(RunLevel.IL);
trainOnline(simulation, section, tp, virtualRealityTrain);
}else{
virtualRealityTrain = trainMap.get(tp.getGroupNum());
+ culStation(virtualRealityTrain,section,tp);
virtualRealityTrain.setRunLevel(RunLevel.IL);
trainOnline(simulation, section, tp, virtualRealityTrain);
}
-
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index fb6cafb9b..e47710a3f 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
+import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType;
@@ -19,9 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -41,6 +40,7 @@ public class TrainPositionService {
* @param mapName
* @param json
*/
+
public void initTrainOrUpdate(String mapName,String json){
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
tp.setReceiveTime(System.currentTimeMillis());
@@ -53,26 +53,25 @@ public class TrainPositionService {
boolean d = true;
SocketMessageVO vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
this.messageService.send(vo);
+
for (Simulation sim : simulationList) {
List sectionList = findDirectionAllSection(sim,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
- if(d){
- tp.setSectionCode(section.getCode());
- log.info(tp.toString());
- d = false;
- }
+// if(d){
+// tp.setSectionCode(section.getCode());
+// log.info(tp.toString());
+// d = false;
+// }
if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",json);
return;
}
-
+ log.info(tp.toString());
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
-
}
-// SocketMessageVO messageVO = new SocketMessageVO(WebSocketMessageType.YJDDZH_RETURN_MSG,);
-// messageService.send();
}
+
/**
* 根据传入的参数 定位对应的所在的区段
* @param sectionList
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java
index af8a15609..eef107055 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java
@@ -36,6 +36,10 @@ public class CiLogic {
@Autowired
private StationDirectionService stationDirectionService;
+ public void runForTrainPosition(Simulation simulation){
+// 采集真实设备状态
+ deviceStatusCollector.collect(simulation);
+ }
public void run(Simulation simulation) {
// 采集真实设备状态
deviceStatusCollector.collect(simulation);
@@ -282,4 +286,9 @@ public class CiLogic {
simulation.addJob(SimulationModule.CI.name(), () -> run(simulation), SimulationConstants.CI_LOOP_RATE);
simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
}
+
+ public void addJobsForTrainPosition(Simulation simulation){
+ simulation.addJob(SimulationModule.CI.name(), () -> runForTrainPosition(simulation), SimulationConstants.CI_LOOP_RATE);
+// simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
index 6550bc565..18d42ef94 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java
@@ -182,10 +182,13 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位
- atsLogicLoop.addJobs(simulation);
+// atsLogicLoop.addJobs(simulation);
+ atsLogicLoop.addJobsForTrainPosition(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
- vrDeviceLogicLoop.addJobs(simulation);
- ciLogic.addJobs(simulation);
+// vrDeviceLogicLoop.addJobs(simulation);
+ vrDeviceLogicLoop.addJobsForTrainPosition(simulation);
+// ciLogic.addJobs(simulation);
+ ciLogic.addJobsForTrainPosition(simulation);
return;
}
if (simulation.getRepository().getConfig().isRailway()) {
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java
index 13765bae1..e66ee544d 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java
@@ -26,6 +26,10 @@ public class VRDeviceLogicLoop {
@Autowired
private VirtualRealityDeviceService virtualRealityDeviceService;
+ public void runForTrainPosition(Simulation simulation){
+ // 列车占压计轴区段检查
+ this.updateTrainOccupySection(simulation);
+ }
public void run(Simulation simulation) {
// long start = System.currentTimeMillis();
// 虚拟真实道岔转动过程
@@ -85,4 +89,7 @@ public class VRDeviceLogicLoop {
public void addJobs(Simulation simulation) {
simulation.addJob(SimulationModule.VRD.name(), () -> this.run(simulation), SimulationConstants.VRD_LOOP_RATE);
}
+ public void addJobsForTrainPosition(Simulation simulation) {
+ simulation.addJob(SimulationModule.VRD.name(), () -> this.runForTrainPosition(simulation), SimulationConstants.VRD_LOOP_RATE);
+ }
}
diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
index 3513844e9..b733dd5ca 100644
--- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
+++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java
@@ -20,9 +20,42 @@ public class TrainPosition {
* 方向1=上行(向右),0=下行(向左)
*/
private int direction;
+ /**
+ * 公里标
+ */
private float location;
+ /**
+ * 数据接受时间
+ */
private Long receiveTime;
+ /**
+ * 对应所在区段code
+ */
private String sectionCode;
+
+ /**
+ * 是否到站
+ */
+// private boolean arrive;
+
+ /**
+ * 启动
+ */
+// private boolean startover;
+ /**
+ * 离开
+ */
+// private boolean leave;
+ /**
+ * 是否开门
+ */
+ private boolean closeDoor;
+ /**
+ * 是否停稳
+ */
+ private boolean stop;
+
+
public Section.SectionRoadType getRoadType(){
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
if(this.direction == 1){
diff --git a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
index 9a0f15248..1e894c9ea 100644
--- a/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
+++ b/src/main/java/club/joylink/rtss/websocket/client/StompClientManager.java
@@ -41,15 +41,19 @@ public class StompClientManager {
// List list = lt.readSource("d:\\t.txt");
// runToLeft(stompSession,"001");
// runToRight(stompSession,"002");
-// list = lt.query(list,"042",Section.SectionRoadType.RIGHT);
+ list = lt.query(list,"004",Section.SectionRoadType.LEFT);
// list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT);
send(stompSession,list);
}
public static void send(StompSession stompSession,List list){
- for (int i = 0; i < list.size(); i++) {
+// for (int i = 25; i < list.size(); i++) {
+ for (int i = 22; i < 23; i++) {
TrainPosition tp = list.get(i);
+ tp.setCloseDoor(false);
+ tp.setStop(false);
+// tp.setLocation(tp.getLocation() - 500);
String val = JsonUtils.writeValueNullableFieldAsString(tp);
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
ZoneId zone = ZoneId.systemDefault();
@@ -70,7 +74,6 @@ public class StompClientManager {
e.printStackTrace();
}
}
-
}
}
From 1bcc1063ed3c73c2a9433a501cd97da2d7585c07 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Thu, 15 Sep 2022 15:47:10 +0800
Subject: [PATCH 25/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../simulation/cbtc/ATS/service/NewAtsTrainLoadService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index ea3589c38..41d90c918 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -52,7 +52,7 @@ public class NewAtsTrainLoadService {
/*for (Stand stand : stands) {
stand.setTrainParking(false);
}*/
- door.setClose(tp.isCloseDoor());
+// door.setClose(true);
train.setSpeed(99F);
}
From 361675fb9f86ee053baa962c8885e00b4292eb94 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 16 Sep 2022 16:10:44 +0800
Subject: [PATCH 26/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../simulation/cbtc/ATS/service/NewAtsTrainLoadService.java | 6 +++---
.../simulation/cbtc/ATS/service/TrainPositionService.java | 2 +-
.../websocket/interceptor/PresenceChannelInterceptor.java | 3 +--
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 41d90c918..6a579fb6c 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -31,10 +31,10 @@ public class NewAtsTrainLoadService {
if(Objects.isNull(station)){
return;
}
- List stands = station.getLdStandList();
+ /*List stands = station.getLdStandList();
if(tp.isRight()){
stands = station.getRdStandList();
- }
+ }*/
VirtualRealityTrain.Door door = train.getDoor1();
if(tp.isRight()){
door = train.getDoor2();
@@ -52,7 +52,7 @@ public class NewAtsTrainLoadService {
/*for (Stand stand : stands) {
stand.setTrainParking(false);
}*/
-// door.setClose(true);
+// door.setClose(tp.isCloseDoor());
train.setSpeed(99F);
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
index e47710a3f..e3950898b 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java
@@ -50,7 +50,7 @@ public class TrainPositionService {
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
return;
}
- boolean d = true;
+// boolean d = true;
SocketMessageVO vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
this.messageService.send(vo);
diff --git a/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java b/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
index 14d934ec9..35eb12f8f 100644
--- a/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
+++ b/src/main/java/club/joylink/rtss/websocket/interceptor/PresenceChannelInterceptor.java
@@ -22,8 +22,7 @@ public class PresenceChannelInterceptor implements ChannelInterceptor {
return;
}
Principal principal = sha.getUser();
-
- log.info(" STOMP " + sha.getCommand());
+// log.info(" STOMP " + sha.getCommand());
String wsSessionId = sha.getSessionId();
String dest = sha.getDestination();
From 37948d68feeea35aaa5d04ca6db287793b7c1eb6 Mon Sep 17 00:00:00 2001
From: tiger_zhou <123456>
Date: Fri, 16 Sep 2022 16:24:24 +0800
Subject: [PATCH 27/31] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF?=
=?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../simulation/cbtc/ATS/service/NewAtsTrainLoadService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
index 6a579fb6c..2fad58b54 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/NewAtsTrainLoadService.java
@@ -52,7 +52,7 @@ public class NewAtsTrainLoadService {
/*for (Stand stand : stands) {
stand.setTrainParking(false);
}*/
-// door.setClose(tp.isCloseDoor());
+ door.setClose(tp.isCloseDoor());
train.setSpeed(99F);
}
From ffd71ef83c7563ee124072f2c4c438c7604b3665 Mon Sep 17 00:00:00 2001
From: joylink_zhangsai <1021828630@qq.com>
Date: Tue, 20 Sep 2022 16:29:01 +0800
Subject: [PATCH 28/31] =?UTF-8?q?PA/PIS=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../rtss/constants/ProjectDeviceType.java | 3 +
.../audio/AudioResourcesController.java | 10 +-
.../iscs/IscsSystemResourcesController.java | 5 +
.../services/audio/AudioResourcesService.java | 2 +
.../audio/AudioResourcesServiceImpl.java | 12 ++
.../services/auth/AuthenticateService.java | 2 +
.../iscs/IscsSystemResourcesService.java | 6 +
.../iscs/IscsSystemResourcesServiceImpl.java | 13 +-
.../interactive/IscsInteractiveService.java | 27 ++-
.../joylink/rtss/simulation/Simulation.java | 5 +
.../ATS/ATSMessageCollectAndDispatcher.java | 4 +-
.../operation/handler/IscsOperateHandler.java | 4 +-
.../simulation/cbtc/ISCS/IscsLogicLoop.java | 10 +-
.../ISCS/IscsMessageCollectAndDispatcher.java | 2 +-
.../ProjectJointSimulationServiceImpl.java | 5 +
.../rtss/simulation/cbtc/Simulation.java | 8 +
.../cbtc/SimulationLifeCycleServiceImpl.java | 15 +-
.../cbtc/build/SimulationBuilder.java | 2 +-
.../cbtc/data/SimulationDataRepository.java | 14 ++
.../data/SimulationIscsDataRepository.java | 38 ++++
.../simulation/cbtc/data/info/OnboardPis.java | 46 ++++
.../simulation/cbtc/data/info/StandPis.java | 106 ++++++++++
.../cbtc/data/{map => iscs}/Audio.java | 10 +-
.../simulation/cbtc/data/plan/TripPlan.java | 8 +
.../cbtc/data/status/OnboardPisStatus.java | 57 +++++
.../cbtc/data/status/StandPisStatus.java | 99 +++++++++
.../simulation/cbtc/data/vo/SimulationVO.java | 5 +-
.../cbtc/data/vo/iscs/IscsAudioStatusVO.java | 9 +-
.../simulation/cbtc/pis/PisLogicLoop.java | 200 ++++++++++++++++++
.../simulation/rt/pis/PisStatusPublisher.java | 70 ++++++
.../vo/client/audio/AudioResourcesVO.java | 9 +-
.../client/factory/SocketMessageFactory.java | 4 +-
32 files changed, 784 insertions(+), 26 deletions(-)
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/info/OnboardPis.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/info/StandPis.java
rename src/main/java/club/joylink/rtss/simulation/cbtc/data/{map => iscs}/Audio.java (90%)
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/status/OnboardPisStatus.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StandPisStatus.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/pis/PisLogicLoop.java
create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/pis/PisStatusPublisher.java
diff --git a/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java b/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java
index f23ac2f96..09d317d9f 100644
--- a/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java
+++ b/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java
@@ -67,6 +67,9 @@ public enum ProjectDeviceType {
SANDBOX,
/** 派班工作站 */
SCHEDULING,
+
+ PIS_STAND,
+ PIS_TRAIN,
/* -----------client device end---------- */
;
diff --git a/src/main/java/club/joylink/rtss/controller/audio/AudioResourcesController.java b/src/main/java/club/joylink/rtss/controller/audio/AudioResourcesController.java
index 6155c0f5d..11439a47f 100644
--- a/src/main/java/club/joylink/rtss/controller/audio/AudioResourcesController.java
+++ b/src/main/java/club/joylink/rtss/controller/audio/AudioResourcesController.java
@@ -23,10 +23,18 @@ public class AudioResourcesController {
* 创建
*/
@PostMapping()
- public void create(@RequestBody @Validated AudioResourcesVO vo) {
+ public void create(@RequestBody @Validated(value = AudioResourcesVO.Create.class) AudioResourcesVO vo) {
audioResourcesService.create(vo);
}
+ /**
+ * 生成资源
+ */
+ @PostMapping("/generate")
+ public void generate(@RequestBody @Validated(value = AudioResourcesVO.Generate.class) AudioResourcesVO vo) {
+ audioResourcesService.generate(vo);
+ }
+
/**
* 查询所有
*/
diff --git a/src/main/java/club/joylink/rtss/controller/iscs/IscsSystemResourcesController.java b/src/main/java/club/joylink/rtss/controller/iscs/IscsSystemResourcesController.java
index a8056c895..245acd770 100644
--- a/src/main/java/club/joylink/rtss/controller/iscs/IscsSystemResourcesController.java
+++ b/src/main/java/club/joylink/rtss/controller/iscs/IscsSystemResourcesController.java
@@ -34,6 +34,11 @@ public class IscsSystemResourcesController {
iscsSystemResourcesService.batchCreate(vos);
}
+ @PostMapping("/generate/{mapId}/{type}")
+ public void generate(@PathVariable long mapId, @PathVariable int type) {
+ iscsSystemResourcesService.generate(mapId, type);
+ }
+
/**
* 获取所有
*/
diff --git a/src/main/java/club/joylink/rtss/services/audio/AudioResourcesService.java b/src/main/java/club/joylink/rtss/services/audio/AudioResourcesService.java
index 8c774da6a..6da3625c2 100644
--- a/src/main/java/club/joylink/rtss/services/audio/AudioResourcesService.java
+++ b/src/main/java/club/joylink/rtss/services/audio/AudioResourcesService.java
@@ -20,4 +20,6 @@ public interface AudioResourcesService {
PageVO pagedQuery(AudioResourcesQueryVO queryVO);
AudioResourcesVO getById(long id);
+
+ void generate(AudioResourcesVO vo);
}
diff --git a/src/main/java/club/joylink/rtss/services/audio/AudioResourcesServiceImpl.java b/src/main/java/club/joylink/rtss/services/audio/AudioResourcesServiceImpl.java
index 9fca111c3..2fa5ba0fb 100644
--- a/src/main/java/club/joylink/rtss/services/audio/AudioResourcesServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/services/audio/AudioResourcesServiceImpl.java
@@ -3,12 +3,14 @@ package club.joylink.rtss.services.audio;
import club.joylink.rtss.dao.AudioResourcesDAO;
import club.joylink.rtss.entity.AudioResources;
import club.joylink.rtss.entity.AudioResourcesExample;
+import club.joylink.rtss.services.voice.IVoiceService;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.audio.AudioResourcesQueryVO;
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@@ -21,6 +23,9 @@ import java.util.List;
public class AudioResourcesServiceImpl implements AudioResourcesService {
@Autowired
private AudioResourcesDAO audioResourcesDAO;
+ @Autowired
+ @Qualifier("baiDuVoiceService")
+ private IVoiceService iVoiceService;
@Override
public void create(AudioResourcesVO vo) {
@@ -82,6 +87,13 @@ public class AudioResourcesServiceImpl implements AudioResourcesService {
return new AudioResourcesVO(getEntity(id));
}
+ @Override
+ public void generate(AudioResourcesVO vo) {
+ String filePath = iVoiceService.synthesis(vo.getDesc());
+ vo.setUrl(filePath);
+ create(vo);
+ }
+
private AudioResources getEntity(long id) {
return audioResourcesDAO.selectByPrimaryKey(id);
}
diff --git a/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java b/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java
index d9c94d2ca..6d1c3ada4 100644
--- a/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java
+++ b/src/main/java/club/joylink/rtss/services/auth/AuthenticateService.java
@@ -468,6 +468,8 @@ public class AuthenticateService implements IAuthenticateService {
case CCTV:
case SANDBOX:
case ILW:
+ case PIS_STAND:
+ case PIS_TRAIN:
case VR_IBP: {
RelationLoginConfigVO config = deviceVO.buildRelationLoginConfig();
if (Objects.nonNull(config) && Objects.nonNull(config.getDeviceCode())) {
diff --git a/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesService.java b/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesService.java
index 221dcbb7e..3cf196f0f 100644
--- a/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesService.java
+++ b/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesService.java
@@ -22,4 +22,10 @@ public interface IscsSystemResourcesService {
List criteriaQuery(IscsSystemResourcesQueryVO queryVO);
void batchCreate(List vos);
+
+ /**
+ * 生成Iscs资源。
+ * @param type 要生成的资源的类型,详见方法体内的注释
+ */
+ void generate(long mapId, int type);
}
diff --git a/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesServiceImpl.java b/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesServiceImpl.java
index b706a218c..fee70bdef 100644
--- a/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/services/iscs/IscsSystemResourcesServiceImpl.java
@@ -4,11 +4,14 @@ import club.joylink.rtss.dao.IscsSystemResourcesDAO;
import club.joylink.rtss.entity.IscsSystemResources;
import club.joylink.rtss.entity.IscsSystemResourcesExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
+import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.audio.AudioResourcesService;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.audio.AudioResourcesVO;
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesQueryVO;
import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO;
+import club.joylink.rtss.vo.map.MapVO;
+import club.joylink.rtss.vo.map.graph.MapStationNewVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,9 +25,10 @@ import java.util.List;
public class IscsSystemResourcesServiceImpl implements IscsSystemResourcesService {
@Autowired
private IscsSystemResourcesDAO iscsSystemResourcesDAO;
-
@Autowired
private AudioResourcesService audioResourcesService;
+ @Autowired
+ private IMapService iMapService;
@Override
public void create(IscsSystemResourcesVO vo) {
@@ -106,6 +110,13 @@ public class IscsSystemResourcesServiceImpl implements IscsSystemResourcesServic
}
}
+ @Override
+ public void generate(long mapId, int type) {
+ MapVO mapDetail = iMapService.getMapDetail(mapId);
+ List stationList = mapDetail.getGraphDataNew().getStationList();
+
+ }
+
private IscsSystemResources findEntityById(long id) {
return iscsSystemResourcesDAO.selectByPrimaryKey(id);
}
diff --git a/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java b/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java
index f31d19a6e..6b787551c 100644
--- a/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java
+++ b/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java
@@ -5,7 +5,7 @@ import club.joylink.rtss.services.audio.AudioResourcesService;
import club.joylink.rtss.services.voice.IVoiceService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
-import club.joylink.rtss.simulation.cbtc.data.map.Audio;
+import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityAudio;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
@@ -18,6 +18,9 @@ import org.springframework.stereotype.Component;
import java.util.List;
+/**
+ * ISCS交互服务
+ */
@Component
public class IscsInteractiveService {
@Autowired
@@ -27,7 +30,7 @@ public class IscsInteractiveService {
@Qualifier("baiDuVoiceService")
private IVoiceService iVoiceService;
- public void play(Simulation simulation, PlayParamVO param, SimulationMember member) {
+ public void paPlay(Simulation simulation, PlayParamVO param, SimulationMember member) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(member != null && (member.isDispatcher() || member.isStationSupervisor()),
"仅行调和行值可操作");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(param.getResourceId(), "资源id不能为null");
@@ -47,6 +50,26 @@ public class IscsInteractiveService {
}
}
+ /**
+ * 信号系统自动通过PA系统播放
+ */
+ public void paPlayBySystem(Simulation simulation, List iscsDeviceCodes,
+ AudioResourcesVO audioResourcesVO, String state) {
+ SimulationDataRepository repository = simulation.getRepository();
+ for (String code : iscsDeviceCodes) {
+ MapElement element = repository.getByCode(code);
+ if (element instanceof Audio) {
+ Audio audio = (Audio) element;
+ audio.updateResource(audioResourcesVO);
+ audio.updateState(state);
+ audio.updateRemain(Audio.DEFAULT_REMAIN);
+ VirtualRealityAudio vrAudio = audio.getVrAudio();
+ vrAudio.updateUrl(audioResourcesVO.getUrl());
+ vrAudio.control(VirtualRealityAudio.Command.PLAY);
+ }
+ }
+ }
+
public void paStopPlaying(Simulation simulation, List iscsDeviceCodes) {
SimulationDataRepository repository = simulation.getRepository();
for (String code : iscsDeviceCodes) {
diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java
index 58651ba6a..d9e9dcb3d 100644
--- a/src/main/java/club/joylink/rtss/simulation/Simulation.java
+++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
+import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -188,6 +189,10 @@ public abstract class Simulation sessions = simulation.getSimulationUserIds();
- SocketMessageVO timeSyncMessage = SocketMessageFactory.buildSimulationTimeSyncMessage(simulation);
+ SocketMessageVO timeSyncMessage = SocketMessageFactory.buildSimulationTimeSyncMessage(simulation);
stompMessageService.sendToUser(sessions, timeSyncMessage);
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/IscsOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/IscsOperateHandler.java
index 45fb734e8..f946b13fe 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/IscsOperateHandler.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/IscsOperateHandler.java
@@ -23,7 +23,7 @@ public class IscsOperateHandler {
*/
@OperateHandlerMapping(type = Operation.Type.ISCS_PA_Play)
public void paPlay(Simulation simulation, PlayParamVO playParamVO, SimulationMember member) {
- iscsInteractiveService.play(simulation, playParamVO, member);
+ iscsInteractiveService.paPlay(simulation, playParamVO, member);
}
/**
@@ -46,7 +46,7 @@ public class IscsOperateHandler {
* PIS系统停止播放
*/
@OperateHandlerMapping(type = Operation.Type.ISCS_PIS_Stop_Playing)
- public void pisPlay(Simulation simulation, List iscsDeviceCodes) {
+ public void pisStopPlaying(Simulation simulation, List iscsDeviceCodes) {
iscsInteractiveService.pisStopPlaying(simulation, iscsDeviceCodes);
}
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java
index 2ec02c318..ad7cf3089 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java
@@ -3,13 +3,17 @@ package club.joylink.rtss.simulation.cbtc.ISCS;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
-import club.joylink.rtss.simulation.cbtc.data.map.Audio;
+import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import org.springframework.stereotype.Component;
@Component
public class IscsLogicLoop {
- private void run(Simulation simulation) {
+ public static final String JOB_NAME = "ISCS_LOGIC_LOOP";
+ public static final int RATE = 1000;
+
+ public void run(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
+ // 广播播放结束逻辑
for (Audio audio : repository.getAudioList()) {
if (audio.isInPa() && !audio.isNotUsed()) {
int remain = audio.getRemainDuration();
@@ -24,6 +28,6 @@ public class IscsLogicLoop {
}
public void addJob(Simulation simulation) {
- simulation.addJob(Simulation.JobName.iscsLogicLoop, () -> run(simulation), SimulationConstants.ATS_LOOP_RATE);
+ simulation.addJob(JOB_NAME, () -> run(simulation), RATE);
}
}
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java
index 857f60d92..b36071f56 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java
@@ -4,7 +4,7 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
-import club.joylink.rtss.simulation.cbtc.data.map.Audio;
+import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsAudioStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
index 59fda98f5..c005adfdc 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java
@@ -141,12 +141,14 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case PSC:
return ((Heb1PscConfig) config).getConfig().getPsdCode();
}
+ break;
}
case XTY:{
switch (config.getDeviceType()) {
case PSD:
return ((XtyPsdConfig) config).getConfig().getPsdCode();
}
+ break;
}
case RICHOR_JOINT: {
switch (config.getDeviceType()) {
@@ -155,6 +157,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case PSL:
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
}
+ break;
}
case SR_SANDBOX: {
switch (config.getDeviceType()) {
@@ -167,6 +170,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case TRAIN:
return ((SrTrainConfig) config).getConfigVO().getVrCode();
}
+ break;
}
case RICHOR_HHCJ: {
switch (config.getDeviceType()) {
@@ -175,6 +179,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case PSD:
return ((HhcjPsdConfig) config).getConfigVO().getPsdCode();
}
+ break;
}
}
return null;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java
index 356973b33..74d0db5e1 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java
@@ -38,6 +38,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -491,6 +492,13 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation voiceCommandBOList = iVoiceCommandService.getAll();
simulation.setVoiceCommandBOList(voiceCommandBOList);
+ // 添加消息发送器
+ addMessagePublisher(simulation);
// 添加任务
addJobs(simulation);
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
return simulation;
}
+ private void addMessagePublisher(Simulation simulation) {
+ simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
+ simulation.addMessagePublisher(new PisStatusPublisher(simulation));
+ }
+
private void addJobs(Simulation simulation) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位
@@ -201,6 +211,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
iVirtualRealityPslService.addJobs(simulation);
iscsMessageCollectAndDispatcher.addJob(simulation);
iscsLogicLoop.addJob(simulation);
+ pisLogicLoop.addJobs(simulation);
}
atpLogicLoop.addJobs(simulation);
atsLogicLoop.addJobs(simulation);
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
index 94eb3a7c0..38b508fe1 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java
@@ -3,11 +3,11 @@ package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
-
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
+import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.plan.TerminalDeparturePlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java
index 7bec0d266..4e7c4a67c 100644
--- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java
+++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java
@@ -5,6 +5,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.communication.vo.TrainHmiDisplay;
+import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan;
@@ -846,6 +847,7 @@ public class SimulationDataRepository {
/**
* 此方法只能用于计划车次号唯一的线路(比如西门子风格的运行计划)
+ *
* @param tripNumber
* @return
*/
@@ -1236,6 +1238,18 @@ public class SimulationDataRepository {
.collect(Collectors.toList());
}
+ public Stream