liuyc 2 years ago
parent
commit
782faf32c3

+ 6 - 3
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/CopyContractTreeNodeVO.java

@@ -33,8 +33,8 @@ public class CopyContractTreeNodeVO {
     @ApiModelProperty("划分编号,单份复制")
     private String partitionCode;
 
-    public void setCopyBatchToPaths(String primaryKeyId, String nodeName, String partitionCode) {
-        this.copyBatchToPaths.add(new CopyBatch(primaryKeyId, nodeName, partitionCode));
+    public void setCopyBatchToPaths(String primaryKeyId, String nodeName, String partitionCode, Integer isSameNode) {
+        this.copyBatchToPaths.add(new CopyBatch(primaryKeyId, nodeName, partitionCode, isSameNode));
     }
 
     @Data
@@ -46,13 +46,16 @@ public class CopyContractTreeNodeVO {
 
         private String partitionCode;
 
+        private Integer isSameNode; //是否同节点(多份复制 同节点=1,不同节点/跨节点=0)
+
         public CopyBatch() {
         }
 
-        public CopyBatch(String primaryKeyId, String nodeName, String partitionCode) {
+        public CopyBatch(String primaryKeyId, String nodeName, String partitionCode, Integer isSameNode) {
             this.primaryKeyId = primaryKeyId;
             this.nodeName = nodeName;
             this.partitionCode = partitionCode;
+            this.isSameNode = isSameNode;
         }
 
     }

+ 339 - 92
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -71,6 +71,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 
 import java.io.IOException;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
@@ -1339,104 +1340,361 @@ public class InformationWriteQueryController extends BladeController {
     @ApiOperationSupport(order = 15)
     @ApiOperation(value = "复制节点(新)")
     public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
-        //首先查询需要复制的节点及其下级所有子节点的信息
-        WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
-        // 获取当前节点的所有子节点
-        String vocational = SnowFlakeUtil.getId() + "";
-        //新增施工台账
-        List<WbsTreeContract> saveList = new ArrayList<>();
-        List<ConstructionLedger> saveLedger = new ArrayList<>();
-        // 获取附件
-        List<WbsTreeContract> nodeChildAll = informationQueryService.getNodeChildAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId(), vo.getNeedCopyPrimaryKeyId());
-        // 获取实体表列对象
-        List<QueryProcessDataVO> nodeTabCols = informationQueryService.getNodeChildTabColsAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId());
-        // 转化为map
-        Map<String, String> nodeTabColsMap = nodeTabCols.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
-        StringBuilder copeSql = new StringBuilder();
-
-        if (StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())) {
-            WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
-            //重塑关键信息
-            Map<Long, Long> oldToNewIdMap = new HashMap<>();
-            //节点信息
-            Map<String, WbsTreeContract> nodeMap = new HashMap<>();
-            nodeChildAll.forEach(node -> {
-                oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId());
-                nodeMap.put(node.getId().toString(), node);
-            });
+        //TODO 单份复制
+        if (("1").equals(vo.getCopyType())) {
+            //首先查询需要复制的节点及其下级所有子节点的信息
+            WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
+            // 获取当前节点的所有子节点
+            String vocational = SnowFlakeUtil.getId() + "";
+            //新增施工台账
+            List<WbsTreeContract> saveList = new ArrayList<>();
+            List<ConstructionLedger> saveLedger = new ArrayList<>();
+            // 获取附件
+            List<WbsTreeContract> nodeChildAll = informationQueryService.getNodeChildAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId(), vo.getNeedCopyPrimaryKeyId());
+            // 获取实体表列对象
+            List<QueryProcessDataVO> nodeTabCols = informationQueryService.getNodeChildTabColsAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId());
+            // 转化为map
+            Map<String, String> nodeTabColsMap = nodeTabCols.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
+            StringBuilder copeSql = new StringBuilder();
 
