增加生成子系统的接口;增加仿真客户端类型;

This commit is contained in:
joylink_zhangsai 2022-10-18 14:19:40 +08:00
parent 761d7e353b
commit 3a5fbb16e9
20 changed files with 580 additions and 270 deletions

View File

@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* 草稿地图 调度台 接口 * 草稿地图 调度台 接口
* <p> * <p>
@ -49,6 +51,15 @@ public class DraftMapDisStationController {
public PageVO<MapDisStationNewVO> findByPage(@PathVariable("id") Long mapId, @RequestBody FindByPageReq req){ public PageVO<MapDisStationNewVO> findByPage(@PathVariable("id") Long mapId, @RequestBody FindByPageReq req){
return this.draftMapDisStationService.findByPage(mapId,req); return this.draftMapDisStationService.findByPage(mapId,req);
} }
/**
* 列表查询所有调度台
*/
@GetMapping("/list")
public List<MapDisStationNewVO> listQuery(@PathVariable long id) {
return draftMapDisStationService.listQuery(id);
}
@Data @Data
public static class FindByPageReq extends PageQueryVO{ public static class FindByPageReq extends PageQueryVO{
/** /**

View File

@ -9,10 +9,7 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.TreeNode; import club.joylink.rtss.vo.client.TreeNode;
import club.joylink.rtss.vo.client.mapSystem.MapSystemCreateVO; import club.joylink.rtss.vo.client.mapSystem.*;
import club.joylink.rtss.vo.client.mapSystem.MapSystemUpdateVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemQueryVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemVO;
import club.joylink.rtss.vo.client.sub.MapSystemDetailVO; import club.joylink.rtss.vo.client.sub.MapSystemDetailVO;
import club.joylink.rtss.vo.client.sub.MapSystemQueryVO; import club.joylink.rtss.vo.client.sub.MapSystemQueryVO;
import club.joylink.rtss.vo.client.sub.MapSystemVO; import club.joylink.rtss.vo.client.sub.MapSystemVO;
@ -122,6 +119,16 @@ public class MapSystemController {
rtsMapSystemService.create(createVO, loginInfo.getAccountVO().getId()); rtsMapSystemService.create(createVO, loginInfo.getAccountVO().getId());
} }
/**
* 生成地图子系统
*/
@Role(RoleEnum.Admin)
@PostMapping("/new/{mapId}/generate")
public List<String> generate(@PathVariable long mapId, @RequestBody @Validated MapSystemGenerateParamVO paramVO,
@RequestAttribute LoginUserInfoVO loginInfo) {
return rtsMapSystemService.generate(mapId, paramVO, loginInfo.getAccountVO().getId());
}
/** /**
* 列表查询地图系统 * 列表查询地图系统
*/ */

View File

@ -4,13 +4,10 @@ import club.joylink.rtss.controller.draft.DraftMapDisStationController;
import club.joylink.rtss.dao.DraftMapDisStationDAO; import club.joylink.rtss.dao.DraftMapDisStationDAO;
import club.joylink.rtss.entity.DraftMapDisStation; import club.joylink.rtss.entity.DraftMapDisStation;
import club.joylink.rtss.entity.DraftMapDisStationExample; import club.joylink.rtss.entity.DraftMapDisStationExample;
import club.joylink.rtss.entity.paper.PaperUser;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO; import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
import club.joylink.rtss.vo.paper.PaperUserInfoVo;
import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -18,6 +15,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class DraftMapDisStationService { public class DraftMapDisStationService {
@ -121,7 +119,7 @@ public class DraftMapDisStationService {
} }
return list; return list;
} }
@Transactional(readOnly = true)
private List<DraftMapDisStation> findByMapIdAndCode(Long mapId, String code){ private List<DraftMapDisStation> findByMapIdAndCode(Long mapId, String code){
DraftMapDisStationExample example = new DraftMapDisStationExample(); DraftMapDisStationExample example = new DraftMapDisStationExample();
example.createCriteria().andMapIdEqualTo(mapId).andCodeEqualTo(code); example.createCriteria().andMapIdEqualTo(mapId).andCodeEqualTo(code);
@ -149,4 +147,11 @@ public class DraftMapDisStationService {
entity.setStationList(JsonUtils.writeValueAsString(from.getStationList())); entity.setStationList(JsonUtils.writeValueAsString(from.getStationList()));
return entity; return entity;
} }
public List<MapDisStationNewVO> listQuery(long mapId) {
DraftMapDisStationExample example = new DraftMapDisStationExample();
example.createCriteria().andMapIdEqualTo(mapId);
List<DraftMapDisStation> list = draftMapDisStationDAO.selectByExample(example);
return list.stream().map(DraftMapDisStationService::convert).collect(Collectors.toList());
}
} }

View File

@ -1,10 +1,7 @@
package club.joylink.rtss.services.mapSystem; package club.joylink.rtss.services.mapSystem;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.mapSystem.MapSystemCreateVO; import club.joylink.rtss.vo.client.mapSystem.*;
import club.joylink.rtss.vo.client.mapSystem.MapSystemUpdateVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemQueryVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemVO;
import java.util.List; import java.util.List;
@ -15,7 +12,23 @@ public interface RtsMapSystemService {
void update(long id, MapSystemUpdateVO updateVO, long updaterId); void update(long id, MapSystemUpdateVO updateVO, long updaterId);
/**
* 列表查询地图子系统
*/
List<RtsMapSystemVO> listQuery(RtsMapSystemQueryVO queryVO); List<RtsMapSystemVO> listQuery(RtsMapSystemQueryVO queryVO);
/**
* 分页查询地图子系统
*/
PageVO<RtsMapSystemVO> pagedQuery(RtsMapSystemQueryVO queryVO); PageVO<RtsMapSystemVO> pagedQuery(RtsMapSystemQueryVO queryVO);
/**
* 生成地图子系统
*
* @param mapId 要生成子系统的地图id
* @param paramVO 指示生成内容的参数
* @param creatorId
* @return 一些特殊的但是算不上异常的信息
*/
List<String> generate(long mapId, MapSystemGenerateParamVO paramVO, long creatorId);
} }

View File

