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

@ -22,9 +22,10 @@ import java.util.List;
@RequestMapping("/api/v2/draft/training") @RequestMapping("/api/v2/draft/training")
public class TrainingDraftV2Controller { public class TrainingDraftV2Controller {
@Autowired @Autowired
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,44 +1,42 @@
package club.joylink.rtss.dao; package club.joylink.rtss.dao;
import club.joylink.rtss.entity.training2.DraftTraining2; import java.util.List;
import club.joylink.rtss.entity.training2.DraftTraining2Example;
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.entity.training2.DraftTraining2;
import org.apache.ibatis.annotations.Mapper; import club.joylink.rtss.entity.training2.DraftTraining2Example;
import org.apache.ibatis.annotations.Param; import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
import org.springframework.stereotype.Repository; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import org.springframework.stereotype.Repository;
@Mapper @Mapper
@Repository @Repository
public interface DraftTraining2DAO { public interface DraftTraining2DAO {
long countByExample(DraftTraining2Example example); long countByExample(DraftTraining2Example example);
int deleteByExample(DraftTraining2Example example); int deleteByExample(DraftTraining2Example example);
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
int insert(DraftTraining2WithBLOBs record); int insert(DraftTraining2WithBLOBs record);
int insertSelective(DraftTraining2WithBLOBs record); int insertSelective(DraftTraining2WithBLOBs record);
List<DraftTraining2WithBLOBs> selectByExampleWithBLOBs(DraftTraining2Example example); List<DraftTraining2WithBLOBs> selectByExampleWithBLOBs(DraftTraining2Example example);
List<DraftTraining2> selectByExample(DraftTraining2Example example); List<DraftTraining2> selectByExample(DraftTraining2Example example);
DraftTraining2WithBLOBs selectByPrimaryKey(Long id); DraftTraining2WithBLOBs selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") DraftTraining2WithBLOBs record, @Param("example") DraftTraining2Example example); int updateByExampleSelective(@Param("record") DraftTraining2WithBLOBs record, @Param("example") DraftTraining2Example example);
int updateByExampleWithBLOBs(@Param("record") DraftTraining2WithBLOBs record, @Param("example") DraftTraining2Example example); int updateByExampleWithBLOBs(@Param("record") DraftTraining2WithBLOBs record, @Param("example") DraftTraining2Example example);
int updateByExample(@Param("record") DraftTraining2 record, @Param("example") DraftTraining2Example example); int updateByExample(@Param("record") DraftTraining2 record, @Param("example") DraftTraining2Example example);
int updateByPrimaryKeySelective(DraftTraining2WithBLOBs record); int updateByPrimaryKeySelective(DraftTraining2WithBLOBs record);
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;
@ -38,4 +39,4 @@ public interface PublishedTraining2DAO {
int updateByPrimaryKeyWithBLOBs(PublishedTraining2WithBLOBs record); int updateByPrimaryKeyWithBLOBs(PublishedTraining2WithBLOBs record);
int updateByPrimaryKey(PublishedTraining2 record); int updateByPrimaryKey(PublishedTraining2 record);
} }

View File

@ -1,59 +1,62 @@
package club.joylink.rtss.entity.training2; package club.joylink.rtss.entity.training2;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.Data; import lombok.Data;
/** /**
* @author * @author
* *
*/ */
@Data @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;
*/
private String description; /**
* 描述
/** */
* 实训类型单操 single场景scene private String description;
*/
private String type; /**
* 实训类型单操 single场景scene
/** */
* 标签用于检索 private String type;
*/
private String labelJson; /**
* 标签用于检索
/** */
* 地图定位json private String labelJson;
*/
private String mapLocationJson; /**
* 地图定位json
/** */
* 运行图id private String mapLocationJson;
*/
private Long runPlanId; /**
* 运行图id
/** */
* 实训失败判定条件 private Long runPlanId;
*/
private String failureConditionJson; /**
* 实训失败判定条件
private Long creatorId; */
private String failureConditionJson;
private LocalDateTime createTime;
private Long creatorId;
private LocalDateTime updateTime;
private LocalDateTime createTime;
private static final long serialVersionUID = 1L;
} private LocalDateTime updateTime;
private static final long serialVersionUID = 1L;
}

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

@ -1,43 +1,48 @@
package club.joylink.rtss.entity.training2; package club.joylink.rtss.entity.training2;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data; import lombok.Data;
/** /**
* @author * @author
* *
*/ */
@Data @Data
public class DraftTraining2WithBLOBs extends DraftTraining2 implements Serializable { public class DraftTraining2WithBLOBs extends DraftTraining2 implements Serializable {
/** /**
* 初始背景 * 初始背景
*/ */
private String bgSceneJson; private String bgSceneJson;
/** /**
* 操作列表json(List<Operation2VO>) * 实训编制完保存为最终场景json数据
*/ */
private String operaJson; private String finalScenesJson;
/** /**
* 步骤列表json(List<Step2VO>的json) * 操作列表json(List<Operation2VO>)
*/ */
private String stepJson; private String operaJson;
/** /**
* 打分规则列表json(List<ScoringRuleVO>的json) * 步骤列表json(List<Step2VO>的json)
*/ */
private String scoringRuleJson; private String stepJson;
/** /**
* 仿真内所有成员 * 打分规则列表json(List<ScoringRuleVO>的json)
*/ */
private String memberJson; private String scoringRuleJson;
/** /**
* 参演的仿真成员id列表Json * 仿真内所有成员
*/ */
private String playerIdJson; private String memberJson;
private static final long serialVersionUID = 1L; /**
* 参演的仿真成员id列表Json
*/
private String playerIdJson;
private static final long serialVersionUID = 1L;
} }

View File

@ -70,4 +70,4 @@ public class PublishedTraining2 implements Serializable {
private Integer state; private Integer state;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

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

@ -18,7 +18,7 @@ import java.util.List;
@Slf4j @Slf4j
public class Training2DraftPublishService { public class Training2DraftPublishService {
@Autowired @Autowired
private DraftTraining2DAO trainingDao; private DraftTraining2DAO trainingDao;
@Autowired @Autowired
private PublishedTraining2DAO publishedDao; private PublishedTraining2DAO publishedDao;

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;
@ -77,7 +76,7 @@ public class Training2PublishService {
final PutOnPublishedTraining2RspVo rsp =new PutOnPublishedTraining2RspVo(); final PutOnPublishedTraining2RspVo rsp =new PutOnPublishedTraining2RspVo();
rsp.setIds(new ArrayList<>()); rsp.setIds(new ArrayList<>());
req.getIds().forEach(id->{ req.getIds().forEach(id->{
PublishedTraining2WithBLOBs pub =new PublishedTraining2WithBLOBs(); PublishedTraining2WithBLOBs pub =new PublishedTraining2WithBLOBs();
pub.setId(Long.valueOf(id)); pub.setId(Long.valueOf(id));
pub.setState(PublishedTraining2StateEnum.PutOn.getState()); pub.setState(PublishedTraining2StateEnum.PutOn.getState());
pub.setUpdateTime(LocalDateTime.now()); pub.setUpdateTime(LocalDateTime.now());
@ -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
*/ */