【处理步骤ID】
This commit is contained in:
parent
db55b8b832
commit
9e1448b053
@ -32,6 +32,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -389,6 +390,8 @@ public class Training2DraftService {
|
||||
} else {
|
||||
String scoringRuleJson = handleStepScoringRule(draftTraining2, step2VOList);
|
||||
updateObj.setScoringRuleJson(scoringRuleJson);
|
||||
// 处理步骤ID
|
||||
handleStepId(draftTraining2, step2VOList);
|
||||
updateObj.setStepJson(JsonUtils.writeValueAsString(step2VOList));
|
||||
// 扮演者集合
|
||||
List<String> playerList = step2VOList.stream().
|
||||
@ -494,6 +497,23 @@ public class Training2DraftService {
|
||||
return playerIds.stream().map(memberMap::get).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存步骤时获取步骤起始ID
|
||||
*/
|
||||
private void handleStepId(DraftTraining2WithBLOBs draftTraining2, List<Step2VO> step2VOList) {
|
||||
Long curStepId;
|
||||
if (StringUtils.isEmpty(draftTraining2.getStepJson())) {
|
||||
curStepId = 0L;
|
||||
} else {
|
||||
// 数据库中的步骤信息
|
||||
List<Step2VO> oldStep2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class);
|
||||
curStepId = oldStep2VOS.stream().map(Step2VO::getId).max(Comparator.comparing(Long::intValue)).get();
|
||||
}
|
||||
AtomicLong atomicId = new AtomicLong(curStepId);
|
||||
step2VOList.stream().filter(s -> s.getId() == null).forEach(s -> s.setId(atomicId.incrementAndGet()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理已经保存的打分规则
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user