Merge remote-tracking branch 'origin/test-training2' into test-training2
This commit is contained in:
commit
a45f0a3295
@ -24,8 +24,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.SocketUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -172,6 +177,7 @@ public class PaperUserService {
|
|||||||
long paperTime = Duration.between(paper.getStartTime(), now).toMinutes();//实际做题时长min
|
long paperTime = Duration.between(paper.getStartTime(), now).toMinutes();//实际做题时长min
|
||||||
for (PaperUserQuestion uq : userQuestionList) {
|
for (PaperUserQuestion uq : userQuestionList) {
|
||||||
PaperRule rule = ruleIdMap.get(uq.getRuleId());
|
PaperRule rule = ruleIdMap.get(uq.getRuleId());
|
||||||
|
|
||||||
switch (PaperQType.GroupType.getItem(uq.getType())) {
|
switch (PaperQType.GroupType.getItem(uq.getType())) {
|
||||||
case Common:
|
case Common:
|
||||||
scoreCommon += calculateCommonScore(uq, rule);break;
|
scoreCommon += calculateCommonScore(uq, rule);break;
|
||||||
@ -204,16 +210,26 @@ public class PaperUserService {
|
|||||||
* 获取题的最终得分
|
* 获取题的最终得分
|
||||||
*/
|
*/
|
||||||
private int calculateCommonScore(PaperUserQuestion puq, PaperRule rule) {
|
private int calculateCommonScore(PaperUserQuestion puq, PaperRule rule) {
|
||||||
// PaperQuestionExample example = new PaperQuestionExample();
|
|
||||||
// example.createCriteria().andIdEqualTo(puq.getQuestionId());
|
|
||||||
// PaperQuestion question = pagerQuestionDAO.selectByExample(example).get(0);
|
|
||||||
if (PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))) {//题答对时
|
if (PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))) {//题答对时
|
||||||
// PaperRule rule = ruleMap.get(this.getPaperQuestionType(question));
|
|
||||||
return rule.getScore();
|
return rule.getScore();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPercentage(double score,int sumScore,int ruleScore) {
|
||||||
|
if(score >= sumScore){
|
||||||
|
return ruleScore;
|
||||||
|
}
|
||||||
|
int d = sumScore * 100;
|
||||||
|
if(sumScore >=10){
|
||||||
|
d = sumScore ;
|
||||||
|
}
|
||||||
|
double t = score / d;
|
||||||
|
if(t <=0.5){
|
||||||
|
return (int)Math.round(t * ruleScore);
|
||||||
|
}
|
||||||
|
return (int)Math.floor(t * ruleScore);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取题的最终得分
|
* 获取题的最终得分
|
||||||
@ -226,12 +242,9 @@ public class PaperUserService {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),PaperSubmitAnswerReqVo.AnswerDetail.class);
|
PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),PaperSubmitAnswerReqVo.AnswerDetail.class);
|
||||||
double sumScore = answerDetail.getTrainDetail().stream().mapToDouble(PaperTrainAnswerDetail::getScore).sum();
|
int sumScore = answerDetail.getSumScore();
|
||||||
double dd = sumScore / (rule.getScore() * 100);
|
double totalScore = answerDetail.getTrainDetail().stream().mapToDouble(PaperTrainAnswerDetail::getScore).sum();
|
||||||
if(dd > 0){
|
return getPercentage(totalScore,sumScore,rule.getScore());
|
||||||
return (int)Math.round(dd);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ import club.joylink.rtss.entity.paper.PaperUserQuestion;
|
|||||||
import club.joylink.rtss.entity.paper.PaperUserQuestionExample;
|
import club.joylink.rtss.entity.paper.PaperUserQuestionExample;
|
||||||
import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
||||||
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
||||||
import club.joylink.rtss.entity.training2.PublishedTraining2;
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssert;
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.exception.PaperExceptionAssert;
|
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||||
import club.joylink.rtss.services.training2.Training2PublishService;
|
import club.joylink.rtss.services.training2.Training2PublishService;
|
||||||
@ -21,10 +19,8 @@ import club.joylink.rtss.vo.client.training2.ScoringRuleVO;
|
|||||||
import club.joylink.rtss.vo.client.training2.Step2VO;
|
import club.joylink.rtss.vo.client.training2.Step2VO;
|
||||||
import club.joylink.rtss.vo.paper.*;
|
import club.joylink.rtss.vo.paper.*;
|
||||||
import club.joylink.rtss.vo.training2.publish.PublishedTraining2DetailRspVo;
|
import club.joylink.rtss.vo.training2.publish.PublishedTraining2DetailRspVo;
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -78,24 +74,22 @@ public class PaperUserSubmitAnswerService {
|
|||||||
rsp.setPqId(req.getPqId());
|
rsp.setPqId(req.getPqId());
|
||||||
rsp.setType(req.getType());
|
rsp.setType(req.getType());
|
||||||
rsp.setSubType(req.getSubType());
|
rsp.setSubType(req.getSubType());
|
||||||
String tmpAnswer = null;
|
TrainAnswerVO answerVO;
|
||||||
|
BusinessExceptionAssertEnum.DATA_INVALID.assertTrue(Objects.nonNull(req.getType()),"未知的考试类型");
|
||||||
//处理用户提交的答案
|
//处理用户提交的答案
|
||||||
if(req.getType() == PaperQType.GroupType.Common){
|
if(req.getType() == PaperQType.GroupType.Common){
|
||||||
rsp.setResult(submitCommonAnswer(puq, req));
|
answerVO = submitCommonAnswer(puq, req);
|
||||||
tmpAnswer = this.getAnswerFromSubmit(req);
|
}else{
|
||||||
}else if(req.getType() == PaperQType.GroupType.Training){
|
|
||||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue((req.getSubType() != PaperQType.SubType.Single && req.getSubType() != PaperQType.SubType.Scene),String.format("未知答题类型[%s]",req.getSubType()));
|
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue((req.getSubType() != PaperQType.SubType.Single && req.getSubType() != PaperQType.SubType.Scene),String.format("未知答题类型[%s]",req.getSubType()));
|
||||||
TrainAnswerVO answerVO = this.submitTrainingAnswer(req,puq);
|
answerVO = this.submitTrainingAnswer(req,puq);
|
||||||
rsp.setResult(answerVO.getState());
|
|
||||||
tmpAnswer = JsonUtils.writeValueAsString(answerVO.getDetail());
|
|
||||||
}
|
}
|
||||||
|
rsp.setResult(answerVO.getState());
|
||||||
//记录用户答题情况
|
//记录用户答题情况
|
||||||
PaperUserQuestion record = new PaperUserQuestion();
|
PaperUserQuestion record = new PaperUserQuestion();
|
||||||
record.setId(puq.getId());
|
record.setId(puq.getId());
|
||||||
record.setState(rsp.getResult().getValue());
|
record.setState(rsp.getResult().getValue());
|
||||||
record.setTmpAnswer(tmpAnswer);
|
record.setTmpAnswer(answerVO.getDetailStr());
|
||||||
paperUserQuestionDAO.updateByPrimaryKeySelective(record);
|
paperUserQuestionDAO.updateByPrimaryKeySelective(record);
|
||||||
//
|
|
||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +106,7 @@ public class PaperUserSubmitAnswerService {
|
|||||||
// PaperExceptionAssert.PuqCanSubmit.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
// PaperExceptionAssert.PuqCanSubmit.assertTrue(PaperQuestionState.Undo.equals(PaperQuestionState.getItem(puq.getState())), "只有未做的题才能提交答案");
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrainAnswerVO submitTrainingAnswer(PaperSubmitAnswerReqVo reqVo,PaperUserQuestion puq){
|
private TrainAnswerVO<PaperSubmitAnswerReqVo.AnswerDetail> submitTrainingAnswer(PaperSubmitAnswerReqVo reqVo,PaperUserQuestion puq){
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Strings.isNullOrEmpty(reqVo.getTrainAnswerDetail().getCosplayMemberId()),"实训考试没有对应的角色");
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(Strings.isNullOrEmpty(reqVo.getTrainAnswerDetail().getCosplayMemberId()),"实训考试没有对应的角色");
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(CollectionUtils.isEmpty(reqVo.getTrainAnswerDetail().getTrainDetail()),"实训考试没有对应的操作");
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(CollectionUtils.isEmpty(reqVo.getTrainAnswerDetail().getTrainDetail()),"实训考试没有对应的操作");
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(reqVo.getTrainAnswerDetail().getTrainDetail().stream().anyMatch(d->Objects.isNull(d.getStepId())),"实训步骤id不能为空");
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(reqVo.getTrainAnswerDetail().getTrainDetail().stream().anyMatch(d->Objects.isNull(d.getStepId())),"实训步骤id不能为空");
|
||||||
@ -126,7 +120,7 @@ public class PaperUserSubmitAnswerService {
|
|||||||
}else if(reqVo.getSubType() == PaperQType.SubType.Scene){
|
}else if(reqVo.getSubType() == PaperQType.SubType.Scene){
|
||||||
return this.submitTrainingAnswerForScene(detailVO,reqVo);
|
return this.submitTrainingAnswerForScene(detailVO,reqVo);
|
||||||
}
|
}
|
||||||
return new TrainAnswerVO(PaperQuestionState.Wrong, null);
|
return new TrainAnswerVO<PaperSubmitAnswerReqVo.AnswerDetail>(PaperQuestionState.Wrong, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,13 +129,13 @@ public class PaperUserSubmitAnswerService {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private TrainAnswerVO submitTrainingAnswerForSingle(PaperSubmitAnswerReqVo req,PublishedTraining2DetailRspVo trainDetailVO/*List<Step2VO> allStepList,PaperUserQuestion puq*/) {
|
private TrainAnswerVO submitTrainingAnswerForSingle(PaperSubmitAnswerReqVo req, PublishedTraining2DetailRspVo trainDetailVO/*List<Step2VO> allStepList,PaperUserQuestion puq*/) {
|
||||||
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(StringUtils.hasText(trainDetailVO.getStepJson()),"场景实训没有对应的操作步骤");
|
BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(StringUtils.hasText(trainDetailVO.getStepJson()),"场景实训没有对应的操作步骤");
|
||||||
List<Step2VO> allStepList = JsonUtils.readCollection(trainDetailVO.getStepJson(),ArrayList.class, Step2VO.class);
|
List<Step2VO> allStepList = JsonUtils.readCollection(trainDetailVO.getStepJson(),ArrayList.class, Step2VO.class);
|
||||||
|
|
||||||
List<Step2VO> cosplayStepList = allStepList.stream().filter(d->Objects.equals(d.getMemberId(),req.getTrainAnswerDetail().getCosplayMemberId())).collect(Collectors.toList());
|
List<Step2VO> cosplayStepList = allStepList.stream().filter(d->Objects.equals(d.getMemberId(),req.getTrainAnswerDetail().getCosplayMemberId())).collect(Collectors.toList());
|
||||||
if(req.getTrainAnswerDetail().getTrainDetail().size() != cosplayStepList.size()){
|
if(req.getTrainAnswerDetail().getTrainDetail().size() != cosplayStepList.size()){
|
||||||
return new TrainAnswerVO(PaperQuestionState.Wrong, req.getTrainAnswerDetail());
|
return new TrainAnswerVO<>(PaperQuestionState.Wrong, req.getTrainAnswerDetail());
|
||||||
}
|
}
|
||||||
if(req.getTrainAnswerDetail().getTrainDetail().stream().allMatch(PaperTrainAnswerDetail::isSuccess)){
|
if(req.getTrainAnswerDetail().getTrainDetail().stream().allMatch(PaperTrainAnswerDetail::isSuccess)){
|
||||||
return new TrainAnswerVO(PaperQuestionState.Right, req.getTrainAnswerDetail());
|
return new TrainAnswerVO(PaperQuestionState.Right, req.getTrainAnswerDetail());
|
||||||
@ -162,12 +156,12 @@ public class PaperUserSubmitAnswerService {
|
|||||||
|
|
||||||
Map<String,PaperTrainAnswerDetail> answerDetailMap = answerDetailList.stream().collect(Collectors.toMap(d->d.getStepId().toString(),Function.identity()));
|
Map<String,PaperTrainAnswerDetail> answerDetailMap = answerDetailList.stream().collect(Collectors.toMap(d->d.getStepId().toString(),Function.identity()));
|
||||||
List<PaperTrainAnswerDetail> resultAnswerDetailList = new ArrayList<>(allDetailVOList.size());
|
List<PaperTrainAnswerDetail> resultAnswerDetailList = new ArrayList<>(allDetailVOList.size());
|
||||||
|
int sumScore = allDetailVOList.stream().mapToInt(d->(int)d.getScore()).sum();
|
||||||
|
|
||||||
for (ScoringRuleVO.DetailVO detailVO : allDetailVOList) {
|
for (ScoringRuleVO.DetailVO detailVO : allDetailVOList) {
|
||||||
PaperTrainAnswerDetail answerDetail = answerDetailMap.get(detailVO.getElementId());
|
PaperTrainAnswerDetail answerDetail = answerDetailMap.get(detailVO.getElementId());
|
||||||
if(Objects.nonNull(answerDetail)){
|
if(Objects.nonNull(answerDetail)){
|
||||||
answerDetail.setScore(detailVO.getScore());
|
answerDetail.setScore(detailVO.getScore());
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
answerDetail = new PaperTrainAnswerDetail();
|
answerDetail = new PaperTrainAnswerDetail();
|
||||||
answerDetail.setScore(0F);
|
answerDetail.setScore(0F);
|
||||||
@ -176,6 +170,7 @@ public class PaperUserSubmitAnswerService {
|
|||||||
}
|
}
|
||||||
resultAnswerDetailList.add(answerDetail);
|
resultAnswerDetailList.add(answerDetail);
|
||||||
}
|
}
|
||||||
|
req.getTrainAnswerDetail().setSumScore(sumScore);
|
||||||
req.getTrainAnswerDetail().setTrainDetail(resultAnswerDetailList);
|
req.getTrainAnswerDetail().setTrainDetail(resultAnswerDetailList);
|
||||||
return new TrainAnswerVO(PaperQuestionState.SECEN_CUL,req.getTrainAnswerDetail());
|
return new TrainAnswerVO(PaperQuestionState.SECEN_CUL,req.getTrainAnswerDetail());
|
||||||
|
|
||||||
@ -183,7 +178,7 @@ public class PaperUserSubmitAnswerService {
|
|||||||
/**
|
/**
|
||||||
* 处理理论题答案
|
* 处理理论题答案
|
||||||
*/
|
*/
|
||||||
private PaperQuestionState submitCommonAnswer(PaperUserQuestion puq, PaperSubmitAnswerReqVo req) {
|
private TrainAnswerVO<String> submitCommonAnswer(PaperUserQuestion puq, PaperSubmitAnswerReqVo req) {
|
||||||
//题目
|
//题目
|
||||||
PaperQuestionExample pqExample = new PaperQuestionExample();
|
PaperQuestionExample pqExample = new PaperQuestionExample();
|
||||||
pqExample.createCriteria().andIdEqualTo(puq.getQuestionId());
|
pqExample.createCriteria().andIdEqualTo(puq.getQuestionId());
|
||||||
@ -192,7 +187,12 @@ public class PaperUserSubmitAnswerService {
|
|||||||
final String qAn = this.getAnswerFromQuestion(pq);
|
final String qAn = this.getAnswerFromQuestion(pq);
|
||||||
final String sAn = this.getAnswerFromSubmit(req);
|
final String sAn = this.getAnswerFromSubmit(req);
|
||||||
//
|
//
|
||||||
return qAn.equals(sAn) ? PaperQuestionState.Right : PaperQuestionState.Wrong;
|
PaperQuestionState qState = PaperQuestionState.Wrong;
|
||||||
|
if(qAn.equals(sAn)){
|
||||||
|
qState = PaperQuestionState.Right;
|
||||||
|
}
|
||||||
|
TrainAnswerVO vo = new TrainAnswerVO(qState,sAn);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAnswerFromQuestion(PaperQuestion pq) {
|
private String getAnswerFromQuestion(PaperQuestion pq) {
|
||||||
|
@ -323,10 +323,6 @@ public class StationOperateHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 车站状态选择切换
|
* 车站状态选择切换
|
||||||
* @param simulation 仿真实体
|
|
||||||
* @param stationCode 车站编码
|
|
||||||
* @param routeSetMode 排路方式
|
|
||||||
* @param planControl 计划控制
|
|
||||||
*/
|
*/
|
||||||
@OperateHandlerMapping(type = Operation.Type.Station_Switch_Route_Set_Model)
|
@OperateHandlerMapping(type = Operation.Type.Station_Switch_Route_Set_Model)
|
||||||
public List<String> switchRouteSetModel(Simulation simulation, List<RouteModelParam> routeSetModeParams) {
|
public List<String> switchRouteSetModel(Simulation simulation, List<RouteModelParam> routeSetModeParams) {
|
||||||
|
@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -616,6 +617,15 @@ public class AtsStationService {
|
|||||||
logList.add(String.format("车站【%s(%s)】 禁止转换", station.getName(), station.getCode()));
|
logList.add(String.format("车站【%s(%s)】 禁止转换", station.getName(), station.getCode()));
|
||||||
} else {
|
} else {
|
||||||
applyOperation.setApplyDateTime(simulation.getCorrectSystemTime());
|
applyOperation.setApplyDateTime(simulation.getCorrectSystemTime());
|
||||||
|
if (applyOperation.isCenterApplication()) { // 如果中心请求,需要车站同意
|
||||||
|
applyOperation.setApprovalMember(Arrays.asList(station.getController()));
|
||||||
|
} else { // 车站同意需要中心同意
|
||||||
|
applyOperation.setApprovalMember(
|
||||||
|
simulation.getSimulationMembers().stream()
|
||||||
|
.filter(s -> Objects.equals(s.getType(), SimulationMember.Type.DISPATCHER))
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
station.setOperationModeApplication(applyOperation);
|
station.setOperationModeApplication(applyOperation);
|
||||||
}
|
}
|
||||||
} else { // 非分散自律抛出异常
|
} else { // 非分散自律抛出异常
|
||||||
@ -654,7 +664,7 @@ public class AtsStationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 发送申请转换操作模式申请
|
||||||
* @param simulation
|
* @param simulation
|
||||||
* @param station
|
* @param station
|
||||||
*/
|
*/
|
||||||
@ -668,29 +678,27 @@ public class AtsStationService {
|
|||||||
station.setOperationModeApplication(null);
|
station.setOperationModeApplication(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimulationMember simulationMember = null;
|
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
|
||||||
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;
|
return;
|
||||||
} else if (simulationMember.isRobot()) {
|
}
|
||||||
doOperationModeSwitch(station);
|
Set<String> userSet = modeApplication.getApprovalMember().stream()
|
||||||
} else {
|
.filter(m -> !m.isRobot()).map(club.joylink.rtss.simulation.SimulationMember::getUserId).collect(Collectors.toSet());
|
||||||
SocketMessageVO<Station.OperationModeApplication> socketMessageVO =
|
if (!CollectionUtils.isEmpty(userSet)) {
|
||||||
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), modeApplication);
|
Map<String, Object> messageMap = new HashMap<>();
|
||||||
stompMessageService.sendToUser(Set.of(simulationMember.getUserId()), socketMessageVO);
|
messageMap.put("source", modeApplication.getSource());
|
||||||
|
messageMap.put("target", modeApplication.getTarget());
|
||||||
|
messageMap.put("applyMember", modeApplication.getApplicationMember().getId());
|
||||||
|
messageMap.put("applyDateTime", modeApplication.getApplyDateTime());
|
||||||
|
SocketMessageVO<Map<String, Object>> socketMessageVO =
|
||||||
|
SocketMessageFactory.build(WebSocketMessageType.Simulation_Operation_Mode_Apply, simulation.getId(), messageMap);
|
||||||
|
stompMessageService.sendToUser(userSet, socketMessageVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作模式直接转换
|
* 操作模式直接转换
|
||||||
*/
|
*/
|
||||||
private void doOperationModeSwitch(Station station) {
|
public void doOperationModeSwitch(Station station) {
|
||||||
Station.OperationModeApplication applyOperation = station.getOperationModeApplication();
|
Station.OperationModeApplication applyOperation = station.getOperationModeApplication();
|
||||||
station.setOperationMode(applyOperation.getTarget());
|
station.setOperationMode(applyOperation.getTarget());
|
||||||
station.setOperationModeApplication(null);
|
station.setOperationModeApplication(null);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.CI;
|
package club.joylink.rtss.simulation.cbtc.CI;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
|
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
|
||||||
@ -36,6 +37,9 @@ public class CiLogic {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StationDirectionService stationDirectionService;
|
private StationDirectionService stationDirectionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AtsStationService atsStationService;
|
||||||
|
|
||||||
public void runForTrainPosition(Simulation simulation){
|
public void runForTrainPosition(Simulation simulation){
|
||||||
// 采集真实设备状态
|
// 采集真实设备状态
|
||||||
deviceStatusCollector.collect(simulation);
|
deviceStatusCollector.collect(simulation);
|
||||||
@ -62,6 +66,8 @@ public class CiLogic {
|
|||||||
if (simulation.getRepository().getConfig().isRailway()) {
|
if (simulation.getRepository().getConfig().isRailway()) {
|
||||||
// 车站
|
// 车站
|
||||||
simulation.getRepository().getStationList().stream().forEach(station -> {
|
simulation.getRepository().getStationList().stream().forEach(station -> {
|
||||||
|
// 车站站控操作模式转换
|
||||||
|
atsStationService.replyOperationMode(simulation, station);
|
||||||
// 允许自律状态刷新
|
// 允许自律状态刷新
|
||||||
station.refreshAllowAutonomyStatus();
|
station.refreshAllowAutonomyStatus();
|
||||||
// 接、发辅助按钮倒计时刷新
|
// 接、发辅助按钮倒计时刷新
|
||||||
|
@ -595,8 +595,16 @@ public class Station extends MayOutOfOrderDevice {
|
|||||||
*/
|
*/
|
||||||
private OperationMode target;
|
private OperationMode target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请人
|
||||||
|
*/
|
||||||
private SimulationMember applicationMember;
|
private SimulationMember applicationMember;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人
|
||||||
|
*/
|
||||||
|
private List<SimulationMember> approvalMember;
|
||||||
|
|
||||||
private LocalDateTime applyDateTime;
|
private LocalDateTime applyDateTime;
|
||||||
|
|
||||||
public OperationModeApplication(SimulationMember applicantMember, OperationMode source, OperationMode target) {
|
public OperationModeApplication(SimulationMember applicantMember, OperationMode source, OperationMode target) {
|
||||||
@ -642,6 +650,16 @@ public class Station extends MayOutOfOrderDevice {
|
|||||||
return stationApplication && centerToShunt();
|
return stationApplication && centerToShunt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人全部是机器人
|
||||||
|
*/
|
||||||
|
public boolean isRobotApproval() {
|
||||||
|
if (CollectionUtils.isEmpty(approvalMember)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return approvalMember.stream().allMatch(SimulationMember::isRobot);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 中心与调车相互转换
|
* 中心与调车相互转换
|
||||||
*/
|
*/
|
||||||
|
@ -15,9 +15,11 @@ import lombok.Setter;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -196,6 +198,11 @@ public class StorageStation extends StorageStatusDevice {
|
|||||||
*/
|
*/
|
||||||
private String applicationMemberId;
|
private String applicationMemberId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批者ID
|
||||||
|
*/
|
||||||
|
private List<String> approvalMemberIds;
|
||||||
|
|
||||||
private LocalDateTime applyDateTime;
|
private LocalDateTime applyDateTime;
|
||||||
|
|
||||||
public static OperationModeApplicationStorage convert2Storage(Station.OperationModeApplication application) {
|
public static OperationModeApplicationStorage convert2Storage(Station.OperationModeApplication application) {
|
||||||
@ -207,13 +214,16 @@ public class StorageStation extends StorageStatusDevice {
|
|||||||
storage.setSource(application.getSource());
|
storage.setSource(application.getSource());
|
||||||
storage.setTarget(application.getTarget());
|
storage.setTarget(application.getTarget());
|
||||||
storage.setApplyDateTime(application.getApplyDateTime());
|
storage.setApplyDateTime(application.getApplyDateTime());
|
||||||
|
storage.setApprovalMemberIds(application.getApprovalMember().stream().map(SimulationMember::getId).collect(Collectors.toList()));
|
||||||
return storage;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Station.OperationModeApplication recover2Simulation(Simulation simulation){
|
public Station.OperationModeApplication recover2Simulation(Simulation simulation){
|
||||||
SimulationMember simulationMember = simulation.getSimulationMemberById(applicationMemberId);
|
SimulationMember simulationMember = simulation.getSimulationMemberById(applicationMemberId);
|
||||||
|
List<SimulationMember> approvalMember = approvalMemberIds.stream().map(simulation::getSimulationMemberById).collect(Collectors.toList());
|
||||||
Station.OperationModeApplication application =new Station.OperationModeApplication(simulationMember, source, target);
|
Station.OperationModeApplication application =new Station.OperationModeApplication(simulationMember, source, target);
|
||||||
application.setApplyDateTime(applyDateTime);
|
application.setApplyDateTime(applyDateTime);
|
||||||
|
application.setApprovalMember(approvalMember);
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,9 +570,16 @@ public class SimulationRobotService {
|
|||||||
if (simulation.getScript() != null && simulation.getScript().isBgSet()) {
|
if (simulation.getScript() != null && simulation.getScript().isBgSet()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
simulation.getRepository().getStationList().stream().filter(station -> station.getOperationModeApplication() != null)
|
// 实训场景模式,已设置背景处于编制状态的实训,不做自动转换处理
|
||||||
.forEach(station -> atsStationService.replyOperationMode(simulation, station));
|
Training2 training2 = simulation.getTraining2();
|
||||||
|
if (training2 != null && training2.isScene() && StringUtils.hasText(training2.getBgSceneJson()) && !training2.isRunning()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
simulation.getRepository().getStationList().stream()
|
||||||
|
.filter(station -> station.getOperationModeApplication() != null && station.getOperationModeApplication().isRobotApproval())
|
||||||
|
.forEach(station -> atsStationService.doOperationModeSwitch(station));
|
||||||
|
}
|
||||||
|
|
||||||
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train, SpeedCurve speedCurve, float remainDistance) {
|
private void doControlBySpeedCurve(Simulation simulation, VirtualRealityTrain train, SpeedCurve speedCurve, float remainDistance) {
|
||||||
if (speedCurve.equals(SpeedCurve.ZERO)) {
|
if (speedCurve.equals(SpeedCurve.ZERO)) {
|
||||||
this.doBreakMax(simulation, train);
|
this.doBreakMax(simulation, train);
|
||||||
|
@ -51,6 +51,7 @@ public class PaperSubmitAnswerReqVo {
|
|||||||
@Data
|
@Data
|
||||||
public static class AnswerDetail{
|
public static class AnswerDetail{
|
||||||
private String cosplayMemberId;
|
private String cosplayMemberId;
|
||||||
|
private int sumScore;
|
||||||
private List<PaperTrainAnswerDetail> trainDetail;
|
private List<PaperTrainAnswerDetail> trainDetail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,27 @@
|
|||||||
package club.joylink.rtss.vo.paper;
|
package club.joylink.rtss.vo.paper;
|
||||||
|
|
||||||
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class TrainAnswerVO {
|
public class TrainAnswerVO<V> {
|
||||||
private PaperQuestionState state;
|
private PaperQuestionState state;
|
||||||
private PaperSubmitAnswerReqVo.AnswerDetail detail;
|
private V detail;
|
||||||
|
|
||||||
|
public String getDetailStr(){
|
||||||
|
if(Objects.isNull(detail)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(this.detail instanceof String){
|
||||||
|
return this.detail.toString();
|
||||||
|
}
|
||||||
|
return JsonUtils.writeValueAsString(this.detail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user