【总辅助验证条件增加】
This commit is contained in:
parent
11252f4f48
commit
6e40df6868
@ -52,9 +52,10 @@ public class StationDirectionOperateHandler {
|
||||
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST)
|
||||
public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum
|
||||
, Integer pressDown) {
|
||||
ButtonValidInterface validInterface = stationDirectionService.getValidMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
|
||||
ButtonThenInterface thenInterface = stationDirectionService.getThenMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
|
||||
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum
|
||||
, StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), null, thenInterface);
|
||||
, StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), validInterface, thenInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,11 +52,20 @@ public class StationDirectionService {
|
||||
if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
|
||||
}
|
||||
// 接车进路有锁闭,有车进入
|
||||
// 原接车站无接车进路锁闭
|
||||
boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
|
||||
if (isReceiveConflict) {
|
||||
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();
|
||||
if (routeOptional.isEmpty()) {
|
||||
@ -65,9 +74,28 @@ public class StationDirectionService {
|
||||
};
|
||||
|
||||
/**
|
||||
* 发辅助按钮操作校验
|
||||
* 总辅助校验
|
||||
*/
|
||||
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()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
|
||||
}
|
||||
@ -78,7 +106,9 @@ public class StationDirectionService {
|
||||
*/
|
||||
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);
|
||||
if (deliverDirection == null) {
|
||||
@ -272,10 +302,12 @@ public class StationDirectionService {
|
||||
this.operationButtonValidMap = new HashMap<>();
|
||||
// 改方按下验证函数
|
||||
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_DELIVER_ASSIST, this.turnAssistValid);
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DELIVER_ASSIST, this.deliverAssistValid);
|
||||
// 操作按钮后续操作集合
|
||||
this.operationButtonThenMap = new HashMap<>();
|
||||
// 总辅助后续操作
|
||||
|
Loading…
Reference in New Issue
Block a user