|
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -89,8 +90,12 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
return true;
|
|
|
}).collect(Collectors.toList());
|
|
|
//获取最大Sort
|
|
|
- Integer sortMax = collect.stream().max(Comparator.comparingInt(WbsTreePrivate::getSort)).get().getSort();
|
|
|
- wbsTreePrivate.setSort(sortMax + 1);
|
|
|
+ Optional<WbsTreePrivate> max = collect.stream().max(Comparator.comparingInt(WbsTreePrivate::getSort));
|
|
|
+ Integer sort = 0;
|
|
|
+ if (max.isPresent()) {
|
|
|
+ sort = max.get().getSort();
|
|
|
+ }
|
|
|
+ wbsTreePrivate.setSort(sort + 1);
|
|
|
|
|
|
//新增
|
|
|
int row = baseMapper.insert(wbsTreePrivate);
|