|
@@ -116,6 +116,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@Autowired
|
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取文件题名
|
|
|
*/
|
|
@@ -1327,6 +1328,18 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperationSupport(order = 15)
|
|
|
@ApiOperation(value = "复制节点(新)")
|
|
|
public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
+ //表单所属方
|
|
|
+ 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) {
|
|
|
+ tabOwner = "1,2,3,4,5,6"; //如果选择的是否复制数据=0(否),默认所属方123456
|
|
|
+ }
|
|
|
+
|
|
|
//TODO 单份复制
|
|
|
if (("1").equals(vo.getCopyType())) {
|
|
|
//首先查询需要复制的节点及其下级所有子节点的信息
|
|
@@ -1355,6 +1368,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
nodeMap.put(node.getId().toString(), node);
|
|
|
});
|
|
|
|
|
|
+ String finalTabOwner1 = tabOwner;
|
|
|
nodeChildAll.forEach(node -> {
|
|
|
WbsTreeContract newData = new WbsTreeContract();
|
|
|
BeanUtils.copyProperties(node, newData);
|
|
@@ -1404,29 +1418,31 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//生成施工日志
|
|
|
this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
}
|
|
|
-
|
|
|
+ //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
// 组织复制值Sql
|
|
|
- if (nodeTabColsMap != null && node.getType() == 2 && StringUtils.isNotEmpty(newData.getInitTableName())) {
|
|
|
+ if (node.getType() == 2 && StringUtils.isNotEmpty(newData.getInitTableName()) && finalTabOwner1.contains(node.getTableOwner()) && vo.getIsCopyData() == 1) {
|
|
|
String tableName = newData.getInitTableName();
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + newData.getPKeyId() + "' as p_key_id,");
|
|
|
- copeSql.append("insert into " + tableName + " (" + col + ") select " + colVal + " from " + tableName + " where p_key_id='" + node.getPKeyId() + "' ;");
|
|
|
+ //delete SQL (先删除旧数据,再新增)
|
|
|
+ String delSql = "delete from " + tableName + " where p_key_id = " + newData.getPKeyId() + " ; ";
|
|
|
+ //insert into SQL
|
|
|
+ copeSql.append(delSql).append("insert into ").append(tableName).append(" (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(node.getPKeyId()).append("' ;");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
//保存节点信息
|
|
|
R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
|
|
|
-
|
|
|
//复制数据逻辑
|
|
|
- if (nodeTabColsMap != null && copeSql.length() >= 10) {
|
|
|
+ if (copeSql.length() >= 10) {
|
|
|
jdbcTemplate.execute(copeSql.toString());
|
|
|
}
|
|
|
-
|
|
|
//获取父节点信息
|
|
|
informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
|
|
|
return booleanR;
|
|
|
|
|
|
+ } else if (("2").equals(vo.getCopyType())) {
|
|
|
/** TODO 多份复制
|
|
|
* @Author liuYC
|
|
|
* @Date 2023年4月10日18:06:53
|
|
@@ -1439,8 +1455,6 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
* 2.1 如果点击选择的是其他父级节点的父级,那么新增一个新的当前选择的复制的节点-新的表-新的表数据(根据所属方查询对应数据)。
|
|
|
* 2.2 如果点击选择的是当前复制节点本身的同等级节点,那么复制对应表数据,如果没有对应表,那么跳过。
|
|
|
*/
|
|
|
- } else if (("2").equals(vo.getCopyType())) {
|
|
|
-
|
|
|
//获取需要复制到的位置节点信息的集合
|
|
|
List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
|
|
|
if (copyBatches.size() > 0) {
|
|
@@ -1457,151 +1471,150 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //缓存需要的节点信息、表信息
|
|
|
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";
|
|
|
- }
|
|
|
-
|
|
|
- //创建线程池,默认设置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
|
|
|
+ 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<>();//表单数据
|
|
|
+
|
|
|
+ //创建线程池,默认设置4个线程
|
|
|
+ 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);
|
|
|
+ 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()));
|
|
|
-
|
|
|
- //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());
|
|
|
-
|
|
|
- //构造新的节点、表、数据
|
|
|
- this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, needCopyNodes, needCopyTab, needCopyNodeRoot, toCopyNode, resultTablesData, 0, finalTabOwner, vo.getIsCopyData());
|
|
|
+ //TODO 跨节点复制
|
|
|
+ } else if (new Integer(0).equals(toCopyVO.getIsSameNode())) {
|
|
|
+ //获取需要复制节点的上级
|
|
|
+ WbsTreeContract parentNodeNeed = wbsTreeContractClient.getContractWbsTreeByContractIdAndId(needCopyNode.getParentId(), Long.parseLong(needCopyNode.getContractId()));
|
|
|
+
|
|
|
+ boolean var = false;
|
|
|
+ //2.1 选择的父级的同级的父级节点,新增(当复制节点父级与选择复制到的位置节点的父级id相同时,表示跨节点新增)
|
|
|
+ if (parentNodeNeed != null) {
|
|
|
+ //2.1.1 如果是跨一级的情况下:parentNodeNeed.getParentId() == toCopyNode.getParentId() ,且 parentNodeNeed.getAncestors() == toCopyNode.getAncestors() ,且节点类型必须一样
|
|
|
+ if (parentNodeNeed.getParentId().equals(toCopyNode.getParentId()) && parentNodeNeed.getAncestors().equals(toCopyNode.getAncestors()) && parentNodeNeed.getNodeType().equals(toCopyNode.getNodeType())) {
|
|
|
+ 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, 0, finalTabOwner, vo.getIsCopyData());
|
|
|
+ var = true;
|
|
|
+
|
|
|
+ } else if (!parentNodeNeed.getParentId().equals(toCopyNode.getParentId()) && !parentNodeNeed.getAncestors().equals(toCopyNode.getAncestors()) && parentNodeNeed.getNodeType().equals(toCopyNode.getNodeType())) {
|
|
|
+ //2.1.2 如果跨多级的情况下父级id不相同 parentNodeNeed.getParentId() != toCopyNode.getParentId() ,且 parentNodeNeed.getAncestors() != toCopyNode.getAncestors() ,且节点类型必须一样
|
|
|
+ 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, 0, finalTabOwner, vo.getIsCopyData());
|
|
|
+ var = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //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 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据),且var=false,表示没有进行到跨节点新增的逻辑,只是跨节点复制数据
|
|
|
+ if (needCopyNode.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNode.getParentId().equals(toCopyNode.getParentId()) && !var) {
|
|
|
+ //构造数据
|
|
|
+ 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
|
|
|
- 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 (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("操作成功");
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("没有找到需要复制的节点信息,请联系管理员");
|
|
|
}
|
|
|
-
|
|
|
- return R.success("操作成功");
|
|
|
}
|
|
|
}
|
|
|
return R.fail("操作失败");
|
|
@@ -1610,18 +1623,29 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
/**
|
|
|
* 重构祖级id
|
|
|
*/
|
|
|
- private void reBuildAncestors(List<WbsTreeContract> result, WbsTreeContract needCopyNodeRoot) {
|
|
|
- for (WbsTreeContract wbsTreeContract : result) {
|
|
|
- //根节点
|
|
|
- if (ObjectUtil.isNotEmpty(needCopyNodeRoot) && wbsTreeContract.getOldId().equals(needCopyNodeRoot.getId().toString())) {
|
|
|
- wbsTreeContract.setAncestors(needCopyNodeRoot.getAncestors());
|
|
|
- }//非根节点
|
|
|
- if (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.nullsFirst(Comparator.comparing(WbsTreeContract::getType, Comparator.nullsLast(Comparator.naturalOrder())))
|
|
|
+ .thenComparing(Comparator.nullsFirst(Comparator.comparing(WbsTreeContract::getNodeType, Comparator.nullsLast(Comparator.naturalOrder()))))
|
|
|
+ .thenComparing(Comparator.nullsFirst(Comparator.comparing(WbsTreeContract::getId, Comparator.nullsLast(Comparator.naturalOrder()))))
|
|
|
+ .thenComparing(Comparator.nullsFirst(Comparator.comparing(WbsTreeContract::getCreateTime, Comparator.nullsLast(Comparator.naturalOrder())))))
|
|
|
+ .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 +1736,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;
|
|
|
if (needNodes.size() == 1) {
|
|
|
//判断是否为最下级节点
|
|
@@ -1788,8 +1814,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
} else { //多层级节点复制
|
|
|
//根节点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, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
|
|
@@ -1810,17 +1836,16 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newParentId = parentIdToId.get(node.getParentId());
|
|
|
} else {
|
|
|
//根节点
|
|
|
- newParentId = toCopyNode.getId();
|
|
|
+ newParentId = needCopyNode.getId();
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(newParentId)) {
|
|
|
- newParentId = toCopyNode.getId();
|
|
|
+ newParentId = needCopyNode.getId();
|
|
|
}
|
|
|
obj.setPKeyId(SnowFlakeUtil.getId());
|
|
|
obj.setOldId(node.getId().toString());
|
|
|
Long id = SnowFlakeUtil.getId();
|
|
|
//数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
|
|
|
parentIdToId.put(node.getId(), id);
|
|
|
-
|
|
|
//重设Id
|
|
|
obj.setId(id);
|
|
|
obj.setParentId(newParentId);
|
|
@@ -1874,19 +1899,19 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
|
|
|
//添加根节点
|
|
|
- toCopyNode.setOldId(needCopyNode.getId() + "");
|
|
|
+ needCopyNode.setOldId(needCopyNodeOldId + "");
|
|
|
if (isSameNode == 1) {
|
|
|
//同节点
|
|
|
- toCopyNode.setParentId(needCopyNode.getParentId());
|
|
|
+ needCopyNode.setParentId(needCopyNode.getParentId());
|
|
|
} 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 +2795,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "contractId", 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<>();
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
@@ -2970,7 +2996,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true),
|
|
|
@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 contractId,
|
|
|
@RequestParam String contractIdRelation,
|