Merge remote-tracking branch 'origin/test-training2' into test-training2

This commit is contained in:
joylink_zhangsai 2023-02-10 17:09:57 +08:00
commit 0a817bdb82
34 changed files with 743 additions and 127 deletions

View File

@ -7,6 +7,10 @@ ALTER TABLE `rts_paper_user_question`
ADD COLUMN `sub_type` bigint not NULL COMMENT '规则类型:理论题(1-单选题2-多选题3-判断题);实训题(4-单操实训5-场景实训)' AFTER `type`;
ALTER TABLE `rts_paper_user_question` MODIFY COLUMN tmp_answer VARCHAR(1000);
ALTER TABLE `rts_paper_user_question` MODIFY COLUMN tmp_answer longtext;
ALTER TABLE `rts_paper_rule` ADD COLUMN scene_detail VARCHAR(1000) COMMENT '场景实训考试的规则';
ALTER TABLE `rts_paper_user_question`
ADD COLUMN `scene_cosplay_id` varchar(10) COMMENT '场景实训考试扮演的角色';

View File

@ -3,6 +3,8 @@ package club.joylink.rtss.entity.paper;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
import club.joylink.rtss.vo.paper.PaperCompositionState;
import lombok.Data;
/**
@ -82,7 +84,8 @@ public class PaperComposition implements Serializable {
private LocalDateTime updateTime;
/**
* 试卷蓝图状态1-正在编辑[查询修改删除]2-封存(只能查看)3- 失效只能从封存状态变更只能查看,当PaperComposition - update_id 为null 说明是同步失效的数据定于见PaperCompositionState
* 试卷蓝图状态1-正在编辑[查询修改删除]2-封存(只能查看)3- 失效只能从封存状态变更只能查看,当PaperComposition - update_id 为null 说明是同步失效的数据
* 定于见{@link PaperCompositionState}
*/
private Integer state;

View File

@ -1,6 +1,9 @@
package club.joylink.rtss.entity.paper;
import java.io.Serializable;
import java.util.List;
import club.joylink.rtss.vo.paper.PaperCompositionWithRuleVo;
import lombok.Data;
/**
@ -44,5 +47,12 @@ public class PaperRule implements Serializable {
*/
private Integer score;
/**
* 实训考试的规则
* {@link List <PaperCompositionWithRuleVo.ScenePagerRuleVO>}
*/
private String sceneDetail;
private static final long serialVersionUID = 1L;
}
}

View File

