Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-19 13:55:30 +08:00
commit ebe85d7c26
22 changed files with 723 additions and 438 deletions

View File

@ -481,11 +481,11 @@ public class SimulationV1Controller {
/**
* 新仿真创建接口
*/
@PostMapping("/new")
public String createSimulation(@RequestBody @Validated SimulationWorkParamVO paramVO,
@PostMapping("/new/{mapId}")
public String createSimulation(@PathVariable long mapId, @RequestBody @Validated SimulationWorkParamVO paramVO,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO loginUserInfoVO) {
return simulationService.createSimulation(loginUserInfoVO, paramVO);
return simulationService.createSimulation(mapId, paramVO, loginUserInfoVO);
}
/**

View File

@ -2,12 +2,13 @@ package club.joylink.rtss.dao;
import club.joylink.rtss.entity.RunPlanRouting;
import club.joylink.rtss.entity.RunPlanRoutingExample;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface RunPlanRoutingDAO {
long countByExample(RunPlanRoutingExample example);
@ -52,4 +53,17 @@ public interface RunPlanRoutingDAO {
"</script>")
Integer countUserRoutingBySectionData(@Param("userId") Long userId, @Param("mapId") Long mapId, @Param("sectionData") String sectionData);
@Insert("<script>" +
" INSERT INTO run_plan_routing (map_id, user_id, `name`, `code`, type, start_station_code, start_section_code, " +
" end_station_code, end_section_code, `right`, destination_code, remarks, section_data)" +
" VALUES " +
" <foreach collection=\"routings\" item=\"item\" separator=\",\">" +
" (#{item.mapId, jdbcType=BIGINT}, #{item.userId, jdbcType=BIGINT}, " +
" #{item.name, jdbcType=VARCHAR}, #{item.code, jdbcType=VARCHAR}, #{item.type, jdbcType=VARCHAR}, " +
" #{item.startStationCode, jdbcType=VARCHAR}, #{item.startSectionCode, jdbcType=VARCHAR}, " +
" #{item.endStationCode, jdbcType=VARCHAR}, #{item.endSectionCode, jdbcType=VARCHAR}, #{item.right, jdbcType=TINYINT}, " +
" #{item.destinationCode, jdbcType=VARCHAR}, #{item.remarks, jdbcType=VARCHAR}, #{item.sectionData, jdbcType=LONGVARCHAR})" +
" </foreach>" +
"</script>")
void batchInsert(List<RunPlanRouting> routings);
}

View File

@ -0,0 +1,35 @@
package club.joylink.rtss.dao.permission;
import java.util.List;
import club.joylink.rtss.entity.permission.PermissionDistribute;
import club.joylink.rtss.entity.permission.PermissionDistributeExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface PermissionDistributeDAO {
long countByExample(PermissionDistributeExample example);
int deleteByExample(PermissionDistributeExample example);
int deleteByPrimaryKey(Long id);
int insert(PermissionDistribute record);
int insertSelective(PermissionDistribute record);
List<PermissionDistribute> selectByExample(PermissionDistributeExample example);
PermissionDistribute selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") PermissionDistribute record, @Param("example") PermissionDistributeExample example);
int updateByExample(@Param("record") PermissionDistribute record, @Param("example") PermissionDistributeExample example);
int updateByPrimaryKeySelective(PermissionDistribute record);
int updateByPrimaryKey(PermissionDistribute record);
}

View File

@ -1,8 +1,9 @@
package club.joylink.rtss.dao.permission;
import java.util.List;
import club.joylink.rtss.entity.permission.PermissionSubject;
import club.joylink.rtss.entity.permission.PermissionSubjectExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -31,4 +32,4 @@ public interface PermissionSubjectDAO {
int updateByPrimaryKeySelective(PermissionSubject record);
int updateByPrimaryKey(PermissionSubject record);
}
}

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.entity.permission;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import lombok.Data;
/**
@ -69,6 +70,7 @@ public class PermissionSubject implements Serializable {
* 来自对应的分发id(rts_permission_distribute)
*/
private Long distributeId;
;
private static final long serialVersionUID = 1L;
}
}

View File