-            //todo 单份复制
-            nodeChildAll.forEach(node -> {
-                WbsTreeContract newData = new WbsTreeContract();
-                BeanUtils.copyProperties(node, newData);
+            if (StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())) {
+                WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
                 //重塑关键信息
-                //重塑primaryKeyId
-                newData.setPKeyId(SnowFlakeUtil.getId());
-                //设置旧ID
-                if (StringUtils.isNotEmpty(node.getOldId())) {
-                    newData.setOldId(node.getOldId());
-                } else {
-                    newData.setOldId(node.getId().toString());
+                Map<Long, Long> oldToNewIdMap = new HashMap<>();
+                //节点信息
+                Map<String, WbsTreeContract> nodeMap = new HashMap<>();
+                nodeChildAll.forEach(node -> {
+                    oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId());
+                    nodeMap.put(node.getId().toString(), node);
+                });
+
+                nodeChildAll.forEach(node -> {
+                    WbsTreeContract newData = new WbsTreeContract();
+                    BeanUtils.copyProperties(node, newData);
+                    //重塑关键信息
+                    //重塑primaryKeyId
+                    newData.setPKeyId(SnowFlakeUtil.getId());
+                    //设置旧ID
+                    if (StringUtils.isNotEmpty(node.getOldId())) {
+                        newData.setOldId(node.getOldId());
+                    } else {
+                        newData.setOldId(node.getId().toString());
+                    }
+
+                    //设置新ID
+                    if (new Integer("1").equals(node.getType())) {
+                        //如果是节点类型才重塑ID
+                        newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
+                        //划分编号
+                        newData.setPartitionCode(StringUtils.isNotEmpty(vo.getPartitionCode()) ? vo.getPartitionCode() : null);
+                    }
+                    //设置父节点ID
+                    if (vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())) {
+                        //找到复制的节点,将parentId更改为 parent.getId()
+                        newData.setParentId(parent.getId());
+                        //设置新名称
+                        newData.setNodeName(vo.getNeedCopyNodeName());
+                        newData.setFullName(vo.getNeedCopyNodeName());
+                    } else {
+                        newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
+                    }
+                    newData.setCreateTime(new Date());
+                    newData.setUpdateTime(new Date());
+                    //初始化是否显示表格,默认显示
+                    newData.setIsBussShow(1);
+                    //初始化表格是否上传附件,默认未上传
+                    newData.setTabFileType(1);
+                    //初始化单表是否可以预览,默认不能
+                    newData.setIsTabPdf(1);
+                    //初始化PDF路径
+                    newData.setPdfUrl(null);
+                    newData.setCreateUser(AuthUtil.getUserId());
+                    //重塑父节点关联关系
+                    this.restoreParent(newData, oldToNewIdMap);
+                    //保存到集合中
+                    saveList.add(newData);
+                    if (new Integer("6").equals(node.getNodeType())) {
+                        //生成施工日志
+                        this.createLedger(newData, saveLedger, nodeMap, null);
+                    }
+
+                    // 组织复制值Sql
+                    if (nodeTabColsMap != null && node.getType() == 2) {
+                        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() + "' ;");
+                    }
+                });
+            }
+            //保存节点信息
+            R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
+
+            //复制数据逻辑
+            if (nodeTabColsMap != null && copeSql.length() >= 10) {
+                jdbcTemplate.execute(copeSql.toString());
+            }
+
+            //获取父节点信息
+            informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
+            return booleanR;
+
+            /** TODO 多份复制
+             * @Author liuYC
+             * @Date 2023年4月10日18:06:53
+             * @Description
+             *  解析复制节点位置信息:
+             *  1:同节点复制(同一个父级下)
+             *      1.1 如果点击选择的是当前复制节点的父级,那么就新增一个当前需要复制的节点-新的子级-新的表-新的表数据(根据所属方查询对应数据)。
+             *      1.2 如果点击选择的是当前复制节点的同级节点(自己本身节点是无法点击进行复制的),那么复制对应表数据,如果没有对应表,那么跳过。
+             *  2:跨节点复制(不同父级下)
+             *      2.1 如果点击选择的是其他父级节点的父级,那么新增一个新的当前选择的复制的节点-新的表-新的表数据(根据所属方查询对应数据)。
+             *      2.2 如果点击选择的是当前复制节点本身的节点,那么就只复制数据。
+             *      2.3 如果点击选择的是当前复制节点本身的同级别节点,那么就表示,要在当前同级别的节点下新增一份当前复制的节点-新的表-新的表数据(根据所属方查询对应数据)。
+             *      2.4 如果点击选择的是当前复制节点本身的同级别节点的子节点,如果是复制本身相同的节点,那么就只复制数据。
+             *      2.5 如果点击选择的是当前复制节点本身的同级别节点的子节点,如果是复制本身不相同的节点,那么复制对应表数据,如果没有对应表,那么跳过。
+             */
+        }/* else if (("2").equals(vo.getCopyType())) {
+            //首先查询需要复制的节点的信息
+            WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
+            //获取需要复制到的位置节点信息的集合
+            List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
+            if (needCopyNode != null && copyBatches.size() > 0) {
+                //获取当前需要复制到的位置节点信息,判断同节点复制或跨节点复制
+                List<Long> toCopyNodePKeyIds = copyBatches.stream().map(CopyContractTreeNodeVO.CopyBatch::getPrimaryKeyId).map(Long::valueOf).collect(Collectors.toList());
+                List<WbsTreeContract> toCopyNodes = wbsTreeContractClient.queryContractTreeNodeByPKIds(toCopyNodePKeyIds);
+                Map<String, CopyContractTreeNodeVO.CopyBatch> toCopyMaps = copyBatches.stream().collect(Collectors.toMap(CopyContractTreeNodeVO.CopyBatch::getPrimaryKeyId, Function.identity()));
+
+                //结果集
+                List<WbsTreeContract> resultNodes = new ArrayList<>();
+                List<WbsTreeContract> resultTables = new ArrayList<>();
+                List<String> resultTablesData = new ArrayList<>();
+
+                //解析位置信息,进行复制数据构造
+                for (WbsTreeContract toCopyNode : toCopyNodes) {
+                    CopyContractTreeNodeVO.CopyBatch toCopyVO = toCopyMaps.get(toCopyNode.getPKeyId().toString());
+                    if (toCopyVO != null) {
+
+                        //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> addChildNodes = this.getChildNodes(needCopyNode);
+
+                                if (addChildNodes == null || addChildNodes.size() == 0) {
+                                    //最下层级节点复制
+                                    addChildNodes = new ArrayList<>();
+                                    addChildNodes.add(needCopyNode);
+                                    List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(addChildNodes, toCopyNode.getContractId());
+                                    //构造
+                                    this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData);
+                                    resultNodes = addChildNodes;
+                                    resultTables = addChildNodesTables;
+
+                                } else {
+                                    //多层级节点复制
+                                    List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(addChildNodes, toCopyNode.getContractId());
+                                    this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData);
+                                    resultNodes = addChildNodes;
+                                    resultTables = addChildNodesTables;
+                                }
+
+                                //1.2 选择的同级的同级节点,只复制数据
+                            } else if (needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
+
+
+                            }
+
+                            //TODO 跨节点复制
+                        } else if (new Integer(0).equals(toCopyVO.getIsSameNode())) {
+
+
+                        }
+                    }
                 }
 
-                //设置新ID
-                if (new Integer("1").equals(node.getType())) {
-                    //如果是节点类型才重塑ID
-                    newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
-                    //划分编号
-                    newData.setPartitionCode(StringUtils.isNotEmpty(vo.getPartitionCode()) ? vo.getPartitionCode() : null);
+                //入库
+                if (resultNodes.size() > 0) {
+                    wbsTreeContractClient.saveBatch(resultNodes);
                 }
-                //设置父节点ID
-                if (vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())) {
-                    //找到复制的节点,将parentId更改为 parent.getId()
-                    newData.setParentId(parent.getId());
-                    //设置新名称
-                    newData.setNodeName(vo.getNeedCopyNodeName());
-                    newData.setFullName(vo.getNeedCopyNodeName());
-                } else {
-                    newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
+                if (resultTables.size() > 0) {
+                    wbsTreeContractClient.saveBatch(resultTables);
                 }
-                newData.setCreateTime(new Date());
-                newData.setUpdateTime(new Date());
+                if (resultTablesData.size() > 0) {
+                    jdbcTemplate.execute(StringUtils.join(resultTablesData, ""));
+                }
+
+            }
+            return null;
+        }*/
+        return null;
+    }
+
+    //新增复制节点、表的数据构造
+    private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData) {
+        Map<Long, Long> parentIdToId = new HashMap<>();
+
+        //TODO 最下层级节点复制
+        if (needNodes.size() == 1) {
+            //todo 构造节点
+            Long id = SnowFlakeUtil.getId();
+            for (WbsTreeContract needNode : needNodes) {
+                needNode.setPKeyId(SnowFlakeUtil.getId());
+                needNode.setId(id);
+                needNode.setNodeName(toCopyNode.getNodeName());
+                needNode.setFullName(toCopyNode.getNodeName());
+                needNode.setPartitionCode(toCopyNode.getPartitionCode());
+                break;
+            }
+            //todo 构造当前节点下所有元素表
+            for (WbsTreeContract needTab : needTabs) {
+                if (StringUtils.isEmpty(needTab.getInitTableName())) {
+                    continue;
+                }
+                Long oldPKeyId = needTab.getPKeyId();
+
+                Long tabId = SnowFlakeUtil.getId();
+                needTab.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
+                needTab.setId(tabId);
+                needTab.setParentId(id);
+                needTab.setPKeyId(SnowFlakeUtil.getId());
                 //初始化是否显示表格,默认显示
-                newData.setIsBussShow(1);
+                needTab.setIsBussShow(1);
                 //初始化表格是否上传附件,默认未上传
-                newData.setTabFileType(1);
+                needTab.setTabFileType(1);
                 //初始化单表是否可以预览,默认不能
-                newData.setIsTabPdf(1);
+                needTab.setIsTabPdf(1);
                 //初始化PDF路径
-                newData.setPdfUrl(null);
-                newData.setCreateUser(AuthUtil.getUserId());
-                //重塑父节点关联关系
-                this.restoreParent(newData, oldToNewIdMap);
-                //保存到集合中
-                saveList.add(newData);
-                if (new Integer("6").equals(node.getNodeType())) {
-                    //生成施工日志
-                    this.createLedger(newData, saveLedger, nodeMap, null);
-                }
-
-                // 组织复制值Sql
-                if (nodeTabColsMap != null && node.getType() == 2) {
-                    String tableName = newData.getInitTableName();
+                needTab.setPdfUrl(null);
+
+                //获取实体表列对象
+                List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
+                //转化为map
+                Map<String, String> nodeTabColsMap = nodeTabColOneTab.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
+                //组织复制表的数据的sql
+                if (nodeTabColsMap.size() > 0) {
+                    StringBuilder copyDataSql = new StringBuilder();
+                    String tableName = needTab.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() + "' ;");
+                    colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + needTab.getPKeyId() + "' as p_key_id,");
+                    copyDataSql.append("insert into ").append(tableName).append("  (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' ;");
+                    resultTablesData.add(copyDataSql.toString());
                 }
-            });
+            }
+
+            //TODO 多层级节点复制
+        } else {
+            Map<Long, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
+            toCopyNode.setId(SnowFlakeUtil.getId());
+            for (WbsTreeContract node : needNodes) {
+                Long oldId = node.getId();
+                //todo 构造节点
+                Long newParentId;
+                if (parentIdToId.size() > 0) {
+                    //去数据源节点获取父级id对应的新id,设置成重设后的新的父级id
+                    newParentId = parentIdToId.get(node.getParentId());
+                } else {
+                    //根节点
+                    newParentId = toCopyNode.getId();
+                }
+                if (ObjectUtils.isEmpty(newParentId)) {
+                    newParentId = toCopyNode.getId();
+                }
+                node.setPKeyId(SnowFlakeUtil.getId());
+                node.setOldId(node.getId().toString());
+                Long id = SnowFlakeUtil.getId();
+                //数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
+                parentIdToId.put(node.getId(), id);
+                //重设祖级id
+                node.setAncestors(node.getAncestors().replace(node.getParentId().toString(), id.toString()));
+                //重设Id
+                node.setId(id);
+                node.setParentId(newParentId);
+
+                //todo 构造当前节点下所有元素表
+                List<WbsTreeContract> tabs = tabMap.get(oldId);
+                //构造节点下的表
+                if (tabs != null && tabs.size() > 0) {
+                    for (WbsTreeContract needTab : tabs) {
+                        if (StringUtils.isEmpty(needTab.getInitTableName())) {
+                            continue;
+                        }
+                        Long oldPKeyId = needTab.getPKeyId();
+
+                        Long tabId = SnowFlakeUtil.getId();
+                        needTab.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
+                        needTab.setId(tabId);
+                        needTab.setParentId(id);
+                        needTab.setPKeyId(SnowFlakeUtil.getId());
+                        //初始化是否显示表格,默认显示
+                        needTab.setIsBussShow(1);
+                        //初始化表格是否上传附件,默认未上传
+                        needTab.setTabFileType(1);
+                        //初始化单表是否可以预览,默认不能
+                        needTab.setIsTabPdf(1);
+                        //初始化PDF路径
+                        needTab.setPdfUrl(null);
+
+                        //获取实体表列对象
+                        List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
+                        //转化为map
+                        Map<String, String> nodeTabColsMap = nodeTabColOneTab.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
+                        //组织复制表的数据的sql
+                        if (nodeTabColsMap.size() > 0) {
+                            StringBuilder copyDataSql = new StringBuilder();
+                            String tableName = needTab.getInitTableName();
+                            String col = nodeTabColsMap.get(tableName);
+                            String colVal = nodeTabColsMap.get(tableName);
+                            colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + needTab.getPKeyId() + "' as p_key_id,");
+                            copyDataSql.append("insert into ").append(tableName).append("  (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' ;");
+                            resultTablesData.add(copyDataSql.toString());
+                        }
+                    }
+                }
+            }
+            //添加根节点
+            needNodes.add(toCopyNode);
         }
