车辆段 出库逻辑
This commit is contained in:
parent
88e5fa6abb
commit
1bf100f117
@ -827,7 +827,7 @@ public class AtsTrainLoadService {
|
||||
List<TripPlan> allTripPlanList = repository.getAllTripPlanList();
|
||||
allTripPlanList.forEach(tripPlan -> {
|
||||
if (!systemTime.isBefore(tripPlan.getStartTime())) {
|
||||
tripPlan.dispatch();
|
||||
tripPlan.departure();
|
||||
tripPlan.finishStationPlanOf(systemTime);
|
||||
}
|
||||
});
|
||||
|
@ -68,7 +68,7 @@ public class AtsManualTrainStageService implements AtsStageService {
|
||||
}
|
||||
if (systemTime.toLocalTime().plusMinutes(10).isAfter(tripPlan.getStartTime())) {
|
||||
this.planTrainStageService.updateTripPlan(simulation, trainInfo, tripPlan);
|
||||
tripPlan.dispatch();
|
||||
tripPlan.departure();
|
||||
this.realRunRecordService.recordTrainRealRun(simulation, trainInfo, parkSection.getStation(),
|
||||
parkSection, true);
|
||||
break;
|
||||
|
@ -232,11 +232,20 @@ public class TripPlan {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按计划发车
|
||||
*/
|
||||
public void departure() {
|
||||
this.departure = true;
|
||||
if (this.isOutbound()) {
|
||||
this.dispatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按计划派发
|
||||
*/
|
||||
public void dispatch() {
|
||||
this.departure = true;
|
||||
public void dispatched() {
|
||||
if (this.isOutbound()) {
|
||||
this.dispatched = true;
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ public class TrainInfo extends MapElement {
|
||||
}
|
||||
|
||||
public synchronized void applyNewTripPlan(TripPlan tripPlan) {
|
||||
tripPlan.dispatch();
|
||||
tripPlan.departure();
|
||||
this.serviceNumber = tripPlan.getServiceNumber();
|
||||
this.tripNumber = tripPlan.getTripNumber();
|
||||
this.destinationCode = tripPlan.getDestinationCode();
|
||||
|
@ -2,7 +2,10 @@ package club.joylink.rtss.simulation.cbtc.depot;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.tools.TrainOutboundLoadTool;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
@ -14,10 +17,12 @@ 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.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -25,7 +30,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@ -37,7 +41,10 @@ public class DepotService {
|
||||
@Autowired
|
||||
private TrainOutboundLoadTool trainOutboundLoadTool;
|
||||
|
||||
private Map<Section, Queue<SchedulingTrainPlan>> stationListMap = new HashMap<>();
|
||||
@Autowired
|
||||
private GroupSimulationService groupSimulationService;
|
||||
|
||||
private Map<Section, List<SchedulingTrainPlan>> sectionDispatchMap = new HashMap<>();
|
||||
|
||||
private List<SchedulingTrainPlan> outboundPlanList = new LinkedList<>();
|
||||
|
||||
@ -68,15 +75,15 @@ public class DepotService {
|
||||
simulation.getRepository().addTrainInfo(trainInfo);
|
||||
}
|
||||
});
|
||||
stationListMap.clear();
|
||||
sectionDispatchMap.clear();
|
||||
outboundPlanList.clear();
|
||||
inboundPlanList.clear();
|
||||
simulation.getRepository().getSchedulingTrainPlanList().stream().
|
||||
sorted(Comparator.comparing(schedulingTrainPlan -> schedulingTrainPlan.getOutDepotTrip().getStartTime().toSecondOfDay()))
|
||||
.forEach(schedulingTrainPlan -> {
|
||||
Queue<SchedulingTrainPlan> queue = stationListMap
|
||||
.computeIfAbsent(schedulingTrainPlan.getOutDepotTrip().getStartSection(), key -> new LinkedList<>());
|
||||
queue.add(schedulingTrainPlan);
|
||||
List<SchedulingTrainPlan> planList = sectionDispatchMap
|
||||
.computeIfAbsent(schedulingTrainPlan.getOutDepotTrip().getStartSection(), key -> new ArrayList<>());
|
||||
planList.add(schedulingTrainPlan);
|
||||
});
|
||||
}
|
||||
|
||||
@ -94,7 +101,7 @@ public class DepotService {
|
||||
timeToDeparture(simulation);
|
||||
settingRouteAndMoving(simulation);
|
||||
arriveTransferTrack(simulation);
|
||||
backToParking(simulation);
|
||||
// backToParking(simulation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,13 +111,16 @@ public class DepotService {
|
||||
*/
|
||||
private void timeToDeparture(Simulation simulation) {
|
||||
LocalDateTime systemTime = simulation.getSystemTime();
|
||||
stationListMap.forEach((section, list) -> {
|
||||
SchedulingTrainPlan schedulingTrainPlan = list.peek();
|
||||
if (!schedulingTrainPlan.getOutDepotTrip().isDeparture()
|
||||
&& schedulingTrainPlan.getOutDepotTrip().getStartTime().minusMinutes(10).isBefore(systemTime.toLocalTime())) {
|
||||
if (!outboundPlanList.contains(schedulingTrainPlan)) {
|
||||
outboundPlanList.add(schedulingTrainPlan);
|
||||
list.add(list.poll());
|
||||
sectionDispatchMap.forEach((section, list) -> {
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : list) {
|
||||
if (schedulingTrainPlan.getOutDepotTrip().isDispatched()) {
|
||||
continue;
|
||||
}
|
||||
if (schedulingTrainPlan.getOutDepotTrip().getStartTime().minusMinutes(10).isBefore(systemTime.toLocalTime())) {
|
||||
if (!outboundPlanList.contains(schedulingTrainPlan)) {
|
||||
outboundPlanList.add(schedulingTrainPlan);
|
||||
schedulingTrainPlan.getOutDepotTrip().dispatched();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -139,9 +149,17 @@ public class DepotService {
|
||||
String groupNumber = schedulingTrainPlan.getGroupNumber();
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
|
||||
if (train.getSpeed() == 0
|
||||
&& train.getHeadPosition().getSection().equals(schedulingTrainPlan.getOutDepotTrip().getStartSection())) {
|
||||
&& train.getHeadPosition().getSection().equals(schedulingTrainPlan.getOutDepotTrip().getStartSection())
|
||||
&& train.getTailPosition().getSection().equals(schedulingTrainPlan.getOutDepotTrip().getStartSection())) {
|
||||
// 到达
|
||||
iterator.remove();
|
||||
// 升级
|
||||
SimulationMember member = simulation.getSimulationMembersByDevice(train).get(0);
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("preselectionMode", "AM_C");
|
||||
CommandInitiateVO commandInitiateVO = new CommandInitiateVO(CommandBO.CommandType.Change_Preselection_Mode,
|
||||
member.getId(), param);
|
||||
groupSimulationService.command(simulation, commandInitiateVO, member);
|
||||
}
|
||||
}
|
||||
for (Iterator<SchedulingTrainPlan> iterator = inboundPlanList.iterator(); iterator.hasNext(); ) {
|
||||
@ -169,7 +187,7 @@ public class DepotService {
|
||||
if (!section.isTransferTrack()) {
|
||||
continue;
|
||||
}
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : stationListMap.get(section)) {
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : sectionDispatchMap.get(section)) {
|
||||
if (!schedulingTrainPlan.getInDepotTrip().getEndSection().equals(section)) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user