@ -1,7 +1,7 @@
package club.joylink.rtss.entity.permission;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class PermissionSubjectExample {
@ -635,52 +635,52 @@ public class PermissionSubjectExample {
return (Criteria) this;
}
public Criteria andStartTimeEqualTo(LocalDateTime value) {
public Criteria andStartTimeEqualTo(Date value) {
addCriterion("start_time =", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeNotEqualTo(LocalDateTime value) {
public Criteria andStartTimeNotEqualTo(Date value) {
addCriterion("start_time <>", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeGreaterThan(LocalDateTime value) {
public Criteria andStartTimeGreaterThan(Date value) {
addCriterion("start_time >", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeGreaterThanOrEqualTo(LocalDateTime value) {
public Criteria andStartTimeGreaterThanOrEqualTo(Date value) {
addCriterion("start_time >=", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeLessThan(LocalDateTime value) {
public Criteria andStartTimeLessThan(Date value) {
addCriterion("start_time <", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeLessThanOrEqualTo(LocalDateTime value) {
public Criteria andStartTimeLessThanOrEqualTo(Date value) {
addCriterion("start_time <=", value, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeIn(List<LocalDateTime> values) {
public Criteria andStartTimeIn(List<Date> values) {
addCriterion("start_time in", values, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeNotIn(List<LocalDateTime> values) {
public Criteria andStartTimeNotIn(List<Date> values) {
addCriterion("start_time not in", values, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andStartTimeBetween(Date value1, Date value2) {
addCriterion("start_time between", value1, value2, "startTime");
return (Criteria) this;
}
public Criteria andStartTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andStartTimeNotBetween(Date value1, Date value2) {
addCriterion("start_time not between", value1, value2, "startTime");
return (Criteria) this;
}
@ -695,52 +695,52 @@ public class PermissionSubjectExample {
return (Criteria) this;
}
public Criteria andEndTimeEqualTo(LocalDateTime value) {
public Criteria andEndTimeEqualTo(Date value) {
addCriterion("end_time =", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeNotEqualTo(LocalDateTime value) {
public Criteria andEndTimeNotEqualTo(Date value) {
addCriterion("end_time <>", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeGreaterThan(LocalDateTime value) {
public Criteria andEndTimeGreaterThan(Date value) {
addCriterion("end_time >", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeGreaterThanOrEqualTo(LocalDateTime value) {
public Criteria andEndTimeGreaterThanOrEqualTo(Date value) {
addCriterion("end_time >=", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeLessThan(LocalDateTime value) {
public Criteria andEndTimeLessThan(Date value) {
addCriterion("end_time <", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeLessThanOrEqualTo(LocalDateTime value) {
public Criteria andEndTimeLessThanOrEqualTo(Date value) {
addCriterion("end_time <=", value, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeIn(List<LocalDateTime> values) {
public Criteria andEndTimeIn(List<Date> values) {
addCriterion("end_time in", values, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeNotIn(List<LocalDateTime> values) {
public Criteria andEndTimeNotIn(List<Date> values) {
addCriterion("end_time not in", values, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andEndTimeBetween(Date value1, Date value2) {
addCriterion("end_time between", value1, value2, "endTime");
return (Criteria) this;
}
public Criteria andEndTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andEndTimeNotBetween(Date value1, Date value2) {
addCriterion("end_time not between", value1, value2, "endTime");
return (Criteria) this;
}
@ -755,52 +755,52 @@ public class PermissionSubjectExample {
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(LocalDateTime value) {
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
@ -960,4 +960,4 @@ public class PermissionSubjectExample {
this(condition, value, secondValue, null);
}
}
}
}

View File

@ -24,51 +24,38 @@ import java.util.stream.Collectors;
public class ReleaseService implements IReleaseService {
@Autowired
private MapDataDAO mapDataDAO;
@Autowired
private RunPlanTemplateDAO runPlanTemplateDAO;
@Autowired
private RunPlanLoadDAO runPlanLoadDAO;
@Autowired
private Map3dDataDAO map3dDataDAO;
@Autowired
private IMapService iMapService;
@Autowired
private CommandDefinitionDAO commandDefinitionDAO;
@Autowired
private RealLineDAO realLineDAO;
@Autowired
private SchedulingPlanDAO schedulingPlanDAO;
@Autowired
private RunPlanTemplateVersionDAO runPlanTemplateVersionDAO;
@Autowired
private IbpDAO ibpDAO;
@Autowired
private CacheController cacheController;
@Autowired
private ScriptDraftDAO scriptDraftDAO;
@Autowired
private ScriptDAO scriptDAO;
@Autowired
private CompetitionDAO competitionDAO;
@Autowired
private IscsDAO iscsDAO;
@Autowired
private IRunPlanTemplateService iRunPlanTemplateService;
@Autowired
private RunPlanRoutingDAO runPlanRoutingDAO;
@Override
public ReleaseVO exportAsJson(Long mapId, ReleaseConfigVO config) {
@ -77,6 +64,11 @@ public class ReleaseService implements IReleaseService {
ReleaseVO releaseVO = new ReleaseVO(mapId, lineCode);
if (config.isMapData()) { //地图数据
releaseVO.setMapData(getMapDataWithBLOBs(mapId, mapInfo.getVersion()));
// 默认运行图交路数据
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
releaseVO.setRunPlanRoutings(runPlanRoutings);
}
if (config.isRealLineConfig()) { //线路配置
RealLineExample realLineExample = new RealLineExample();
@ -197,6 +189,16 @@ public class ReleaseService implements IReleaseService {
cacheController.remove(BusinessConsts.CachePrefix.Map + mapId);
}
//更新运行图交路数据
if (!CollectionUtils.isEmpty(releaseVO.getRunPlanRoutings())) {
// 默认运行图交路数据
RunPlanRoutingExample example = new RunPlanRoutingExample();
example.createCriteria().andMapIdEqualTo(mapId).andUserIdIsNull();
runPlanRoutingDAO.deleteByExample(example);
releaseVO.getRunPlanRoutings().forEach(routing -> routing.setMapId(mapId));
runPlanRoutingDAO.batchInsert(releaseVO.getRunPlanRoutings());
}
if (!CollectionUtils.isEmpty(releaseVO.getRunPlanTemplateList())) {
//删除旧的运行图相关数据
RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample();

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.entity.RtsMapSystem;
import club.joylink.rtss.entity.RtsMapSystemExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.permission.SystemAbilityService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
@ -15,6 +16,7 @@ import club.joylink.rtss.vo.map.graph.MapMemberVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.core.internal.Function;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@ -32,6 +34,8 @@ public class RtsMapSystemServiceImpl implements RtsMapSystemService {
private RtsMapSystemDAO rtsMapSystemDAO;
@Autowired
private IMapService iMapService;
@Autowired
private SystemAbilityService systemAbilityService;
@Override
public void create(MapSystemCreateVO createVO, long creatorId) {
@ -91,244 +95,201 @@ public class RtsMapSystemServiceImpl implements RtsMapSystemService {
List<String> msgList = new ArrayList<>();
MapVO mapData = iMapService.getMapDetail(mapId);
String msgPrefix;
List<MapMemberVO> mapMemberVOS;
List<Function<MapSystemCreateVO, MapSystemCreateVO>> fillCreatVOFunctions;
for (Simulation.Type simType : paramVO.getSimTypes()) {
mapMemberVOS = mapData.getGraphDataNew().getMemberMap().get(simType);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertCollectionNotEmpty(mapMemberVOS,
String.format("%s成员列表为空不能生成子系统", simType));
switch (simType) {
case METRO:
generateMetroSystem(mapId, mapData, creatorId, msgList);
msgPrefix = "地铁CBTC系统";
fillCreatVOFunctions = buildMetroFillCreateVOFunctions(msgList, msgPrefix, simType, mapMemberVOS);
break;
case RAILWAY:
generateRailwaySystem(mapId, mapData, creatorId, msgList);
msgPrefix = "大铁CTC系统";
fillCreatVOFunctions = buildRailwayFillCreateVOFunctions(msgList, msgPrefix, simType, mapMemberVOS);
break;
case EMERGENCY:
break;
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("未实现");
// msgPrefix = "紧急调度系统";
// fillCreatVOFunctions = Collections.emptyList();
default:
throw new IllegalStateException("Unexpected value: " + simType);
}
//填充参数并创建子系统
for (Function<MapSystemCreateVO, MapSystemCreateVO> fillParamFunction : fillCreatVOFunctions) {
MapSystemCreateVO createVO = new MapSystemCreateVO();
createVO.setMapId(mapId);
MapSystemCreateVO filledCreateVO = fillParamFunction.apply(createVO);
if (filledCreateVO != null) {
create(createVO, creatorId);
}
}
}
return null;
return msgList;
}
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);
}
/**
* 构建填充{@link MapSystemCreateVO}的方法
*
* @param msgList 记录特殊但不算异常的信息
* @param msgPrefix 特殊信息的统一前缀
* @param simType 仿真类型
* @param mapMemberVOS 地图成员列表
* @return 调用apply方法时当地图子系统的参数有问题无法创建子系统时返回null否则返回填充好所有参数的{@link MapSystemCreateVO}
*/
private List<Function<MapSystemCreateVO, MapSystemCreateVO>> buildMetroFillCreateVOFunctions(List<String> msgList, String msgPrefix, Simulation.Type simType, List<MapMemberVO> mapMemberVOS) {
List<Function<MapSystemCreateVO, MapSystemCreateVO>> fillFunctions = new ArrayList<>();
//ATS行调工作站
Function<MapSystemCreateVO, MapSystemCreateVO> dispatchSystem = (vo) -> {
String name = "ATS行调工作站";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER))
.findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无行调成员未生成%s", msgPrefix, name));
} else {
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberOptional.get().getId());
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(true, false, false));
return vo;
}
return null;
};
//ATS现地工作站
Function<MapSystemCreateVO, MapSystemCreateVO> stationSystem = (vo) -> {
String name = "ATS现地工作站";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR))
.findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无行值成员未生成%s", msgPrefix, name));
} else {
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberOptional.get().getId());
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(true, false, false));
return vo;
}
return null;
};
//司机模拟驾驶系统
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);
Function<MapSystemCreateVO, MapSystemCreateVO> driveSystem = (vo) -> {
String name = "司机模拟驾驶系统";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DRIVER))
.findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无司机角色未生成%s", msgPrefix, name));
} else {
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberOptional.get().getId());
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(true, false, false));
return vo;
}
return null;
};
//综合演练
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);
Function<MapSystemCreateVO, MapSystemCreateVO> joint = (vo) -> {
String name = "综合演练";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER))
.findFirst();
String memberId;
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无行调成员%s未设置默认扮演成员", msgPrefix, name));
memberId = null;
} else {
memberId = memberOptional.get().getId();
}
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberId);
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(false, false, false));
return vo;
};
initParamVO = new SimulationWorkParamVO.InitParamVO(memberOptional.get().getId(), null);
workParamVO.setInitParam(initParamVO);
fillFunctions.add(dispatchSystem);
fillFunctions.add(stationSystem);
fillFunctions.add(driveSystem);
fillFunctions.add(joint);
domConfigVO = new SimulationWorkParamVO.DomConfigVO(false, false, false);
workParamVO.setDomConfig(domConfigVO);
create(createVO, creatorId);
}
return fillFunctions;
}
/**
* 构建大铁填充{@link MapSystemCreateVO}的方法列表
*
* @param msgList 记录特殊的但是不算异常的信息
* @param msgPrefix msgList内容的统一前缀
* @param mapMemberVOS 地图数据中的成员列表
* @return 调用apply方法时当地图子系统的参数有问题无法创建子系统时返回null否则返回填充好所有参数的{@link MapSystemCreateVO}
*/
private List<Function<MapSystemCreateVO, MapSystemCreateVO>> buildRailwayFillCreateVOFunctions(List<String> msgList, String msgPrefix, Simulation.Type simType, List<MapMemberVO> mapMemberVOS) {
List<Function<MapSystemCreateVO, MapSystemCreateVO>> fillFunctions = new ArrayList<>();
//调度台
Function<MapSystemCreateVO, MapSystemCreateVO> dispatchSystem = (vo) -> {
String name = "调度台";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.DISPATCHER))
.findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无行调成员未生成%s", msgPrefix, name));
} else {
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberOptional.get().getId());
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(true, false, false));
return vo;
}
return null;
};
//车站
Function<MapSystemCreateVO, MapSystemCreateVO> stationSystem = (vo) -> {
String name = "车站";
Optional<MapMemberVO> memberOptional = mapMemberVOS.stream()
.filter(member -> Objects.equals(member.getType(), SimulationMember.Type.STATION_SUPERVISOR))
.findFirst();
if (memberOptional.isEmpty()) {
msgList.add(String.format("%s无行值成员未生成%s", msgPrefix, name));
} else {
vo.setName(name);
vo.setDesc(name);
SimulationWorkParamVO workParamVO = new SimulationWorkParamVO();
vo.setParamVO(workParamVO);
workParamVO.setType(simType);
workParamVO.setMemberId(memberOptional.get().getId());
workParamVO.setDomConfig(new SimulationWorkParamVO.DomConfigVO(true, false, false));
return vo;
}
return null;
};
fillFunctions.add(dispatchSystem);
fillFunctions.add(stationSystem);
return fillFunctions;
}
private Optional<RtsMapSystem> findEntityOptional(long id) {

View File

@ -12,12 +12,12 @@ public interface SimulationService {
/**
* 创建仿真
*/
String createSimulation(@NonNull LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO);
String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO);
/**
* 给仿真添加功能
*/
void addFunctions(String simulationId, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo);
void addFunctions(String simulationId, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionMap, LoginUserInfoVO loginInfo);
/**
* 从仿真中移除功能

View File

@ -34,9 +34,9 @@ public class SimulationServiceImpl implements SimulationService {
private DefaultMessageSender defaultMessageSender;
@Override
public String createSimulation(@NonNull LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
public String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) {
SimulationWorkService initService = simulationWorkServiceManager.getInitService(workParamVO.getType());
Simulation simulation = initService.create(loginUserInfoVO, workParamVO);
Simulation simulation = initService.create(mapId, workParamVO, loginUserInfoVO);
LoginUserInfoVO loginUserInfo = simulation.getBuildParams().getLoginUserInfo();
if (Objects.nonNull(loginUserInfo)) {
@ -58,8 +58,8 @@ public class SimulationServiceImpl implements SimulationService {
initService.addJobs(simulation);
initService.addMessagePublisher(simulation);
initService.init(simulation);
if (!CollectionUtils.isEmpty(workParamVO.getFunctionMap())) {
initService.addFunctions(simulation, workParamVO.getFunctionMap(), loginUserInfoVO);
if (!CollectionUtils.isEmpty(workParamVO.getFunctionInfoMap())) {
initService.addFunctions(simulation, workParamVO.getFunctionInfoMap(), loginUserInfoVO);
}
applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation));
@ -69,27 +69,31 @@ public class SimulationServiceImpl implements SimulationService {
}
@Override
public void addFunctions(@NonNull String simulationId, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
addFunctions(simulation, functionMap, loginInfo);
}
private void addFunctions(@NonNull Simulation simulation, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo) {
if (!CollectionUtils.isEmpty(functionMap)) {
public void addFunctions(@NonNull String simulationId, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionInfoMap, LoginUserInfoVO loginInfo) {
if (!CollectionUtils.isEmpty(functionInfoMap)) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
Simulation.Type simulationType = simulation.getType();
SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulationType);
if (StringUtils.hasText(simulation.getCreatorId())) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
"非仿真创建者不能使用该功能");
}
initService.addFunctions(simulation, functionMap, loginInfo);
initService.addFunctions(simulation, functionInfoMap, loginInfo);
}
}
@Override
public void removeFunctions(@NonNull String simulationId, List<Simulation.Function> functions, LoginUserInfoVO loginInfo) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
removeFunctions(simulation, functions, loginInfo);
if (!CollectionUtils.isEmpty(functions)) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
Simulation.Type simulationType = simulation.getType();
SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulationType);
if (StringUtils.hasText(simulation.getCreatorId())) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
"非仿真创建者不能使用该功能");
}
initService.removeFunctions(simulation, functions);
}
}
@Override
@ -105,16 +109,4 @@ public class SimulationServiceImpl implements SimulationService {
SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulation.getType());
initService.reset(simulation);
}
private void removeFunctions(@NonNull Simulation simulation, List<Simulation.Function> functions, LoginUserInfoVO loginInfo) {
if (!CollectionUtils.isEmpty(functions)) {
Simulation.Type simulationType = simulation.getType();
SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulationType);
if (StringUtils.hasText(simulation.getCreatorId())) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(),
"非仿真创建者不能使用该功能");
}
initService.removeFunctions(simulation, functions);
}
}
}

View File

@ -1,73 +0,0 @@
package club.joylink.rtss.simulation.cbtc.bo;
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 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 {
private Simulation.Type type;
private SimulationWorkParamVO.InitParamVO initParam;
/**
* 仿真所使用的功能
*/
@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
@ToString
public static abstract class FunctionParam {
}
@Getter
@Setter
@NoArgsConstructor
public static class TrainingFunctionParam extends FunctionParam {
private Long trainingId;
}
@Getter
@Setter
@NoArgsConstructor
public static class LPFFunctionParam extends FunctionParam {
private Long dataId;
}
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,7 +31,7 @@ public class InterlockBuilder2 {
static void checkAndBuildMapCILogicData(MapVO map, SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult) {
MapLogicDataNewVO logicData = map.getLogicDataNew();
MapGraphDataNewVO graphData = map.getGraphDataNew();
boolean railway = map.getConfigVO().isRailway();
MapCiGenerateConfig generateConfig = graphData.getGenerateConfig();
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
List<String> errMsgList = mapDataBuildResult.getErrMsgList();
@ -49,7 +49,7 @@ public class InterlockBuilder2 {
// 接近区段
InterlockBuilder2.buildApproachSections(logicData, elementMap, errMsgList);
// ------------进路start-------------
if (railway) {
if (generateConfig != null && generateConfig.isRailway()) {
InterlockBuilder2.buildRailRoute(graphData, logicData, elementMap, errMsgList, flsMap);
} else {
InterlockBuilder2.buildRoute(logicData, elementMap, errMsgList, flsMap);

View File

@ -42,8 +42,14 @@ public class SimulationIscsDataRepository {
*/
private final Map<String, StandPis> standPisMap = new HashMap<>();
/**
* k - groupNumber
*/
private final Map<String, OnboardPisStatus> onboardPisStatusMap = new HashMap<>();
/**
* k - standCode
*/
private final Map<String, StandPisStatus> standPisStatusMap = new HashMap<>();
private final List<TimedPlayParamVO> timedPlayParamVOS = new ArrayList<>();

View File

@ -17,48 +17,51 @@ import java.util.Map;
@Setter
@NoArgsConstructor
public class SimulationWorkParamVO {
private Long mapId;
@NotNull(message = "仿真类型不能为空")
private Simulation.Type type;
private InitParamVO initParam;
/**
* 创建仿真时默认扮演的成员的id
*/
private String memberId;
/**
* 创建仿真时默认使用的客户端
*/
private Simulation.Client client;
/**
* 仿真所使用的功能
*/
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Map<Simulation.Function, Map<String, Object>> functionMap;
private Map<Simulation.Function, FunctionInfoVO> functionInfoMap;
/**
* 前端控制元素显隐的配置后端暂时用不到所以先用Map接收
* 前端控制元素显隐的配置
*/
private DomConfigVO domConfig;
public void addFunctionInfos(@NonNull Map<Simulation.Function, Map<String, Object>> functionMap) {
if (CollectionUtils.isEmpty(this.functionMap)) {
this.functionMap = new LinkedHashMap<>();
public void addFunctionInfos(@NonNull Map<Simulation.Function, FunctionInfoVO> functionMap) {
if (CollectionUtils.isEmpty(this.functionInfoMap)) {
this.functionInfoMap = new LinkedHashMap<>();
}
this.functionMap.putAll(functionMap);
this.functionInfoMap.putAll(functionMap);
}
public void removeFunctions(Collection<Simulation.Function> functions) {
if (!CollectionUtils.isEmpty(functionMap)) {
functions.forEach(function -> functionMap.remove(function));
if (!CollectionUtils.isEmpty(functionInfoMap)) {
functions.forEach(function -> functionInfoMap.remove(function));
}
}
/**
* 使用方式参数
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class InitParamVO {
private String memberId;
public static class FunctionInfoVO {
private Simulation.Function function;
private Simulation.Client client;
private Long id;
}
@Getter
@ -72,5 +75,4 @@ public class SimulationWorkParamVO {
private boolean hasTraining;
}
}

View File

@ -19,7 +19,7 @@ public class EmergencySimulationWorkServiceImpl implements SimulationWorkService
}
@Override
public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
public Simulation create(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
return null;
}
@ -54,7 +54,7 @@ public class EmergencySimulationWorkServiceImpl implements SimulationWorkService
}
@Override
public void addFunctions(Simulation simulation, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo) {
public void addFunctions(Simulation simulation, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionInfoMap, LoginUserInfoVO loginInfo) {
}

View File

@ -26,7 +26,6 @@ import club.joylink.rtss.simulation.cbtc.depot.DepotService;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService;
@ -35,10 +34,8 @@ import club.joylink.rtss.simulation.cbtc.passenger.strategy.LargePassengerFlowSt
import club.joylink.rtss.simulation.cbtc.pis.PisLogicLoop;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.simulation.cbtc.vo.TrainingParamVO;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.simulation.rt.pis.PisStatusPublisher;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.CommandDefinitionVO;
import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO;
@ -87,8 +84,6 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
@Autowired
private IscsSystemResourcesService iscsSystemResourcesService;
@Autowired
private MemberManager memberManager;
@Autowired
private DeviceStatusService deviceStatusService;
@Autowired
private DepotService depotService;
@ -143,10 +138,10 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
}
@Override
public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
public Simulation create(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
checkParam(workParamVO);
SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, workParamVO);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), workParamVO.getMapId());
SimulationBuildParams params = prepareSimulationParams(mapId, workParamVO, loginUserInfoVO);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
Simulation simulation = new Simulation(group);
simulation.setBuildParams(params);
return simulation;
@ -215,13 +210,13 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
@Override
public void runAsPlan(Simulation simulation, RunAsPlanParam param) {
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
Map<Simulation.Function, Map<String, Object>> functionMap = workParamVO.getFunctionMap();
Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionMap = workParamVO.getFunctionInfoMap();
if (CollectionUtils.isEmpty(functionMap)) {
groupSimulationService.runAsPlan(simulation.getId(), param);
} else {
for (Map.Entry<Simulation.Function, Map<String, Object>> entry : functionMap.entrySet()) {
for (Map.Entry<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> entry : functionMap.entrySet()) {
Simulation.Function function = entry.getKey();
Map<String, Object> funcParam = entry.getValue();
SimulationWorkParamVO.FunctionInfoVO info = entry.getValue();
switch (function) {
case LPF:
boolean initSuccess = passengerFlowSimulateService.initPassengerFlow(simulation);
@ -246,11 +241,11 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
simulationLifeCycleService.reset(simulation);
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
Map<Simulation.Function, Map<String, Object>> functionMap = workParamVO.getFunctionMap();
Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionMap = workParamVO.getFunctionInfoMap();
if (!CollectionUtils.isEmpty(functionMap)) {
for (Map.Entry<Simulation.Function, Map<String, Object>> entry : functionMap.entrySet()) {
for (Map.Entry<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> entry : functionMap.entrySet()) {
Simulation.Function function = entry.getKey();
Map<String, Object> funcParam = entry.getValue();
SimulationWorkParamVO.FunctionInfoVO info = entry.getValue();
switch (function) {
case LPF:
passengerFlowSimulateService.simulationReset(simulation);
@ -270,10 +265,10 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
}
@Override
public void addFunctions(Simulation simulation, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo) {
for (Map.Entry<Simulation.Function, Map<String, Object>> entry : functionMap.entrySet()) {
public void addFunctions(Simulation simulation, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionInfoMap, LoginUserInfoVO loginInfo) {
for (Map.Entry<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> entry : functionInfoMap.entrySet()) {
Simulation.Function function = entry.getKey();
Map<String, Object> param = entry.getValue();
SimulationWorkParamVO.FunctionInfoVO info = entry.getValue();
switch (function) {
case LPF:
break;
@ -282,10 +277,8 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
case TRAINING_DESIGN:
break;
case TRAINING:
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertMapNotEmpty(param, "参数不能为空");
TrainingParamVO paramVO = JsonUtils.read(JsonUtils.writeValueAsString(param), TrainingParamVO.class);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(paramVO.getTrainingId(), "参数不能为空");
iTrainingV1Service.loadTraining(simulation.getId(), paramVO.getTrainingId(), loginInfo.getAccountVO());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(info, "参数不能为空");
iTrainingV1Service.loadTraining(simulation.getId(), info.getId(), loginInfo.getAccountVO());
break;
case EXAM:
break;
@ -293,7 +286,7 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
throw new IllegalStateException("Unexpected value: " + function);
}
}
simulation.getBuildParams().getWorkParamVO().addFunctionInfos(functionMap);
simulation.getBuildParams().getWorkParamVO().addFunctionInfos(functionInfoMap);
}
@Override
@ -375,9 +368,8 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
SimulationBuilder.loadDepotInOutRoutePath(simulation);
}
private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
private SimulationBuildParams prepareSimulationParams(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
// 获取地图数据
Long mapId = workParamVO.getMapId();
MapVO mapVO = iMapService.getMapDetail(mapId);
List<RunPlanRunlevelVO> runLevelList = this.prepareRunLevelData(loginUserInfoVO, mapId);
List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(loginUserInfoVO, mapId);
@ -416,7 +408,7 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
RunPlanLoadVO loadPlan = null;
Simulation.Type type = createParamVO.getType();
if (Simulation.Type.METRO == type) {
Map<Simulation.Function, Map<String, Object>> functionMap = createParamVO.getFunctionMap();
Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionMap = createParamVO.getFunctionInfoMap();
if (CollectionUtils.isEmpty(functionMap)) {
//优先使用用户的运行图
loadPlan = iLoadPlanService.findUserLoadPlan(userId, mapId, runPlanDate);
@ -424,7 +416,7 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
loadPlan = iLoadPlanService.findCommonLoadPlanOfMap(mapId);
}
} else {
for (Map.Entry<Simulation.Function, Map<String, Object>> entry : functionMap.entrySet()) {
for (Map.Entry<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> entry : functionMap.entrySet()) {
Simulation.Function function = entry.getKey();
switch (function) {
case LPF:

View File

@ -82,10 +82,10 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
}
@Override
public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
public Simulation create(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO) {
checkParam(workParamVO);
SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, workParamVO);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), workParamVO.getMapId());
SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, workParamVO, mapId);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId);
Simulation simulation = new Simulation(group);
simulation.setBuildParams(params);
return simulation;
@ -143,7 +143,7 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
}
@Override
public void addFunctions(Simulation simulation, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo) {
public void addFunctions(Simulation simulation, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionInfoMap, LoginUserInfoVO loginInfo) {
}
@ -152,9 +152,8 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
}
private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) {
private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO, long mapId) {
// 获取地图数据
Long mapId = workParamVO.getMapId();
MapVO mapVO = iMapService.getMapDetail(mapId);
// 获取操作定义数据
List<CommandDefinitionVO> operationDefinitionList = iCommandService

View File

@ -14,7 +14,7 @@ import java.util.Map;
public interface SimulationWorkService {
Simulation.Type getType();
Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO);
Simulation create(long mapId, SimulationWorkParamVO workParamVO, LoginUserInfoVO loginUserInfoVO);
void loadData(Simulation simulation);
@ -28,7 +28,7 @@ public interface SimulationWorkService {
void reset(Simulation simulation);
void addFunctions(Simulation simulation, Map<Simulation.Function, Map<String, Object>> functionMap, LoginUserInfoVO loginInfo);
void addFunctions(Simulation simulation, Map<Simulation.Function, SimulationWorkParamVO.FunctionInfoVO> functionInfoMap, LoginUserInfoVO loginInfo);
void removeFunctions(Simulation simulation, Collection<Simulation.Function> functions);
@ -37,9 +37,8 @@ public interface SimulationWorkService {
*/
default void checkParam(@NonNull SimulationWorkParamVO workParamVO) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO, "仿真工作参数不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getMapId(), "仿真线路id不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getType(), "仿真类型不能为空");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(workParamVO.getFunctionMap())
&& workParamVO.getFunctionMap().size() > 1, "功能数量超限");
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(workParamVO.getFunctionInfoMap())
&& workParamVO.getFunctionInfoMap().size() > 1, "功能数量超限");
}
}

View File

@ -77,10 +77,10 @@ public class SimulationWorkServiceManager implements ApplicationContextAware {
*/
public void playMember(Simulation simulation) {
SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO();
SimulationWorkParamVO.InitParamVO initParamVO = workParamVO.getInitParam();
if (initParamVO != null && initParamVO.getMemberId() != null) {
String memberId = workParamVO.getMemberId();
if (StringUtils.hasText(memberId)) {
Long creatorId = simulation.getBuildParams().getLoginUserInfo().getAccountVO().getId();
memberManager.playRole(simulation, creatorId, initParamVO.getMemberId());
memberManager.playRole(simulation, creatorId, memberId);
}
}
}

View File

@ -65,6 +65,8 @@ public class ReleaseVO {
private List<CompetitionWithBLOBs> competitions;
private List<RunPlanRouting> runPlanRoutings;
public ReleaseVO(Long mapId, String realLineCode) {
this.mapId = mapId;
this.realLineCode = realLineCode;

View File

@ -0,0 +1,28 @@
package club.joylink.rtss.vo.permission;
import club.joylink.rtss.entity.permission.PermissionDistribute;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
public class PermissionDistributeVO implements Serializable {
private static final long serialVersionUID = 2597089293400946877L;
private Long permissionId;
private String sourceSubjectId;
private Integer amount;
private Integer remains;
private Boolean forever;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private LocalDateTime startTime;
private LocalDateTime endTime;
private String dsc;
public PermissionDistribute toBean(){
PermissionDistribute pd = new PermissionDistribute();
return pd;
}
}

View File

@ -0,0 +1,323 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.rtss.dao.permission.PermissionDistributeDAO">
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.permission.PermissionDistribute">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="permission_id" jdbcType="BIGINT" property="permissionId" />
<result column="source_subject_id" jdbcType="BIGINT" property="sourceSubjectId" />
<result column="amount" jdbcType="INTEGER" property="amount" />
<result column="remains" jdbcType="INTEGER" property="remains" />
<result column="forever" jdbcType="BIT" property="forever" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="create_id" jdbcType="BIGINT" property="createId" />
<result column="dsc" jdbcType="VARCHAR" property="dsc" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, permission_id, source_subject_id, amount, remains, forever, create_time, update_time,
start_time, end_time, create_id, dsc
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.permission.PermissionDistributeExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from rts_permission_distribute
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from rts_permission_distribute
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from rts_permission_distribute
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.permission.PermissionDistributeExample">
delete from rts_permission_distribute
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.permission.PermissionDistribute" useGeneratedKeys="true">
insert into rts_permission_distribute (permission_id, source_subject_id, amount,
remains, forever, create_time,
update_time, start_time, end_time,
create_id, dsc)
values (#{permissionId,jdbcType=BIGINT}, #{sourceSubjectId,jdbcType=BIGINT}, #{amount,jdbcType=INTEGER},
#{remains,jdbcType=INTEGER}, #{forever,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{createId,jdbcType=BIGINT}, #{dsc,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.permission.PermissionDistribute" useGeneratedKeys="true">
insert into rts_permission_distribute
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="permissionId != null">
permission_id,
</if>
<if test="sourceSubjectId != null">
source_subject_id,
</if>
<if test="amount != null">
amount,
</if>
<if test="remains != null">
remains,
</if>
<if test="forever != null">
forever,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="createId != null">
create_id,
</if>
<if test="dsc != null">
dsc,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="permissionId != null">
#{permissionId,jdbcType=BIGINT},
</if>
<if test="sourceSubjectId != null">
#{sourceSubjectId,jdbcType=BIGINT},
</if>
<if test="amount != null">
#{amount,jdbcType=INTEGER},
</if>
<if test="remains != null">
#{remains,jdbcType=INTEGER},
</if>
<if test="forever != null">
#{forever,jdbcType=BIT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="startTime != null">
#{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
#{endTime,jdbcType=TIMESTAMP},
</if>
<if test="createId != null">
#{createId,jdbcType=BIGINT},
</if>
<if test="dsc != null">
#{dsc,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.permission.PermissionDistributeExample" resultType="java.lang.Long">
select count(*) from rts_permission_distribute
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update rts_permission_distribute
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.permissionId != null">
permission_id = #{record.permissionId,jdbcType=BIGINT},
</if>
<if test="record.sourceSubjectId != null">
source_subject_id = #{record.sourceSubjectId,jdbcType=BIGINT},
</if>
<if test="record.amount != null">
amount = #{record.amount,jdbcType=INTEGER},
</if>
<if test="record.remains != null">
remains = #{record.remains,jdbcType=INTEGER},
</if>
<if test="record.forever != null">
forever = #{record.forever,jdbcType=BIT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.startTime != null">
start_time = #{record.startTime,jdbcType=TIMESTAMP},
</if>
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=TIMESTAMP},
</if>
<if test="record.createId != null">
create_id = #{record.createId,jdbcType=BIGINT},
</if>
<if test="record.dsc != null">
dsc = #{record.dsc,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update rts_permission_distribute
set id = #{record.id,jdbcType=BIGINT},
permission_id = #{record.permissionId,jdbcType=BIGINT},
source_subject_id = #{record.sourceSubjectId,jdbcType=BIGINT},
amount = #{record.amount,jdbcType=INTEGER},
remains = #{record.remains,jdbcType=INTEGER},
forever = #{record.forever,jdbcType=BIT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
start_time = #{record.startTime,jdbcType=TIMESTAMP},
end_time = #{record.endTime,jdbcType=TIMESTAMP},
create_id = #{record.createId,jdbcType=BIGINT},
dsc = #{record.dsc,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.permission.PermissionDistribute">
update rts_permission_distribute
<set>
<if test="permissionId != null">
permission_id = #{permissionId,jdbcType=BIGINT},
</if>
<if test="sourceSubjectId != null">
source_subject_id = #{sourceSubjectId,jdbcType=BIGINT},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=INTEGER},
</if>
<if test="remains != null">
remains = #{remains,jdbcType=INTEGER},
</if>
<if test="forever != null">
forever = #{forever,jdbcType=BIT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=TIMESTAMP},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=TIMESTAMP},
</if>
<if test="createId != null">
create_id = #{createId,jdbcType=BIGINT},
</if>
<if test="dsc != null">
dsc = #{dsc,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.permission.PermissionDistribute">
update rts_permission_distribute
set permission_id = #{permissionId,jdbcType=BIGINT},
source_subject_id = #{sourceSubjectId,jdbcType=BIGINT},
amount = #{amount,jdbcType=INTEGER},
remains = #{remains,jdbcType=INTEGER},
forever = #{forever,jdbcType=BIT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
start_time = #{startTime,jdbcType=TIMESTAMP},
end_time = #{endTime,jdbcType=TIMESTAMP},
create_id = #{createId,jdbcType=BIGINT},
dsc = #{dsc,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>