diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java index f71ed39a9..d7a322a83 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -30,6 +30,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; @@ -104,13 +105,15 @@ public class Training2DraftService { List find = this.trainingDao.selectByExample(example); return null != find && !find.isEmpty(); } + @Transactional(readOnly = true) - public DraftTraining2 findById(Long id){ + public DraftTraining2 findById(Long id) { DraftTraining2Example example = new DraftTraining2Example(); example.createCriteria().andIdEqualTo(id); List find = this.trainingDao.selectByExample(example); - return null != find && find.size()>0 ? find.get(0):null; + return null != find && find.size() > 0 ? find.get(0) : null; } + /** * 更新用户实训草稿的初始背景 */ @@ -360,6 +363,12 @@ public class Training2DraftService { if (draftTraining2 == null) { throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在"); } + AtomicInteger operationId = new AtomicInteger(0); // 操作ID + // 设置Operation的Id + step2VOList.stream().filter(s -> !CollectionUtils.isEmpty(s.getOperations())).forEach(s -> { + operationId.set(0); + s.getOperations().forEach(o -> o.setId(operationId.getAndIncrement())); + }); // 保存当前背景 Simulation simulation = this.roupSimulationService.getSimulationByGroup(group); DraftTraining2WithBLOBs updateObj = new DraftTraining2WithBLOBs();