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;
@ -99,7 +100,7 @@ public class SimulationBuilder {
// 停车轨到转换轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp=tryFindRoutePathByDirection(parkSec, transSec,10);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
@ -112,7 +113,7 @@ public class SimulationBuilder {
// 转换轨到停车轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp=tryFindRoutePathByDirection(transSec, parkSec,10);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
@ -129,6 +130,23 @@ public class SimulationBuilder {
}
});
}
/**
* 当方向未知时起点终点不变不同方向搜索route path
*/
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
*/