|
@@ -116,6 +116,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
@Autowired
|
|
@Autowired
|
|
StringRedisTemplate RedisTemplate;
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取文件题名
|
|
* 获取文件题名
|
|
*/
|
|
*/
|
|
@@ -1440,7 +1441,6 @@ public class InformationWriteQueryController extends BladeController {
|
|
* 2.2 如果点击选择的是当前复制节点本身的同等级节点,那么复制对应表数据,如果没有对应表,那么跳过。
|
|
* 2.2 如果点击选择的是当前复制节点本身的同等级节点,那么复制对应表数据,如果没有对应表,那么跳过。
|
|
*/
|
|
*/
|
|
} else if (("2").equals(vo.getCopyType())) {
|
|
} else if (("2").equals(vo.getCopyType())) {
|
|
-
|
|
|
|
//获取需要复制到的位置节点信息的集合
|
|
//获取需要复制到的位置节点信息的集合
|
|
List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
|
|
List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
|
|
if (copyBatches.size() > 0) {
|
|
if (copyBatches.size() > 0) {
|
|
@@ -1457,151 +1457,141 @@ public class InformationWriteQueryController extends BladeController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //缓存需要的节点信息、表信息
|
|
|
|
|
|
+ //缓存需要复制的节点信息、表信息
|
|
WbsTreeContract needCopyNodeRoot = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
WbsTreeContract needCopyNodeRoot = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
- Map<String, List<WbsTreeContract>> needCopyNodeAndTabMap = new HashMap<>();
|
|
|
|
- List<WbsTreeContract> needCopyChildNodes = this.getChildNodes(needCopyNodeRoot);
|
|
|
|
- if (ObjectUtil.isEmpty(needCopyChildNodes) || needCopyChildNodes.size() == 0) {
|
|
|
|
- //最下层级节点复制
|
|
|
|
- needCopyChildNodes = new ArrayList<>();
|
|
|
|
- needCopyChildNodes.add(needCopyNodeRoot);
|
|
|
|
- }
|
|
|
|
- needCopyNodeAndTabMap.put("node:" + needCopyNodeRoot.getPKeyId(), needCopyChildNodes);
|
|
|
|
- List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(needCopyChildNodes, needCopyNodeRoot.getContractId());
|
|
|
|
- needCopyNodeAndTabMap.put("tab:" + needCopyNodeRoot.getPKeyId(), addChildNodesTables);
|
|
|
|
-
|
|
|
|
- //TODO 结果集
|
|
|
|
- //节点
|
|
|
|
- List<WbsTreeContract> addNodeList = new ArrayList<>();
|
|
|
|
- //表单
|
|
|
|
- List<WbsTreeContract> addTabList = new ArrayList<>();
|
|
|
|
- //redis同步信息
|
|
|
|
- List<WbsTreeContract> asyncWbsTreeNodes = new ArrayList<>();
|
|
|
|
- //表单附件数据源
|
|
|
|
- Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>(addChildNodesTables);
|
|
|
|
- //表单数据
|
|
|
|
- List<String> resultTablesData = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- //表单所属方
|
|
|
|
- String tabOwner = "";
|
|
|
|
- if (("1,2").equals(vo.getClassifyType()) || ("2,1").equals(vo.getClassifyType())) {
|
|
|
|
- tabOwner = "1,2,3,4,5,6";
|
|
|
|
- } else if (("1").equals(vo.getClassifyType())) {
|
|
|
|
- tabOwner = "1,2,3";
|
|
|
|
- } else if (("2").equals(vo.getClassifyType())) {
|
|
|
|
- tabOwner = "4,5,6";
|
|
|
|
- } else if (vo.getIsCopyData() == 0 && StringUtils.isEmpty(tabOwner)) {
|
|
|
|
- //如果选择的是否复制数据=0(否),默认所属方123456
|
|
|
|
- tabOwner = "1,2,3,4,5,6";
|
|
|
|
- }
|
|
|
|
|
|
+ if (needCopyNodeRoot != null) {
|
|
|
|
+ Map<String, List<WbsTreeContract>> needCopyNodeAndTabMap = new HashMap<>();
|
|
|
|
+ List<WbsTreeContract> needCopyChildNodes = this.getChildNodes(needCopyNodeRoot);
|
|
|
|
+ if (ObjectUtil.isEmpty(needCopyChildNodes) || needCopyChildNodes.size() == 0) {
|
|
|
|
+ //最下层级节点复制
|
|
|
|
+ needCopyChildNodes = new ArrayList<>();
|
|
|
|
+ needCopyChildNodes.add(needCopyNodeRoot);
|
|
|
|
+ }
|
|
|
|
+ needCopyNodeAndTabMap.put("node:" + needCopyNodeRoot.getPKeyId(), needCopyChildNodes);
|
|
|
|
+ List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(needCopyChildNodes, needCopyNodeRoot.getContractId());
|
|
|
|
+ needCopyNodeAndTabMap.put("tab:" + needCopyNodeRoot.getPKeyId(), addChildNodesTables);
|
|
|
|
+
|
|
|
|
+ //结果集
|
|
|
|
+ List<WbsTreeContract> addNodeList = new ArrayList<>();//节点
|
|
|
|
+ List<WbsTreeContract> addTabList = new ArrayList<>(); //表单
|
|
|
|
+ List<WbsTreeContract> asyncWbsTreeNodes = new ArrayList<>(); //redis同步信息
|
|
|
|
+ Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>(addChildNodesTables);//表单附件数据源
|
|
|
|
+ List<String> resultTablesData = new ArrayList<>();//表单数据
|
|
|
|
+
|
|
|
|
+ //表单所属方
|
|
|
|
+ String tabOwner = "";
|
|
|
|
+ if (("1,2").equals(vo.getClassifyType()) || ("2,1").equals(vo.getClassifyType())) {
|
|
|
|
+ tabOwner = "1,2,3,4,5,6";
|
|
|
|
+ } else if (("1").equals(vo.getClassifyType())) {
|
|
|
|
+ tabOwner = "1,2,3";
|
|
|
|
+ } else if (("2").equals(vo.getClassifyType())) {
|
|
|
|
+ tabOwner = "4,5,6";
|
|
|
|
+ } else if (vo.getIsCopyData() == 0 && StringUtils.isEmpty(tabOwner)) {
|
|
|
|
+ tabOwner = "1,2,3,4,5,6"; //如果选择的是否复制数据=0(否),默认所属方123456
|
|
|
|
+ }
|
|
|
|
|
|
- //创建线程池,默认设置8个线程
|
|
|
|
- ExecutorService executor = Executors.newFixedThreadPool(8);
|
|
|
|
- try {
|
|
|
|
- //解析位置信息,进行复制数据构造
|
|
|
|
- if (toCopyNodes.size() == copyBatches.size()) {
|
|
|
|
- for (int i = 0; i < toCopyNodes.size(); i++) {
|
|
|
|
- //首先查询需要复制的节点的信息
|
|
|
|
- WbsTreeContract toCopyNode = toCopyNodes.get(i);
|
|
|
|
- CopyContractTreeNodeVO.CopyBatch toCopyVO = copyBatches.get(i);
|
|
|
|
-
|
|
|
|
- String finalTabOwner = tabOwner;
|
|
|
|
- //使用线程池提交任务
|
|
|
|
- executor.submit(() -> {
|
|
|
|
- //redis缓存node
|
|
|
|
|
|
+ //创建线程池,默认设置8个线程
|
|
|
|
+ ExecutorService executor = Executors.newFixedThreadPool(4);
|
|
|
|
+ try {
|
|
|
|
+ //解析位置信息,进行复制数据构造
|
|
|
|
+ if (toCopyNodes.size() == copyBatches.size()) {
|
|
|
|
+ for (int i = 0; i < toCopyNodes.size(); i++) {
|
|
|
|
+ WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
|
|
+ //首先查询需要复制的节点的信息
|
|
|
|
+ WbsTreeContract toCopyNode = toCopyNodes.get(i);
|
|
|
|
+ CopyContractTreeNodeVO.CopyBatch toCopyVO = copyBatches.get(i);
|
|
asyncWbsTreeNodes.add(toCopyNode);
|
|
asyncWbsTreeNodes.add(toCopyNode);
|
|
|
|
+ String finalTabOwner = tabOwner;
|
|
|
|
+ executor.submit(() -> {
|
|
|
|
+ if (toCopyNode != null && toCopyVO != null && needCopyNodeAndTabMap.size() > 0) {
|
|
|
|
+ //TODO 同节点复制
|
|
|
|
+ if (new Integer(1).equals(toCopyVO.getIsSameNode())) {
|
|
|
|
+ //1.1 选择当前节点的父级节点,新增
|
|
|
|
+ if (needCopyNode.getParentId().equals(toCopyNode.getId())) {
|
|
|
|
+ toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
|
+ toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
|
+
|
|
|
|
+ //获取缓存节点、表信息
|
|
|
|
+ List<WbsTreeContract> needCopyNodes = needCopyNodeAndTabMap.get("node:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
+ List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
+
|
|
|
|
+ //构造新的节点、表、数据
|
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 1, finalTabOwner, vo.getIsCopyData());
|
|
|
|
+
|
|
|
|
+ //1.2 选择同父级的同级节点,只复制数据
|
|
|
|
+ } else if (needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
+ //构造数据
|
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
|
+ }
|
|
|
|
|
|
- if (toCopyNode != null && toCopyVO != null && needCopyNodeAndTabMap.size() > 0) {
|
|
|
|
- //TODO 同节点复制
|
|
|
|
- if (new Integer(1).equals(toCopyVO.getIsSameNode())) {
|
|
|
|
- //1.1 选择当前节点的父级节点,新增
|
|
|
|
- if (needCopyNodeRoot.getParentId().equals(toCopyNode.getId())) {
|
|
|
|
- toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
|
- toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
|
-
|
|
|
|
- //获取缓存节点、表信息
|
|
|
|
- List<WbsTreeContract> needCopyNodes = needCopyNodeAndTabMap.get("node:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
- List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
-
|
|
|
|
- //构造新的节点、表、数据
|
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNodeRoot, toCopyNode, resultTablesData, 1, finalTabOwner, vo.getIsCopyData());
|
|
|
|
-
|
|
|
|
- //1.2 选择同父级的同级节点,只复制数据
|
|
|
|
- } else if (needCopyNodeRoot.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
- //构造数据
|
|
|
|
- this.addCopyTabData(needCopyNodeRoot, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //TODO 跨节点复制
|
|
|
|
- } else if (new Integer(0).equals(toCopyVO.getIsSameNode())) {
|
|
|
|
- //获取需要复制节点的上级
|
|
|
|
- WbsTreeContract parentNodeNeed = wbsTreeContractClient.getContractWbsTreeByContractIdAndId(needCopyNodeRoot.getParentId(), Long.parseLong(needCopyNodeRoot.getContractId()));
|
|
|
|
|
|
+ //TODO 跨节点复制
|
|
|
|
+ } else if (new Integer(0).equals(toCopyVO.getIsSameNode())) {
|
|
|
|
+ //获取需要复制节点的上级
|
|
|
|
+ WbsTreeContract parentNodeNeed = wbsTreeContractClient.getContractWbsTreeByContractIdAndId(needCopyNode.getParentId(), Long.parseLong(needCopyNode.getContractId()));
|
|
|
|
|
|
- //2.1 选择的父级的同级的父级节点,新增(当复制节点父级与选择复制到的位置节点的父级id相同时,表示跨节点)
|
|
|
|
- if (parentNodeNeed != null && parentNodeNeed.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
- toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
|
- toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
|
|
|
+ //2.1 选择的父级的同级的父级节点,新增(当复制节点父级与选择复制到的位置节点的父级id相同时,表示跨节点)
|
|
|
|
+ if (parentNodeNeed != null && parentNodeNeed.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
+ toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
|
+ toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
|
|
|
- //获取缓存节点、表信息
|
|
|
|
- List<WbsTreeContract> needCopyNodes = needCopyNodeAndTabMap.get("node:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
- List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
+ //获取缓存节点、表信息
|
|
|
|
+ List<WbsTreeContract> needCopyNodes = needCopyNodeAndTabMap.get("node:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
+ List<WbsTreeContract> needCopyTab = needCopyNodeAndTabMap.get("tab:" + needCopyNodeRoot.getPKeyId());
|
|
|
|
|
|
- //构造新的节点、表、数据
|
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNodeRoot, toCopyNode, resultTablesData, 0, finalTabOwner, vo.getIsCopyData());
|
|
|
|
|
|
+ //构造新的节点、表、数据
|
|
|
|
+ this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNode, toCopyNode, resultTablesData, 0, finalTabOwner, vo.getIsCopyData());
|
|
|
|
|
|
- //2.2 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据)
|
|
|
|
- } else if (needCopyNodeRoot.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNodeRoot.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
- //构造数据
|
|
|
|
- this.addCopyTabData(needCopyNodeRoot, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
|
|
|
+ //2.2 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据)
|
|
|
|
+ } else if (needCopyNode.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
|
+ //构造数据
|
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ //关闭线程池
|
|
|
|
+ executor.shutdown();
|
|
|
|
+ //等待所有线程执行完毕
|
|
|
|
+ while (!executor.isTerminated()) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- //关闭线程池
|
|
|
|
- executor.shutdown();
|
|
|
|
- //等待所有线程执行完毕
|
|
|
|
- while (!executor.isTerminated()) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- //节点
|
|
|
|
- Boolean aBoolean = false;
|
|
|
|
- if (addNodeList.size() > 0) {
|
|
|
|
//重构祖级id
|
|
//重构祖级id
|
|
- this.reBuildAncestors(addNodeList, needCopyNodeRoot);
|
|
|
|
- aBoolean = wbsTreeContractClient.saveBatch(addNodeList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //元素表
|
|
|
|
- if (addTabList.size() > 0) {
|
|
|
|
- this.reBuildAncestors(addTabList, null);
|
|
|
|
- aBoolean = wbsTreeContractClient.saveBatch(addTabList);
|
|
|
|
- //表单文件附件
|
|
|
|
- if (addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
|
- this.addCopyTabFile(addTabList, addChildNodesTablesOldAll);
|
|
|
|
|
|
+ List<WbsTreeContract> resultAll = new ArrayList<>();
|
|
|
|
+ resultAll.addAll(addNodeList);
|
|
|
|
+ resultAll.addAll(addTabList);
|
|
|
|
+ List<WbsTreeContract> allData = this.reBuildAncestors(resultAll);
|
|
|
|
+ List<WbsTreeContract> nodes = allData.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList());
|
|
|
|
+ List<WbsTreeContract> tabs = allData.stream().filter(f -> f.getType().equals(2)).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //入库
|
|
|
|
+ Boolean row = false;
|
|
|
|
+ if (nodes.size() > 0) {
|
|
|
|
+ row = wbsTreeContractClient.saveBatch(nodes);
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- //实体表数据
|
|
|
|
- if (resultTablesData.size() > 0) {
|
|
|
|
- jdbcTemplate.execute(StringUtils.join(resultTablesData, ""));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //更新redis缓存
|
|
|
|
- if (aBoolean && asyncWbsTreeNodes.size() > 0) {
|
|
|
|
- List<WbsTreeContract> collect = asyncWbsTreeNodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
- for (WbsTreeContract asyncWbsTreeNode : collect) {
|
|
|
|
- informationQueryService.AsyncWbsTree("", asyncWbsTreeNode.getId() + "", contractId, "", "1");
|
|
|
|
- informationQueryService.AsyncWbsTree("", asyncWbsTreeNode.getParentId() + "", contractId, "", "1");
|
|
|
|
|
|
+ if (tabs.size() > 0) {
|
|
|
|
+ row = wbsTreeContractClient.saveBatch(tabs);
|
|
|
|
+ if (addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
|
+ this.addCopyTabFile(tabs, addChildNodesTablesOldAll);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (row && resultTablesData.size() > 0) {
|
|
|
|
+ jdbcTemplate.execute(StringUtils.join(resultTablesData, ""));
|
|
}
|
|
}
|
|
|
|
+ if (row && asyncWbsTreeNodes.size() > 0) {
|
|
|
|
+ List<WbsTreeContract> collect = asyncWbsTreeNodes.stream().distinct().collect(Collectors.toList());
|
|
|
|
+ for (WbsTreeContract asyncWbsTreeNode : collect) {
|
|
|
|
+ informationQueryService.AsyncWbsTree("", asyncWbsTreeNode.getId() + "", contractId, "", "1");
|
|
|
|
+ informationQueryService.AsyncWbsTree("", asyncWbsTreeNode.getParentId() + "", contractId, "", "1");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.success("操作成功");
|
|
}
|
|
}
|
|
-
|
|
|
|
- return R.success("操作成功");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return R.fail("操作失败");
|
|
return R.fail("操作失败");
|
|
@@ -1610,18 +1600,29 @@ public class InformationWriteQueryController extends BladeController {
|
|
/**
|
|
/**
|
|
* 重构祖级id
|
|
* 重构祖级id
|
|
*/
|
|
*/
|
|
- private void reBuildAncestors(List<WbsTreeContract> result, WbsTreeContract needCopyNodeRoot) {
|
|
|
|
- for (WbsTreeContract wbsTreeContract : result) {
|
|
|
|
- //根节点
|
|
|
|
- if (needCopyNodeRoot != null && wbsTreeContract.getOldId().equals(needCopyNodeRoot.getId().toString())) {
|
|
|
|
- wbsTreeContract.setAncestors(needCopyNodeRoot.getAncestors());
|
|
|
|
- }//非根节点
|
|
|
|
- if (wbsTreeContract != null && ObjectUtil.isNotEmpty(wbsTreeContract.getParentId()) && ObjectUtil.isNotEmpty(wbsTreeContract.getAncestors()) && !wbsTreeContract.getAncestors().contains(wbsTreeContract.getParentId() + "")) {
|
|
|
|
- String[] split = wbsTreeContract.getAncestors().split(",");
|
|
|
|
- String s = split[split.length - 1];
|
|
|
|
- wbsTreeContract.setAncestors(wbsTreeContract.getAncestors().replace(s, wbsTreeContract.getParentId() + ""));
|
|
|
|
|
|
+ private List<WbsTreeContract> reBuildAncestors(List<WbsTreeContract> list) {
|
|
|
|
+ List<WbsTreeContract> result = new ArrayList<>();
|
|
|
|
+ List<WbsTreeContract> sortedResult = list.stream()
|
|
|
|
+ .sorted(Comparator.comparing(WbsTreeContract::getType)
|
|
|
|
+ .thenComparing(WbsTreeContract::getNodeType)
|
|
|
|
+ .thenComparing(WbsTreeContract::getId)
|
|
|
|
+ .thenComparing(WbsTreeContract::getCreateTime))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ Map<Long, WbsTreeContract> newMap = BeanUtil.copyProperties(result, WbsTreeContract.class).stream().collect(Collectors.toMap(WbsTreeContract::getId, Function.identity()));
|
|
|
|
+ for (WbsTreeContract obj : sortedResult) {
|
|
|
|
+ if (obj != null && ObjectUtil.isNotEmpty(obj.getParentId())) {
|
|
|
|
+ if (newMap.size() > 0) {
|
|
|
|
+ WbsTreeContract parentObj = newMap.get(obj.getParentId());
|
|
|
|
+ if (parentObj != null && !obj.getAncestors().contains(obj.getParentId().toString())) {
|
|
|
|
+ String parentAncestors = parentObj.getAncestors();
|
|
|
|
+ obj.setAncestors(parentAncestors + "," + obj.getParentId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ newMap.put(obj.getId(), obj);
|
|
|
|
+ result.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1712,7 +1713,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
/**
|
|
/**
|
|
* 新增复制的节点、表的数据构造
|
|
* 新增复制的节点、表的数据构造
|
|
*/
|
|
*/
|
|
- private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, List<WbsTreeContract> addTabList, List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData, Integer isSameNode, String tabOwner, Integer isCopyData) {
|
|
|
|
|
|
+ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> addNodeList, List<WbsTreeContract> addTabList, List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract
|
|
|
|
+ needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData, Integer isSameNode, String
|
|
|
|
+ tabOwner, Integer isCopyData) {
|
|
int var = 0;
|
|
int var = 0;
|
|
if (needNodes.size() == 1) {
|
|
if (needNodes.size() == 1) {
|
|
//判断是否为最下级节点
|
|
//判断是否为最下级节点
|
|
@@ -1788,8 +1791,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
} else { //多层级节点复制
|
|
} else { //多层级节点复制
|
|
//根节点id
|
|
//根节点id
|
|
- Long toCopyNodeOldId = toCopyNode.getId();
|
|
|
|
- toCopyNode.setId(SnowFlakeUtil.getId());
|
|
|
|
|
|
+ Long needCopyNodeOldId = needCopyNode.getId();
|
|
|
|
+ needCopyNode.setId(SnowFlakeUtil.getId());
|
|
|
|
|
|
Map<Long, Long> parentIdToId = new HashMap<>();
|
|
Map<Long, Long> parentIdToId = new HashMap<>();
|
|
Map<Long, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
|
|
Map<Long, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
|
|
@@ -1810,17 +1813,16 @@ public class InformationWriteQueryController extends BladeController {
|
|
newParentId = parentIdToId.get(node.getParentId());
|
|
newParentId = parentIdToId.get(node.getParentId());
|
|
} else {
|
|
} else {
|
|
//根节点
|
|
//根节点
|
|
- newParentId = toCopyNode.getId();
|
|
|
|
|
|
+ newParentId = needCopyNode.getId();
|
|
}
|
|
}
|
|
if (ObjectUtils.isEmpty(newParentId)) {
|
|
if (ObjectUtils.isEmpty(newParentId)) {
|
|
- newParentId = toCopyNode.getId();
|
|
|
|
|
|
+ newParentId = needCopyNode.getId();
|
|
}
|
|
}
|
|
obj.setPKeyId(SnowFlakeUtil.getId());
|
|
obj.setPKeyId(SnowFlakeUtil.getId());
|
|
obj.setOldId(node.getId().toString());
|
|
obj.setOldId(node.getId().toString());
|
|
Long id = SnowFlakeUtil.getId();
|
|
Long id = SnowFlakeUtil.getId();
|
|
//数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
|
|
//数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
|
|
parentIdToId.put(node.getId(), id);
|
|
parentIdToId.put(node.getId(), id);
|
|
-
|
|
|
|
//重设Id
|
|
//重设Id
|
|
obj.setId(id);
|
|
obj.setId(id);
|
|
obj.setParentId(newParentId);
|
|
obj.setParentId(newParentId);
|
|
@@ -1874,19 +1876,19 @@ public class InformationWriteQueryController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
//添加根节点
|
|
//添加根节点
|
|
- toCopyNode.setOldId(needCopyNode.getId() + "");
|
|
|
|
|
|
+ needCopyNode.setOldId(needCopyNodeOldId + "");
|
|
if (isSameNode == 1) {
|
|
if (isSameNode == 1) {
|
|
//同节点
|
|
//同节点
|
|
- toCopyNode.setParentId(needCopyNode.getParentId());
|
|
|
|
|
|
+ needCopyNode.setParentId(needCopyNode.getParentId());
|
|
} else {
|
|
} else {
|
|
//跨节点
|
|
//跨节点
|
|
- toCopyNode.setParentId(toCopyNodeOldId);
|
|
|
|
|
|
+ needCopyNode.setParentId(toCopyNode.getId());
|
|
}
|
|
}
|
|
- toCopyNode.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
- toCopyNode.setNodeName(toCopyNode.getNodeName());
|
|
|
|
- toCopyNode.setFullName(toCopyNode.getNodeName());
|
|
|
|
- toCopyNode.setPartitionCode(toCopyNode.getPartitionCode());
|
|
|
|
- addNodeList.add(toCopyNode);
|
|
|
|
|
|
+ needCopyNode.setPKeyId(SnowFlakeUtil.getId());
|
|
|
|
+ needCopyNode.setNodeName(toCopyNode.getNodeName());
|
|
|
|
+ needCopyNode.setFullName(toCopyNode.getNodeName());
|
|
|
|
+ needCopyNode.setPartitionCode(toCopyNode.getPartitionCode());
|
|
|
|
+ addNodeList.add(needCopyNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2770,7 +2772,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID"),
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID"),
|
|
@ApiImplicitParam(name = "id", value = "点击节点ID")
|
|
@ApiImplicitParam(name = "id", value = "点击节点ID")
|
|
})
|
|
})
|
|
- public R<List<WbsTreeContractTreeVOS>> queryWbsTreeContractByContractIdAndId(@RequestParam String contractId, @RequestParam String id) {
|
|
|
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryWbsTreeContractByContractIdAndId(@RequestParam String
|
|
|
|
+ contractId, @RequestParam String id) {
|
|
List<WbsTreeContractTreeVOS> result = new ArrayList<>();
|
|
List<WbsTreeContractTreeVOS> result = new ArrayList<>();
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
@@ -2970,7 +2973,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true),
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true),
|
|
@ApiImplicitParam(name = "classifyType", value = "所属方,监理、总监办的资料查询使用,=1施工数据(默认),=2监理数据")
|
|
@ApiImplicitParam(name = "classifyType", value = "所属方,监理、总监办的资料查询使用,=1施工数据(默认),=2监理数据")
|
|
})
|
|
})
|
|
- public R<List<WbsTreeContractTreeVOS>> queryContractWbsTreeByContractIdAndType(@RequestParam String primaryKeyId,
|
|
|
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryContractWbsTreeByContractIdAndType(@RequestParam String
|
|
|
|
+ primaryKeyId,
|
|
@RequestParam String parentId,
|
|
@RequestParam String parentId,
|
|
@RequestParam String contractId,
|
|
@RequestParam String contractId,
|
|
@RequestParam String contractIdRelation,
|
|
@RequestParam String contractIdRelation,
|