【实训操作保存时,生成操作ID】

This commit is contained in:
weizhihong 2022-09-15 15:10:00 +08:00
parent f0bbb332c0
commit d544413f50

View File

@ -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<DraftTraining2> 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<DraftTraining2> 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();