@ -4,19 +4,25 @@ import club.joylink.rtss.dao.RtsMapSystemDAO;
import club.joylink.rtss.entity.RtsMapSystem; import club.joylink.rtss.entity.RtsMapSystem;
import club.joylink.rtss.entity.RtsMapSystemExample; import club.joylink.rtss.entity.RtsMapSystemExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.mapSystem.MapSystemCreateVO; import club.joylink.rtss.vo.client.mapSystem.*;
import club.joylink.rtss.vo.client.mapSystem.MapSystemUpdateVO; import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemQueryVO; import club.joylink.rtss.vo.map.graph.MapMemberVO;
import club.joylink.rtss.vo.client.mapSystem.RtsMapSystemVO;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -24,6 +30,8 @@ import java.util.stream.Collectors;
public class RtsMapSystemServiceImpl implements RtsMapSystemService { public class RtsMapSystemServiceImpl implements RtsMapSystemService {
@Autowired @Autowired
private RtsMapSystemDAO rtsMapSystemDAO; private RtsMapSystemDAO rtsMapSystemDAO;
@Autowired
private IMapService iMapService;
@Override @Override
public void create(MapSystemCreateVO createVO, long creatorId) { public void create(MapSystemCreateVO createVO, long creatorId) {
@ -71,6 +79,258 @@ public class RtsMapSystemServiceImpl implements RtsMapSystemService {
return PageVO.convert(page, list); return PageVO.convert(page, list);
} }
@Transactional
@Override
public List<String> generate(long mapId, MapSystemGenerateParamVO paramVO, long creatorId) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(paramVO.getSimTypes(),
"要生成子系统的仿真系统类型不能为空");
//删除所有旧数据
RtsMapSystemExample example = new RtsMapSystemExample();
example.createCriteria().andMapIdEqualTo(mapId);
rtsMapSystemDAO.deleteByExample(example);
List<String> msgList = new ArrayList<>();
MapVO mapData = iMapService.getMapDetail(mapId);
for (Simulation.Type simType : paramVO.getSimTypes()) {
switch (simType) {
case METRO:
generateMetroSystem(mapId, mapData, creatorId, msgList);
break;
case RAILWAY:
generateRailwaySystem(mapId, mapData, creatorId, msgList);
break;
case EMERGENCY:
break;
default:
throw new IllegalStateException("Unexpected value: " + simType);
}
}
return null;
}
private void generateRailwaySystem(long mapId, MapVO mapData, long creatorId, List<String> msgList) {
String msgPrefix = "大铁CTC系统";
Simulation.Type simType = Simulation.Type.RAILWAY;
List<MapMemberVO> mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(simType);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(mapMemberVOS,
String.format("%s成员列表为空不能生成子系统", msgPrefix));
MapSystemCreateVO createVO;
SimulationWorkParamVO workParamVO;
SimulationWorkParamVO.InitParamVO initParamVO;
SimulationWorkParamVO.DomConfigVO domConfigVO;
//调度台终端
Optional<MapMemberVO> dispatcherOptional = mapMemberVOS.stream()
.filter(vo -> Objects.equals(vo.getType(), SimulationMember.Type.DISPATCHER))
.findFirst();
if (dispatcherOptional.isEmpty()) {
msgList.add(String.format("%s无行调角色未生成调度台", msgPrefix));
} else {
MapMemberVO mapMemberVO = dispatcherOptional.get();
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc("调度台");
createVO.setName("调度台");
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(mapMemberVO.getId(), null);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
//车站
Optional<MapMemberVO> stationSupervisorOptional = mapMemberVOS.stream()
.filter(vo -> Objects.equals(vo.getType(), SimulationMember.Type.STATION_SUPERVISOR))
.findFirst();
if (stationSupervisorOptional.isEmpty()) {
msgList.add(String.format("%s无行值角色未生成调度台", msgPrefix));
} else {
MapMemberVO mapMemberVO = stationSupervisorOptional.get();
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc("车站");
createVO.setName("车站");
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(mapMemberVO.getId(), null);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
}
private void generateMetroSystem(long mapId, MapVO mapData, long creatorId, List<String> msgList) {
String msgPrefix = "地铁CBTC系统";
Simulation.Type simType = Simulation.Type.METRO;
List<MapMemberVO> mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(simType);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(mapMemberVOS,
String.format("%s成员列表为空不能生成子系统", msgPrefix));
MapSystemCreateVO createVO;
SimulationWorkParamVO workParamVO;
SimulationWorkParamVO.InitParamVO initParamVO;
SimulationWorkParamVO.DomConfigVO domConfigVO;
String name;
//行调工作站
name = "行调工作站";
Optional<MapMemberVO> dispatcherOptional = mapMemberVOS.stream()
.filter(vo -> Objects.equals(vo.getType(), SimulationMember.Type.DISPATCHER))
.findFirst();
if (dispatcherOptional.isEmpty()) {
msgList.add(String.format("%s无行调角色未生成%s", msgPrefix, name));
} else {
MapMemberVO mapMemberVO = dispatcherOptional.get();
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(mapMemberVO.getId(), null);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
//行值工作站
name = "现地工作站";
Optional<MapMemberVO> stationSupervisorOptional = mapMemberVOS.stream()
.filter(vo -> Objects.equals(vo.getType(), SimulationMember.Type.STATION_SUPERVISOR))
.findFirst();
if (dispatcherOptional.isEmpty()) {
msgList.add(String.format("%s无行值角色未生成%s", name));
} else {
MapMemberVO mapMemberVO = stationSupervisorOptional.get();
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(mapMemberVO.getId(), null);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
//司机模拟驾驶系统
name = "司机模拟驾驶系统";
Optional<MapMemberVO> driverOptional = mapMemberVOS.stream()
.filter(vo -> Objects.equals(vo.getType(), SimulationMember.Type.DRIVER))
.findFirst();
if (driverOptional.isEmpty()) {
msgList.add(String.format("%s无司机角色未生成%s", msgPrefix, name));
} else {
MapMemberVO mapMemberVO = driverOptional.get();
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(mapMemberVO.getId(), Simulation.Client.DRIVE);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(false, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
//大屏工作站
name = "大屏工作站";
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(null, Simulation.Client.C_ATS_BS);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, true, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
//ISCS工作站
name = "ISCS工作站";
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(null, Simulation.Client.ISCS);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(true, true, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
//运行图编制工作站
name = "运行图编制工作站";
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(null, Simulation.Client.RUN_PLAN_DESIGN);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(false, true, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
//综合演练
name = "综合演练";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream().findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无成员未生成%s", msgPrefix, name));
} else {
createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
createVO.setDesc(name);
createVO.setName(name);
workParamVO = new SimulationWorkParamVO();
createVO.setParamVO(workParamVO);
workParamVO.setType(simType);
initParamVO = new SimulationWorkParamVO.InitParamVO(memberOptional.get().getId(), null);
workParamVO.setInitParam(initParamVO);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(false, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
}
private Optional<RtsMapSystem> findEntityOptional(long id) { private Optional<RtsMapSystem> findEntityOptional(long id) {
RtsMapSystem entity = rtsMapSystemDAO.selectByPrimaryKey(id); RtsMapSystem entity = rtsMapSystemDAO.selectByPrimaryKey(id);
return Optional.ofNullable(entity); return Optional.ofNullable(entity);

View File

@ -1,8 +1,6 @@
package club.joylink.rtss.services.student; package club.joylink.rtss.services.student;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.student.ExportStudentInfo; import club.joylink.rtss.vo.client.student.ExportStudentInfo;
import club.joylink.rtss.vo.client.student.ImportStudentInfo;
import club.joylink.rtss.vo.client.student.StudentInfoExportParam; import club.joylink.rtss.vo.client.student.StudentInfoExportParam;
import java.util.List; import java.util.List;

View File

@ -759,15 +759,21 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
public enum Function { public enum Function {
/** 大客流Large passenger flow */ /** 大客流Large passenger flow */
LPF, LPF("LPF"),
/** 实训室 */ /** 实训室 */
TRAINING_ROOM, TRAINING_ROOM("TRAINING_ROOM"),
/** 实训设计 */ /** 实训设计 */
TRAINING_DESIGN, TRAINING_DESIGN("TRAINING_DESIGN"),
/** 实训 */ /** 实训 */
TRAINING, TRAINING("TRAINING"),
/** 考试 */ /** 考试 */
EXAM, EXAM("EXAM"),
;
public final String name;
Function(String name) {
this.name = name;
}
} }
/** /**
@ -782,6 +788,8 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
C_PA, C_PA,
/** 中心视频监控系统 */ /** 中心视频监控系统 */
C_CCTV, C_CCTV,
/** 综合监控 */
ISCS,
/** 现地ATS工作站 */ /** 现地ATS工作站 */
L_ATS, L_ATS,
@ -791,6 +799,12 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
L_PA, L_PA,
/** 现地视频监控系统 */ /** 现地视频监控系统 */
L_CCTV, L_CCTV,
IBP,
PSL,
/** 列车驾驶 */
DRIVE,
/** 运行图编制/设计 */
RUN_PLAN_DESIGN,
/** 调度台终端(含 WintgTerm、LayoutTerm、DcmdTerm、TSRTerm、C3Term、ShuntTerm来源文档 */ /** 调度台终端(含 WintgTerm、LayoutTerm、DcmdTerm、TSRTerm、C3Term、ShuntTerm来源文档 */

View File

@ -18,6 +18,7 @@ import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Service @Service
public class SimulationServiceImpl implements SimulationService { public class SimulationServiceImpl implements SimulationService {
@ -37,6 +38,13 @@ public class SimulationServiceImpl implements SimulationService {
SimulationWorkService initService = simulationWorkServiceManager.getInitService(workParamVO.getType()); SimulationWorkService initService = simulationWorkServiceManager.getInitService(workParamVO.getType());
Simulation simulation = initService.create(loginUserInfoVO, workParamVO); Simulation simulation = initService.create(loginUserInfoVO, workParamVO);
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
if (Objects.nonNull(loginUserInfo)) {
simulation.setCreatorId(loginUserInfo.getAccountVO().getIdStr());
simulation.setProject(loginUserInfo.getProject());
simulation.setProjectVO(loginUserInfo.getProjectInfo());
}
// 删除旧仿真保存新仿真 // 删除旧仿真保存新仿真
club.joylink.rtss.simulation.Simulation oldSimulation = simulationManager.queryByCreatorId(simulation.getCreatorId()); club.joylink.rtss.simulation.Simulation oldSimulation = simulationManager.queryByCreatorId(simulation.getCreatorId());
if (oldSimulation != null) { if (oldSimulation != null) {

View File

@ -1,57 +1,73 @@
package club.joylink.rtss.simulation.cbtc.bo; package club.joylink.rtss.simulation.cbtc.bo;
import club.joylink.rtss.simulation.cbtc.vo.TrainingParamVO; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
@Getter
public class SimulationWorkParam { public class SimulationWorkParam {
private Simulation.Type type;
public static void main(String[] args) { private SimulationWorkParamVO.InitParamVO initParam;
FunctionInfo functionInfo = new TrainingFunctionInfo(Function.TRAINING, new TrainingParamVO());
functionInfo.getParam();
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "function") /**
* 仿真所使用的功能
*/
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Map<Simulation.Function, FunctionParam> functionMap;
/**
* 前端控制元素显隐的配置
*/
private SimulationWorkParamVO.DomConfigVO domConfig;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
@JsonSubTypes({
@JsonSubTypes.Type(value = TrainingFunctionParam.class, name = "TRAINING"),
@JsonSubTypes.Type(value = LPFFunctionParam.class, name = "LPF")
})
@Getter @Getter
public static abstract class FunctionInfo { @ToString
Function function; public static abstract class FunctionParam {
public Object param;
public FunctionInfo(Function function, Object param) {
this.function = function;
this.param = param;
}
} }
@Getter @Getter
@JsonTypeName("TRAINING") @Setter
public static class TrainingFunctionInfo extends FunctionInfo{ @NoArgsConstructor
TrainingParamVO param; public static class TrainingFunctionParam extends FunctionParam {
private Long trainingId;
public TrainingFunctionInfo(Function function, TrainingParamVO param) {
super(function, param);
}
} }
@Getter
public enum Function { @Setter
/** 大客流Large passenger flow */ @NoArgsConstructor
LPF(Object.class), public static class LPFFunctionParam extends FunctionParam {
/** 实训室 */ private Long dataId;
TRAINING_ROOM(Object.class),
/** 实训设计 */
TRAINING_DESIGN(Object.class),
/** 实训 */
TRAINING(TrainingParamVO.class),
/** 考试 */
EXAM(Object.class),
;
private Class<?> paramCls;
Function(Class<?> paramCls) {
this.paramCls = paramCls;
} }
public SimulationWorkParam(SimulationWorkParamVO vo) {
this.type = vo.getType();
this.initParam = vo.getInitParam();
Map<Simulation.Function, Map<String, Object>> voFunctionMap = vo.getFunctionMap();
if (!CollectionUtils.isEmpty(voFunctionMap)) {
this.functionMap = new HashMap<>();
for (Map.Entry<Simulation.Function, Map<String, Object>> entry : voFunctionMap.entrySet()) {
String json = JsonUtils.writeValueAsString(entry);
FunctionParam param = JsonUtils.read(json, FunctionParam.class);
this.functionMap.put(entry.getKey(), param);
}
}
this.domConfig = vo.getDomConfig();
} }
} }

View File

@ -31,8 +31,7 @@ public class InterlockBuilder2 {
static void checkAndBuildMapCILogicData(MapVO map, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) { static void checkAndBuildMapCILogicData(MapVO map, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) {
MapLogicDataNewVO logicData = map.getLogicDataNew(); MapLogicDataNewVO logicData = map.getLogicDataNew();
MapGraphDataNewVO graphData = map.getGraphDataNew(); MapGraphDataNewVO graphData = map.getGraphDataNew();
boolean railway = map.getConfigVO().isRailway();
MapCiGenerateConfig generateConfig = graphData.getGenerateConfig();
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap(); Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
List<String> errMsgList = mapDataBuildResult.getErrMsgList(); List<String> errMsgList = mapDataBuildResult.getErrMsgList();
@ -50,7 +49,7 @@ public class InterlockBuilder2 {
// 接近区段 // 接近区段
InterlockBuilder2.buildApproachSections(logicData, elementMap, errMsgList); InterlockBuilder2.buildApproachSections(logicData, elementMap, errMsgList);
// ------------进路start------------- // ------------进路start-------------
if (generateConfig != null && generateConfig.isRailway()) { if (railway) {
InterlockBuilder2.buildRailRoute(graphData, logicData, elementMap, errMsgList, flsMap); InterlockBuilder2.buildRailRoute(graphData, logicData, elementMap, errMsgList, flsMap);
} else { } else {
InterlockBuilder2.buildRoute(logicData, elementMap, errMsgList, flsMap); InterlockBuilder2.buildRoute(logicData, elementMap, errMsgList, flsMap);
@ -90,14 +89,14 @@ public class InterlockBuilder2 {
// if (!errMsgList.isEmpty()) { // if (!errMsgList.isEmpty()) {
// return; // return;
// } // }
InterlockBuilder2.buildRoutePathFromStationRunLevel(generateConfig, stationRunLevelList, mapDataBuildResult, errMsgList); InterlockBuilder2.buildRoutePathFromStationRunLevel(stationRunLevelList, mapDataBuildResult, errMsgList);
// buildParkTimes(logicData, elementMap, mapDataBuildResult.getParkTimeMap(), errMsgList); // buildParkTimes(logicData, elementMap, mapDataBuildResult.getParkTimeMap(), errMsgList);
} }
/** /**
* 构建自动折返 * 构建自动折返
*/ */
private static void buildAutoReentry(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) { public static void buildAutoReentry(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) {
List<MapAutoReentryVO> autoReentryList = logicData.getAutoReentryList(); List<MapAutoReentryVO> autoReentryList = logicData.getAutoReentryList();
for (MapAutoReentryVO mapAutoReentryVO : autoReentryList) { for (MapAutoReentryVO mapAutoReentryVO : autoReentryList) {
Cycle cycle = new Cycle(mapAutoReentryVO.getCode(), mapAutoReentryVO.getName()); Cycle cycle = new Cycle(mapAutoReentryVO.getCode(), mapAutoReentryVO.getName());
@ -185,7 +184,7 @@ public class InterlockBuilder2 {
/** /**
* 构建自动信号 * 构建自动信号
*/ */
private static void buildAutoSignal(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) { public static void buildAutoSignal(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) {
List<MapAutoSignalNewVO> autoSignalList = logicData.getAutoSignalList(); List<MapAutoSignalNewVO> autoSignalList = logicData.getAutoSignalList();
for (MapAutoSignalNewVO autoSignalNewVO : autoSignalList) { for (MapAutoSignalNewVO autoSignalNewVO : autoSignalList) {
AutoSignal autoSignal = new AutoSignal(autoSignalNewVO.getCode()); AutoSignal autoSignal = new AutoSignal(autoSignalNewVO.getCode());
@ -272,7 +271,7 @@ public class InterlockBuilder2 {
/** /**
* 从大铁数据构建 * 从大铁数据构建
*/ */
private static void buildRailRoute(MapGraphDataNewVO graphData, MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) { public static void buildRailRoute(MapGraphDataNewVO graphData, MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) {
Map<String, MapSignalButtonVO> signalButtonMap = graphData.getSignalButtonList().stream() Map<String, MapSignalButtonVO> signalButtonMap = graphData.getSignalButtonList().stream()
.collect(Collectors.toMap(MapSignalButtonVO::getCode, Function.identity())); .collect(Collectors.toMap(MapSignalButtonVO::getCode, Function.identity()));
List<MapRouteNewVO> routeList = logicData.getRouteList(); List<MapRouteNewVO> routeList = logicData.getRouteList();
@ -460,7 +459,7 @@ public class InterlockBuilder2 {
} }
} }
private static void buildRoute(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) { public static void buildRoute(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) {
List<MapRouteNewVO> routeList = logicData.getRouteList(); List<MapRouteNewVO> routeList = logicData.getRouteList();
for (MapRouteNewVO mapRouteVO : routeList) { for (MapRouteNewVO mapRouteVO : routeList) {
Route route = new Route(mapRouteVO.getCode(), mapRouteVO.getName()); Route route = new Route(mapRouteVO.getCode(), mapRouteVO.getName());
@ -618,7 +617,7 @@ public class InterlockBuilder2 {
} }
} }
private static void buildApproachSections(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) { public static void buildApproachSections(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList) {
List<MapSignalApproachSectionVO> signalApproachSectionList = logicData.getSignalApproachSectionList(); List<MapSignalApproachSectionVO> signalApproachSectionList = logicData.getSignalApproachSectionList();
for (MapSignalApproachSectionVO approachSectionVO : signalApproachSectionList) { for (MapSignalApproachSectionVO approachSectionVO : signalApproachSectionList) {
Signal signal = (Signal) elementMap.get(approachSectionVO.getSignalCode()); Signal signal = (Signal) elementMap.get(approachSectionVO.getSignalCode());
@ -650,7 +649,7 @@ public class InterlockBuilder2 {
/** /**
* 构建延续保护 * 构建延续保护
*/ */
private static void buildOverlap(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) { public static void buildOverlap(MapLogicDataNewVO logicData, Map<String, MapElement> elementMap, List<String> errMsgList, Map<String, RouteFls> flsMap) {
List<MapOverlapVO> overlapList = logicData.getOverlapList(); List<MapOverlapVO> overlapList = logicData.getOverlapList();
for (MapOverlapVO mapOverlapVO : overlapList) { for (MapOverlapVO mapOverlapVO : overlapList) {
RouteOverlap routeOverlap = new RouteOverlap(mapOverlapVO.getCode(), mapOverlapVO.getName()); RouteOverlap routeOverlap = new RouteOverlap(mapOverlapVO.getCode(), mapOverlapVO.getName());
@ -720,7 +719,7 @@ public class InterlockBuilder2 {
} }
} }
private static void buildOverrun(List<MapRouteOverrunVO> overrunList, Map<String, MapElement> elementMap, List<String> errMsgList) { public static void buildOverrun(List<MapRouteOverrunVO> overrunList, Map<String, MapElement> elementMap, List<String> errMsgList) {
if (CollectionUtils.isEmpty(overrunList)) if (CollectionUtils.isEmpty(overrunList))
return; return;
for (MapRouteOverrunVO vo : overrunList) { for (MapRouteOverrunVO vo : overrunList) {
@ -756,7 +755,7 @@ public class InterlockBuilder2 {
} }
} }
private static Map<String, RouteFls> checkAndBuildRouteFls(List<MapRouteFlankProtectionNewVO> flankProtectionList, Map<String, MapElement> elementMap) { public static Map<String, RouteFls> checkAndBuildRouteFls(List<MapRouteFlankProtectionNewVO> flankProtectionList, Map<String, MapElement> elementMap) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Map<String, RouteFls> map = new HashMap<>(); Map<String, RouteFls> map = new HashMap<>();
for (MapRouteFlankProtectionNewVO fpVO : flankProtectionList) { for (MapRouteFlankProtectionNewVO fpVO : flankProtectionList) {
@ -1128,7 +1127,7 @@ public class InterlockBuilder2 {
return stationRunLevelList; return stationRunLevelList;
} }
private static void buildRoutePathFromStationRunLevel(MapCiGenerateConfig generateConfig, List<StationRunLevel> stationRunLevelList, private static void buildRoutePathFromStationRunLevel(List<StationRunLevel> stationRunLevelList,
SimulationBuilder.SimulationDeviceBuildResult buildResult, SimulationBuilder.SimulationDeviceBuildResult buildResult,
List<String> errMsgList) { List<String> errMsgList) {
// long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
@ -1599,7 +1598,7 @@ public class InterlockBuilder2 {
return new SectionPath(sectionPathVO.isRight(), switchElementList, sectionList, logicList); return new SectionPath(sectionPathVO.isRight(), switchElementList, sectionList, logicList);
} }
private static void checkBetweenRouteSameDirectionSignal(Map<String, MapElement> elementMap, List<String> errMsgList) { public static void checkBetweenRouteSameDirectionSignal(Map<String, MapElement> elementMap, List<String> errMsgList) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
InterlockBuilder2.log.debug("构建自动折返进路开始"); InterlockBuilder2.log.debug("构建自动折返进路开始");
if (!CollectionUtils.isEmpty(errMsgList)) { // 数据中本身存在错误不检查 if (!CollectionUtils.isEmpty(errMsgList)) { // 数据中本身存在错误不检查
@ -1646,7 +1645,7 @@ public class InterlockBuilder2 {
* @param stationDirectionList 逻辑关联关系 * @param stationDirectionList 逻辑关联关系
* @param elementMap 设备信息 * @param elementMap 设备信息
*/ */
private static void buildStationDirectionLabelLogic(Map<String, MapElement> elementMap, List<String> errMsgList, List<DraftMapStationDirection> stationDirectionList) { public static void buildStationDirectionLabelLogic(Map<String, MapElement> elementMap, List<String> errMsgList, List<DraftMapStationDirection> stationDirectionList) {
if (!CollectionUtils.isEmpty(stationDirectionList)) { if (!CollectionUtils.isEmpty(stationDirectionList)) {
// 过滤掉调车进路调车进路不影响运行方向开关 // 过滤掉调车进路调车进路不影响运行方向开关
List<Route> routeList = elementMap.values().stream() List<Route> routeList = elementMap.values().stream()

View File

@ -32,44 +32,6 @@ public class MemberManager {
@Autowired @Autowired
private SimulationManager simulationManager; private SimulationManager simulationManager;
/**
* 初始化地铁成员
*/
public void addMetroMembers(Simulation simulation) {
/* -----------默认创建一个行调,一个通号;车站和司机按设备创建----------- */
// 调度
this.addRole(simulation, SimulationMember.Type.DISPATCHER);
// 通号
this.addRole(simulation, SimulationMember.Type.MAINTAINER);
// 行值
List<Station> stationList = simulation.getRepository().getSortedStationList();
for (Station station : stationList) {
if (station.isNormal()) {
this.addRole(simulation, SimulationMember.Type.STATION_SUPERVISOR, null, station);
} else if (station.isDepot()) {
// 车辆段调度
this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station);
}
}
// 司机
List<VirtualRealityTrain> vrTrainList = simulation.getRepository().getAllVrTrain();
for (VirtualRealityTrain vrTrain : vrTrainList) {
this.addRole(simulation, SimulationMember.Type.DRIVER, null, vrTrain);
}
// 工电调度
this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER);
// // 车辆段信号楼
// this.addRole(simulation, SimulationMember.Type.DEPOT_SIGNAL_BUILDING);
// // 停车场信号楼
// this.addRole(simulation, SimulationMember.Type.PARKING_LOT_SIGNAL_BUILDING);
// 上级部门
this.addRole(simulation, SimulationMember.Type.PARENT_DEPARTMENT);
// 派班员
this.addRole(simulation, SimulationMember.Type.SCHEDULING);
// 车务段段长
this.addRole(simulation, SimulationMember.Type.TRAIN_MASTER);
}
/** /**
* 初始化仿真成员 * 初始化仿真成员
*/ */
@ -124,10 +86,10 @@ public class MemberManager {
// this.addRole(simulation, SimulationMember.Type.DEPOT_SIGNAL_BUILDING); // this.addRole(simulation, SimulationMember.Type.DEPOT_SIGNAL_BUILDING);
// // 停车场信号楼 // // 停车场信号楼
// this.addRole(simulation, SimulationMember.Type.PARKING_LOT_SIGNAL_BUILDING); // this.addRole(simulation, SimulationMember.Type.PARKING_LOT_SIGNAL_BUILDING);
// 上级部门 // // 上级部门
this.addRole(simulation, SimulationMember.Type.PARENT_DEPARTMENT); // this.addRole(simulation, SimulationMember.Type.PARENT_DEPARTMENT);
// 派班员 // // 派班员
this.addRole(simulation, SimulationMember.Type.SCHEDULING); // this.addRole(simulation, SimulationMember.Type.SCHEDULING);
// 车务段段长 // 车务段段长
this.addRole(simulation, SimulationMember.Type.TRAIN_MASTER); this.addRole(simulation, SimulationMember.Type.TRAIN_MASTER);
} }
@ -182,9 +144,9 @@ public class MemberManager {
String name, MapElement device) { String name, MapElement device) {
switch (type) { switch (type) {
case DISPATCHER: case DISPATCHER:
case SCHEDULING: { // case SCHEDULING: {
break; // break;
} // }
case DEPOT_DISPATCHER: { case DEPOT_DISPATCHER: {
if (Objects.isNull(device) || if (Objects.isNull(device) ||
!Objects.equals(device.getDeviceType(), MapElement.DeviceType.STATION) || !Objects.equals(device.getDeviceType(), MapElement.DeviceType.STATION) ||
@ -305,38 +267,4 @@ public class MemberManager {
this.cancelPlay(simulation, userId); this.cancelPlay(simulation, userId);
} }
} }
public void addRailMembers(Simulation simulation) {
// 通号
this.addRole(simulation, SimulationMember.Type.MAINTAINER);
// 行值
List<Station> stationList = simulation.getRepository().getSortedStationList();
for (Station station : stationList) {
Arrays.asList(
SimulationMember.Type.STATION_SUPERVISOR,
SimulationMember.Type.STATION_ASSISTANT,
SimulationMember.Type.STATION_MASTER,
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));
}
// 调度台--调度关联
List<DisStation> disStationList = simulation.getRepository().getDisStationList();
if (null != disStationList) {
for (DisStation disStation : disStationList) {
this.addRole(simulation, 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, SimulationMember.Type.PARENT_DEPARTMENT);
}
} }

View File

@ -141,88 +141,107 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem
return null; return null;
} }
/**
* 区域
*/
public interface Area {
/** OCC控制中心 */
int OCC = 0;
/** 车站 */
int STATION = 1;
/** 地铁车辆段/停车场 */
int VEHICLE_DEPOT = 2;
/** 列车上 */
int TRAIN = 3;
/** 大铁车务段 */
int TRAIN_DEPOT = 4;
}
/** /**
* 仿真成员岗位 * 仿真成员岗位
*/ */
public enum Type { public enum Type {
/** /**
* 车务段段长 * 值班主任
*/ */
TRAIN_MASTER, SHIFT_MANAGER(Area.OCC),
/** /**
* 中心调度员 * 中心调度员
*/ */
DISPATCHER, DISPATCHER(Area.OCC),
/** /**
* 工电调度 * 调度
*/ */
ELECTRIC_DISPATCHER, ELECTRIC_DISPATCHER(Area.OCC),
/**
* 环控调度
*/
ENVIRONMENT_DISPATCHER(Area.OCC),
/** /**
* 车辆段调度 * 车辆段调度
*/ */
DEPOT_DISPATCHER, DEPOT_DISPATCHER(Area.VEHICLE_DEPOT),
/** /**
* 车站值班员 * 车站值班员
*/ */
STATION_SUPERVISOR, STATION_SUPERVISOR(Area.STATION),
/** /**
* 司机 * 司机
*/ */
DRIVER, DRIVER(Area.TRAIN),
/** /**
* 通号 * 通号
*/ */
MAINTAINER, MAINTAINER(Area.STATION),
/**
* 车辆段信号楼
* 车辆段和停车场信号楼合并防止以前的剧本反序列化出问题所以暂不删除
*
* @see #SIGNAL_BUILDING
*/
@Deprecated(since = "2022.10.13", forRemoval = true)
DEPOT_SIGNAL_BUILDING,
/**
* 停车场信号楼
* 车辆段和停车场信号楼合并防止以前的剧本反序列化出问题所以暂不删除
*
* @see #SIGNAL_BUILDING
*/
@Deprecated(since = "2022.10.13", forRemoval = true)
PARKING_LOT_SIGNAL_BUILDING,
/** /**
* 车辆段/停车场信号楼 * 车辆段/停车场信号楼
*/ */
SIGNAL_BUILDING, SIGNAL_BUILDING(Area.VEHICLE_DEPOT),
/** /**
* 上级部门 * 上级部门
*/ */
PARENT_DEPARTMENT, @Deprecated(since = "2022-10-17", forRemoval = true)
PARENT_DEPARTMENT(Area.OCC),
/** /**
* 派班员 * 派班员
*/ */
SCHEDULING, @Deprecated(since = "2022-10-17", forRemoval = true)
SCHEDULING(Area.OCC),
/**
* 车务段段长
*/
TRAIN_MASTER(Area.TRAIN_DEPOT),
/** /**
* 车站助理 * 车站助理
*/ */
STATION_ASSISTANT, STATION_ASSISTANT(Area.STATION),
/*** 车站站长 */ /*** 车站站长 */
STATION_MASTER, STATION_MASTER(Area.STATION),
/** /**
* 车站信号员 * 车站信号员
*/ */
STATION_SIGNALER, STATION_SIGNALER(Area.STATION),
/** /**
* 车站客运员 * 车站客运员
*/ */
STATION_PASSENGER, STATION_PASSENGER(Area.STATION),
/*** 车站扳道员 */ /** 车站扳道员 */
STATION_SWITCH_MAN, STATION_SWITCH_MAN(Area.STATION),
/*** 车站引导员 */ /** 车站引导员 */
STATION_FACILITATOR, STATION_FACILITATOR(Area.STATION),
/*** 车站工务工*/ /** 车站工务工*/
STATION_WORKER, STATION_WORKER(Area.STATION),
/*** 设备管理员 **/ /** 设备管理员 */
DEVICE_MANAGER, DEVICE_MANAGER(Area.STATION),
;
private final int area;
Type(int area) {
this.area = area;
}
} }
public enum Gender { public enum Gender {

View File

@ -1,12 +1,8 @@
package club.joylink.rtss.simulation.cbtc.vo; package club.joylink.rtss.simulation.cbtc.vo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter; import lombok.*;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -21,13 +17,12 @@ import java.util.Map;
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
public class SimulationWorkParamVO { public class SimulationWorkParamVO {
@NotNull(message = "线路id不能为空")
private Long mapId; private Long mapId;
@NotNull(message = "仿真类型不能为空") @NotNull(message = "仿真类型不能为空")
private Simulation.Type type; private Simulation.Type type;
private UsageInfoVO usageInfo; private InitParamVO initParam;
/** /**
* 仿真所使用的功能 * 仿真所使用的功能
@ -35,34 +30,22 @@ public class SimulationWorkParamVO {
@JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonInclude(value = JsonInclude.Include.NON_NULL)
private Map<Simulation.Function, Map<String, Object>> functionMap; private Map<Simulation.Function, Map<String, Object>> functionMap;
public Simulation.Usage findUsage() { /**
return usageInfo == null ? null : usageInfo.getUsage(); * 前端控制元素显隐的配置后端暂时用不到所以先用Map接收
} */
private DomConfigVO domConfig;
public Simulation.Usage getUsage() {
Simulation.Usage usage = findUsage();
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(usage, "仿真创建参数的使用方式不能为空");
return usage;
}
public void addFunctionInfos(@NonNull Map<Simulation.Function, Map<String, Object>> functionMap) { public void addFunctionInfos(@NonNull Map<Simulation.Function, Map<String, Object>> functionMap) {
if (CollectionUtils.isEmpty(this.functionMap)) if (CollectionUtils.isEmpty(this.functionMap)) {
this.functionMap = new LinkedHashMap<>(); this.functionMap = new LinkedHashMap<>();
}
this.functionMap.putAll(functionMap); this.functionMap.putAll(functionMap);
} }
public void removeFunctions(Collection<Simulation.Function> functions) { public void removeFunctions(Collection<Simulation.Function> functions) {
if (!CollectionUtils.isEmpty(functionMap)) if (!CollectionUtils.isEmpty(functionMap)) {
functions.forEach(function -> functionMap.remove(function)); functions.forEach(function -> functionMap.remove(function));
} }
@Getter
@Setter
@NoArgsConstructor
public static class UsageInfoVO {
private Simulation.Usage usage;
private UsageParamVO param;
} }
/** /**
@ -71,9 +54,23 @@ public class SimulationWorkParamVO {
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
public static class UsageParamVO { @AllArgsConstructor
public static class InitParamVO {
private String memberId; private String memberId;
private Simulation.Client client; private Simulation.Client client;
} }
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class DomConfigVO {
private boolean singleMember;
private boolean singleClient;
private boolean hasTraining;
}
} }

View File

@ -10,9 +10,12 @@ import club.joylink.rtss.simulation.cbtc.DeviceStatusService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.SimulationIdGenerator; import club.joylink.rtss.simulation.cbtc.SimulationIdGenerator;
import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService; import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
import club.joylink.rtss.simulation.cbtc.build.InterlockBuilder2;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService; import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.RouteFls;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop; import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService; import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator; import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
@ -24,6 +27,8 @@ import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.CommandDefinitionVO; import club.joylink.rtss.vo.client.CommandDefinitionVO;
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.MapLogicDataNewVO;
import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.MapVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -34,7 +39,6 @@ import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
@ -167,26 +171,23 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
private void loadMapData(Simulation simulation) { private void loadMapData(Simulation simulation) {
SimulationBuildParams buildParams = simulation.getBuildParams(); SimulationBuildParams buildParams = simulation.getBuildParams();
simulation.setBuildParams(buildParams);
if (Objects.nonNull(buildParams.getLoginUserInfo())) {
simulation.setCreatorId(buildParams.getLoginUserInfo().getAccountVO().getIdStr());
simulation.setProject(buildParams.getLoginUserInfo().getProject());
simulation.setProjectVO(buildParams.getLoginUserInfo().getProjectInfo());
}
// 线路配置参数 // 线路配置参数
simulation.getRepository().setConfig(SimulationBuilder.buildConfig(buildParams.getMap().getConfigVO(), MapVO map = buildParams.getMap();
buildParams.getMap().getGraphDataNew().getMapFunctionConfig())); simulation.getRepository().setConfig(SimulationBuilder.buildConfig(map.getConfigVO(),
map.getGraphDataNew().getMapFunctionConfig()));
simulation.getRepository().getConfig() simulation.getRepository().getConfig()
.setRouteLikeHa1(buildParams.getMap().getGraphDataNew().getGenerateConfig().isLikeHa1()); .setRouteLikeHa1(map.getGraphDataNew().getGenerateConfig().isLikeHa1());
simulation.getRepository().getConfig() simulation.getRepository().getConfig()
.setOverlapSettingByTrigger(buildParams.getMap().getGraphDataNew().getGenerateConfig().isOverlapSettingByTrigger()); .setOverlapSettingByTrigger(map.getGraphDataNew().getGenerateConfig().isOverlapSettingByTrigger());
simulation.getRepository().getConfig() simulation.getRepository().getConfig()
.setSharingECStations(buildParams.getMap().getGraphDataNew().getGenerateConfig().getSharingECStations()); .setSharingECStations(map.getGraphDataNew().getGenerateConfig().getSharingECStations());
simulation.getRepository().getConfig() simulation.getRepository().getConfig()
.setHandleDepot(buildParams.getMap().getGraphDataNew().getGenerateConfig().isHandleDepot()); .setHandleDepot(map.getGraphDataNew().getGenerateConfig().isHandleDepot());
// 地图数据构建 // 地图数据构建
SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult = SimulationBuilder.checkAndBuildMapData(buildParams.getMap()); SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult = SimulationBuilder.checkAndBuildBasicMapData(map); //地图基础数据
if (CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) {
buildLogicData(map, mapDataBuildResult);
}
simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap()); simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap());
simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.getSectionArriveNearMap()); simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.getSectionArriveNearMap());
simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap()); simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap());
@ -195,13 +196,46 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap()); simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap());
if (!CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 存在数据异常 if (!CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 存在数据异常
mapDataBuildResult.getErrMsgList().forEach(errMsg -> log.warn(String.format("地图数据异常:%s", errMsg))); mapDataBuildResult.getErrMsgList().forEach(errMsg -> log.warn(String.format("地图数据异常:%s", errMsg)));
// simulation.setMapDataError(true); //目前大铁线路缺少数据导致检验不通过后续修改之后取消注释 simulation.setMapDataError(true); //目前大铁线路缺少数据导致检验不通过后续修改之后取消注释
simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList()); simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList());
} }
SimulationBuilder.loadDepotInOutRoutePath(simulation); SimulationBuilder.loadDepotInOutRoutePath(simulation);
// CTC行车日志数据结构构建 // CTC行车日志数据结构构建
if (simulation.getRepository().getConfig().isRailway()) {
SimulationBuilder.buildCtcStationRunPlanLog(simulation); SimulationBuilder.buildCtcStationRunPlanLog(simulation);
} }
private void buildLogicData(MapVO map, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) {
MapLogicDataNewVO logicData = map.getLogicDataNew();
MapGraphDataNewVO graphData = map.getGraphDataNew();
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
List<String> errMsgList = mapDataBuildResult.getErrMsgList();
// ------------侧防start-------------
Map<String, RouteFls> flsMap = InterlockBuilder2.checkAndBuildRouteFls(logicData.getFlankProtectionList(), elementMap);
// ------------侧防end-------------
// ------------延续保护start-------------
InterlockBuilder2.buildOverlap(logicData, elementMap, errMsgList, flsMap);
// ------------延续保护end-------------
//超限区段
InterlockBuilder2.buildOverrun(logicData.getOverrunList(), elementMap, errMsgList);
// 接近区段
InterlockBuilder2.buildApproachSections(logicData, elementMap, errMsgList);
// ------------进路start-------------
InterlockBuilder2.buildRailRoute(graphData, logicData, elementMap, errMsgList, flsMap);
// ------------进路end-------------
// ------------自动信号start-------------
InterlockBuilder2.buildAutoSignal(logicData, elementMap, errMsgList);
// ------------自动信号end-------------
// ------------自动折返进路start-------------
InterlockBuilder2.buildAutoReentry(logicData, elementMap, errMsgList);
// ------------自动折返进路end-------------
InterlockBuilder2.checkBetweenRouteSameDirectionSignal(elementMap, errMsgList);
// 处理指示灯按钮逻辑信息
InterlockBuilder2.buildStationDirectionLabelLogic(elementMap, errMsgList, logicData.getDraftMapStationDirectionList());
} }
} }

View File

@ -39,7 +39,6 @@ public interface SimulationWorkService {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO, "仿真工作参数不能为空"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO, "仿真工作参数不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getMapId(), "仿真线路id不能为空"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getMapId(), "仿真线路id不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getType(), "仿真类型不能为空"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getType(), "仿真类型不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.findUsage(), "仿真用途不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(workParamVO.getFunctionMap()) BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(workParamVO.getFunctionMap())
&& workParamVO.getFunctionMap().size() > 1, "功能数量超限"); && workParamVO.getFunctionMap().size() > 1, "功能数量超限");
} }

View File

@ -70,8 +70,6 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
} }
memberManager.addRole(simulation, memberVO.getType(), memberVO.getName(), mapElement); memberManager.addRole(simulation, memberVO.getType(), memberVO.getName(), mapElement);
} }
if (!dataErrMsgList.isEmpty())
simulation.setMapDataError(true);
} }
/** /**
@ -79,28 +77,10 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
*/ */
public void playMember(Simulation simulation) { public void playMember(Simulation simulation) {
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO(); SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
SimulationWorkParamVO.UsageInfoVO usageInfo = workParamVO.getUsageInfo(); SimulationWorkParamVO.InitParamVO initParamVO = workParamVO.getInitParam();
SimulationWorkParamVO.UsageParamVO usageParamVO = usageInfo.getParam(); if (initParamVO != null && initParamVO.getMemberId() != null) {
switch (usageInfo.getUsage()) {
case SINGLE_MEMBER:
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(usageParamVO, "缺少要扮演的角色参数");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(usageParamVO.getMemberId(), "缺少要扮演的角色参数");
break;
case SINGLE_CLIENT:
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(usageParamVO, "缺少要扮演的角色参数");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(usageParamVO.getMemberId(), "缺少要扮演的角色参数");
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(usageParamVO.getClient(), "缺少要使用的客户端参数");
break;
case JOINT:
break;
default:
throw new IllegalStateException("Unexpected value: " + usageInfo.getUsage());
}
if (usageParamVO != null && usageParamVO.getMemberId() != null) {
Long creatorId = simulation.getBuildParams().getLoginUserInfo().getAccountVO().getId(); Long creatorId = simulation.getBuildParams().getLoginUserInfo().getAccountVO().getId();
memberManager.playRole(simulation, creatorId, usageParamVO.getMemberId()); memberManager.playRole(simulation, creatorId, initParamVO.getMemberId());
} }
} }
} }

View File

@ -31,7 +31,6 @@ public class MapSystemCreateVO {
mapSystemNew.setName(name); mapSystemNew.setName(name);
mapSystemNew.setDesc(desc); mapSystemNew.setDesc(desc);
mapSystemNew.setType(paramVO.getType().name()); mapSystemNew.setType(paramVO.getType().name());
mapSystemNew.setUsage(paramVO.getUsage().name());
mapSystemNew.setParam(JsonUtils.writeValueAsString(paramVO)); mapSystemNew.setParam(JsonUtils.writeValueAsString(paramVO));
return mapSystemNew; return mapSystemNew;
} }

View File

@ -0,0 +1,21 @@
package club.joylink.rtss.vo.client.mapSystem;
import club.joylink.rtss.simulation.cbtc.Simulation;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* 地图子系统自动生成的参数
*/
@Getter
@Setter
@NoArgsConstructor
public class MapSystemGenerateParamVO {
/** 要生成子系统的仿真系统类型 */
@NotEmpty(message = "要生成子系统的仿真系统类型不能为空")
private List<Simulation.Type> simTypes;
}

View File

@ -26,7 +26,6 @@ public class MapSystemUpdateVO {
entity.setName(name); entity.setName(name);
entity.setDesc(desc); entity.setDesc(desc);
entity.setType(paramVO.getType().name()); entity.setType(paramVO.getType().name());
entity.setUsage(paramVO.getUsage().name());
entity.setParam(JsonUtils.writeValueAsString(paramVO)); entity.setParam(JsonUtils.writeValueAsString(paramVO));
} }
} }

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.util.JsonUtils;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -42,7 +43,9 @@ public class RtsMapSystemVO {
name = entity.getName(); name = entity.getName();
desc = entity.getDesc(); desc = entity.getDesc();
simType = Simulation.Type.valueOf(entity.getType()); simType = Simulation.Type.valueOf(entity.getType());
if (StringUtils.hasText(entity.getUsage())) {
simUsage = Simulation.Usage.valueOf(entity.getUsage()); simUsage = Simulation.Usage.valueOf(entity.getUsage());
}
paramVO = JsonUtils.read(entity.getParam(), SimulationWorkParamVO.class); paramVO = JsonUtils.read(entity.getParam(), SimulationWorkParamVO.class);
creatorId = entity.getCreatorId(); creatorId = entity.getCreatorId();
createTime = entity.getCreateTime(); createTime = entity.getCreateTime();