修改:有关进路的移动授权计算逻辑bug

This commit is contained in:
joylink_zhangsai 2021-07-06 11:13:56 +08:00
parent 5bb62daef0
commit 2ddb1c38c5
2 changed files with 30 additions and 11 deletions

View File

@ -23,7 +23,6 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -440,9 +439,10 @@ public class ZCLogicLoop {
boolean lock = false;
if (!CollectionUtils.isEmpty(settingRoutes)) {
for (Route route : settingRoutes) {
if (route.isRouteSection(section)) {
if (route.isRouteSection(section) && route.isRight() == right) {
lock = true;
if (!this.checkSwitchPosition(route) || !routeService.isFlsCheckPass(route.getFlsList())) {
List<SwitchElement> switches = screenSwitchesInFront(route, section);
if (!routeService.checkRouteSwitchPosition(switches) || !this.isFlsCheckPass(route.getFlsList(), switches)) {
return new MovementAuthority.End(section, MovementAuthority.EndType.ROUTE_INTERLOCK_NOT_MET);
}
break;
@ -475,14 +475,29 @@ public class ZCLogicLoop {
return null;
}
private boolean checkSwitchPosition(Route route) {
Set<Switch> sectionRelSwitches = route.getSectionList().stream()
.filter(Section::isRouteLock)
.map(Section::getRelSwitch)
.collect(Collectors.toSet());
List<SwitchElement> switchList;
switchList = route.getSwitchList().stream().filter(element -> sectionRelSwitches.contains(element.getASwitch())).collect(Collectors.toList());
return routeService.checkRouteSwitchPosition(switchList);
private boolean isFlsCheckPass(List<RouteFls> flsList, List<SwitchElement> switches) {
if (!CollectionUtils.isEmpty(flsList) && !CollectionUtils.isEmpty(switches)) {
List<RouteFls> collect = flsList.stream().filter(fls -> switches.contains(fls.getBase())).collect(Collectors.toList());
return routeService.isFlsCheckPass(collect);
}
return true;
}
/**
* 筛选前方的道岔
*/
private List<SwitchElement> screenSwitchesInFront(Route route, Section section) {
boolean right = route.isRight();
List<Section> sectionList = route.getSectionList();
List<Switch> sectionRelSwitches = new ArrayList<>();
while (sectionList.contains(section)) {
if (section.getRelSwitch() != null)
sectionRelSwitches.add(section.getRelSwitch());
section = section.getNextRunningSectionOf(right);
}
return route.getSwitchList().stream()
.filter(element -> sectionRelSwitches.contains(element.getASwitch()))
.collect(Collectors.toList());
}
/**

View File

@ -578,6 +578,10 @@ public class Route extends MapNamedElement {
return this.sectionList.stream().anyMatch(Section::isTransferTrack);
}
public boolean isRight() {
return this.start.isRight();
}
/**
* 进路检查失败原因
*/