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

This commit is contained in:
joylink_zhangsai 2021-12-09 16:33:36 +08:00
commit f681f3a20f
4 changed files with 44 additions and 57 deletions

View File

@ -838,7 +838,7 @@ public class AtsTrainLoadService {
*/
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right) {
SimulationDataRepository repository = simulation.getRepository();
if (repository.isVrTrainOnline(groupNumber)) {
if (!simulation.getRepository().getConfig().isHandleDepot() && repository.isVrTrainOnline(groupNumber)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
String.format("车组号[%s]的列车已经在运行中", groupNumber));
} else {
@ -877,9 +877,11 @@ public class AtsTrainLoadService {
train.initAsRM();
}
}
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
trainInfo.tracking(train);
repository.addOnlineTrain(train);
repository.addTrainInfo(trainInfo);
if (!repository.getConfig().isHandleDepot()) {
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
trainInfo.tracking(train);
repository.addOnlineTrain(train);
repository.addTrainInfo(trainInfo);
}
}
}

View File

@ -100,7 +100,7 @@ public class SimulationBuilder {
// 停车轨到转换轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 20);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 5);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
@ -113,7 +113,7 @@ public class SimulationBuilder {
// 转换轨到停车轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 20);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 1);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
@ -135,7 +135,7 @@ public class SimulationBuilder {
* 当方向未知时起点终点不变不同方向搜索route path
*/
private static List<RoutePath> tryFindRoutePathForOutByDirection(Section start, Section end, int iterTimes) {
List<RoutePath> r = tryFindRoutePathByDirection(start, end, iterTimes);
List<RoutePath> r = tryFindRoutePathByDirection(start, end, iterTimes);
if (r.size() == 2) {
return r.stream().sorted((RoutePath r1, RoutePath r2) -> {
return r1.getSignalList().size() - r2.getSignalList().size();
@ -143,7 +143,7 @@ public class SimulationBuilder {
} else if (r.size() > 2) {
log.warn("获取车辆段从停车轨到转换轨的路径, routeKey = {} , 路径数量大于2异常 ");
}
}
return r;
}

View File

@ -229,7 +229,7 @@ public class SimulationDataRepository {
private List<SchedulingTrainPlan> outboundPlanList = new ArrayList<>();
private List<SchedulingTrainPlan> inboundPlanList = new ArrayList<>();
private List<VirtualRealityTrain> inboundTrainList = new ArrayList<>();
/**
* 间隔时间/s

View File

@ -115,28 +115,30 @@ public class DepotService {
* @param simulation
*/
private void backToParking(Simulation simulation) {
for (VirtualRealityTrain train : simulation.getRepository().getOnlineTrainList()) {
if (!train.isParkingAt()) {
continue;
}
Section section = train.getHeadPosition().getSection();
if (!section.isTransferTrack()) {
continue;
}
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getSchedulingTrainPlanList()) {
if (!schedulingTrainPlan.getInDepotTrip().getEndSection().equals(section)) {
continue;
}
if (!train.getGroupNumber().equals(schedulingTrainPlan.getGroupNumber())) {
continue;
}
if (!schedulingTrainPlan.getInDepotTrip().getEndTime().minusMinutes(10)
.isBefore(simulation.getSystemTime().toLocalTime())) {
continue;
}
if (!simulation.getRepository().getInboundPlanList().contains(schedulingTrainPlan)) {
for (TrainInfo trainInfo : simulation.getRepository().getTrainInfoMap().values()) {
if (trainInfo.isInbound() && trainInfo.isParking()) {
VirtualRealityTrain train = simulation.getRepository().getVRByCode(trainInfo.getGroupNumber(), VirtualRealityTrain.class);
if (train.getHeadPosition().getSection().isTransferTrack() && train.getTailPosition().getSection().isTransferTrack()) {
simulation.getRepository().getInboundTrainList().add(train);
train.initAsRM();
simulation.getRepository().getInboundPlanList().add(schedulingTrainPlan);
Section startSection = train.getHeadPosition().getSection();
Section endSection = null;
for (Section section : simulation.getRepository().getParkingTracksMap().get(startSection.getStation())) {
if (section.isOccupied()) {
continue;
}
if (section.getLeftSection() == null || section.getRightSection() == null) {
endSection = section;
} else if (section.getLeftSection().isParkingTrack() && !section.getLeftSection().isOccupied()) {
endSection = section.getLeftSection();
} else if (section.getRightSection().isParkingTrack() && !section.getRightSection().isOccupied()) {
endSection = section.getRightSection();
} else {
endSection = section;
}
break;
}
train.setTarget(endSection);
break;
}
}
@ -149,38 +151,23 @@ public class DepotService {
*/
private void settingRouteAndMoving(Simulation simulation) {
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getOutboundPlanList()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), schedulingTrainPlan.getOutDepotTrip().getStartSection());
VirtualRealityTrain train = simulation.getRepository().getVRByCode(schedulingTrainPlan.getGroupNumber(), VirtualRealityTrain.class);
moving(simulation, train, schedulingTrainPlan.getOutDepotTrip().getStartSection());
}
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getInboundPlanList()) {
Section endSection = schedulingTrainPlan.getInDepotTrip().getEndSection();
for (Section section : simulation.getRepository().getParkingTracksMap().get(endSection.getStation())) {
if (section.isOccupied()) {
continue;
}
if (section.getLeftSection() == null || section.getRightSection() == null) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section);
} else if (section.getLeftSection().isParkingTrack() && !section.getLeftSection().isOccupied()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section.getLeftSection());
} else if (section.getRightSection().isParkingTrack() && !section.getRightSection().isOccupied()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section.getRightSection());
} else {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section);
}
break;
}
for (VirtualRealityTrain train : simulation.getRepository().getInboundTrainList()) {
moving(simulation, train, train.getTarget());
}
}
private void moving(Simulation simulation, String groupNumber, Section endSection) {
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
private void moving(Simulation simulation, VirtualRealityTrain train, Section endSection) {
Section startSection = train.getHeadPosition().getSection();
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
if (routePaths == null || routePaths.isEmpty()) {
return;
}
RoutePath routePath = routePaths.get(0);
Section lastSection = routePath.getEnd();
train.setRobotTargetPosition(new SectionPosition(lastSection, lastSection.getStopPointByDirection(routePath.isRight())));
Section pathEnd = routePath.getEnd();
train.setRobotTargetPosition(new SectionPosition(pathEnd, pathEnd.getStopPointByDirection(routePath.isRight())));
for (Signal signal : routePath.getSignalList()) {
for (Route route : signal.getRouteList()) {
if (routePath.getRouteList().contains(route)) {
@ -220,10 +207,8 @@ public class DepotService {
groupSimulationService.command(simulation, commandInitiateVO, member);
}
}
for (Iterator<SchedulingTrainPlan> iterator = simulation.getRepository().getInboundPlanList().iterator(); iterator.hasNext(); ) {
SchedulingTrainPlan schedulingTrainPlan = iterator.next();
String groupNumber = schedulingTrainPlan.getGroupNumber();
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
for (Iterator<VirtualRealityTrain> iterator = simulation.getRepository().getInboundTrainList().iterator(); iterator.hasNext(); ) {
VirtualRealityTrain train = iterator.next();
if (train.getSpeed() == 0 && train.getHeadPosition().getSection().isParkingTrack()
&& train.getTailPosition().getSection().isParkingTrack()) {
// 到达