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

This commit is contained in:
joylink_zhangsai 2022-08-29 10:32:41 +08:00
commit 68726b9939
19 changed files with 1268 additions and 1277 deletions

View File

@ -75,6 +75,15 @@ public class SimulationTrainingV2Controller {
return training2Service.completionClientStep(group, stepId, user); return training2Service.completionClientStep(group, stepId, user);
} }
/**
* 客户端步骤完成后操作回调
*/
@PutMapping("/{group}/completion/step/{stepId}/operation/{id}")
public Integer completionClientStepOperation(@PathVariable String group, @PathVariable Integer stepId
, @PathVariable Integer id, @RequestAttribute AccountVO user) {
return training2Service.completionClientStepOperation(group, stepId, id, user);
}
/** /**
* 绘制剧本 * 绘制剧本
*/ */

View File

@ -25,6 +25,7 @@ public class TrainingDraftV2Controller {
private Training2DraftService training2DraftService; private Training2DraftService training2DraftService;
@Autowired @Autowired
private ExpConditionMaterialCollector collector; private ExpConditionMaterialCollector collector;
/** /**
* 创建实训草稿 * 创建实训草稿
*/ */
@ -33,71 +34,81 @@ public class TrainingDraftV2Controller {
log.debug("==>>创建实训草稿: mapId = {} , name = {} type = {} des = {}", req.getMapId(), req.getName(), req.getType(), req.getDescription()); log.debug("==>>创建实训草稿: mapId = {} , name = {} type = {} des = {}", req.getMapId(), req.getName(), req.getType(), req.getDescription());
return this.training2DraftService.createTraining(req, user); return this.training2DraftService.createTraining(req, user);
} }
/** /**
* 删除当前用户的实训草稿 * 删除当前用户的实训草稿
*/ */
@DeleteMapping @DeleteMapping
public DeleteTraining2RspVo deleteTrainings(@RequestBody DeleteTraining2ReqVo req,@RequestAttribute AccountVO user) { public DeleteTraining2RspVo deleteTrainings(@RequestBody DeleteTraining2ReqVo req, @RequestAttribute AccountVO user) {
return this.training2DraftService.deleteTrainings(req,user); return this.training2DraftService.deleteTrainings(req, user);
} }
/** /**
* 分页获取当前用户实训草稿基础信息 * 分页获取当前用户实训草稿基础信息
*/ */
@PostMapping("/info/page") @PostMapping("/info/page")
public PageVO<DraftTraining2InfoVo> findTrainingsInfoByPage(@RequestBody DraftTraining2InfoPageReqVo req, @RequestAttribute AccountVO user){ public PageVO<DraftTraining2InfoVo> findTrainingsInfoByPage(@RequestBody DraftTraining2InfoPageReqVo req, @RequestAttribute AccountVO user) {
return this.training2DraftService.findTrainingsInfoByPage(req,user.getId()); return this.training2DraftService.findTrainingsInfoByPage(req, user.getId());
} }
/** /**
* 更新当前用户的某个实训草稿(大字段信息) * 更新当前用户的某个实训草稿(大字段信息)
*/ */
@PostMapping("/update/content") @PostMapping("/update/content")
public void updateTraining(@RequestBody UpdateDraftTraining2BlobReqVo req,@RequestAttribute AccountVO user) { public void updateTraining(@RequestBody UpdateDraftTraining2BlobReqVo req, @RequestAttribute AccountVO user) {
this.training2DraftService.updateTrainingBlob(req, user.getId()); this.training2DraftService.updateTrainingBlob(req, user.getId());
} }
/** /**
* 单独更新当前用户的某个实训草稿的初始背景 * 单独更新当前用户的某个实训草稿的初始背景
* <p> * <p>
* 背景内容由后端自己生成 * 背景内容由后端自己生成
*/ */
@PostMapping("/update/content/backgroud") @PostMapping("/update/content/backgroud")
public void updateTrainingBackgroud(@RequestBody UpdateTraining2BackgroudReqVo req,@RequestAttribute AccountVO user){ public void updateTrainingBackgroud(@RequestBody UpdateTraining2BackgroudReqVo req, @RequestAttribute AccountVO user) {
this.training2DraftService.updateTrainingBackgroud(req,user.getId()); this.training2DraftService.updateTrainingBackgroud(req, user.getId());
} }
/** /**
* 单独重置当前用户的某个实训草稿的初始背景 * 单独重置当前用户的某个实训草稿的初始背景
*/ */
@PostMapping("/reset/content/backgroud") @PostMapping("/reset/content/backgroud")
public void resetTrainingBackgroud(@RequestBody ResetTraining2BackgroudReqVo req,@RequestAttribute AccountVO user){ public void resetTrainingBackgroud(@RequestBody ResetTraining2BackgroudReqVo req, @RequestAttribute AccountVO user) {
this.training2DraftService.resetTrainingBackgroud(req,user.getId()); this.training2DraftService.resetTrainingBackgroud(req, user.getId());
} }
/** /**
* 更新当前用户实训草稿定位 * 更新当前用户实训草稿定位
*/ */
@PostMapping("/update/content/maplocation") @PostMapping("/update/content/maplocation")
public void updateTrainingMapLocation(@RequestBody UpdateTraining2MapLocationReqVo req,@RequestAttribute AccountVO user){ public void updateTrainingMapLocation(@RequestBody UpdateTraining2MapLocationReqVo req, @RequestAttribute AccountVO user) {
this.training2DraftService.updateTrainingMapLocation(req,user.getId()); this.training2DraftService.updateTrainingMapLocation(req, user.getId());
} }
/** /**
* 获取实训表达式条件素材 * 获取实训表达式条件素材
*/ */
@GetMapping("/expression/materials") @GetMapping("/expression/materials")
public List<ExpConditionMaterialSrcVo> findTrainingExpressionMaterials(){ public List<ExpConditionMaterialSrcVo> findTrainingExpressionMaterials() {
return collector.doCollect(); return collector.doCollect();
} }
/** /**
* 更新当前用户的某个实训草稿的基础信息 * 更新当前用户的某个实训草稿的基础信息
*/ */
@PostMapping("/update/info") @PostMapping("/update/info")
public void updateTrainingInfo(@RequestBody UpdateDraftTraining2InfoReqVo req,@RequestAttribute AccountVO user){ public void updateTrainingInfo(@RequestBody UpdateDraftTraining2InfoReqVo req, @RequestAttribute AccountVO user) {
this.training2DraftService.updateTrainingInfo(req, user.getId()); this.training2DraftService.updateTrainingInfo(req, user.getId());
} }
/** /**
* 获取当前用户的某个实训草稿的所有信息 * 获取当前用户的某个实训草稿的所有信息
*/ */
@GetMapping("/all/{trainingId}") @GetMapping("/all/{trainingId}")
public DraftTraining2DetailRspVo findTrainingDetail(@NotNull(message = "实训草稿id不能为空") @PathVariable("trainingId") Long trainingDraftId, @RequestAttribute AccountVO user){ public DraftTraining2DetailRspVo findTrainingDetail(@NotNull(message = "实训草稿id不能为空") @PathVariable("trainingId") Long trainingDraftId, @RequestAttribute AccountVO user) {
return this.training2DraftService.findTrainingDetail(trainingDraftId,user.getId()); return this.training2DraftService.findTrainingDetail(trainingDraftId, user.getId());
} }
/** /**
* 查询步骤列表 * 查询步骤列表
*/ */
@ -109,9 +120,10 @@ public class TrainingDraftV2Controller {
/** /**
* 修改实训所有步骤 * 修改实训所有步骤
*/ */
@PutMapping("/{trainingId}/step/update") @PutMapping("/{group}/{trainingId}/step/update")
public void updateSteps(@PathVariable("trainingId") Long trainingId, @RequestBody List<Step2VO> step2VOList) { public void updateSteps(@PathVariable("group") String group, @PathVariable("trainingId") Long trainingId
training2DraftService.updateSteps(trainingId, step2VOList); , @RequestBody List<Step2VO> step2VOList) {
training2DraftService.updateSteps(group, trainingId, step2VOList);
} }
/** /**

View File

@ -1,5 +1,7 @@
package club.joylink.rtss.dao; package club.joylink.rtss.dao;
import java.util.List;
import club.joylink.rtss.entity.training2.DraftTraining2; import club.joylink.rtss.entity.training2.DraftTraining2;
import club.joylink.rtss.entity.training2.DraftTraining2Example; import club.joylink.rtss.entity.training2.DraftTraining2Example;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
@ -7,8 +9,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper @Mapper
@Repository @Repository
public interface DraftTraining2DAO { public interface DraftTraining2DAO {
@ -39,6 +39,4 @@ public interface DraftTraining2DAO {
int updateByPrimaryKeyWithBLOBs(DraftTraining2WithBLOBs record); int updateByPrimaryKeyWithBLOBs(DraftTraining2WithBLOBs record);
int updateByPrimaryKey(DraftTraining2 record); int updateByPrimaryKey(DraftTraining2 record);
int updateStepJson(@Param("id") Long id, @Param("stepJson") String stepJson, @Param("playerIdJson") String playerIdJson);
} }

View File

@ -1,9 +1,10 @@
package club.joylink.rtss.dao; package club.joylink.rtss.dao;
import java.util.List;
import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.entity.training2.PublishedTraining2;
import club.joylink.rtss.entity.training2.PublishedTraining2Example; import club.joylink.rtss.entity.training2.PublishedTraining2Example;
import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs; import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -12,13 +12,16 @@ import lombok.Data;
public class DraftTraining2 implements Serializable { public class DraftTraining2 implements Serializable {
private Long id; private Long id;
private Long mapId;
/** /**
* 实训名称 * 实训名称
*/ */
private String name; private String name;
/**
* 实训地图id
*/
private Long mapId;
/** /**
* 描述 * 描述
*/ */

View File

@ -1,90 +0,0 @@
package club.joylink.rtss.entity.training2;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class DraftTraining2All {
private Long id;
private Long mapId;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 实训类型单操场景
*/
private String type;
/**
* 标签用于检索
*/
private String labelJson;
/**
* 地图定位json
*/
private String mapLocationJson;
/**
* 初始背景
*/
private String bgSceneJson;
/**
* 运行图id
*/
private Long runPlanId;
/**
* List<Operation2VO>的json
*/
private String operaJson;
/**
* List<Step2VO>的json
*/
private String stepJson;
/**
* List<ScoringRuleVO>的json
*/
private String scoringRuleJson;
// /**
// * 保存数据时的背景
// */
// private String saveSceneJson;
/**
* 仿真内所有成员
*/
private String memberJson;
/**
* 参演的仿真成员id列表Json
*/
private String playerIdJson;
/**
* 实训失败判定条件
*/
private String failureConditionJson;
private Long creatorId;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

View File

@ -185,66 +185,6 @@ public class DraftTraining2Example {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andMapIdIsNull() {
addCriterion("map_id is null");
return (Criteria) this;
}
public Criteria andMapIdIsNotNull() {
addCriterion("map_id is not null");
return (Criteria) this;
}
public Criteria andMapIdEqualTo(Long value) {
addCriterion("map_id =", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotEqualTo(Long value) {
addCriterion("map_id <>", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThan(Long value) {
addCriterion("map_id >", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThanOrEqualTo(Long value) {
addCriterion("map_id >=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThan(Long value) {
addCriterion("map_id <", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThanOrEqualTo(Long value) {
addCriterion("map_id <=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdIn(List<Long> values) {
addCriterion("map_id in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotIn(List<Long> values) {
addCriterion("map_id not in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdBetween(Long value1, Long value2) {
addCriterion("map_id between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotBetween(Long value1, Long value2) {
addCriterion("map_id not between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andNameIsNull() { public Criteria andNameIsNull() {
addCriterion("`name` is null"); addCriterion("`name` is null");
return (Criteria) this; return (Criteria) this;
@ -315,6 +255,66 @@ public class DraftTraining2Example {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andMapIdIsNull() {
addCriterion("map_id is null");
return (Criteria) this;
}
public Criteria andMapIdIsNotNull() {
addCriterion("map_id is not null");
return (Criteria) this;
}
public Criteria andMapIdEqualTo(Long value) {
addCriterion("map_id =", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotEqualTo(Long value) {
addCriterion("map_id <>", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThan(Long value) {
addCriterion("map_id >", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdGreaterThanOrEqualTo(Long value) {
addCriterion("map_id >=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThan(Long value) {
addCriterion("map_id <", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdLessThanOrEqualTo(Long value) {
addCriterion("map_id <=", value, "mapId");
return (Criteria) this;
}
public Criteria andMapIdIn(List<Long> values) {
addCriterion("map_id in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotIn(List<Long> values) {
addCriterion("map_id not in", values, "mapId");
return (Criteria) this;
}
public Criteria andMapIdBetween(Long value1, Long value2) {
addCriterion("map_id between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andMapIdNotBetween(Long value1, Long value2) {
addCriterion("map_id not between", value1, value2, "mapId");
return (Criteria) this;
}
public Criteria andDescriptionIsNull() { public Criteria andDescriptionIsNull() {
addCriterion("description is null"); addCriterion("description is null");
return (Criteria) this; return (Criteria) this;

View File

@ -14,6 +14,11 @@ public class DraftTraining2WithBLOBs extends DraftTraining2 implements Serializa
*/ */
private String bgSceneJson; private String bgSceneJson;
/**
* 实训编制完保存为最终场景json数据
*/
private String finalScenesJson;
/** /**
* 操作列表json(List<Operation2VO>) * 操作列表json(List<Operation2VO>)
*/ */

View File

@ -39,5 +39,10 @@ public class PublishedTraining2WithBLOBs extends PublishedTraining2 implements S
*/ */
private String playerIdJson; private String playerIdJson;
/**
* 实训编制后的最终场景json数据
*/
private String finalScenesJson;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -33,6 +33,7 @@ public class Training2Convertor {
// //
pub.setMemberJson(from.getMemberJson()); pub.setMemberJson(from.getMemberJson());
pub.setBgSceneJson(from.getBgSceneJson()); pub.setBgSceneJson(from.getBgSceneJson());
pub.setFinalScenesJson(from.getFinalScenesJson());
pub.setOperaJson(from.getOperaJson()); pub.setOperaJson(from.getOperaJson());
pub.setDescription(from.getDescription()); pub.setDescription(from.getDescription());
pub.setCreateTime(LocalDateTime.now()); pub.setCreateTime(LocalDateTime.now());

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.services.training2; package club.joylink.rtss.services.training2;
import club.joylink.rtss.dao.DraftTraining2DAO; import club.joylink.rtss.dao.DraftTraining2DAO;
import club.joylink.rtss.entity.TrainingWithBLOBs;
import club.joylink.rtss.entity.training2.DraftTraining2; import club.joylink.rtss.entity.training2.DraftTraining2;
import club.joylink.rtss.entity.training2.DraftTraining2Example; import club.joylink.rtss.entity.training2.DraftTraining2Example;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
@ -23,8 +22,6 @@ 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.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,6 +39,7 @@ public class Training2DraftService {
private DraftTraining2DAO trainingDao; private DraftTraining2DAO trainingDao;
@Autowired @Autowired
private GroupSimulationService roupSimulationService; private GroupSimulationService roupSimulationService;
/** /**
* 根据基本信息创建实训 * 根据基本信息创建实训
* *
@ -123,10 +121,11 @@ public class Training2DraftService {
// //
this.trainingDao.updateByExampleSelective(b, example); this.trainingDao.updateByExampleSelective(b, example);
} }
/** /**
* 重置用户实训草稿的初始背景 * 重置用户实训草稿的初始背景
*/ */
public void resetTrainingBackgroud(ResetTraining2BackgroudReqVo req, Long userId){ public void resetTrainingBackgroud(ResetTraining2BackgroudReqVo req, Long userId) {
DraftTraining2Example example = new DraftTraining2Example(); DraftTraining2Example example = new DraftTraining2Example();
example.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(req.getId()); example.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(req.getId());
List<DraftTraining2> find = this.trainingDao.selectByExample(example); List<DraftTraining2> find = this.trainingDao.selectByExample(example);
@ -138,6 +137,7 @@ public class Training2DraftService {
// //
this.trainingDao.updateByExampleSelective(b, example); this.trainingDao.updateByExampleSelective(b, example);
} }
/** /**
* 更新用户实训草稿的地图定位信息 * 更新用户实训草稿的地图定位信息
*/ */
@ -155,6 +155,7 @@ public class Training2DraftService {
// //
this.trainingDao.updateByExampleSelective(b, example); this.trainingDao.updateByExampleSelective(b, example);
} }
/** /**
* 更新当前用户的实训草稿基础信息 * 更新当前用户的实训草稿基础信息
*/ */
@ -256,7 +257,7 @@ public class Training2DraftService {
// //
DraftTraining2Example example = new DraftTraining2Example(); DraftTraining2Example example = new DraftTraining2Example();
DraftTraining2Example.Criteria c = example.createCriteria().andCreatorIdEqualTo(userId); DraftTraining2Example.Criteria c = example.createCriteria().andCreatorIdEqualTo(userId);
if(null!=req.getMapId()){ if (null != req.getMapId()) {
c.andMapIdEqualTo(req.getMapId()); c.andMapIdEqualTo(req.getMapId());
} }
// //
@ -315,11 +316,14 @@ public class Training2DraftService {
/** /**
* 修改实训所有步骤 * 修改实训所有步骤
*/ */
public void updateSteps(Long trainingId, List<Step2VO> step2VOList) { public void updateSteps(String group, Long trainingId, List<Step2VO> step2VOList) {
DraftTraining2WithBLOBs draftTraining2 = trainingDao.selectByPrimaryKey(trainingId); DraftTraining2WithBLOBs draftTraining2 = trainingDao.selectByPrimaryKey(trainingId);
if (draftTraining2 == null) { if (draftTraining2 == null) {
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在"); throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在");
} }
// 保存当前背景
Simulation simulation = this.roupSimulationService.getSimulationByGroup(group);
StorageSimulation scenesSaving = new StorageSimulation(simulation, false);
String stepJson; String stepJson;
if (CollectionUtils.isEmpty(step2VOList)) { if (CollectionUtils.isEmpty(step2VOList)) {
stepJson = StringUtil.EMPTY_STRING; stepJson = StringUtil.EMPTY_STRING;
@ -333,7 +337,12 @@ public class Training2DraftService {
if (CollectionUtils.isEmpty(playerList)) { if (CollectionUtils.isEmpty(playerList)) {
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据:无扮演者"); throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据:无扮演者");
} }
trainingDao.updateStepJson(trainingId, stepJson, JsonUtils.writeValueAsString(playerList)); DraftTraining2WithBLOBs updateObj = new DraftTraining2WithBLOBs();
updateObj.setId(trainingId);
updateObj.setStepJson(stepJson);
updateObj.setPlayerIdJson(JsonUtils.writeValueAsString(playerList));
updateObj.setFinalScenesJson(JsonUtils.writeValueAsString(scenesSaving));
trainingDao.updateByPrimaryKeySelective(updateObj);
} }
/** /**
@ -344,6 +353,11 @@ public class Training2DraftService {
if (draftTraining2 == null) { if (draftTraining2 == null) {
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在"); throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在");
} }
trainingDao.updateStepJson(trainingId, StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING); DraftTraining2WithBLOBs updateObj = new DraftTraining2WithBLOBs();
updateObj.setId(trainingId);
updateObj.setStepJson(StringUtil.EMPTY_STRING);
updateObj.setPlayerIdJson(StringUtil.EMPTY_STRING);
updateObj.setFinalScenesJson(StringUtil.EMPTY_STRING);
trainingDao.updateByPrimaryKeySelective(updateObj);
} }
} }

View File

@ -11,7 +11,6 @@ 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.web.bind.annotation.PathVariable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
@ -198,6 +197,7 @@ public class Training2PublishService {
rsp.setRunPlanId(b.getRunPlanId()); rsp.setRunPlanId(b.getRunPlanId());
rsp.setScoringRuleJson(b.getScoringRuleJson()); rsp.setScoringRuleJson(b.getScoringRuleJson());
rsp.setState(b.getState()); rsp.setState(b.getState());
rsp.setFinalScenesJson(b.getFinalScenesJson());
// //
return rsp; return rsp;
} }

View File

@ -77,6 +77,8 @@ public class Training2Service {
.filter(s -> !s.isCompletion()).findFirst().orElse(null); .filter(s -> !s.isCompletion()).findFirst().orElse(null);
if (step == null) { // 步骤已经运行完毕 if (step == null) { // 步骤已经运行完毕
training2.finish(); training2.finish();
// 发送实训完成消息
sendTrainingFinish(training2, simulation);
return; return;
} }
// 步骤触发 // 步骤触发
@ -274,6 +276,14 @@ public class Training2Service {
return 1; return 1;
} }
/**
* 完成步骤中操作
*/
public Integer completionClientStepOperation(String group, Integer stepId
, Integer id, AccountVO user) {
return null;
}
@Async("trainingV2Executor") @Async("trainingV2Executor")
@EventListener @EventListener
public void handle(SimulationOperationEvent event) { public void handle(SimulationOperationEvent event) {
@ -355,6 +365,17 @@ public class Training2Service {
} }
} }
/**
* 实训完成发送消息
*/
public void sendTrainingFinish(Training2 training2, Simulation simulation) {
if (training2.isFinish()) {
SocketMessageVO<String> message =
SocketMessageFactory.build(WebSocketMessageType.Simulation_Training_Finish, simulation.getId(), "实训完成");
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
}
/** /**
* 绘制草稿时加载实训背景 * 绘制草稿时加载实训背景
* TODO 后续看根据需求是否加载到最后一步 * TODO 后续看根据需求是否加载到最后一步

View File

@ -98,15 +98,15 @@ public class Training2 {
this.playerIds = JsonUtils.readCollection(draftTraining2.getPlayerIdJson(), List.class, String.class); this.playerIds = JsonUtils.readCollection(draftTraining2.getPlayerIdJson(), List.class, String.class);
} }
labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class); labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class);
if (StringUtils.isEmpty(draftTraining2.getOperaJson())) { if (!StringUtils.isEmpty(draftTraining2.getOperaJson())) {
List<Operation2VO> operation2VOS = JsonUtils.readCollection(draftTraining2.getOperaJson(), List.class, Operation2VO.class); List<Operation2VO> operation2VOS = JsonUtils.readCollection(draftTraining2.getOperaJson(), List.class, Operation2VO.class);
operations = operation2VOS.stream().map(vo -> vo.convert2BO(simulation)).collect(Collectors.toList()); operations = operation2VOS.stream().map(vo -> vo.convert2BO(simulation)).collect(Collectors.toList());
} }
if (StringUtils.isEmpty(draftTraining2.getStepJson())) { if (!StringUtils.isEmpty(draftTraining2.getStepJson())) {
List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class); List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class);
steps = step2VOS.stream().map(vo -> new Step2(vo, simulation)).collect(Collectors.toList()); steps = step2VOS.stream().map(vo -> new Step2(vo, simulation)).collect(Collectors.toList());
} }
if (StringUtils.isEmpty(draftTraining2.getScoringRuleJson())) { if (!StringUtils.isEmpty(draftTraining2.getScoringRuleJson())) {
List<ScoringRuleVO> scoringRuleVOS = JsonUtils.readCollection(draftTraining2.getScoringRuleJson(), List.class, ScoringRuleVO.class); List<ScoringRuleVO> scoringRuleVOS = JsonUtils.readCollection(draftTraining2.getScoringRuleJson(), List.class, ScoringRuleVO.class);
scoringRules = scoringRuleVOS.stream().map(vo -> vo.convert2BO(simulation, this)).collect(Collectors.toList()); scoringRules = scoringRuleVOS.stream().map(vo -> vo.convert2BO(simulation, this)).collect(Collectors.toList());
} }
@ -165,6 +165,7 @@ public class Training2 {
/** /**
* 打分 * 打分
*
* @return k-memberId v-分数 * @return k-memberId v-分数
*/ */
public Map<String, Float> mark() { public Map<String, Float> mark() {

View File

@ -409,6 +409,11 @@ public enum WebSocketMessageType {
* 操作完成提示信息 * 操作完成提示信息
*/ */
Simulation_Training_Operate_Finish, Simulation_Training_Operate_Finish,
/**
* 实训完成
*/
Simulation_Training_Finish
/** ------------ 新实训消息 ----------- */ /** ------------ 新实训消息 ----------- */
; ;
} }

View File

@ -145,7 +145,8 @@ public class SocketMessageFactory {
case Simulation_Training_Step_Tip: case Simulation_Training_Step_Tip:
case Simulation_Training_Step_Finish: case Simulation_Training_Step_Finish:
case Simulation_Training_Operate_Error: case Simulation_Training_Operate_Error:
case Simulation_Training_Operate_Finish: { case Simulation_Training_Operate_Finish:
case Simulation_Training_Finish: {
topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group)); topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group));
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group)); topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group)); topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group));

View File

@ -48,6 +48,11 @@ public class PublishedTraining2DetailRspVo {
*/ */
private String bgSceneJson; private String bgSceneJson;
/**
* 实训编制后的最终场景json数据
*/
private String finalScenesJson;
/** /**
* 运行图id * 运行图id
*/ */