修改道岔转动及控制权交出、接收bug

This commit is contained in:
joylink_zhangsai 2021-10-25 16:05:35 +08:00
parent 13506c2faa
commit 89c23e50e3
3 changed files with 39 additions and 18 deletions

View File

@ -255,13 +255,18 @@ public class AtsStationService {
} else {
deviceStation = station.getDeviceStation();
}
//确认控制权现在属于该成员
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue((member.isDispatcher() && station.isCenterControl())
|| (member.isStationSupervisor() && station.isStandControl()),
String.format("车站[%s]所属设备集中站[%s]当前控制权不在成员[%s]手中", station.getCode(), deviceStation.getCode(), member.getId()));
SimulationDataRepository repository = simulation.getRepository();
Set<Station> stations = repository.getStationsByDeviceStations(deviceStation);
boolean canSurrender = false;
if (member.isDispatcher() && deviceStation.isCenterControl()) {
canSurrender = true;
} else if (member.isStationSupervisor() && deviceStation.isLocalControl()) {
if (stations.stream().anyMatch(sta -> Objects.equals(sta, member.getDevice()))) {
canSurrender = true;
}
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(canSurrender,
String.format("成员[%s]无权交出设备集中站[%s]的控制权", member.getId(), deviceStation.debugStr()));
stations.forEach(Station::surrenderControl);
}
@ -279,18 +284,34 @@ public class AtsStationService {
} else {
deviceStation = station.getDeviceStation();
}
List<SimulationMember> dispatchers = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
if (!CollectionUtils.isEmpty(dispatchers)) {
boolean allDispatchersAreRobots = dispatchers.stream().allMatch(SimulationMember::isRobot);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
.assertTrue(allDispatchersAreRobots,
String.format("车站[%s]控制权未交出", deviceStation.debugStr()));
if ((member.isDispatcher() && deviceStation.isCenterControl())
|| (member.isStationSupervisor() && deviceStation.isLocalControl())) { //已是期望的控制模式
return;
}
SimulationDataRepository repository = simulation.getRepository();
Set<Station> stations = repository.getStationsByDeviceStations(deviceStation);
if (member.isDispatcher()) {
if (!deviceStation.isSurrenderControl()) {
List<SimulationMember> stationMember = simulation.getSimulationMembersByDevice(deviceStation);
if (!CollectionUtils.isEmpty(stationMember)) {
boolean allDispatchersAreRobots = stationMember.stream().allMatch(SimulationMember::isRobot);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
.assertTrue(allDispatchersAreRobots,
String.format("车站[%s]控制权未交出", deviceStation.debugStr()));
}
}
stations.forEach(Station::occControl);
} else if (member.isStationSupervisor()) {
if (!deviceStation.isSurrenderControl()) {
List<SimulationMember> dispatchers = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
if (!CollectionUtils.isEmpty(dispatchers)) {
boolean allDispatchersAreRobots = dispatchers.stream().allMatch(SimulationMember::isRobot);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
.assertTrue(allDispatchersAreRobots,
String.format("车站[%s]控制权未交出", deviceStation.debugStr()));
}
}
stations.forEach(Station::localControl);
}
}

View File

@ -1,7 +1,8 @@
package club.joylink.rtss.simulation.cbtc.CI.device;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
@ -100,7 +101,7 @@ public class CiSwitchControlService {
if (vrSwitch.isPosN()) {
return this.turn2ReversePosition(simulation, aSwitch);
} else if (vrSwitch.isPosR()) {
return this.turn2ReversePosition(simulation, aSwitch);
return this.turn2NormalPosition(simulation, aSwitch);
}
}
return this.turn2NormalPosition(simulation, aSwitch);

View File

@ -13,7 +13,6 @@ import lombok.NonNull;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@ -475,7 +474,7 @@ public class Station extends MayOutOfOrderDevice {
/**
* 是否站控
*/
public boolean isStandControl() {
public boolean isLocalControl() {
return Objects.equals(ControlMode.Local, this.controlMode);
}
@ -498,11 +497,11 @@ public class Station extends MayOutOfOrderDevice {
*/
public boolean underStandControl() {
if (isCentralized())
return isStandControl();
return isLocalControl();
if (hasControlMode) {
return isStandControl();
return isLocalControl();
} else {
return deviceStation.isStandControl();
return deviceStation.isLocalControl();
}
}