SimulationBuilder.build中实现加载车辆段route path

This commit is contained in:
xiazengbin 2021-12-06 18:06:01 +08:00
parent 05e0eedb34
commit eb56128954

View File

@ -79,9 +79,70 @@ public class SimulationBuilder {
checkAndLoadRunPlan(simulation, buildParams.getRunPlan()); checkAndLoadRunPlan(simulation, buildParams.getRunPlan());
// 加载派班计划 // 加载派班计划
checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan()); checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan());
// 加载车辆段route path
loadDepotInOutRoutePath(simulation);
return simulation; return simulation;
} }
/**
* 加载进出depot的route path
*/
private static void loadDepotInOutRoutePath(Simulation simulation) {
final Map<String, List<RoutePath>> srps = simulation.getRepository().getRoutePathMap();
// 仿真车辆段站台停车轨列表
Map<Station, List<Section>> parkingTracksMap = simulation.getRepository().getParkingTracksMap();
if (CollectionUtils.isEmpty(parkingTracksMap)) {
return;
}
parkingTracksMap.forEach((station, secs) -> {
if (station.isDepot()) {// 车站为车辆段
List<Section> transferList = station.getTransferList();// 转换轨列表
if(!CollectionUtils.isEmpty(transferList)) {
transferList.forEach(transSec->{
//停车轨到转换轨
secs.forEach(parkSec->{
final String rpKey=RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp=tryFindRoutePathByDirection(parkSec, transSec,10);
List<RoutePath> srp=srps.get(rpKey);
if(null==srp) {
srp=new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if(!CollectionUtils.isEmpty(nrp)) {
srp.addAll(nrp);
}
});
//转换轨到停车轨
secs.forEach(parkSec->{
final String rpKey=RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp=tryFindRoutePathByDirection(transSec, parkSec,10);
List<RoutePath> srp=srps.get(rpKey);
if(null==srp) {
srp=new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if(!CollectionUtils.isEmpty(nrp)) {
srp.addAll(nrp);
}
});
});
}else {
log.info("仿真数据有问题,车辆段[{}]没有转换轨",station.getName());
}
}
});
}
/**
*当方向未知时起点终点不变不同方向搜索route path
*/
private static List<RoutePath> tryFindRoutePathByDirection(Section start, Section end,int iterTimes) {
List<RoutePath> r= CalculateService.queryRoutePathsOnDirection(start, end,true, iterTimes);
if(!CollectionUtils.isEmpty(r)) {
return r;
}else {
return CalculateService.queryRoutePathsOnDirection(start, end,false, iterTimes);
}
}
private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) { private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) {
if (CollectionUtils.isEmpty(ibpList)) if (CollectionUtils.isEmpty(ibpList))
return; return;