新版仿真构建成员时使用既定的id而不是生成;当向仿真中重复添加某一账号的仿真用户时,将原来仿真用户取消扮演
This commit is contained in:
parent
0548541ff3
commit
15b5653083
@ -463,7 +463,14 @@ public abstract class Simulation<U extends SimulationUser, M extends SimulationM
|
||||
// } else {
|
||||
// user.setType(SimulationUser.Type.STUDENT);
|
||||
// }
|
||||
return this.simulationUserMap.put(user.getId(), user);
|
||||
U oldUser = this.simulationUserMap.put(user.getId(), user);
|
||||
if (oldUser != null) {
|
||||
log.warn("[{}]被[{}]替换", oldUser, user);
|
||||
if (oldUser instanceof club.joylink.rtss.simulation.cbtc.member.SimulationUser) {
|
||||
((club.joylink.rtss.simulation.cbtc.member.SimulationUser) oldUser).cancelPlay();
|
||||
}
|
||||
}
|
||||
return oldUser;
|
||||
}
|
||||
|
||||
public U removeSimulationUser(U user) {
|
||||
|
@ -824,7 +824,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
||||
MapElement mapElement = null;
|
||||
if (StringUtils.hasText(param.getDeviceCode()))
|
||||
mapElement = simulation.getRepository().getByCode(param.getDeviceCode());
|
||||
SimulationMember member = this.memberManager.addRole(simulation, param.getType(), param.getName(), mapElement);
|
||||
SimulationMember member = this.memberManager.addRole(simulation, null, param.getType(), param.getName(), mapElement);
|
||||
return new SimulationMemberVO(member);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import club.joylink.rtss.services.IMapService;
|
||||
import club.joylink.rtss.services.auth.ProjectDeviceLogoutEvent;
|
||||
import club.joylink.rtss.services.auth.UserLogoutEvent;
|
||||
import club.joylink.rtss.services.project.DeviceService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceThread;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig;
|
||||
@ -25,11 +24,9 @@ import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSwitchConfi
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrTrainConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.project.LwConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.project.ProjectVO;
|
||||
@ -217,52 +214,52 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
||||
simulation.addSimulationUser(simulationUser);
|
||||
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
||||
this.applicationContext.publishEvent(userEnterEvent);
|
||||
switch (deviceVO.getType()) {
|
||||
case LW: {
|
||||
// 暂时默认先按配置的车站创建成员
|
||||
LwConfigVO lwConfigVO = deviceVO.buildLwConfig();
|
||||
Station station = simulation.getRepository().getByCode(lwConfigVO.getStationCode(), Station.class);
|
||||
SimulationMember member = simulation.getSimulationMember(station, SimulationMember.Type.STATION_SUPERVISOR);
|
||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), member.getId());
|
||||
// 现地工作站
|
||||
break;
|
||||
}
|
||||
case CW: {
|
||||
// 行调工作站
|
||||
List<SimulationMember> dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
|
||||
SimulationMember dispatcher = null;
|
||||
for (SimulationMember member : dispatcherList) {
|
||||
if (member.isRobot()) {
|
||||
dispatcher = member;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(dispatcher)) {
|
||||
// 行调都被占用,添加新的行调
|
||||
dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
||||
}
|
||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId());
|
||||
break;
|
||||
}
|
||||
case DEPOT: {
|
||||
List<SimulationMember> depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER);
|
||||
SimulationMember depoter = null;
|
||||
for (SimulationMember member : depoterList) {
|
||||
if (member.isRobot()) {
|
||||
depoter = member;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(depoter)) {
|
||||
depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER);
|
||||
}
|
||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId());
|
||||
break;
|
||||
}
|
||||
case SCHEDULING: {
|
||||
|
||||
}
|
||||
}
|
||||
// switch (deviceVO.getType()) {
|
||||
// case LW: {
|
||||
// // 暂时默认先按配置的车站创建成员
|
||||
// LwConfigVO lwConfigVO = deviceVO.buildLwConfig();
|
||||
// Station station = simulation.getRepository().getByCode(lwConfigVO.getStationCode(), Station.class);
|
||||
// SimulationMember member = simulation.getSimulationMember(station, SimulationMember.Type.STATION_SUPERVISOR);
|
||||
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), member.getId());
|
||||
// // 现地工作站
|
||||
// break;
|
||||
// }
|
||||
// case CW: {
|
||||
// // 行调工作站
|
||||
// List<SimulationMember> dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
|
||||
// SimulationMember dispatcher = null;
|
||||
// for (SimulationMember member : dispatcherList) {
|
||||
// if (member.isRobot()) {
|
||||
// dispatcher = member;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (Objects.isNull(dispatcher)) {
|
||||
// // 行调都被占用,添加新的行调
|
||||
// dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
||||
// }
|
||||
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId());
|
||||
// break;
|
||||
// }
|
||||
// case DEPOT: {
|
||||
// List<SimulationMember> depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER);
|
||||
// SimulationMember depoter = null;
|
||||
// for (SimulationMember member : depoterList) {
|
||||
// if (member.isRobot()) {
|
||||
// depoter = member;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (Objects.isNull(depoter)) {
|
||||
// depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER);
|
||||
// }
|
||||
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId());
|
||||
// break;
|
||||
// }
|
||||
// case SCHEDULING: {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
loginUserInfo.setGroup(simulation.getId());
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,10 @@ public class MemberManager {
|
||||
List<Station> stationList = simulation.getRepository().getSortedStationList();
|
||||
for (Station station : stationList) {
|
||||
if (station.isNormal()) {
|
||||
this.addRole(simulation, SimulationMember.Type.STATION_SUPERVISOR, null, station);
|
||||
this.addRole(simulation, null, SimulationMember.Type.STATION_SUPERVISOR, null, station);
|
||||
} else if (station.isDepot()) {
|
||||
// 车辆段调度
|
||||
this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station);
|
||||
this.addRole(simulation, null, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station);
|
||||
}
|
||||
// 大铁CTC
|
||||
if (simulation.getRepository().getConfig().isRailway()) {
|
||||
@ -60,7 +60,7 @@ public class MemberManager {
|
||||
SimulationMember.Type.STATION_SIGNALER, SimulationMember.Type.STATION_PASSENGER,
|
||||
SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR,
|
||||
SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER
|
||||
).forEach(type -> this.addRole(simulation, type, null, station));
|
||||
).forEach(type -> this.addRole(simulation, null, type, null, station));
|
||||
}
|
||||
}
|
||||
//调度台
|
||||
@ -69,14 +69,14 @@ public class MemberManager {
|
||||
List<DisStation> disStationList = simulation.getRepository().getDisStationList();
|
||||
if (null != disStationList) {
|
||||
for (DisStation disStation : disStationList) {
|
||||
this.addRole(simulation, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation);
|
||||
this.addRole(simulation, null, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 司机
|
||||
List<VirtualRealityTrain> vrTrainList = simulation.getRepository().getAllVrTrain();
|
||||
for (VirtualRealityTrain vrTrain : vrTrainList) {
|
||||
this.addRole(simulation, SimulationMember.Type.DRIVER, null, vrTrain);
|
||||
this.addRole(simulation, null, SimulationMember.Type.DRIVER, null, vrTrain);
|
||||
}
|
||||
// 工电调度
|
||||
this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER);
|
||||
@ -130,18 +130,18 @@ public class MemberManager {
|
||||
}
|
||||
|
||||
public SimulationMember addRole(Simulation simulation, SimulationMember.Type type) {
|
||||
SimulationMember member = this.addRole(simulation, type, null, null);
|
||||
SimulationMember member = this.addRole(simulation, null, type, null, null);
|
||||
SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member);
|
||||
this.applicationContext.publishEvent(memberAddEvent);
|
||||
return member;
|
||||
}
|
||||
|
||||
public SimulationMember addRole(Simulation simulation, SimulationMember.Type type, String name) {
|
||||
return this.addRole(simulation, type, name, null);
|
||||
return this.addRole(simulation, null, type, name, null);
|
||||
}
|
||||
|
||||
public SimulationMember addRole(Simulation simulation,
|
||||
SimulationMember.Type type,
|
||||
String id, SimulationMember.Type type,
|
||||
String name, MapElement device) {
|
||||
switch (type) {
|
||||
case DISPATCHER:
|
||||
@ -174,7 +174,10 @@ public class MemberManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SimulationMember member = new SimulationMember(simulation.getIdGenerator().nextMemberId(), type, device);
|
||||
if (id == null) {
|
||||
id = simulation.getIdGenerator().nextMemberId();
|
||||
}
|
||||
SimulationMember member = new SimulationMember(id, type, device);
|
||||
member.setName(name);
|
||||
simulation.addSimulationMember(member);
|
||||
SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member);
|
||||
|
@ -73,7 +73,7 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
|
||||
mapElement = repository.getVRByCode(memberVO.getDeviceCode());
|
||||
}
|
||||
}
|
||||
memberManager.addRole(simulation, memberVO.getType(), memberVO.getName(), mapElement);
|
||||
memberManager.addRole(simulation, memberVO.getId(), memberVO.getType(), memberVO.getName(), mapElement);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,10 +91,7 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
|
||||
* 添加仿真用户
|
||||
*/
|
||||
public void addSimulationUser(Simulation simulation, SimulationUser simulationUser) {
|
||||
SimulationUser oldUser = simulation.addSimulationUser(simulationUser);
|
||||
if (oldUser != null) {
|
||||
log.warn("[{}]被[{}]替换", oldUser, simulationUser.toString());
|
||||
}
|
||||
simulation.addSimulationUser(simulationUser);
|
||||
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
||||
this.applicationContext.publishEvent(userEnterEvent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user