【优化实训加载速度,结束后直接获取下一步】
This commit is contained in:
parent
9d1677128f
commit
8e6060eaa2
@ -72,23 +72,14 @@ public class Training2Service {
|
||||
return;
|
||||
}
|
||||
// 获取运行步骤
|
||||
Step2 step = training2.getCurrentRunStep();
|
||||
if (step == null) { // 步骤已经运行完毕
|
||||
training2.finish();
|
||||
// 发送实训完成消息
|
||||
sendTrainingFinish(training2, simulation);
|
||||
Step2 step = getNextStepAndCheckTrainingStatus(training2, simulation);
|
||||
if (step == null) {
|
||||
return;
|
||||
}
|
||||
// 步骤是否已经触发
|
||||
// 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回
|
||||
if (!Step2.StepStatus.isAlreadyTrigger(step.getStepStatus()) && !step.doTriggerVail()) {
|
||||
// 尝试触发步骤
|
||||
if (!tryTriggerStep(step, simulation)) {
|
||||
return;
|
||||
}
|
||||
// 发送步骤提示信息
|
||||
if (!step.isPrompt()) {
|
||||
step.setPrompt(true); // 标识已发送过消息
|
||||
sendStepTips(step, simulation);
|
||||
}
|
||||
// 获取步骤中未完成的操作
|
||||
Operation2 operation2 = step.getCurrentRunOperation();
|
||||
// 操作全部完成的情况,检查步骤完成条件
|
||||
@ -126,7 +117,7 @@ public class Training2Service {
|
||||
sendOperationFinish(operation2, simulation);
|
||||
// 如果是最后一步,直接检查步骤有没有完成
|
||||
if (step.getOperations().indexOf(operation2) == (step.getOperations().size() - 1) && completion) {
|
||||
checkTrainStepCompletion(step, simulation);
|
||||
checkStepCompletionAndSendNext(step, simulation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,7 +274,7 @@ public class Training2Service {
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
checkTrainStepCompletion(step, simulation); // 直接检查步骤是否完成
|
||||
checkStepCompletionAndSendNext(step, simulation); // 直接检查步骤是否完成
|
||||
}
|
||||
// 恢复前端运行
|
||||
pauseOrStartSimulation(simulation, false);
|
||||
@ -492,6 +483,55 @@ public class Training2Service {
|
||||
sendStepFinish(step, simulation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实训下一步未执行的步骤,如果实训已结束则返回null
|
||||
*/
|
||||
private Step2 getNextStepAndCheckTrainingStatus(Training2 training2, Simulation simulation) {
|
||||
// 获取运行步骤
|
||||
Step2 nextStep = training2.getCurrentRunStep();
|
||||
if (nextStep == null) { // 步骤已经运行完毕
|
||||
training2.finish();
|
||||
// 发送实训完成消息
|
||||
sendTrainingFinish(training2, simulation);
|
||||
return null;
|
||||
}
|
||||
return nextStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试触发步骤,如果触发返回true,可以继续,未触发返回false
|
||||
*/
|
||||
private boolean tryTriggerStep(Step2 step, Simulation simulation) {
|
||||
// 步骤是否已经触发
|
||||
// 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回
|
||||
if (!Step2.StepStatus.isAlreadyTrigger(step.getStepStatus()) && !step.doTriggerVail()) {
|
||||
return false;
|
||||
}
|
||||
// 发送步骤提示信息
|
||||
if (!step.isPrompt()) {
|
||||
step.setPrompt(true); // 标识已发送过消息
|
||||
sendStepTips(step, simulation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接完成并尝试触发下一步
|
||||
*/
|
||||
private void checkStepCompletionAndSendNext(Step2 step, Simulation simulation) {
|
||||
boolean result = step.doCompletionVail();
|
||||
if (result) {
|
||||
// 发送步骤完成信息
|
||||
sendStepFinish(step, simulation);
|
||||
// 获取运行步骤
|
||||
Step2 nextStep = getNextStepAndCheckTrainingStatus(simulation.getTraining2(), simulation);
|
||||
if (nextStep == null) {
|
||||
return;
|
||||
}
|
||||
tryTriggerStep(nextStep, simulation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停、恢复实训
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user