diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Convertor.java b/src/main/java/club/joylink/rtss/services/training2/Training2Convertor.java index c1027ba14..cf3345af0 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Convertor.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Convertor.java @@ -31,23 +31,23 @@ public class Training2Convertor { // pub.setState(PublishedTraining2StateEnum.PutOn.getState()); // - pub.setMemberJson(from.getMemberJson()); - pub.setBgSceneJson(from.getBgSceneJson()); - pub.setFinalScenesJson(from.getFinalScenesJson()); - pub.setOperaJson(from.getOperaJson()); - pub.setDescription(from.getDescription()); + pub.setMemberJson(null==from.getMemberJson()?"":from.getMemberJson()); + pub.setBgSceneJson(null==from.getBgSceneJson()?"":from.getBgSceneJson()); + pub.setFinalScenesJson(null==from.getFinalScenesJson()?"":from.getFinalScenesJson()); + pub.setOperaJson(null==from.getOperaJson()?"":from.getOperaJson()); + pub.setDescription(null==from.getDescription()?"":from.getDescription()); pub.setCreateTime(LocalDateTime.now()); pub.setUpdateTime(LocalDateTime.now()); pub.setCreatorId(from.getCreatorId()); - pub.setName(from.getName()); - pub.setPlayerIdJson(from.getPlayerIdJson()); - pub.setScoringRuleJson(from.getScoringRuleJson()); - pub.setStepJson(from.getStepJson()); - pub.setFailureConditionJson(from.getFailureConditionJson()); - pub.setLabelJson(from.getLabelJson()); + pub.setName(null==from.getName()?"":from.getName()); + pub.setPlayerIdJson(null==from.getPlayerIdJson()?"":from.getPlayerIdJson()); + pub.setScoringRuleJson(null==from.getScoringRuleJson()?"":from.getScoringRuleJson()); + pub.setStepJson(null==from.getStepJson()?"":from.getStepJson()); + pub.setFailureConditionJson(null==from.getFailureConditionJson()?"":from.getFailureConditionJson()); + pub.setLabelJson(null==from.getLabelJson()?"":from.getLabelJson()); pub.setMapId(from.getMapId()); - pub.setMapLocationJson(from.getMapLocationJson()); - pub.setType(from.getType()); + pub.setMapLocationJson(null==from.getMapLocationJson()?"":from.getMapLocationJson()); + pub.setType(null==from.getType()?"":from.getType()); pub.setRunPlanId(from.getRunPlanId()); // return pub; diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java index 826ee2330..76293afc4 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftPublishService.java @@ -41,19 +41,27 @@ public class Training2DraftPublishService { if(null!=req.getReName()&&req.getReName().trim().length()>0){ pub.setName(req.getReName()); } + // 该字段废弃,数据库对应字段后续删除 + pub.setFinalScenesJson(""); //根据要发布的草稿名称来查找已发布的实训 //如果以有同名的则会被覆盖 PublishedTraining2Example ptExample = new PublishedTraining2Example(); ptExample.createCriteria().andNameEqualTo(pub.getName()).andMapIdEqualTo(pub.getMapId()); List ptFinds = this.publishedDao.selectByExample(ptExample); // - if (null != ptFinds && !ptFinds.isEmpty()) {//已发布实训存在时则直接删除 - this.publishedDao.deleteByExample(ptExample); + if(null==ptFinds||ptFinds.isEmpty()){//同地图同名已发布实训不存在则直接存入 + //发布 + this.publishedDao.insertSelective(pub); + }else{//同地图同名已发布实训存在 + if(ptFinds.size()>1){//当有多个存在时,则全部删除再存入 + this.publishedDao.deleteByExample(ptExample); + this.publishedDao.insertSelective(pub); + }else{//当有且仅有一个时,直接更新 + PublishedTraining2 old = ptFinds.get(0); + pub.setId(old.getId()); + this.publishedDao.updateByPrimaryKeySelective(pub); + } } - // 该字段废弃,数据库对应字段后续删除 - pub.setFinalScenesJson(null); - //发布 - this.publishedDao.insertSelective(pub); //记录发布轨迹 final PublishedTraining2 tracePub = this.findByNameAndMapId(pub.getName(),pub.getMapId()); final DraftTraining2 traceDraft = draft;