【总辅助验证条件增加】

This commit is contained in:
weizhihong 2022-07-14 09:53:26 +08:00
parent 11252f4f48
commit 6e40df6868
2 changed files with 38 additions and 5 deletions

View File

@ -52,9 +52,10 @@ public class StationDirectionOperateHandler {
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST) @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST)
public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum
, Integer pressDown) { , Integer pressDown) {
ButtonValidInterface validInterface = stationDirectionService.getValidMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
ButtonThenInterface thenInterface = stationDirectionService.getThenMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST); ButtonThenInterface thenInterface = stationDirectionService.getThenMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum
, StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), null, thenInterface); , StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), validInterface, thenInterface);
} }
/** /**

View File

@ -52,11 +52,20 @@ public class StationDirectionService {
if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) { if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
} }
// 接车进路锁闭有车进入 // 原接车站无接车进路锁闭
boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock); boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
if (isReceiveConflict) { if (isReceiveConflict) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突");
} }
// 原发车站无发车进路锁闭
StationDirection relativeDirection = getRelativeStationDirection(simulation, stationDirection);
boolean isDeliverConflict = relativeDirection != null;
if (isDeliverConflict) {
isDeliverConflict = relativeDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
}
if (isDeliverConflict) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:相对方向存在发车进路");
}
// 查找发车进路方向的站台上是否有停靠列车 // 查找发车进路方向的站台上是否有停靠列车
Optional<Route> routeOptional = stationDirection.getReceiveRouteList().stream().findAny(); Optional<Route> routeOptional = stationDirection.getReceiveRouteList().stream().findAny();
if (routeOptional.isEmpty()) { if (routeOptional.isEmpty()) {
@ -65,9 +74,28 @@ public class StationDirectionService {
}; };
/** /**
* 发辅助按钮操作校验 * 总辅助校验
*/ */
private final ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> { private final ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> {
// 原接车站无接车进路锁闭
boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
// 原发车站无发车进路锁闭
boolean isDeliverConflict = stationDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
// 相对车站
StationDirection relativeDirection = getRelativeStationDirection(simulation, stationDirection);
if (relativeDirection != null) {
isReceiveConflict = isReceiveConflict || relativeDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
isDeliverConflict = isDeliverConflict || relativeDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
}
if (isReceiveConflict || isDeliverConflict) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在锁闭进路");
}
};
/**
* 发辅助按钮操作校验
*/
private final ButtonValidInterface deliverAssistValid = (simulation, stationDirection) -> {
if (!stationDirection.isMainAssistStatus()) { if (!stationDirection.isMainAssistStatus()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
} }
@ -78,7 +106,9 @@ public class StationDirectionService {
*/ */
private final ButtonValidInterface receiveAssistValid = (simulation, stationDirection) -> { private final ButtonValidInterface receiveAssistValid = (simulation, stationDirection) -> {
// 判断总辅助 // 判断总辅助
this.turnAssistValid.valid(simulation, stationDirection); if (!stationDirection.isMainAssistStatus()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
}
// 发车方向 // 发车方向
StationDirection deliverDirection = getRelativeStationDirection(simulation, stationDirection); StationDirection deliverDirection = getRelativeStationDirection(simulation, stationDirection);
if (deliverDirection == null) { if (deliverDirection == null) {
@ -272,10 +302,12 @@ public class StationDirectionService {
this.operationButtonValidMap = new HashMap<>(); this.operationButtonValidMap = new HashMap<>();
// 改方按下验证函数 // 改方按下验证函数
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION, this.turnDirectionPressDownValid); this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION, this.turnDirectionPressDownValid);
// 总辅助按下验证函数
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_MAIN_ASSIST, this.turnAssistValid);
// 接辅助按下验证函数 // 接辅助按下验证函数
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST, this.receiveAssistValid); this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST, this.receiveAssistValid);
// 发辅助按下验证函数 // 发辅助按下验证函数
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DELIVER_ASSIST, this.turnAssistValid); this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DELIVER_ASSIST, this.deliverAssistValid);
// 操作按钮后续操作集合 // 操作按钮后续操作集合
this.operationButtonThenMap = new HashMap<>(); this.operationButtonThenMap = new HashMap<>();
// 总辅助后续操作 // 总辅助后续操作