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

This commit is contained in:
joylink_zhangsai 2021-12-07 15:47:53 +08:00
commit bc2451cc18

View File

@ -22,6 +22,7 @@ import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -84,61 +85,78 @@ public class SimulationBuilder {
/**
* 加载进出depot的route path
*/
private static void loadDepotInOutRoutePath(Simulation simulation) {
private static void loadDepotInOutRoutePath(Simulation simulation) {
// 仿真车辆段站台停车轨列表
Map<Station, List<Section>> parkingTracksMap = simulation.getRepository().getParkingTracksMap();
if (CollectionUtils.isEmpty(parkingTracksMap)) {
return;
}
final Map<String, List<RoutePath>> srps = simulation.getRepository().getRoutePathMap();
final Map<String, List<RoutePath>> srps = simulation.getRepository().getRoutePathMap();
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>();
if (!CollectionUtils.isEmpty(transferList)) {
transferList.forEach(transSec -> {
// 停车轨到转换轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if(!CollectionUtils.isEmpty(nrp)) {
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>();
// 转换轨到停车轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if(!CollectionUtils.isEmpty(nrp)) {
if (!CollectionUtils.isEmpty(nrp)) {
srp.addAll(nrp);
}
});
});
}else {
log.info("仿真数据有问题,车辆段[{}]没有转换轨",station.getName());
});
} else {
log.info("仿真数据有问题,车辆段[{}]没有转换轨", station.getName());
}
}
});
});
}
/**
*当方向未知时起点终点不变不同方向搜索route path
* 当方向未知时起点终点不变不同方向搜索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)) {
private static List<RoutePath> tryFindRoutePathForOutByDirection(Section start, Section end, int 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();
}).findFirst().stream().collect(Collectors.toList());
} else if (r.size() > 2) {
log.warn("获取车辆段从停车轨到转换轨的路径, routeKey = {} , 路径数量大于2异常 ");
}
return r;
}
/**
* 当方向未知时起点终点不变不同方向搜索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);
}
} else {
return CalculateService.queryRoutePathsOnDirection(start, end, false, iterTimes);
}
}
private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) {
if (CollectionUtils.isEmpty(ibpList))