-        //保存节点信息
-        R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
+    }
 
-        //复制数据逻辑
-        if (nodeTabColsMap != null && copeSql.length() >= 10) {
-            jdbcTemplate.execute(copeSql.toString());
+    //获取所有子级节点
+    private List<WbsTreeContract> getChildNodes(WbsTreeContract obj) {
+        if (obj != null) {
+            List<WbsTreeContract> wbsTreeContracts = Collections.singletonList(obj);
+            List<WbsTreeContract> result = new ArrayList<>();
+            this.recursionGetChildNodes(wbsTreeContracts, result, obj.getContractId());
+            if (result.size() > 0) {
+                return result;
+            }
         }
+        return null;
+    }
 
-        //获取父节点信息
-        informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
-        return booleanR;
+    //递归获取所有子级节点
+    private void recursionGetChildNodes(List<WbsTreeContract> list, List<WbsTreeContract> result, String contractId) {
+        List<Long> ids = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
+        if (ids.size() > 0) {
+            List<WbsTreeContract> query = jdbcTemplate.query("select * from m_wbs_tree_contract where type = 1 and parent_id in(" + StringUtils.join(ids, ",") + ") and status = 1 and is_deleted = 0 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+            if (query.size() > 0) {
+                result.addAll(query);
+                recursionGetChildNodes(query, result, contractId);
+            }
+        }
+    }
+
+    //获取所有子级下的表
+    private List<WbsTreeContract> getChildNodesTables(List<WbsTreeContract> list, String contractId) {
+        if (list != null && list.size() > 0) {
+            List<Long> parentIds = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
+            return jdbcTemplate.query("select * from m_wbs_tree_contract where type = 2 and is_deleted = 0 and status = 1 and parent_id in(" + StringUtils.join(parentIds, ",") + ") and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+        }
+        return null;
     }
 
 
@@ -1619,17 +1877,6 @@ public class InformationWriteQueryController extends BladeController {
                         newData.setPdfUrl(null);
 
                         //获取当前所有复制的节点的最大sort
-                        /*String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";
-                        List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                        List<Integer> collect = query.stream().filter(f -> ObjectUtils.isNotEmpty(f.getSort())).collect(Collectors.toList()).stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
-                        Integer max = 1;
-                        if (collect.size() > 0) {
-                            max = collect.stream().reduce(collect.get(0), Integer::max);
-                        } else {
-                            max = 1;
-                        }
-                        //设置sort
-                        newData.setSort(max);*/
                         newData.setSort(ObjectUtils.isNotEmpty(node.getSort()) ? node.getSort() : 0);
 
                         //重塑父节点关联关系

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.java

@@ -111,4 +111,8 @@ public interface InformationQueryMapper extends BaseMapper<InformationQuery> {
 
 	// 获取当前节点下,所有表单的字段数据
 	List<QueryProcessDataVO> getNodeChildTabColsAllByNodeId(String nodeId, String contractId);
+
+	// 获取当前节点下,所有表单的字段数据,根据表名
+	List<QueryProcessDataVO> getNodeChildTabColsAllByTabName(String tabName);
+
 }

File diff suppressed because it is too large
+ 491 - 405
blade-service/blade-business/src/main/java/org/springblade/business/mapper/InformationQueryMapper.xml


+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java

@@ -126,6 +126,9 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
     // 获取当前节点所有的表的字段信息
     List<QueryProcessDataVO> getNodeChildTabColsAllByNodeId(String nodeId, String contractId);
 
+    // 获取当前节点下,所有表单的字段数据,根据表名
+    List<QueryProcessDataVO> getNodeChildTabColsAllByTabName(String tabName);
+
     // 测试节点信息
     List<WbsTreeContractTreeVOS> queryContractTree(String parentId, String contractId, String contractIdRelation, String classifyType);
 

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -717,6 +717,10 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
         return baseMapper.getNodeChildTabColsAllByNodeId(nodeId, contractId);
     }
 
+    @Override
+    public List<QueryProcessDataVO> getNodeChildTabColsAllByTabName(String tabName) {
+        return baseMapper.getNodeChildTabColsAllByTabName(tabName);
+    }
 
     @Override
     public void AsyncWbsTree(String primaryKeyId, String parentId, String contractId, String contractIdRelation, String classifyType) {

+ 0 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -77,10 +77,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         WbsInfo wbsInfo = wbsInfoMapper.selectOne(Wrappers.<WbsInfo>query().lambda().eq(WbsInfo::getId, wbsId));
         if (wbsInfo != null) {
             //公有引用
-            List<WbsTreePrivateVO> tree = baseMapper.tree(wbsId, projectId, wbsInfo.getWbsType());
-            for (WbsTreePrivateVO wbsTreePrivateVO : tree) {
-
-            }
             return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, wbsInfo.getWbsType()));
         } else {
             //私有引用

Some files were not shown because too many files changed in this diff