新版仿真构建成员时使用既定的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 {
|
// } else {
|
||||||
// user.setType(SimulationUser.Type.STUDENT);
|
// 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) {
|
public U removeSimulationUser(U user) {
|
||||||
|
@ -824,7 +824,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
MapElement mapElement = null;
|
MapElement mapElement = null;
|
||||||
if (StringUtils.hasText(param.getDeviceCode()))
|
if (StringUtils.hasText(param.getDeviceCode()))
|
||||||
mapElement = simulation.getRepository().getByCode(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);
|
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.ProjectDeviceLogoutEvent;
|
||||||
import club.joylink.rtss.services.auth.UserLogoutEvent;
|
import club.joylink.rtss.services.auth.UserLogoutEvent;
|
||||||
import club.joylink.rtss.services.project.DeviceService;
|
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.SimulationRealDeviceThread;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig;
|
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.device.real.udp.sr.config.SrTrainConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
|
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
|
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.simulation.cbtc.member.SimulationUser;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
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.client.project.ProjectDeviceVO;
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.map.MapVO;
|
||||||
import club.joylink.rtss.vo.project.ProjectVO;
|
import club.joylink.rtss.vo.project.ProjectVO;
|
||||||
@ -217,52 +214,52 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
|
|||||||
simulation.addSimulationUser(simulationUser);
|
simulation.addSimulationUser(simulationUser);
|
||||||
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
||||||
this.applicationContext.publishEvent(userEnterEvent);
|
this.applicationContext.publishEvent(userEnterEvent);
|
||||||
switch (deviceVO.getType()) {
|
// switch (deviceVO.getType()) {
|
||||||
case LW: {
|
// case LW: {
|
||||||
// 暂时默认先按配置的车站创建成员
|
// // 暂时默认先按配置的车站创建成员
|
||||||
LwConfigVO lwConfigVO = deviceVO.buildLwConfig();
|
// LwConfigVO lwConfigVO = deviceVO.buildLwConfig();
|
||||||
Station station = simulation.getRepository().getByCode(lwConfigVO.getStationCode(), Station.class);
|
// Station station = simulation.getRepository().getByCode(lwConfigVO.getStationCode(), Station.class);
|
||||||
SimulationMember member = simulation.getSimulationMember(station, SimulationMember.Type.STATION_SUPERVISOR);
|
// SimulationMember member = simulation.getSimulationMember(station, SimulationMember.Type.STATION_SUPERVISOR);
|
||||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), member.getId());
|
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), member.getId());
|
||||||
// 现地工作站
|
// // 现地工作站
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case CW: {
|
// case CW: {
|
||||||
// 行调工作站
|
// // 行调工作站
|
||||||
List<SimulationMember> dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
|
// List<SimulationMember> dispatcherList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DISPATCHER);
|
||||||
SimulationMember dispatcher = null;
|
// SimulationMember dispatcher = null;
|
||||||
for (SimulationMember member : dispatcherList) {
|
// for (SimulationMember member : dispatcherList) {
|
||||||
if (member.isRobot()) {
|
// if (member.isRobot()) {
|
||||||
dispatcher = member;
|
// dispatcher = member;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (Objects.isNull(dispatcher)) {
|
// if (Objects.isNull(dispatcher)) {
|
||||||
// 行调都被占用,添加新的行调
|
// // 行调都被占用,添加新的行调
|
||||||
dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
// dispatcher = this.memberManager.addRole(simulation, SimulationMember.Type.DISPATCHER);
|
||||||
}
|
// }
|
||||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId());
|
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), dispatcher.getId());
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case DEPOT: {
|
// case DEPOT: {
|
||||||
List<SimulationMember> depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER);
|
// List<SimulationMember> depoterList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER);
|
||||||
SimulationMember depoter = null;
|
// SimulationMember depoter = null;
|
||||||
for (SimulationMember member : depoterList) {
|
// for (SimulationMember member : depoterList) {
|
||||||
if (member.isRobot()) {
|
// if (member.isRobot()) {
|
||||||
depoter = member;
|
// depoter = member;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (Objects.isNull(depoter)) {
|
// if (Objects.isNull(depoter)) {
|
||||||
depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER);
|
// depoter = this.memberManager.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER);
|
||||||
}
|
// }
|
||||||
this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId());
|
// this.memberManager.playRole(simulation, loginUserInfo.getAccountVO().getId(), depoter.getId());
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case SCHEDULING: {
|
// case SCHEDULING: {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
loginUserInfo.setGroup(simulation.getId());
|
loginUserInfo.setGroup(simulation.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ public class MemberManager {
|
|||||||
List<Station> stationList = simulation.getRepository().getSortedStationList();
|
List<Station> stationList = simulation.getRepository().getSortedStationList();
|
||||||
for (Station station : stationList) {
|
for (Station station : stationList) {
|
||||||
if (station.isNormal()) {
|
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()) {
|
} 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
|
// 大铁CTC
|
||||||
if (simulation.getRepository().getConfig().isRailway()) {
|
if (simulation.getRepository().getConfig().isRailway()) {
|
||||||
@ -60,7 +60,7 @@ public class MemberManager {
|
|||||||
SimulationMember.Type.STATION_SIGNALER, SimulationMember.Type.STATION_PASSENGER,
|
SimulationMember.Type.STATION_SIGNALER, SimulationMember.Type.STATION_PASSENGER,
|
||||||
SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR,
|
SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR,
|
||||||
SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER
|
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();
|
List<DisStation> disStationList = simulation.getRepository().getDisStationList();
|
||||||
if (null != disStationList) {
|
if (null != disStationList) {
|
||||||
for (DisStation disStation : 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();
|
List<VirtualRealityTrain> vrTrainList = simulation.getRepository().getAllVrTrain();
|
||||||
for (VirtualRealityTrain vrTrain : vrTrainList) {
|
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);
|
this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER);
|
||||||
@ -130,18 +130,18 @@ public class MemberManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SimulationMember addRole(Simulation simulation, SimulationMember.Type type) {
|
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);
|
SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member);
|
||||||
this.applicationContext.publishEvent(memberAddEvent);
|
this.applicationContext.publishEvent(memberAddEvent);
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimulationMember addRole(Simulation simulation, SimulationMember.Type type, String name) {
|
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,
|
public SimulationMember addRole(Simulation simulation,
|
||||||
SimulationMember.Type type,
|
String id, SimulationMember.Type type,
|
||||||
String name, MapElement device) {
|
String name, MapElement device) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DISPATCHER:
|
case DISPATCHER:
|
||||||
@ -174,7 +174,10 @@ public class MemberManager {
|
|||||||
break;
|
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);
|
member.setName(name);
|
||||||
simulation.addSimulationMember(member);
|
simulation.addSimulationMember(member);
|
||||||
SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member);
|
SimulationMemberAddEvent memberAddEvent = new SimulationMemberAddEvent(this, simulation, member);
|
||||||
|
@ -73,7 +73,7 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
|
|||||||
mapElement = repository.getVRByCode(memberVO.getDeviceCode());
|
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) {
|
public void addSimulationUser(Simulation simulation, SimulationUser simulationUser) {
|
||||||
SimulationUser oldUser = simulation.addSimulationUser(simulationUser);
|
simulation.addSimulationUser(simulationUser);
|
||||||
if (oldUser != null) {
|
|
||||||
log.warn("[{}]被[{}]替换", oldUser, simulationUser.toString());
|
|
||||||
}
|
|
||||||
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
SimulationUserEnterEvent userEnterEvent = new SimulationUserEnterEvent(this, simulation, simulationUser);
|
||||||
this.applicationContext.publishEvent(userEnterEvent);
|
this.applicationContext.publishEvent(userEnterEvent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user