Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
joylink_zhangsai 2020-12-07 15:27:01 +08:00
commit 29875967a6
5 changed files with 63 additions and 7 deletions

View File

@ -13,7 +13,6 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.event.*;
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType;
@ -38,9 +37,6 @@ public class Joylink3DMessageService {
@Autowired
private StompMessageService stompMessageService;
@Autowired
private MemberManager memberManager;
@Autowired
private GroupSimulationService groupSimulationService;

View File

@ -144,7 +144,7 @@ public class SimulationSubscribeManager {
}
subscribeInfos.removeAll(removeList);
return set.stream()
.filter(dest -> this.containsSubDestination(dest) ? false : true)
.filter(dest -> !this.containsSubDestination(dest))
.collect(Collectors.toList());
}
@ -162,7 +162,7 @@ public class SimulationSubscribeManager {
.map(subscribeInfo -> subscribeInfo.destination)
.collect(Collectors.toSet())
.stream()
.filter(dest -> this.containsSubDestination(dest) ? false : true)
.filter(dest -> !this.containsSubDestination(dest))
.collect(Collectors.toList());
}

View File

@ -114,9 +114,31 @@ public class PassengerFlowSimulateService {
// 发送初始化数据
this.sendStandPassengerFlowData(simulation, standPassengerFlowMap);
this.sendTrainPassengerFlowData(simulation, trainPassengerFlowMap);
// 发送列车pis数据
this.sendTrainInitPisData(simulation, trainPassengerFlowMap);
log.debug(String.format("客流初始化成功"));
}
private void sendTrainInitPisData(Simulation simulation, Map<String, TrainPassengerFlow> trainPassengerFlowMap) {
List<Map<String, Object>> trainPisList = new ArrayList<>();
for (TrainPassengerFlow tpf : trainPassengerFlowMap.values()) {
VirtualRealityTrain train = tpf.getTrain();
Map<String, Object> pisInfo = new HashMap<>();
pisInfo.put("code", train.getGroupNumber());
pisInfo.put("nextStation", train.getNextStation() != null ? train.getNextStation().getCode() : null);
pisInfo.put("endStation", train.getTerminalStation() != null ? train.getTerminalStation().getCode() : null);
trainPisList.add(pisInfo);
}
if (!trainPisList.isEmpty()) {
Set<String> users = simulation.getSimulationUserIds();
String json = JsonUtils.writeValueNullableFieldAsString(trainPisList);
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.TRAIN_PIS,
simulation.getGroup(), json);
this.stompMessageService.sendToUser(users, message);
}
}
private void sendTrainPassengerFlowData(Simulation simulation, Map<String, TrainPassengerFlow> trainPassengerFlowMap) {
List<Map<String, Object>> trainPFNumList = new ArrayList<>();
for (TrainPassengerFlow flow : trainPassengerFlowMap.values()) {
@ -162,6 +184,8 @@ public class PassengerFlowSimulateService {
}
this.sendStandPassengerFlowData(simulation, passengerFlowSimulationData.getStandPassengerFlowMap());
this.sendTrainPassengerFlowData(simulation, passengerFlowSimulationData.getTrainPassengerFlowMap());
// 发生列车pis数据
this.sendTrainInitPisData(simulation, passengerFlowSimulationData.getTrainPassengerFlowMap());
}
private Map<String, TrainPassengerFlow> loadTrainPassengerFlow(Simulation simulation, PassengerFlowData passengerFlowData) {
@ -289,6 +313,7 @@ public class PassengerFlowSimulateService {
SimulationDataRepository repository = simulation.getRepository();
List<TrainPassengerFlow> allTrainPassengerFlows = passengerFlowSimulationData.getAllTrainPassengerFlow();
PassengerFlowData passengerFlowData = passengerFlowSimulationData.getPassengerFlowData();
Set<String> users = simulation.getSimulationUserIds();
for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlows) {
VirtualRealityTrain train = trainPassengerFlow.getTrain();
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber());
@ -328,14 +353,46 @@ public class PassengerFlowSimulateService {
sendData.put("out", tripStationPassengerFlowData.getDown());
trainPassengerFlow.startBoarding(station, tripStationPassengerFlowData);
Set<String> users = simulation.getSimulationUserIds();
String json = JsonUtils.writeValueNullableFieldAsString(sendData);
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.TRAIN_PFI_BL,
simulation.getGroup(), json);
this.stompMessageService.sendToUser(users, message);
}
});
}
@Async("nsExecutor")
@Scheduled(fixedRate = 5000)
public void trainPis() {
passengerFlowSimulationDataMap.forEach((group, passengerFlowSimulationData) -> {
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
SimulationDataRepository repository = simulation.getRepository();
List<TrainPassengerFlow> allTrainPassengerFlows = passengerFlowSimulationData.getAllTrainPassengerFlow();
List<Map<String, Object>> trainPisList = new ArrayList<>();
for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlows) {
VirtualRealityTrain train = trainPassengerFlow.getTrain();
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber());
if (Objects.isNull(trainInfo) || !trainInfo.isPlanTrain() || !trainInfo.isParking()) {
continue;
}
if (train.isStandReadyStart()) {
Map<String, Object> pisInfo = new HashMap<>();
pisInfo.put("code", train.getGroupNumber());
pisInfo.put("nextStation", train.getNextStation() != null ? train.getNextStation().getCode() : null);
pisInfo.put("endStation", train.getTerminalStation() != null ? train.getTerminalStation().getCode() : null);
trainPisList.add(pisInfo);
}
}
if (trainPisList.isEmpty()) {
return;
}
Set<String> users = simulation.getSimulationUserIds();
String json = JsonUtils.writeValueNullableFieldAsString(trainPisList);
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.TRAIN_PIS,
simulation.getGroup(), json);
this.stompMessageService.sendToUser(users, message);
});
}

View File

@ -164,6 +164,8 @@ public enum WebSocketMessageType {
TRAIN_PFI_NUM,
/** 列车客流乘降人数信息 */
TRAIN_PFI_BL,
/** 列车位置信息 */
TRAIN_PIS,
/** 车站客流当前人数信息 */
STATION_PFI_NUM,
// ------------客流消息end------------

View File

@ -131,6 +131,7 @@ public class SocketMessageFactory {
case STAND_PFI:
case TRAIN_PFI_NUM:
case TRAIN_PFI_BL:
case TRAIN_PIS:
case PFV:
case SJL3D_TrainStatus: {
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));