客流列车到站上车调整
This commit is contained in:
parent
df250b5c71
commit
6f6a323d8d
@ -288,20 +288,25 @@ public class PassengerFlowSimulateService {
|
||||
Map<String, Object> sendData = new HashMap<>();
|
||||
Stand stand = standPassengerFlow.getStand();
|
||||
StandTimePassengerFlowData flowData = standTimePassengerFlowDataMap.get(stand.getCode());
|
||||
int add = flowData.getNum() - standPassengerFlow.getPassengerQuantity();
|
||||
int add = flowData.getNum() - standPassengerFlow.getLastLoad();
|
||||
if (add < 0) {
|
||||
log.warn(String.format("站台[%s]时间[%s]到站人数计算小于0,站台本身数量[%s],下一时间数量[%s]",
|
||||
stand.debugStr(), systemTimeStr,
|
||||
standPassengerFlow.getPassengerQuantity(), flowData.getNum()));
|
||||
add = 0;
|
||||
// 列车拉走了站台上的人
|
||||
add = flowData.getNum();
|
||||
}
|
||||
sendData.put("standCode", stand.getCode());
|
||||
sendData.put("num", flowData.getNum());
|
||||
sendData.put("to", add);
|
||||
sendDataList.add(sendData);
|
||||
// standPassengerFlow.passengerEnter(add);
|
||||
standPassengerFlow.updateRemain(flowData.getNum());
|
||||
standPassengerFlow.passengerEnter(add);
|
||||
standPassengerFlow.reload(flowData.getNum());
|
||||
}
|
||||
sendStandPassengerToUser(simulation, systemTime, passengerFlowSimulationData, sendDataList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendStandPassengerToUser(Simulation simulation, LocalDateTime systemTime,
|
||||
PassengerFlowSimulationData passengerFlowSimulationData, List<Map<String, Object>> sendDataList) {
|
||||
Set<String> users = simulation.getSimulationUserIds();
|
||||
String json = JsonUtils.writeValueNullableFieldAsString(sendDataList);
|
||||
SocketMessageVO<String> message = SocketMessageFactory.build(
|
||||
@ -324,8 +329,6 @@ public class PassengerFlowSimulateService {
|
||||
stompMessageService.sendToUser(users, sendMessage);
|
||||
passengerFlowSimulationData.getHistoryPassengerMessage2TD().add(message2TD);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Async("nsExecutor")
|
||||
@Scheduled(fixedRate = 500)
|
||||
@ -336,6 +339,7 @@ public class PassengerFlowSimulateService {
|
||||
List<TrainPassengerFlow> allTrainPassengerFlows = passengerFlowSimulationData.getAllTrainPassengerFlow();
|
||||
PassengerFlowData passengerFlowData = passengerFlowSimulationData.getPassengerFlowData();
|
||||
Set<String> users = simulation.getSimulationUserIds();
|
||||
LocalDateTime systemTime = simulation.getCorrectSystemTime();
|
||||
for (TrainPassengerFlow trainPassengerFlow : allTrainPassengerFlows) {
|
||||
VirtualRealityTrain train = trainPassengerFlow.getTrain();
|
||||
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber());
|
||||
@ -350,6 +354,7 @@ public class PassengerFlowSimulateService {
|
||||
}
|
||||
if (train.isStandReadyStart()) {
|
||||
trainPassengerFlow.endBoarding();
|
||||
continue;
|
||||
}
|
||||
if (!train.isStandBoarding()) {
|
||||
continue;
|
||||
@ -366,20 +371,47 @@ public class PassengerFlowSimulateService {
|
||||
log.debug(String.format("车站[%s]列车车次[%s]客流数据不存在,不更新", station.debugStr(), tripPlan.debugStr()));
|
||||
continue;
|
||||
}
|
||||
if (Objects.equals(trainPassengerFlow.getStation(), station)) { // 已经处理过
|
||||
Stand stand = station.getStandOf(train.isRight()).get(0);
|
||||
StandPassengerFlow standPassengerFlow = passengerFlowSimulationData.getStandPassengerFlowMap().get(stand.getCode());
|
||||
if (standPassengerFlow.getPassengerQuantity() == 0 && Objects.nonNull(trainPassengerFlow.getStation())) {
|
||||
// 已下过车且车站没人等车
|
||||
continue;
|
||||
}
|
||||
// 列车最大容量1500
|
||||
int in = Math.min(1500 - trainPassengerFlow.getPassengerQuantity(), standPassengerFlow.getPassengerQuantity());
|
||||
Map<String, Object> sendData = new HashMap<>();
|
||||
sendData.put("code", train.getGroupNumber());
|
||||
sendData.put("in", tripStationPassengerFlowData.getUp());
|
||||
sendData.put("in", in);
|
||||
if (Objects.isNull(trainPassengerFlow.getStation())) {
|
||||
if (train.getTerminalStation().equals(station)) {
|
||||
if (trainPassengerFlow.getPassengerQuantity() > tripStationPassengerFlowData.getDown()) {
|
||||
log.warn("列车[{}]到达终点站,车上乘客人数[{}]多余下车人数[{}]", train.getGroupNumber(),
|
||||
trainPassengerFlow.getPassengerQuantity(), tripStationPassengerFlowData.getDown());
|
||||
}
|
||||
// 全部下车
|
||||
sendData.put("out", trainPassengerFlow.getPassengerQuantity());
|
||||
trainPassengerFlow.startOutboard(station, trainPassengerFlow.getPassengerQuantity());
|
||||
} else {
|
||||
sendData.put("out", tripStationPassengerFlowData.getDown());
|
||||
trainPassengerFlow.startBoarding(station, tripStationPassengerFlowData);
|
||||
trainPassengerFlow.startOutboard(station, tripStationPassengerFlowData.getDown());
|
||||
}
|
||||
} else {
|
||||
sendData.put("out", 0);
|
||||
}
|
||||
trainPassengerFlow.startBoarding(station, in);
|
||||
|
||||
String json = JsonUtils.writeValueNullableFieldAsString(sendData);
|
||||
SocketMessageVO<String> message = SocketMessageFactory.build(
|
||||
WebSocketMessageType.TRAIN_PFI_BL,
|
||||
simulation.getGroup(), json);
|
||||
this.stompMessageService.sendToUser(users, message);
|
||||
// 发送站台数据变更
|
||||
Map<String, Object> sendStandData = new HashMap<>();
|
||||
sendStandData.put("standCode", stand.getCode());
|
||||
sendStandData.put("num", standPassengerFlow.getPassengerQuantity() - in);
|
||||
sendStandData.put("to", 0);
|
||||
standPassengerFlow.passengerGetTrain(in);
|
||||
sendStandPassengerToUser(simulation, systemTime, passengerFlowSimulationData, Collections.singletonList(sendStandData));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ public class StandPassengerFlow {
|
||||
|
||||
private Stand stand;
|
||||
|
||||
private int lastLoad;
|
||||
|
||||
private int passengerQuantity;
|
||||
|
||||
public StandPassengerFlow(Stand stand) {
|
||||
@ -27,6 +29,14 @@ public class StandPassengerFlow {
|
||||
this.passengerQuantity += add;
|
||||
}
|
||||
|
||||
public void passengerGetTrain(int num) {
|
||||
this.passengerQuantity -= num;
|
||||
}
|
||||
|
||||
public void reload(int num) {
|
||||
this.lastLoad = num;
|
||||
}
|
||||
|
||||
public void updateRemain(int num) {
|
||||
this.passengerQuantity = num;
|
||||
}
|
||||
|
@ -26,6 +26,16 @@ public class TrainPassengerFlow {
|
||||
this.passengerQuantity = remain;
|
||||
}
|
||||
|
||||
public void startOutboard(Station station, int num) {
|
||||
this.station = station;
|
||||
this.passengerQuantity -= num;
|
||||
}
|
||||
|
||||
public void startBoarding(Station station, int num) {
|
||||
this.station = station;
|
||||
this.passengerQuantity += num;
|
||||
}
|
||||
|
||||
public void startBoarding(Station station, TripStationPassengerFlowData tripStationPassengerFlowData) {
|
||||
this.station = station;
|
||||
this.passengerQuantity = tripStationPassengerFlowData.getRemain();
|
||||
|
Loading…
Reference in New Issue
Block a user