【实训执行逻辑、更新步骤参数修改】
This commit is contained in:
parent
6689da99ee
commit
e748120a8d
@ -131,8 +131,8 @@ public class TrainingDraftV2Controller {
|
||||
*/
|
||||
@PutMapping("/{group}/{trainingId}/step/update")
|
||||
public void updateSteps(@PathVariable("group") String group, @PathVariable("trainingId") Long trainingId
|
||||
, @RequestBody List<Step2VO> step2VOList) {
|
||||
training2DraftService.updateSteps(group, trainingId, step2VOList);
|
||||
, @RequestBody UpdateStepReqVo reqParam) {
|
||||
training2DraftService.updateSteps(group, trainingId, reqParam);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,7 +383,7 @@ public class Training2DraftService {
|
||||
* 修改实训所有步骤
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSteps(String group, Long trainingId, List<Step2VO> step2VOList) {
|
||||
public void updateSteps(String group, Long trainingId, UpdateStepReqVo reqParam) {
|
||||
DraftTraining2WithBLOBs draftTraining2 = trainingDao.selectByPrimaryKey(trainingId);
|
||||
if (draftTraining2 == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在");
|
||||
@ -392,6 +392,7 @@ public class Training2DraftService {
|
||||
Simulation simulation = this.groupSimulationService.getSimulationByGroup(group);
|
||||
DraftTraining2WithBLOBs updateObj = new DraftTraining2WithBLOBs();
|
||||
updateObj.setId(trainingId);
|
||||
List<Step2VO> step2VOList = reqParam.getStep2VOList();
|
||||
if (CollectionUtils.isEmpty(step2VOList)) {
|
||||
updateObj.setStepJson(StringUtil.EMPTY_STRING);
|
||||
updateObj.setScoringRuleJson(StringUtil.EMPTY_STRING);
|
||||
@ -404,13 +405,10 @@ public class Training2DraftService {
|
||||
handleStepId(draftTraining2, step2VOList);
|
||||
updateObj.setStepJson(JsonUtils.writeValueAsString(step2VOList));
|
||||
// 扮演者集合
|
||||
List<String> playerList = step2VOList.stream().
|
||||
filter(s -> !StringUtils.isEmpty(s.getMemberId())).map(s -> s.getMemberId())
|
||||
.distinct().sorted().collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(playerList)) {
|
||||
if (CollectionUtils.isEmpty(reqParam.getPlayerIdList())) {
|
||||
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据:无扮演者");
|
||||
}
|
||||
updateObj.setPlayerIdJson(JsonUtils.writeValueAsString(playerList));
|
||||
updateObj.setPlayerIdJson(JsonUtils.writeValueAsString(reqParam.getPlayerIdList()));
|
||||
// 背景
|
||||
StorageSimulation scenesSaving = new StorageSimulation(simulation, true);
|
||||
updateObj.setFinalScenesJson(JsonUtils.writeValueAsString(scenesSaving));
|
||||
|
@ -642,20 +642,22 @@ public class Training2Service {
|
||||
*/
|
||||
private boolean tryDoOperation(Simulation simulation, Step2 step, Operation2.SimCommand2 operation2) {
|
||||
boolean isRobot = step.getSimulationMember().isRobot(); // 角色是否是机器人
|
||||
long simCurTime = simulation.getCorrectSystemTimeStamp();
|
||||
// 未操作过
|
||||
if (Step2.StepStatus.isUndo(operation2.getStatus())) {
|
||||
if (isRobot) {
|
||||
atsOperationDispatcher.execute(simulation, step.getSimulationMember(), operation2.getOperationType().name()
|
||||
, operation2.getParams());
|
||||
return true;
|
||||
} else { // 非机器人,暂停仿真等待用户操作
|
||||
if (operation2.getSimTime() != null) {
|
||||
long simCurTime = simulation.getCorrectSystemTimeStamp();
|
||||
// 如果时间到达操作时间,或者在1s内则暂停仿真
|
||||
if (simCurTime == operation2.getSimTime() || operation2.getSimTime() < simCurTime) {
|
||||
simulation.onlyPause();
|
||||
}
|
||||
boolean isExec = true; // 是否要执行
|
||||
if (operation2.getSimTime() != null) {
|
||||
isExec = (simCurTime == operation2.getSimTime() || operation2.getSimTime() < simCurTime);
|
||||
}
|
||||
if (isExec) {
|
||||
if (isRobot || operation2.isSpecial()) { // 特殊操作直接执行
|
||||
atsOperationDispatcher.execute(simulation, step.getSimulationMember(), operation2.getOperationType().name()
|
||||
, operation2.getParams());
|
||||
return true;
|
||||
} else { // 非机器人,暂停仿真等待用户操作
|
||||
simulation.onlyPause();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ public abstract class Operation2 {
|
||||
@Setter
|
||||
private Expression failureCondition;
|
||||
|
||||
@Setter
|
||||
boolean special;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ -151,6 +154,9 @@ public abstract class Operation2 {
|
||||
if (vo.getFailureCondition() != null) {
|
||||
this.setFailureCondition(vo.getFailureCondition().convert2BO(simulation.getRepository()));
|
||||
}
|
||||
if (vo.getSpecial() != null) {
|
||||
this.setSpecial(vo.getSpecial());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,6 +194,9 @@ public abstract class Operation2 {
|
||||
if (vo.getCompletionCondition() != null) {
|
||||
this.setCompletionCondition(vo.getCompletionCondition().convert2BO(simulation.getRepository()));
|
||||
}
|
||||
if (vo.getSpecial() != null) {
|
||||
this.setSpecial(vo.getSpecial());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,11 @@ public abstract class Operation2VO {
|
||||
*/
|
||||
ExpressionVO failureCondition;
|
||||
|
||||
/**
|
||||
* 特殊操作,直接执行
|
||||
*/
|
||||
Boolean special;
|
||||
|
||||
public abstract Operation2 convert2BO(Simulation simulation);
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,14 @@
|
||||
package club.joylink.rtss.vo.training2.draft;
|
||||
|
||||
import club.joylink.rtss.vo.client.training2.Step2VO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateStepReqVo {
|
||||
|
||||
private List<Step2VO> step2VOList;
|
||||
|
||||
private List<String> playerIdList;
|
||||
}
|
Loading…
Reference in New Issue
Block a user