@ -553,6 +553,76 @@ public class PaperRuleExample {
addCriterion("score not between", value1, value2, "score");
return (Criteria) this;
}
public Criteria andSceneDetailIsNull() {
addCriterion("scene_detail is null");
return (Criteria) this;
}
public Criteria andSceneDetailIsNotNull() {
addCriterion("scene_detail is not null");
return (Criteria) this;
}
public Criteria andSceneDetailEqualTo(String value) {
addCriterion("scene_detail =", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailNotEqualTo(String value) {
addCriterion("scene_detail <>", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailGreaterThan(String value) {
addCriterion("scene_detail >", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailGreaterThanOrEqualTo(String value) {
addCriterion("scene_detail >=", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailLessThan(String value) {
addCriterion("scene_detail <", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailLessThanOrEqualTo(String value) {
addCriterion("scene_detail <=", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailLike(String value) {
addCriterion("scene_detail like", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailNotLike(String value) {
addCriterion("scene_detail not like", value, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailIn(List<String> values) {
addCriterion("scene_detail in", values, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailNotIn(List<String> values) {
addCriterion("scene_detail not in", values, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailBetween(String value1, String value2) {
addCriterion("scene_detail between", value1, value2, "sceneDetail");
return (Criteria) this;
}
public Criteria andSceneDetailNotBetween(String value1, String value2) {
addCriterion("scene_detail not between", value1, value2, "sceneDetail");
return (Criteria) this;
}
}
/**
@ -649,4 +719,4 @@ public class PaperRuleExample {
this(condition, value, secondValue, null);
}
}
}
}

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.entity.paper;
import java.io.Serializable;
import club.joylink.rtss.vo.paper.PaperSubmitAnswerReqVo;
import lombok.Data;
/**
@ -50,9 +52,16 @@ public class PaperUserQuestion implements Serializable {
private Integer state;
/**
* 答案内容
* 答题存储的答案
* 理论题 存储的时对应的答案选项
* 实训题-单操存储的是 {@link PaperSubmitAnswerReqVo.AnswerDetail}
*/
private String tmpAnswer;
/**
* 场景实训考试扮演的角色
*/
private String sceneCosplayId;
private static final long serialVersionUID = 1L;
}

View File

@ -673,6 +673,76 @@ public class PaperUserQuestionExample {
addCriterion("tmp_answer not between", value1, value2, "tmpAnswer");
return (Criteria) this;
}
public Criteria andSceneCosplayIdIsNull() {
addCriterion("scene_cosplay_id is null");
return (Criteria) this;
}
public Criteria andSceneCosplayIdIsNotNull() {
addCriterion("scene_cosplay_id is not null");
return (Criteria) this;
}
public Criteria andSceneCosplayIdEqualTo(String value) {
addCriterion("scene_cosplay_id =", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdNotEqualTo(String value) {
addCriterion("scene_cosplay_id <>", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdGreaterThan(String value) {
addCriterion("scene_cosplay_id >", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdGreaterThanOrEqualTo(String value) {
addCriterion("scene_cosplay_id >=", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdLessThan(String value) {
addCriterion("scene_cosplay_id <", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdLessThanOrEqualTo(String value) {
addCriterion("scene_cosplay_id <=", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdLike(String value) {
addCriterion("scene_cosplay_id like", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdNotLike(String value) {
addCriterion("scene_cosplay_id not like", value, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdIn(List<String> values) {
addCriterion("scene_cosplay_id in", values, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdNotIn(List<String> values) {
addCriterion("scene_cosplay_id not in", values, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdBetween(String value1, String value2) {
addCriterion("scene_cosplay_id between", value1, value2, "sceneCosplayId");
return (Criteria) this;
}
public Criteria andSceneCosplayIdNotBetween(String value1, String value2) {
addCriterion("scene_cosplay_id not between", value1, value2, "sceneCosplayId");
return (Criteria) this;
}
}
/**

View File

@ -28,6 +28,9 @@ public enum PaperExceptionAssert implements BusinessExceptionAssert {
PpValid(60020,"请求参数有效"),
PdValid(60021,"数据有效"),
PcScore(60022,"试卷定义中分数"),
PcRepeatScene(60023,"重复的场景实训规则"),
PcInvalid(60024,"试卷已失效不能作答"),
;
int code;

View File

@ -50,6 +50,8 @@ public class PaperCompositionService {
@Transactional(rollbackFor = Exception.class)
public CreatePaperCompositionRspVo createPaperCompositionWithRule(PaperCompositionWithRuleVo req, AccountVO user) {
//根据项目和名称来查如果存在则结束
// long sceneCount = req.getRuleList().stream().filter(d->d.getSubtype() == PaperQType.SubType.Scene).count();
// PaperExceptionAssert.PcRepeatScene.assertTrue(sceneCount > 1,"场景数据规则只能有一个");
PaperExceptionAssert.PcNotExisted.assertTrue(Objects.nonNull(req.getMapId()), "请选择对应的线路");
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
PaperExceptionAssert.PcNotExisted.assertTrue(CollectionUtils.isEmpty(pcList), "试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName());
@ -68,11 +70,11 @@ public class PaperCompositionService {
newPc.setUpdateTime(LocalDateTime.now());
newPc.setCreatorId(user.getId());
newPc.setState(PaperCompositionState.Editing.getValue());
int newRt = compositionDAO.insertSelective(newPc);
PaperExceptionAssert.PcStoreSuccess.assertTrue(newRt > 0, "存储试卷定义失败");
compositionDAO.insertSelective(newPc);
// PaperExceptionAssert.PcStoreSuccess.assertTrue(newRt > 0, "存储试卷定义失败");
//
pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
newPc = pcList.get(0);
// pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
// newPc = pcList.get(0);
//
if (!CollectionUtils.isEmpty(req.getRuleList())) {
final Long pcId = newPc.getId();
@ -97,8 +99,7 @@ public class PaperCompositionService {
private void createPaperCompositionRule(Long pcId, List<PaperCompositionWithRuleVo.PaperRuleVo> reqList) {
Map<String,List<PaperCompositionWithRuleVo.PaperRuleVo>> tmpList = reqList.stream().collect(Collectors.groupingBy(k->ruleMapKey(k)));
reqList.forEach(req -> {
for (PaperCompositionWithRuleVo.PaperRuleVo req : reqList) {
req.setPcId(pcId);
//
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
@ -117,7 +118,7 @@ public class PaperCompositionService {
//
ruleDAO.insertSelective(rule);
});
}
}
/**
@ -131,9 +132,7 @@ public class PaperCompositionService {
//
List<PaperComposition> pcList = this.findCompositionByCompanyIdAndName(req.getOrgId(), req.getName());
if (!CollectionUtils.isEmpty(pcList)) {
boolean exist = pcList.stream().anyMatch(c -> {
return c.getId().compareTo(curPc.getId()) != 0;
});
boolean exist = pcList.stream().anyMatch(c ->c.getId().compareTo(curPc.getId()) != 0);
PaperExceptionAssert.PcExisted.assertNotTrue(exist, "试卷定义已经存在orgId=" + req.getOrgId() + " name=" + req.getName());
}
//
@ -156,7 +155,11 @@ public class PaperCompositionService {
}
private void updateCompositionRule(List<PaperCompositionWithRuleVo.PaperRuleVo> updateRuleList, Long pcId) {
List<PaperRule> oldRuleList = this.findRuleByPcId(pcId);
PaperRuleExample ruleExample = new PaperRuleExample();
ruleExample.createCriteria().andPcIdEqualTo(pcId);
this.ruleDAO.deleteByExample(ruleExample);
this.createPaperCompositionRule(pcId,updateRuleList);
/* List<PaperRule> oldRuleList = this.findRuleByPcId(pcId);
Set<Long> oldRuleIdSet = new HashSet<>();
if (!CollectionUtils.isEmpty(oldRuleList)) {
oldRuleIdSet = oldRuleList.stream().map(PaperRule::getId).collect(Collectors.toSet());
@ -188,7 +191,7 @@ public class PaperCompositionService {
neeDelete.forEach(nd -> {
this.ruleDAO.deleteByPrimaryKey(nd);
});
}
}*/
}
/**
@ -420,10 +423,10 @@ public class PaperCompositionService {
//
final List<PaperCompositionWithRuleVo> rtList = new ArrayList<>();
if(!CollectionUtils.isEmpty(sqlPage.getResult())){
sqlPage.getResult().forEach(pc->{
for (PaperComposition pc : sqlPage.getResult()) {
List<PaperRule> prList = this.findRuleByPcId(pc.getId());
rtList.add(PaperCompositionConvertor.convert(pc, prList));
});
}
}
//
PageVO<PaperCompositionWithRuleVo> page = PageVO.convert(sqlPage,rtList);

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.entity.paper.question.PaperQuestion;
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.exception.PaperExceptionAssert;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.util.JsonUtils;
@ -92,10 +93,10 @@ public class PaperUserCreateService {
// 检测是否创建过试卷
// PaperUser oldPu = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
// PaperExceptionAssert.PcNotExisted.assertTrue(null == oldPu, "该用户的试卷已经存在pcId = " + pcId);
this.resetPaperRecord(pcId,user.getId());
// 校验试卷蓝图
PaperComposition composition = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcExisted.assertNotNull(composition, "创建试卷的试卷定义不存在pcId = " + pcId);
PaperExceptionAssert.PcInvalid.assertTrue(composition.getState() != PaperCompositionState.Invalid.getValue(), "试卷已失效不能作答pcId = " + pcId);
PaperExceptionAssert.PcCanCreatePu.assertTrue(!PaperCompositionState.Editing.equals(PaperCompositionState.getItem(composition.getState())), "编辑中的试卷定义无法用于生成用户试卷pcId = " + pcId);
LocalDateTime now = LocalDateTime.now();
if (null != composition.getStartTime() && null != composition.getEndTime()) {
@ -104,6 +105,7 @@ public class PaperUserCreateService {
// 试卷蓝图规则
List<PaperRule> ruleList = compositionService.findRuleByPcId(pcId);
PaperExceptionAssert.PcHavePr.assertCollectionNotEmpty(ruleList, "试卷定义没有规则定义无法生成用户试卷pcId = " + pcId);
this.resetPaperRecord(pcId,user.getId());
//
Long orgId = composition.getOrgId();
// 标记封存的试卷蓝图已使用
@ -112,12 +114,13 @@ public class PaperUserCreateService {
PaperUser paper = new PaperUser();
paper.setUserId(user.getId());
paper.setPcId(pcId);
paper.setOrgId(composition.getOrgId());
// paper.setOrgId(orgId);
paper.setCreateTime(LocalDateTime.now());
paper.setStartTime(LocalDateTime.now());
paper.setCreateTime(now);
paper.setStartTime(now);
// paper.setStatus(true);
paperUserDAO.insertSelective(paper);
paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
// paper = paperUserService.findByUserIdAndPcId(user.getId(), pcId);
//
// this.dispatcherQuestion(paper, composition, ruleList);
this.dispatcherQuestion2(paper, composition, ruleList);
@ -154,17 +157,16 @@ public class PaperUserCreateService {
List<PaperCompositionWithRuleVo.PaperRuleVo> voList = this.sortPaperRule(rule);
Map<Integer,List<Long>> ruleVOMapList = Maps.newHashMap();
for (PaperCompositionWithRuleVo.PaperRuleVo ruleVO : voList) {
List<Long> mapIdList = ruleVOMapList.get(ruleVO.getSubtype().getValue());
if(Objects.isNull(mapIdList)){
mapIdList = Lists.newArrayList();
ruleVOMapList.put(ruleVO.getSubtype().getValue(),mapIdList);
}
List<Long> mapIdList = ruleVOMapList.computeIfAbsent(ruleVO.getSubtype().getValue(),k-> Lists.newArrayList());
List<Long> createQuestionIdList = null;
if(ruleVO.getType() == PaperQType.GroupType.Common){
createQuestionIdList = this.dispatcherCommonQuestion2(pu, pc, ruleVO,mapIdList);
}else if(ruleVO.getType() == PaperQType.GroupType.Training){
PaperRule rule2 = PaperRuleConvertor.convert(ruleVO);
createQuestionIdList = this.dispatcherTrainingQuestion(pu, pc, rule2,mapIdList);
if(ruleVO.getSubtype() == PaperQType.SubType.Single){
createQuestionIdList = this.dispatcherTrainingQuestion(pu, pc, ruleVO,mapIdList);
}else{
dispatcherTrainScene(pu, ruleVO);
}
}
if(!CollectionUtils.isEmpty(createQuestionIdList)){
mapIdList.addAll(createQuestionIdList);
@ -247,13 +249,13 @@ public class PaperUserCreateService {
/**
* 随机选择实训题目
*/
private List<Long> dispatcherTrainingQuestion(PaperUser pu, PaperComposition pc, PaperRule rule,List<Long> existTrainIds) {
private List<Long> dispatcherTrainingQuestion(PaperUser pu, PaperComposition pc, PaperCompositionWithRuleVo.PaperRuleVo rule,List<Long> existTrainIds) {
final int qSum = rule.getAmount();//该类型问题个数
//
PublishedTraining2Example questionExample = this.trainingQuestionExample(pu, pc, rule,existTrainIds);
//符合条件的题目数目
long count = trainingDAO.countByExample(questionExample);
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype().getValue());
PaperExceptionAssert.PqEnough.assertTrue(count >= qSum, "符合条件的实训题数目过少pcId = " + pc.getId() + " pcName = " + pc.getName() + " orgId = " + pc.getOrgId() + " ruleType = " + subType.name() + " ruleSum = " + qSum);
final String orderBy = "rand()";
questionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, 0, qSum));
@ -268,30 +270,54 @@ public class PaperUserCreateService {
puq.setPuId(pu.getId());
puq.setOrgId(pc.getOrgId());
puq.setRuleId(rule.getId());
puq.setType(PaperQType.GroupType.getItem(rule.getType()).getValue());
puq.setType(rule.getType().getValue());
puq.setQuestionId(q.getId());
puq.setSubType(rule.getSubtype());
puq.setSubType(rule.getSubtype().getValue());
paperUserQuestionDAO.insertSelective(puq);
});
return findRand.stream().map(d->d.getId()).collect(Collectors.toList());
}
private void dispatcherTrainScene(PaperUser pu, PaperCompositionWithRuleVo.PaperRuleVo rule){
PaperExceptionAssert.PrNotExisted.assertTrue(!CollectionUtils.isEmpty(rule.getSceneInfo()),"场景实训规则不存在");
List<Long> allIds = rule.getSceneInfo().stream().map(PaperCompositionWithRuleVo.ScenePagerRuleVO::getPublishTrainId).collect(Collectors.toList());
PublishedTraining2Example example = new PublishedTraining2Example();
example.createCriteria().andStateEqualTo(1).andIdIn(allIds);
long count = trainingDAO.countByExample(example);
PaperExceptionAssert.PqEnough.assertTrue(allIds.size() == count, "没有足够的符合条件的实训题目");
rule.getSceneInfo().forEach(q -> {
PaperUserQuestion puq = new PaperUserQuestion();
puq.setState(PaperQuestionState.Undo.getValue());
puq.setPuId(pu.getId());
puq.setOrgId(pu.getOrgId());
puq.setRuleId(rule.getId());
puq.setType(rule.getType().getValue());
puq.setQuestionId(q.getPublishTrainId());
puq.setSceneCosplayId(q.getCosplayId());
puq.setSubType(rule.getSubtype().getValue());
paperUserQuestionDAO.insertSelective(puq);
});
}
/**
* 生成根据tag查询的条件
*/
private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperRule rule,List<Long> existTrainIds) {
String tags = rule.getTags();//规则标签list json
List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
String subTypeStr = this.paperUserService.getTrainingType(subType);
private PublishedTraining2Example trainingQuestionExample(PaperUser pu, PaperComposition pc, PaperCompositionWithRuleVo.PaperRuleVo rule,List<Long> existTrainIds) {
// String tags = rule.getTags();//规则标签list json
// List<String> tagArray = null != tags && tags.length() > 0 ? JsonUtils.readCollection(tags, ArrayList.class, String.class) : null;
// PaperQType.SubType subType = PaperQType.SubType.getItem(rule.getSubtype());
String subTypeStr = this.paperUserService.getTrainingType(rule.getSubtype());
PublishedTraining2Example questionExample = new PublishedTraining2Example();
PublishedTraining2Example.Criteria criteria = questionExample.createCriteria();
if(!CollectionUtils.isEmpty(existTrainIds)){
criteria.andIdNotIn(existTrainIds);
}
this.training2PublishService.basicQueryCriteria(criteria,pc.getMapId(),pc.getOrgId(), StringUtils.hasText(subTypeStr) ? subTypeStr.toUpperCase():null);
if(!CollectionUtils.isEmpty(tagArray)){
for (String tag : tagArray) {
if(!CollectionUtils.isEmpty(rule.getTags())){
for (String tag : rule.getTags()) {
criteria.andLabelJsonLike(String.format("%%%s%%", tag));
}
}

View File

@ -8,8 +8,10 @@ import club.joylink.rtss.entity.paper.question.PaperQuestion;
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.exception.PaperExceptionAssert;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.paper.*;
import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor;
@ -63,6 +65,7 @@ public class PaperUserService {
if(req.getGroupType() == PaperQType.GroupType.Common){
return paperQuestionService.findAllLable(req.getOrgId(),req.getSubType().name().toLowerCase());
}else if(PaperQType.GroupType.Training.equals(req.getGroupType())){
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(req.getSubType() == PaperQType.SubType.Scene,"不支持此操作");
return this.training2PublishService.findAllLabel(req.getMapId(),req.getOrgId(),req.getSubType().name().toUpperCase());
}
return Collections.emptyList();
@ -81,6 +84,7 @@ public class PaperUserService {
return paperQuestionService.queryCount(req.getOrgId(),theoryType,tagStr);
}else if(PaperQType.GroupType.Training.equals(req.getGroupType())){
// PaperExceptionAssert.PdValid.assertTrue(!PaperQType.GroupType.Training.equals(groupType),"不支持查询实训题数量");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(req.getSubType() == PaperQType.SubType.Scene,"不支持此操作");
return training2PublishService.queryCountForLabel(req.getMapId(), req.getOrgId(), req.getSubType().name().toUpperCase(),req.getTags());
}
return 0L;
@ -159,11 +163,7 @@ public class PaperUserService {
//统计最终结果
PaperComposition composition = compositionDAO.selectByPrimaryKey(paper.getPcId());
List<PaperRule> ruleList = compositionService.findRuleByPcId(paper.getPcId());
/* Map<PaperQType.SubType, PaperRule> ruleMap = new HashMap<>(ruleList.size());
ruleList.forEach(r -> {
ruleMap.put(PaperQType.SubType.getItem(r.getSubtype()), r);
});*/
Map<Long, PaperRule> ruleIdMap = ruleList.stream().collect(Collectors.toMap(d->d.getId(),Function.identity()));
Map<Long, PaperRule> ruleIdMap = ruleList.stream().collect(Collectors.toMap(PaperRule::getId,Function.identity()));
List<PaperUserQuestion> userQuestionList = findUserSortedQuestions(puId);
int scoreCommon = 0;
@ -185,7 +185,7 @@ public class PaperUserService {
endPaper.setEndTime(now);
endPaper.setScore(scoreCommon + scoreTraining);
paperUserDAO.updateByPrimaryKeySelective(endPaper);
this.deletePaperQuestion(puId);
// this.deletePaperQuestion(puId);
//
PaperSubmitRspVo rsp = new PaperSubmitRspVo();
rsp.setPuId(puId);
@ -218,16 +218,25 @@ public class PaperUserService {
* 获取题的最终得分
*/
private int calculateTrainingScore(PaperUserQuestion puq,PaperRule rule) {
// PublishedTraining2Example example = new PublishedTraining2Example();
// example.createCriteria().andIdEqualTo(puq.getQuestionId());
// PublishedTraining2 training = trainingDAO.selectByExample(example).get(0);
if (PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))) {//题答对时
// PaperRule rule = ruleMap.get(this.getTrainingType(training));
if(Objects.equals(puq.getSubType(), PaperQType.SubType.Single.getValue()) && PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))){
return rule.getScore();
}else if(Objects.equals(puq.getSubType(), PaperQType.SubType.Scene.getValue())){
if(!StringUtils.hasText(puq.getTmpAnswer())){
return 0;
}
PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),PaperSubmitAnswerReqVo.AnswerDetail.class);
double sumScore = answerDetail.getTrainDetail().stream().mapToDouble(PaperTrainAnswerDetail::getScore).sum();
double dd = sumScore / (rule.getScore() * 100);
if(dd > 0){
return (int)Math.round(dd);
}
return 0;
}
return 0;
}
/**
* 获取用户试卷试题(已排序)
*
@ -237,8 +246,9 @@ public class PaperUserService {
public List<PaperUserQuestion> findUserSortedQuestions(Long puId) {
PaperUserQuestionExample example = new PaperUserQuestionExample();
example.createCriteria().andPuIdEqualTo(puId);
example.setOrderByClause(" id asc ");
List<PaperUserQuestion> findList = paperUserQuestionDAO.selectByExample(example);
List<PaperUserQuestion> commonList = new ArrayList<>();
/* List<PaperUserQuestion> commonList = new ArrayList<>();
List<PaperUserQuestion> trainingList = new ArrayList<>();
if (!CollectionUtils.isEmpty(findList)) {
findList.forEach(puq -> {
@ -253,14 +263,15 @@ public class PaperUserService {
}
});
}
//
commonList.sort((puq1, puq2) -> puq1.getId().compareTo(puq2.getId()));
trainingList.sort((puq1, puq2) -> puq1.getId().compareTo(puq2.getId()));
//
commonList.sort(Comparator.comparing(PaperUserQuestion::getId));
trainingList.sort(Comparator.comparing(PaperUserQuestion::getId));
List<PaperUserQuestion> rt = new ArrayList<>(commonList.size() + trainingList.size());
rt.addAll(commonList);
rt.addAll(trainingList);
return rt;
rt.addAll(trainingList);*/
findList.sort(Comparator.comparing(PaperUserQuestion::getId));
return findList;
}
/**

View File

@ -17,10 +17,13 @@ import club.joylink.rtss.exception.PaperExceptionAssert;
import club.joylink.rtss.services.training2.Training2PublishService;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.training2.ScoringRuleVO;
import club.joylink.rtss.vo.client.training2.Step2VO;
import club.joylink.rtss.vo.paper.*;
import club.joylink.rtss.vo.training2.publish.PublishedTraining2DetailRspVo;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -83,7 +86,7 @@ public class PaperUserSubmitAnswerService {
break;
case Training:{
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue((req.getSubType() != PaperQType.SubType.Single && req.getSubType() != PaperQType.SubType.Scene),String.format("未知答题类型[%s]",req.getSubType()));
TrainAnswerVO answerVO = this.submitTrainingAnswer(req);
TrainAnswerVO answerVO = this.submitTrainingAnswer(req,puq);
rsp.setResult(answerVO.getState());
tmpAnswer = JsonUtils.writeValueAsString(answerVO.getDetail());
break;
@ -112,49 +115,81 @@ public class PaperUserSubmitAnswerService {
// PaperExceptionAssert.PuqCanSubmit.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
}
private TrainAnswerVO submitTrainingAnswer(PaperSubmitAnswerReqVo reqVo){
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Strings.isNullOrEmpty(reqVo.getCosplayMemberId()),"实训考试没有对应的角色");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(reqVo.getTrainDetail().stream().anyMatch(d->Objects.isNull(d.getStepId())),"实训步骤id不能为空");
private TrainAnswerVO submitTrainingAnswer(PaperSubmitAnswerReqVo reqVo,PaperUserQuestion puq){
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Strings.isNullOrEmpty(reqVo.getTrainAnswerDetail().getCosplayMemberId()),"实训考试没有对应的角色");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(reqVo.getTrainAnswerDetail().getTrainDetail().stream().anyMatch(d->Objects.isNull(d.getStepId())),"实训步骤id不能为空");
PublishedTraining2DetailRspVo detailVO = this.training2PublishService.findTrainingAllInfoById(reqVo.getPqId());
log.debug("查找对应的实训数据 type:[{}],id[{}]",reqVo.getSubType(),reqVo.getPqId());
if(CollectionUtils.isEmpty(reqVo.getTrainDetail())){
return new TrainAnswerVO(PaperQuestionState.Undo, Collections.EMPTY_LIST);
if(CollectionUtils.isEmpty(reqVo.getTrainAnswerDetail().getTrainDetail())){
return new TrainAnswerVO(PaperQuestionState.Wrong, null);
}
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(detailVO),String.format("未找到对应的实训数据[%s]",reqVo.getPqId()));
List<Step2VO> stepList = JsonUtils.readCollection(detailVO.getStepJson(),ArrayList.class, Step2VO.class);
Map<Long,PaperTrainAnswerDetail> stepMapper = reqVo.getTrainDetail().stream().collect(Collectors.toMap(d->d.getStepId(), Function.identity(),(v1,v2)->v1));
stepList = stepList.stream().filter(d->Objects.equals(d.getMemberId(),reqVo.getCosplayMemberId())).collect(Collectors.toList());
if(stepMapper.values().size() != stepList.size()){
return new TrainAnswerVO(PaperQuestionState.Wrong, reqVo.getTrainDetail());
}
if(reqVo.getSubType() == PaperQType.SubType.Single){
return this.submitTrainingAnswerForSingle(reqVo,stepMapper);
return this.submitTrainingAnswerForSingle(reqVo,stepList,puq);
}else if(reqVo.getSubType() == PaperQType.SubType.Scene){
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(false,String.format("目前不支持场景实训"));
return this.submitTrainingAnswerForScene(detailVO,reqVo,puq);
}
return null;
return new TrainAnswerVO(PaperQuestionState.Wrong, null);
}
/**
* 处理实训题答案
* @param req
* @param stepMapper
*
* @return
*/
private TrainAnswerVO submitTrainingAnswerForSingle(PaperSubmitAnswerReqVo req,Map<Long,PaperTrainAnswerDetail> stepMapper) {
if(stepMapper.values().stream().allMatch(d->d.isSuccess())){
return new TrainAnswerVO(PaperQuestionState.Right, req.getTrainDetail());
private TrainAnswerVO submitTrainingAnswerForSingle(PaperSubmitAnswerReqVo req,List<Step2VO> allStepList,PaperUserQuestion puq) {
List<Step2VO> cosplayStepList = allStepList.stream().filter(d->Objects.equals(d.getMemberId(),req.getTrainAnswerDetail().getCosplayMemberId())).collect(Collectors.toList());
if(req.getTrainAnswerDetail().getTrainDetail().size() != cosplayStepList.size()){
return new TrainAnswerVO(PaperQuestionState.Wrong, req.getTrainAnswerDetail());
}
return new TrainAnswerVO(PaperQuestionState.Wrong, req.getTrainDetail());
if(req.getTrainAnswerDetail().getTrainDetail().stream().allMatch(d->d.isSuccess())){
return new TrainAnswerVO(PaperQuestionState.Right, req.getTrainAnswerDetail());
}
return new TrainAnswerVO(PaperQuestionState.Wrong, req.getTrainAnswerDetail());
}
private TrainAnswerVO submitTrainingAnswerForScene(PublishedTraining2DetailRspVo trainVO,PaperSubmitAnswerReqVo req,List<Step2VO> stepList){
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(false,String.format("目前不支持场景实训"));
return null;
private TrainAnswerVO submitTrainingAnswerForScene(PublishedTraining2DetailRspVo trainVO,PaperSubmitAnswerReqVo req,PaperUserQuestion puq){
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(StringUtils.hasText(trainVO.getScoringRuleJson()),"场景实训没有对应的评分规则");
List<ScoringRuleVO> scoreList = JsonUtils.readCollection(trainVO.getScoringRuleJson(),ArrayList.class, ScoringRuleVO.class);
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(!CollectionUtils.isEmpty(scoreList),String.format("场景实训[%s]没有评分规则",req.getPqId()));
List<ScoringRuleVO.DetailVO> allDetailVOList = scoreList.stream().filter(d->Objects.equals(d.getMemberId(),req.getTrainAnswerDetail().getCosplayMemberId())).flatMap(d->d.getDetails().stream()).collect(Collectors.toList());
List<PaperTrainAnswerDetail> answerDetailList = req.getTrainAnswerDetail().getTrainDetail();
answerDetailList = Objects.isNull(answerDetailList) ? Collections.emptyList() : answerDetailList;
// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(allDetailVOList.size() == answerDetailList.size(),String.format("场景实训[%s] 评分规则与提交的答案数量不陪配",puq.getQuestionId()));
Map<String,PaperTrainAnswerDetail> answerDetailMap = answerDetailList.stream().collect(Collectors.toMap(d->d.getStepId().toString(),Function.identity()));
List<PaperTrainAnswerDetail> resultAnswerDetailList = new ArrayList<>(allDetailVOList.size());
for (ScoringRuleVO.DetailVO detailVO : allDetailVOList) {
PaperTrainAnswerDetail answerDetail = answerDetailMap.get(detailVO.getElementId());
if(Objects.nonNull(answerDetail)){
answerDetail.setScore(detailVO.getScore());
}else{
answerDetail = new PaperTrainAnswerDetail();
answerDetail.setScore(0F);
answerDetail.setNotExistAppend(true);
answerDetail.setStepId(Long.parseLong(detailVO.getElementId()));
}
resultAnswerDetailList.add(answerDetail);
}
/* answerDetailList = answerDetailList.stream().peek(d->{
if(Objects.isNull(d.getScore())){
d.setScore(0F);
d.setNotExistAppend(true);
}
}).collect(Collectors.toList());*/
req.getTrainAnswerDetail().setTrainDetail(resultAnswerDetailList);
return new TrainAnswerVO(PaperQuestionState.SECEN_CUL,req.getTrainAnswerDetail());
}
/**
* 处理理论题答案
@ -178,15 +213,16 @@ public class PaperUserSubmitAnswerService {
for (String an : ans) {
set.add(an.trim());
}
StringBuilder sb = new StringBuilder();
return Joiner.on(",").join(set);
/*StringBuilder sb = new StringBuilder();
set.forEach(an -> {
if (sb.length() <= 0) {
sb.append(an);
} else {
sb.append(",").append(an);
}
});
return sb.toString();
});*/
// return sb.toString();
}
private String getAnswerFromSubmit(PaperSubmitAnswerReqVo req) {
@ -194,7 +230,8 @@ public class PaperUserSubmitAnswerService {
for (String an : req.getAnswer()) {
set.add(an.trim());
}
StringBuilder sb = new StringBuilder();
return Joiner.on(",").join(set);
/*StringBuilder sb = new StringBuilder();
set.forEach(an -> {
if (sb.length() <= 0) {
sb.append(an);
@ -202,7 +239,7 @@ public class PaperUserSubmitAnswerService {
sb.append(",").append(an);
}
});
return sb.toString();
return sb.toString();*/
}
}

View File

@ -170,7 +170,18 @@ public class PermissionSubjectService {
return subjectVOList;
}
}
// findPermissionWithMapIdAndUserInfo
/**
* 根据mapId,用户id包括组织,项目查找对应的权限,并计算剩余权限数量
* @param mapId
* @param loginUserInfoVO
* @return
*/
@Deprecated
public List<PermissionSubjectVO> findPermissionCalRemains(Long mapId, LoginUserInfoVO loginUserInfoVO){
List<PermissionSubjectVO> list = findPermissionWithMapIdAndUserInfo(mapId,loginUserInfoVO);
return list;
}
private void createSystemAbilityVOForProejctOrMap(List<PermissionSubjectVO> subjectVOS,List<SystemAbility> saList){
for (PermissionSubjectVO mapVO : subjectVOS) {

View File

@ -621,6 +621,16 @@ public class Operation {
* 车站处理功能选择
*/
Station_Switch_Route_Set_Model(new Label[]{Label.CLIENT},true),
/**
* 分散自律操作模式转换
*/
Station_Switch_Control_Operation_Mode(new Label[]{Label.CLIENT},true),
/**
* 分散自律同意转换
*/
Station_Agree_Operation_Mode(new Label[]{Label.CLIENT},true),
//--------------------------- 列车 ---------------------------
/**
* 在指定区段加载一辆计划列车本地开发使用

View File

@ -330,4 +330,20 @@ public class StationOperateHandler {
public void switchRouteSetModel(Simulation simulation, String stationCode, Station.RouteSetMode routeSetMode, boolean planControl) {
atsStationService.switchRouteSetModel(simulation, stationCode, routeSetMode, planControl);
}
/**
* 车站在分散自律时操作模式转换
*/
@OperateHandlerMapping(type = Operation.Type.Station_Switch_Control_Operation_Mode)
public void controlOperationModeSwitch(Simulation simulation, SimulationMember fromMember, String stationCode, Station.OperationMode target) {
atsStationService.controlOperationModeSwitch(simulation, fromMember, stationCode, target);
}
/**
* 分散自律同意转换模式操作
*/
@OperateHandlerMapping(type = Operation.Type.Station_Agree_Operation_Mode)
public void agreeOperationModel(Simulation simulation, String stationCode) {
atsStationService.agreeOperationMode(simulation, stationCode);
}
}

View File

@ -14,6 +14,9 @@ import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
@ -580,4 +583,81 @@ public class AtsStationService {
station.setPlanControl(planControl); // 计划控制
station.setRouteSetMode(routeSetMode); // 进路排列方式
}
/**
* 车站在分散自律时操作模式转换
* @param simulation 仿真
* @param fromMember 操作角色
* @param stationCode 车站
* @param target 目的操作模式
*/
public void controlOperationModeSwitch(Simulation simulation, SimulationMember fromMember, String stationCode, Station.OperationMode target) {
Station station = getStation(simulation, stationCode);
if (Station.ControlMode.Local.equals(station.getControlMode())) {
Station.OperationModeApplication applyOperation = new Station.OperationModeApplication(fromMember, station.getOperationMode(), target);
if (applyOperation.isNoHandle()) { // 车站操作方式与目的方式相同直接返回
return;
} else if (applyOperation.isDirectConversion()) { // 如果可以直接转换
doOperationModeSwitch(station);
return;
} else if (applyOperation.isProhibitConversion()) { // 禁止转换
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed);
} else {
station.setOperationModeApplication(applyOperation);
}
} else { // 非分散自律抛出异常
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "车站控制模式不匹配");
}
}
/**
* 同意分散自律操作模式转换
*
* @param simulation 仿真
* @param stationCode 车站编码
*/
public void agreeOperationMode(Simulation simulation, String stationCode) {
Station station = getStation(simulation, stationCode);
if (station.getOperationModeApplication() != null) {
doOperationModeSwitch(station);
}
}
/**
*
* @param simulation
* @param station
*/
public void replyOperationMode(Simulation simulation, Station station) {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
if (modeApplication == null) {
return;
}
SimulationMember simulationMember = null;
if (modeApplication.isCenterApplication()) { // 如果中心请求
simulationMember = station.getController();
} else {
simulationMember = simulation.getSimulationMembers().stream()
.filter(s -> Objects.equals(s.getType(), SimulationMember.Type.DISPATCHER))
.findFirst().orElse(null);
}
if (simulationMember == null) {
return;
} else if (simulationMember.isRobot()) {
doOperationModeSwitch(station);
} else {
SocketMessageVO<Station.OperationModeApplication> socketMessageVO =
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), modeApplication);
stompMessageService.sendToUser(Set.of(simulationMember.getUserId()), socketMessageVO);
}
}
/**
* 操作模式直接转换
*/
private void doOperationModeSwitch(Station station) {
Station.OperationModeApplication applyOperation = station.getOperationModeApplication();
station.setOperationMode(applyOperation.getTarget());
station.setOperationModeApplication(null);
}
}

View File

@ -193,6 +193,10 @@ public class CtcRepository {
for (Station station : simulation.getRepository().getStationList()) {
stationRegisterMap.put(station.getCode(), new Register());
}
keyLinkControlInfo.reset();
equipmentConstructionInfo.reset();
supervisorHandOverInfo.reset();
controlFloodSignInfo.reset();
}
public void buildRouteSequence(Simulation simulation) {

View File

@ -77,6 +77,11 @@ public class ControlFloodSignInfo {
return allList;
}
public void reset(){
idGenerator.set(0);
stationDetailInfoMap.clear();
}
/**
* 详情信息
*/

View File

@ -54,6 +54,10 @@ public class EquipmentConstructionInfo {
return allList;
}
public void reset(){
idGenerator.set(0);
stationDetailInfoMap.clear();
}
/**
* 施工登记信息

View File

@ -78,6 +78,11 @@ public class KeyLinkControlInfo {
return allDetailList;
}
public void reset(){
idGenerator.set(0);
stationDetailInfoMap.clear();
}
/**
* 表详情
*/

View File

@ -59,6 +59,11 @@ public class SupervisorHandOverInfo {
return allList;
}
public void reset(){
idGenerator.set(0);
handOverDetailInfoMap.clear();
}
/**
* 一些公共属性
*/

View File

@ -14,9 +14,7 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno;
import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno;
import club.joylink.rtss.simulation.cbtc.training2.ecm.vo.ExpTypeCategory;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.*;
import org.springframework.util.CollectionUtils;
import java.time.LocalTime;
@ -36,6 +34,9 @@ public class Station extends MayOutOfOrderDevice {
ldStandList = new ArrayList<>();
controlMode = ControlMode.Center;
stationDirectionMap = new HashMap<>();
planControl = true;
routeSetMode = RouteSetMode.Plan_Set_Route;
operationMode = OperationMode.Center;
}
/**
@ -227,6 +228,18 @@ public class Station extends MayOutOfOrderDevice {
*/
private RouteSetMode routeSetMode;
/**
* 操作模式
* 控制模式分为分散自律非常站控
* 分散自律分为中心操作车站操作车站调车
*/
private OperationMode operationMode;
/**
* 操作模式
*/
private OperationModeApplication operationModeApplication;
@Override
public void reset() {
super.reset();
@ -253,6 +266,9 @@ public class Station extends MayOutOfOrderDevice {
sGuideMasterLock = false;
xGuideMasterLock = false;
counter = null;
planControl = true;
routeSetMode = RouteSetMode.Plan_Set_Route;
operationMode = OperationMode.Center;
}
public List<Stand> getStandOf(boolean right) {
@ -538,6 +554,97 @@ public class Station extends MayOutOfOrderDevice {
}
}
/**
* 操作方式
*/
public enum OperationMode {
Center("中心操作"), Station("车站操作"), Station_Shunt("车站调车");
private String label;
OperationMode(String label) {
this.label = label;
}
}
/**
* 操作模式申请信息
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class OperationModeApplication {
/**
* 是否中心申请
*/
private boolean centerApplication;
/**
* 是否车站申请
*/
private boolean stationApplication;
/**
* 源操作方式
*/
private OperationMode source;
/**
* 目的操作方式
*/
private OperationMode target;
public OperationModeApplication(SimulationMember applicantMember, OperationMode source, OperationMode target) {
this.centerApplication = Objects.equals(applicantMember.getType(), SimulationMember.Type.DISPATCHER);
this.stationApplication = Objects.equals(applicantMember.getType(), SimulationMember.Type.STATION_SUPERVISOR);
this.source = source;
this.target = target;
}
/**
* 不做处理情况
*/
public boolean isNoHandle() {
return Objects.equals(source, target);
}
/**
* 需要中心同意
*/
public boolean needCenterApply() {
return !this.isNoHandle() && stationApplication && !this.isProhibitConversion();
}
/**
* 需要车站同意
*/
public boolean needStationApply() {
return !this.isNoHandle() && centerApplication && !this.isDirectConversion() ;
}
/**
* 直接转换
*/
public boolean isDirectConversion() {
return centerApplication && centerToShunt();
}
/**
* 禁止转换
*/
public boolean isProhibitConversion() {
return stationApplication && centerToShunt();
}
/**
* 中心与调车相互转换
*/
private boolean centerToShunt() {
return (OperationMode.Center.equals(source) && OperationMode.Station_Shunt.equals(target))
|| (OperationMode.Center.equals(target) && OperationMode.Station_Shunt.equals(source));
}
}
/**
* 是否中控
*/

View File

@ -25,12 +25,14 @@ public class StorageCtcRegister {
return storageCtcRegister;
}
public void recover2Simulation(Register register) {
public Register recover2Simulation() {
Register register = new Register();
if (this.registerId != null && this.registerId != 0) {
register.getIdGenerator().set(this.registerId);
}
if (this.lines != null) {
register.getLines().addAll(this.lines);
}
return register;
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.data.storage.ctc;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
import club.joylink.rtss.simulation.cbtc.CTC.data.Register;
import club.joylink.rtss.simulation.cbtc.CTC.data.Ticket;
import club.joylink.rtss.simulation.cbtc.CTC.data.book.ControlFloodSignInfo;
import club.joylink.rtss.simulation.cbtc.CTC.data.book.EquipmentConstructionInfo;
@ -16,6 +17,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Getter
@ -42,6 +44,11 @@ public class StorageSimulationCtcDataRepository {
*/
private Map<String, StorageCtcRouteSequence> routeSequenceMap;
/**
* 车站-行车簿册
*/
private Map<String, StorageCtcRegister> stationRegisterMap;
/**
* 票据ID
*/
@ -141,12 +148,35 @@ public class StorageSimulationCtcDataRepository {
this.storageDisCmdDb = StorageDisCmdDb.convert2Storage(repository.getDisCmdDb());
// 非正常情况接发列车关键环节控制表
this.keyLinkControlInfo = repository.getKeyLinkControlInfo().getAllDetailInfo();
if (CollectionUtils.isEmpty(this.keyLinkControlInfo)) {
this.keyLinkControlInfo = null;
}
// 行车设备施工登记簿
this.equipmentConstructionInfo = repository.getEquipmentConstructionInfo().getAllDetailInfo();
if (CollectionUtils.isEmpty(this.equipmentConstructionInfo)) {
this.equipmentConstructionInfo = null;
}
// 交接班记录登记薄
this.supervisorHandOverInfo = repository.getSupervisorHandOverInfo().getAllDetailInfo();
if (CollectionUtils.isEmpty(this.supervisorHandOverInfo)) {
this.supervisorHandOverInfo = null;
}
// 防洪安全上岗签到表
this.controlFloodSignInfo = repository.getControlFloodSignInfo().getAllDetailInfo();
if (CollectionUtils.isEmpty(this.controlFloodSignInfo)) {
this.controlFloodSignInfo = null;
}
if (!repository.getStationRegisterMap().isEmpty()) {
this.stationRegisterMap = new HashMap<>(repository.getStationRegisterMap().size());
repository.getStationRegisterMap().forEach((k, v) -> {
if (!v.getLines().isEmpty()) {
this.stationRegisterMap.put(k, StorageCtcRegister.convert2Storage(v));
}
});
if (this.stationRegisterMap.isEmpty()) {
this.stationRegisterMap = null;
}
}
}
/**
@ -214,12 +244,17 @@ public class StorageSimulationCtcDataRepository {
if (!CollectionUtils.isEmpty(this.controlFloodSignInfo)) {
this.controlFloodSignInfo.forEach(detailInfo -> repository.getControlFloodSignInfo().saveDetailInfo(detailInfo));
}
if (!CollectionUtils.isEmpty(this.stationRegisterMap)) {
this.stationRegisterMap.forEach((k, v) -> repository.getStationRegisterMap().put(k, v.recover2Simulation()));
}
}
public boolean isNotEmpty() {
return this.storageCtcZoneData != null || this.storageCtcEffectData != null || this.runPlanLogList != null
|| this.routeSequenceMap != null || this.ticketId != null || this.railTicketList != null
|| this.greenLicensesList != null || this.redLicenseList != null || this.dispatchCommandId != null
|| this.dispatchCommandList != null || this.storageDisCmdDb != null;
|| this.dispatchCommandList != null || this.storageDisCmdDb != null || this.stationRegisterMap != null
|| !CollectionUtils.isEmpty(this.keyLinkControlInfo) || !CollectionUtils.isEmpty(this.supervisorHandOverInfo)
|| !CollectionUtils.isEmpty(this.equipmentConstructionInfo) || !CollectionUtils.isEmpty(this.controlFloodSignInfo);
}
}

View File

@ -70,6 +70,7 @@ public class SimulationRobotService {
}
robotReplyControlTransferApplicationLogicLoop(simulation);
robotStationControlAutoTransfer(simulation);
robotStationOperationModel(simulation);
}
/**
@ -562,6 +563,16 @@ public class SimulationRobotService {
}
}
/**
* 机器人执行车站分散自律模式操作方式转换
*/
private void robotStationOperationModel(Simulation simulation) {
if (simulation.getScript() != null && simulation.getScript().isBgSet()) {
return;
}
simulation.getRepository().getStationList().stream().filter(station -> station.getOperationModeApplication() != null)
.forEach(station -> atsStationService.replyOperationMode(simulation, station));
}
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train, SpeedCurve speedCurve, float remainDistance) {
if (speedCurve.equals(SpeedCurve.ZERO)) {
this.doBreakMax(simulation, train);

View File

@ -163,6 +163,11 @@ public enum WebSocketMessageType {
*/
Simulation_Alarm,
/**
* 仿真-分散自律-操作模式申请
*/
Simulation_Operation_Mode_Apply,
//------------------ 仿真剧本 ------------------
/**
* 仿真-剧本已加载

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.vo.paper.PaperQType;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.Getter;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
@ -138,6 +139,10 @@ public class PaperCompositionWithRuleVo {
*/
private List<String> tags;
/**
* 场景信息
*/
private List<ScenePagerRuleVO> sceneInfo;
/**
* 该类型题目数量
*/
@ -148,4 +153,29 @@ public class PaperCompositionWithRuleVo {
*/
private Integer score;
}
@Data
public static class ScenePagerRuleVO{
/**
* 实训id
*/
private Long publishTrainId;
/**
* 实训名称
*/
// private String name;
/**
* 实训参演角色
*/
// private String memberList;
/**
* 可选角色
*/
// private List<String> selectPlayId;
/**
* 扮演角色
*/
private String cosplayId;
}
}

View File

@ -27,9 +27,9 @@ public enum PaperQuestionState {
*/
TimeOut(4),
/**
* 5-没有全部回答正确针对实训场景使用
* 5-实训场景交卷时候需要计算
*/
Not_All_Right(5),
SECEN_CUL(5),
;
private Integer state;

View File

@ -46,8 +46,11 @@ public class PaperSubmitAnswerReqVo {
/**
* 实操
*/
private List<PaperTrainAnswerDetail> trainDetail;
private String cosplayMemberId;
private AnswerDetail trainAnswerDetail;
@Data
public static class AnswerDetail{
private String cosplayMemberId;
private List<PaperTrainAnswerDetail> trainDetail;
}
}

View File

@ -19,11 +19,16 @@ public class PaperTrainAnswerDetail {
*/
private boolean success;
private Integer score;
private Float score;
private boolean notExistAppend;
/**
* 客户端操作的实训,对应的id必须要传
*/
private List<TrainOperations> clientOperations;
/**
* 原有的操作列表
*/

View File

@ -11,5 +11,5 @@ import java.util.List;
@NoArgsConstructor
public class TrainAnswerVO {
private PaperQuestionState state;
private List<PaperTrainAnswerDetail> detail;
private PaperSubmitAnswerReqVo.AnswerDetail detail;
}

View File

@ -28,7 +28,10 @@ public class PaperRuleConvertor {
tmpTags = tmpTags.stream().filter(StringUtils::hasText)/*.filter(d-> !Objects.equals(d,"无"))*/.collect(Collectors.toList());
to.setTags(tmpTags);
}
if(StringUtils.hasText(from.getSceneDetail())){
List<PaperCompositionWithRuleVo.ScenePagerRuleVO> sceneRuleList = JsonUtils.readCollection(from.getSceneDetail(),ArrayList.class, PaperCompositionWithRuleVo.ScenePagerRuleVO.class);
to.setSceneInfo(sceneRuleList);
}
to.setScore(from.getScore());
to.setAmount(from.getAmount());
@ -53,6 +56,9 @@ public class PaperRuleConvertor {
} else {
to.setTags(JsonUtils.writeValueAsString(new ArrayList<String>()));
}
if(Objects.nonNull(from.getSceneInfo())){
to.setSceneDetail(JsonUtils.writeValueAsString(from.getSceneInfo()));
}
to.setScore(from.getScore());
to.setAmount(from.getAmount());
return to;

View File

@ -118,7 +118,7 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.paper.PaperComposition">
<insert id="insert" parameterType="club.joylink.rtss.entity.paper.PaperComposition" keyProperty="id" useGeneratedKeys="true" keyColumn="id">
insert into rts_paper_composition (id, `name`, profile,
map_id, org_id, start_time,
end_time, valid_duration, pass_score,
@ -132,7 +132,7 @@
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{state,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.paper.PaperComposition">
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.paper.PaperComposition" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into rts_paper_composition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">

View File

@ -9,6 +9,7 @@
<result column="tags" jdbcType="VARCHAR" property="tags" />
<result column="amount" jdbcType="INTEGER" property="amount" />
<result column="score" jdbcType="INTEGER" property="score" />
<result column="scene_detail" jdbcType="VARCHAR" property="sceneDetail" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, pc_id, `type`, subType, tags, amount, score
id, pc_id, `type`, subType, tags, amount, score, scene_detail
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.paper.PaperRuleExample" resultMap="BaseResultMap">
select
@ -109,20 +110,17 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.paper.PaperRule">
insert into rts_paper_rule (id, pc_id, `type`,
subType, tags, amount,
score)
values (#{id,jdbcType=BIGINT}, #{pcId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER},
#{subtype,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR}, #{amount,jdbcType=INTEGER},
#{score,jdbcType=INTEGER})
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.paper.PaperRule" useGeneratedKeys="true">
insert into rts_paper_rule (pc_id, `type`, subType,
tags, amount, score,
scene_detail)
values (#{pcId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{subtype,jdbcType=INTEGER},
#{tags,jdbcType=VARCHAR}, #{amount,jdbcType=INTEGER}, #{score,jdbcType=INTEGER},
#{sceneDetail,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.paper.PaperRule">
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.paper.PaperRule" useGeneratedKeys="true">
insert into rts_paper_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="pcId != null">
pc_id,
</if>
@ -141,11 +139,11 @@
<if test="score != null">
score,
</if>
<if test="sceneDetail != null">
scene_detail,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="pcId != null">
#{pcId,jdbcType=BIGINT},
</if>
@ -164,6 +162,9 @@
<if test="score != null">
#{score,jdbcType=INTEGER},
</if>
<if test="sceneDetail != null">
#{sceneDetail,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.paper.PaperRuleExample" resultType="java.lang.Long">
@ -196,6 +197,9 @@
<if test="record.score != null">
score = #{record.score,jdbcType=INTEGER},
</if>
<if test="record.sceneDetail != null">
scene_detail = #{record.sceneDetail,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -209,7 +213,8 @@
subType = #{record.subtype,jdbcType=INTEGER},
tags = #{record.tags,jdbcType=VARCHAR},
amount = #{record.amount,jdbcType=INTEGER},
score = #{record.score,jdbcType=INTEGER}
score = #{record.score,jdbcType=INTEGER},
scene_detail = #{record.sceneDetail,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -235,6 +240,9 @@
<if test="score != null">
score = #{score,jdbcType=INTEGER},
</if>
<if test="sceneDetail != null">
scene_detail = #{sceneDetail,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -245,7 +253,8 @@
subType = #{subtype,jdbcType=INTEGER},
tags = #{tags,jdbcType=VARCHAR},
amount = #{amount,jdbcType=INTEGER},
score = #{score,jdbcType=INTEGER}
score = #{score,jdbcType=INTEGER},
scene_detail = #{sceneDetail,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
</mapper>

View File

@ -11,6 +11,7 @@
<result column="question_id" jdbcType="BIGINT" property="questionId" />
<result column="state" jdbcType="INTEGER" property="state" />
<result column="tmp_answer" jdbcType="VARCHAR" property="tmpAnswer" />
<result column="scene_cosplay_id" jdbcType="VARCHAR" property="sceneCosplayId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -71,7 +72,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, pu_id, rule_id, org_id, `type`, sub_type, question_id, `state`, tmp_answer
id, pu_id, rule_id, org_id, `type`, sub_type, question_id, `state`, tmp_answer, scene_cosplay_id
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.paper.PaperUserQuestionExample" resultMap="BaseResultMap">
select
@ -114,10 +115,12 @@
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.paper.PaperUserQuestion" useGeneratedKeys="true">
insert into rts_paper_user_question (pu_id, rule_id, org_id,
`type`, sub_type, question_id,
`state`, tmp_answer)
`state`, tmp_answer, scene_cosplay_id
)
values (#{puId,jdbcType=BIGINT}, #{ruleId,jdbcType=BIGINT}, #{orgId,jdbcType=BIGINT},
#{type,jdbcType=INTEGER}, #{subType,jdbcType=INTEGER}, #{questionId,jdbcType=BIGINT},
#{state,jdbcType=INTEGER}, #{tmpAnswer,jdbcType=VARCHAR})
#{state,jdbcType=INTEGER}, #{tmpAnswer,jdbcType=VARCHAR}, #{sceneCosplayId,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.paper.PaperUserQuestion" useGeneratedKeys="true">
insert into rts_paper_user_question
@ -146,6 +149,9 @@
<if test="tmpAnswer != null">
tmp_answer,
</if>
<if test="sceneCosplayId != null">
scene_cosplay_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="puId != null">
@ -172,6 +178,9 @@
<if test="tmpAnswer != null">
#{tmpAnswer,jdbcType=VARCHAR},
</if>
<if test="sceneCosplayId != null">
#{sceneCosplayId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.paper.PaperUserQuestionExample" resultType="java.lang.Long">
@ -210,6 +219,9 @@
<if test="record.tmpAnswer != null">
tmp_answer = #{record.tmpAnswer,jdbcType=VARCHAR},
</if>
<if test="record.sceneCosplayId != null">
scene_cosplay_id = #{record.sceneCosplayId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -225,7 +237,8 @@
sub_type = #{record.subType,jdbcType=INTEGER},
question_id = #{record.questionId,jdbcType=BIGINT},
`state` = #{record.state,jdbcType=INTEGER},
tmp_answer = #{record.tmpAnswer,jdbcType=VARCHAR}
tmp_answer = #{record.tmpAnswer,jdbcType=VARCHAR},
scene_cosplay_id = #{record.sceneCosplayId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -257,6 +270,9 @@
<if test="tmpAnswer != null">
tmp_answer = #{tmpAnswer,jdbcType=VARCHAR},
</if>
<if test="sceneCosplayId != null">
scene_cosplay_id = #{sceneCosplayId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -269,7 +285,8 @@
sub_type = #{subType,jdbcType=INTEGER},
question_id = #{questionId,jdbcType=BIGINT},
`state` = #{state,jdbcType=INTEGER},
tmp_answer = #{tmpAnswer,jdbcType=VARCHAR}
tmp_answer = #{tmpAnswer,jdbcType=VARCHAR},
scene_cosplay_id = #{sceneCosplayId,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>