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

This commit is contained in:
weizhihong 2022-12-06 17:41:11 +08:00
commit 473446cef0
5 changed files with 216 additions and 8 deletions

View File

@ -1,13 +1,23 @@
package club.joylink.rtss.controller.org;
import club.joylink.rtss.dao.org.OrgProjectDao;
import club.joylink.rtss.entity.org.OrgProject;
import club.joylink.rtss.services.org.IOrgProjectService;
import club.joylink.rtss.services.org.OrgService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.client.org.OrgProjectVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
/**
* 组织-项目关系管理接口
*/
@RestController
@RequestMapping("/api/org")
public class OrgProjectController {
@ -30,4 +40,34 @@ public class OrgProjectController {
public void signInOrg(@PathVariable Long orgId, @RequestAttribute LoginUserInfoVO loginInfo) {
orgProjectService.signInOrg(orgId, loginInfo);
}
@Autowired
private OrgProjectDao orgProjectDao;
@Autowired
private OrgService orgService;
/**
* 旧数据处理用完删除
*/
@Transactional(rollbackFor = Exception.class)
@PostMapping("/oldData/handle")
public void oldDataHandle() {
orgProjectDao.deleteByExample(null);
OrgProject orgProject = new OrgProject();
orgProject.setCreateTime(LocalDateTime.now());
orgProject.setCreatorId(1L);
List<CompanyVO> orgs = orgService.queryAllTopOrg();
for (CompanyVO org : orgs) {
List<String> projectCodes = org.getProjectCodes();
if (!CollectionUtils.isEmpty(projectCodes)) {
for (String projectCode : projectCodes) {
orgProject.setId(null);
orgProject.setOrgId(org.getId());
orgProject.setProjectCode(projectCode);
orgProjectDao.insert(orgProject);
}
}
}
}
}

View File

@ -2,15 +2,37 @@ package club.joylink.rtss.controller.paper;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.dao.ExamDefinitionDAO;
import club.joylink.rtss.dao.OrgDAO;
import club.joylink.rtss.dao.UserExamMapper;
import club.joylink.rtss.dao.org.OrgProjectDao;
import club.joylink.rtss.dao.paper.PaperUserDAO;
import club.joylink.rtss.entity.ExamDefinitionExample;
import club.joylink.rtss.entity.UserExam;
import club.joylink.rtss.entity.UserExamExample;
import club.joylink.rtss.entity.org.OrgProject;
import club.joylink.rtss.entity.paper.PaperUser;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.paper.PaperCompositionService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.paper.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 试卷蓝图业务接口
@ -27,6 +49,7 @@ public class PaperCompositionController {
/**
* 数据管理查询
*
* @param req
* @return
*/
@ -35,9 +58,11 @@ public class PaperCompositionController {
public PageVO<PaperCompositionWithRuleVo> findPaperCompositionForPage(@RequestBody FindPaperCompositionPageReqVo req) {
return this.compositionService.findPaperCompositionByPage(req);
}
/**
* 创建试卷蓝图包括规则定义
* 参数 tags 只支持单个
*
* @param orgId 组织id
*/
@PostMapping("/{orgId}")
@ -99,6 +124,7 @@ public class PaperCompositionController {
public List<PaperCompositionWithRuleVo> findPaperCompositionByList(@RequestBody FindPaperCompositionPageReqVo req) {
return this.compositionService.findPaperCompositionList(req);
}
/**
* 根据试卷蓝图名称简介分页查找某个组织的试卷蓝图
*/
@ -123,6 +149,96 @@ public class PaperCompositionController {
*/
@GetMapping("/{pcId}")
public PaperCompositionWithRuleVo findPaperComposition(@PathVariable("pcId") Long pcId, @RequestAttribute AccountVO user) {
return this.compositionService.findPaperComposition(pcId,user);
return this.compositionService.findPaperComposition(pcId, user);
}
@Autowired
ExamDefinitionDAO examDefinitionDAO;
@Autowired
IMapService iMapService;
@Autowired
OrgDAO orgDAO;
@Autowired
OrgProjectDao orgProjectDao;
@Autowired
UserExamMapper userExamMapper;
@Autowired
private PaperUserDAO paperUserDAO;
/**
* 旧数据处理接口用完删除
*/
@Transactional(rollbackFor = Exception.class)
@PostMapping("/oldData/handle")
public List<String> oldDataHandle(@RequestAttribute AccountVO user) {
examDefinitionDAO.deleteByExample(null);
paperUserDAO.deleteByExample(null);
List<String> msg = new ArrayList<>();
//所有在线地图
Map<Long, MapVO> onlineMaps = iMapService.listOnline().stream().collect(Collectors.toMap(MapVO::getId, Function.identity()));
//所有项目-组织对应关系
Map<String, Long> projectCode_orgId_map = orgProjectDao.selectByExample(null).stream().collect(Collectors.toMap(OrgProject::getProjectCode, OrgProject::getOrgId));
//转化试卷并记录试卷id变化
ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
examDefinitionExample.createCriteria().andStatusEqualTo("1");
Map<Long, Long> old_newExamIdMap = new HashMap<>();
examDefinitionDAO.selectByExample(examDefinitionExample).stream()
.filter(exam -> {
if (exam.getOrgId() != null) {
return true;
}
MapVO map = onlineMaps.get(exam.getMapId());
if (map == null) {
msg.add(String.format("[id:%s]的试卷对应的地图[id:%s]不存在或已下架", exam.getId(), exam.getMapId()));
return false;
}
String projectCode = map.getProjectCode();
if (!StringUtils.hasText(projectCode)) {
exam.setOrgId(projectCode_orgId_map.get("DEFAULT"));
} else {
exam.setOrgId(projectCode_orgId_map.get(projectCode));
}
return true;
}).forEach(exam -> {
PaperCompositionWithRuleVo paperCompositionWithRuleVo = new PaperCompositionWithRuleVo();
paperCompositionWithRuleVo.setMapId(exam.getMapId());
paperCompositionWithRuleVo.setName(exam.getName());
paperCompositionWithRuleVo.setProfile(exam.getRemarks());
paperCompositionWithRuleVo.setOrgId(exam.getOrgId());
paperCompositionWithRuleVo.setStartTime(exam.getStartTime());
paperCompositionWithRuleVo.setEndTime(exam.getEndTime());
paperCompositionWithRuleVo.setValidDuration(exam.getDuration() / 60);
paperCompositionWithRuleVo.setPassScore(exam.getPassingPoint());
paperCompositionWithRuleVo.setFullScore(exam.getFullPoint());
paperCompositionWithRuleVo.setCreatorId(exam.getCreatorId());
paperCompositionWithRuleVo.setCreateTime(exam.getCreateTime());
paperCompositionWithRuleVo.setUpdateTime(null);
paperCompositionWithRuleVo.setState(PaperCompositionState.Locked);
CreatePaperCompositionRspVo paperComposition = createPaperCompositionWithRuleForOrg(exam.getOrgId(), paperCompositionWithRuleVo, user);
old_newExamIdMap.put(exam.getId(), paperComposition.getId());
});
//查询试卷记录
ArrayList<Long> oldExamIds = new ArrayList<>(old_newExamIdMap.keySet());
UserExamExample userExamExample = new UserExamExample();
userExamExample.createCriteria().andExamIdIn(oldExamIds);
List<UserExam> userExams = userExamMapper.selectByExample(userExamExample);
//转化试卷记录
LocalDateTime now = LocalDateTime.now();
for (UserExam userExam : userExams) {
PaperUser paperUser = new PaperUser();
paperUser.setUserId(userExam.getUserId());
Long newExamId = old_newExamIdMap.get(userExam.getExamId());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(newExamId);
paperUser.setPcId(newExamId);
paperUser.setScore(userExam.getScore().intValue());
paperUser.setStartTime(userExam.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
if (userExam.getEndTime() != null) {
paperUser.setEndTime(userExam.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
}
paperUser.setCreateTime(now);
paperUserDAO.insert(paperUser);
}
return msg;
}
}

View File

@ -2,15 +2,16 @@ package club.joylink.rtss.controller.publish;
import club.joylink.rtss.constants.RoleEnum;
import club.joylink.rtss.controller.advice.Role;
import club.joylink.rtss.dao.MapDataDAO;
import club.joylink.rtss.dao.MapSystemDAO;
import club.joylink.rtss.dao.RtsMapFunctionDAO;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.mapFunction.RtsMapFunctionService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.mapFunction.*;
import club.joylink.rtss.vo.map.MapVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -99,15 +100,16 @@ public class MapFunctionController {
@Autowired
private IMapService iMapService;
@Autowired
private MapSystemDAO mapSystemDAO;
@Autowired
private MapDataDAO mapDataDAO;
private RtsMapFunctionDAO rtsMapFunctionDAO;
/**
* 旧数据处理用完删除
*/
@Transactional(rollbackFor = Exception.class)
@PostMapping("/oldDataHandle")
public List<String> oldDataHandle() {
rtsMapFunctionDAO.deleteByExample(null);
List<MapVO> onlineMaps = iMapService.listOnline();
List<String> msgList = new ArrayList<>();
for (MapVO onlineMap : onlineMaps) {
@ -116,4 +118,24 @@ public class MapFunctionController {
}
return msgList;
}
/**
* 为所有在线地图生成功能用完删除
*/
@Transactional
@PostMapping("/generate/all")
public void generateAll(@RequestAttribute LoginUserInfoVO loginInfo) {
for (MapVO mapVO : iMapService.listOnline()) {
MapVO mapDetail = iMapService.getMapDetail(mapVO.getId());
RtsMapFunctionGenerateParamVO paramVO = new RtsMapFunctionGenerateParamVO();
List<Simulation.Type> types = new ArrayList<>();
if (mapDetail.getConfigVO().isRailway()) {
types.add(Simulation.Type.RAILWAY);
} else {
types.add(Simulation.Type.METRO);
}
paramVO.setSimTypes(types);
generate(mapDetail.getId(), paramVO, loginInfo);
}
}
}

View File

@ -14,6 +14,7 @@ import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.publishData.MapPassengerFlowDataService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.training2.Training2;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.mapFunction.*;
@ -260,7 +261,8 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
supplier = getRunPlanDesignFunctionSupplier(mapId, systemNameSet, msgList, simType);
break;
case DEPOT_IL:
supplier = getDepotILFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, mapMemberVOS);
// supplier = getDepotILFunctionSupplier(mapId, systemNameSet, msgList, prefixMsg, simType, mapMemberVOS);
supplier = () -> null;
break;
case YJDDZH:
supplier = getEmergencyFunctionSupplier(mapId, systemNameSet, msgList, Simulation.Type.EMERGENCY);
@ -337,6 +339,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
Supplier<RtsMapFunctionCreateVO> stationExamSystem = getExamFunctionSupplier(mapId, systemNameSet, msgList, simType);
Supplier<RtsMapFunctionCreateVO> joint = getJointFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional);
Supplier<RtsMapFunctionCreateVO> trainingDesign = getTrainingDesignFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType, dispatcherOptional);
Supplier<RtsMapFunctionCreateVO> trainingRoom = getTrainingRoomFunctionSupplier(mapId, systemNameSet, msgList, msgPrefix, simType);
fillFunctions.add(dispatchSystem);
fillFunctions.add(stationSystem);
@ -346,10 +349,29 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
fillFunctions.add(stationExamSystem);
fillFunctions.add(joint);
fillFunctions.add(trainingDesign);
fillFunctions.add(trainingRoom);
return fillFunctions;
}
private Supplier<RtsMapFunctionCreateVO> getTrainingRoomFunctionSupplier(long mapId, Set<String> systemNameSet, List<String> msgList, String msgPrefix, Simulation.Type simType) {
//实训设计
return () -> {
String name = "实训室";
if (systemNameSet.contains(name)) {
msgList.add(String.format("%s已存在不生成", name));
return null;
}
Map<SimulationWorkParamVO.Item, String> itemMap = new HashMap<>();
itemMap.put(SimulationWorkParamVO.Item.REAL_DEVICE, null);
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
.trainingDesign(true)
.hasMemberManager(true)
.hasDeviceManager(true)
.build();
return buildCreateVO(mapId, name, name, simType, itemMap, domConfig);
};
}
private Supplier<RtsMapFunctionCreateVO> getTrainingDesignFunctionSupplier(long mapId, Set<String> systemNameSet, List<String> msgList, String msgPrefix, Simulation.Type simType, Optional<MapMemberVO> dispatcherOptional) {
//实训设计
return () -> {
@ -423,6 +445,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
.hasVoice(true)
.hasTraining(true)
.trainingType(Training2.Type.SCENE)
.hasMemberManager(true)
.build();
return buildCreateVO(mapId, name, name, simType, null, domConfig);
@ -439,6 +462,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
.hasVoice(true)
.hasTraining(true)
.trainingType(Training2.Type.SINGLE)
.build();
return buildCreateVO(mapId, name, name, simType, null, domConfig);
};

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.vo;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.training2.Training2;
import lombok.*;
import org.springframework.util.CollectionUtils;
@ -98,6 +99,8 @@ public class SimulationWorkParamVO {
private boolean hasTraining;
private Training2.Type trainingType;
private boolean hasExam;
private boolean trainingDesign;
@ -106,6 +109,9 @@ public class SimulationWorkParamVO {
private boolean hasVoice;
/**
* 是综合演练目前仅决定了是否显示生成仿真二维码
*/
private boolean isJoint;
private boolean hasDeviceManager;