|
@@ -14,10 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -55,9 +52,7 @@ public class WbsSynchronousEViSaServiceImpl {
|
|
|
List<Long> ids = collect.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
|
|
|
List<Long> parentIds = collect.stream().map(WbsTreePrivate::getParentId).collect(Collectors.toList());
|
|
|
//节点公式同步
|
|
|
- for (Long parentId : parentIds) {
|
|
|
- saveFormula(Long.valueOf(wbsTreePrivate.getProjectId()), wbsTreePrivate.getParentId(), parentId);
|
|
|
- }
|
|
|
+ saveFormula(Long.valueOf(wbsTreePrivate.getProjectId()), wbsTreePrivate.getParentId(), parentIds);
|
|
|
|
|
|
wbsTreePrivateMapper.update(null, Wrappers.<WbsTreePrivate>lambdaUpdate()
|
|
|
.set(WbsTreePrivate::getHtmlUrl, wbsTreePrivate.getHtmlUrl())
|
|
@@ -228,31 +223,37 @@ public class WbsSynchronousEViSaServiceImpl {
|
|
|
* 同项目下不同节点 不同的节点公式
|
|
|
* @param projectId 项目id
|
|
|
* @param tempParentId 源节点父级id
|
|
|
- * @param parentId 节点父级id
|
|
|
+ * @param parentIds 节点父级id
|
|
|
*/
|
|
|
- public void saveFormula(Long projectId, Long tempParentId, Long parentId) {
|
|
|
+ public void saveFormula(Long projectId, Long tempParentId, List<Long> parentIds) {
|
|
|
|
|
|
List<ElementFormulaMapping> tempElementFormulaMappings = elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery()
|
|
|
.eq(ElementFormulaMapping::getProjectId, projectId)
|
|
|
.in(ElementFormulaMapping::getNodeId, tempParentId));
|
|
|
List<ElementFormulaMapping> elementFormulaMappings = elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery()
|
|
|
.eq(ElementFormulaMapping::getProjectId, projectId)
|
|
|
- .in(ElementFormulaMapping::getNodeId, parentId));
|
|
|
- List<Long> collect = elementFormulaMappings.stream().map(ElementFormulaMapping::getElementId).collect(Collectors.toList());
|
|
|
-
|
|
|
- //当前节点不存在的元素公式
|
|
|
- List<ElementFormulaMapping> collect1 = tempElementFormulaMappings.stream().filter(f -> !collect.contains(f.getElementId())).collect(Collectors.toList());
|
|
|
-
|
|
|
-
|
|
|
- collect1.forEach(f -> {
|
|
|
- f.setId(SnowFlakeUtil.getId());
|
|
|
- f.setProjectId(projectId);
|
|
|
- f.setNodeId(parentId);
|
|
|
- f.setCreateTime(DateTime.now());
|
|
|
- });
|
|
|
-
|
|
|
+ .in(ElementFormulaMapping::getNodeId, parentIds));
|
|
|
+ Map<Long, List<ElementFormulaMapping>> collect = elementFormulaMappings.stream().collect(Collectors.groupingBy(ElementFormulaMapping::getNodeId));
|
|
|
+
|
|
|
+ Set<Long> longs = collect.keySet();
|
|
|
+
|
|
|
+ List<ElementFormulaMapping> collect2 = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Long parentId : longs) {
|
|
|
+ List<ElementFormulaMapping> list = collect.get(parentId);
|
|
|
+ List<Long> collect3 = list.stream().map(ElementFormulaMapping::getElementId).collect(Collectors.toList());
|
|
|
+ //当前节点不存在的元素公式
|
|
|
+ List<ElementFormulaMapping> collect1 = tempElementFormulaMappings.stream().filter(f -> !collect3.contains(f.getElementId())).collect(Collectors.toList());
|
|
|
+ collect1.forEach(f -> {
|
|
|
+ f.setId(SnowFlakeUtil.getId());
|
|
|
+ f.setProjectId(projectId);
|
|
|
+ f.setNodeId(parentId);
|
|
|
+ f.setCreateTime(DateTime.now());
|
|
|
+ });
|
|
|
+ collect2.addAll(collect1);
|
|
|
+ }
|
|
|
//复制新增模板节点的公式
|
|
|
- elementFormulaMappingService.saveBatch(collect1);
|
|
|
+ elementFormulaMappingService.saveBatch(collect2);
|
|
|
|
|
|
}
|
|
|
}
|