liuyc 2 ani în urmă
părinte
comite
8e7e1d4a17

+ 7 - 2
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -28,11 +28,12 @@ public interface InformationQueryClient {
 
     /**
      * 获取当前合同树和所有已填报表信息
+     *
      * @param contractId
      * @return
      */
     @PostMapping(API_PREFIX + "/getTreeAllTable")
-    Map<String,Long> getTreeAllTable(@RequestParam String contractId);
+    Map<String, Long> getTreeAllTable(@RequestParam String contractId);
 
     /**
      * 保存填报时新增或修改填报资料记录表数据
@@ -64,6 +65,10 @@ public interface InformationQueryClient {
 
     // 更新redis数据
     @PostMapping(API_PREFIX + "/AsyncWbsTree")
-    void  AsyncWbsTree(@RequestParam String primaryKeyId,@RequestParam String parentId,@RequestParam String contractId,@RequestParam String contractIdRelation,@RequestParam String classifyType);
+    void AsyncWbsTree(@RequestParam String primaryKeyId, @RequestParam String parentId, @RequestParam String contractId, @RequestParam String contractIdRelation, @RequestParam String classifyType);
+
+    // 删除更新redis数据
+    @PostMapping(API_PREFIX + "/delAsyncWbsTree")
+    void delAsyncWbsTree(@RequestParam String parentId, @RequestParam String contractId,@RequestParam String classifyType);
 
 }

+ 152 - 130
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -58,6 +58,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;
 
 /**
@@ -1403,7 +1404,7 @@ public class InformationWriteQueryController extends BladeController {
                     }
 
                     // 组织复制值Sql
-                    if (nodeTabColsMap != null && node.getType() == 2) {
+                    if (nodeTabColsMap != null && node.getType() == 2 && StringUtils.isNotEmpty(newData.getInitTableName())) {
                         String tableName = newData.getInitTableName();
                         String col = nodeTabColsMap.get(tableName);
                         String colVal = nodeTabColsMap.get(tableName);
@@ -1437,6 +1438,7 @@ public class InformationWriteQueryController extends BladeController {
              *      2.2 如果点击选择的是当前复制节点本身的同等级节点,那么复制对应表数据,如果没有对应表,那么跳过。
              */
         } else if (("2").equals(vo.getCopyType())) {
+
             //获取需要复制到的位置节点信息的集合
             List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
             if (copyBatches.size() > 0) {
@@ -1454,8 +1456,9 @@ public class InformationWriteQueryController extends BladeController {
                 }
 
                 //结果集
-                List<WbsTreeContract> addChildNodesAll = new ArrayList<>();
-                List<WbsTreeContract> addChildNodesTablesAll = new ArrayList<>();
+                List<WbsTreeContract> addNodeList = new ArrayList<>();
+                List<WbsTreeContract> addTabList = new ArrayList<>();
+                List<WbsTreeContract> asyncWbsTreeNodes = new ArrayList<>();
                 Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>();
                 List<String> resultTablesData = new ArrayList<>();
 
@@ -1467,6 +1470,9 @@ public class InformationWriteQueryController extends BladeController {
                     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";
                 }
 
                 //解析位置信息,进行复制数据构造
@@ -1475,6 +1481,7 @@ public class InformationWriteQueryController extends BladeController {
                         //首先查询需要复制的节点的信息
                         WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
                         WbsTreeContract toCopyNode = toCopyNodes.get(i);
+                        asyncWbsTreeNodes.add(toCopyNode);
                         CopyContractTreeNodeVO.CopyBatch toCopyVO = copyBatches.get(i);
 
                         if (toCopyNode != null && toCopyVO != null && needCopyNode != null) {
@@ -1502,16 +1509,12 @@ public class InformationWriteQueryController extends BladeController {
                                     addChildNodesTablesOldAll.addAll(oldTab);
 
                                     //构造新的节点、表、数据
-                                    this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData());
-
-                                    //返回结果集
-                                    addChildNodesAll.addAll(addChildNodes);
-                                    addChildNodesTablesAll.addAll(addChildNodesTables);
+                                    this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData());
 
                                     //1.2 选择同父级的同级节点,只复制数据
                                 } else if (needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
                                     //构造数据
-                                    this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addChildNodesTablesAll, vo.getIsCopyData());
+                                    this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addTabList, vo.getIsCopyData());
                                 }
 
                                 //TODO 跨节点复制
@@ -1541,16 +1544,12 @@ public class InformationWriteQueryController extends BladeController {
                                     addChildNodesTablesOldAll.addAll(oldTab);
 
                                     //构造新的节点、表、数据
-                                    this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData());
-
-                                    //返回结果集
-                                    addChildNodesAll.addAll(addChildNodes);
-                                    addChildNodesTablesAll.addAll(addChildNodesTables);
+                                    this.addCopyNodesAndTabsBuildData(addNodeList, addTabList, addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData());
 
                                     //2.2 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据)
                                 } else if (needCopyNode.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
                                     //构造数据
-                                    this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addChildNodesTablesAll, vo.getIsCopyData());
+                                    this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addTabList, vo.getIsCopyData());
                                 }
                             }
                         }
@@ -1558,21 +1557,22 @@ public class InformationWriteQueryController extends BladeController {
                 }
 
                 //节点
-                if (addChildNodesAll.size() > 0) {
-                    wbsTreeContractClient.saveBatch(addChildNodesAll);
+                if (addNodeList.size() > 0) {
+                    wbsTreeContractClient.saveBatch(addNodeList);
                     //更新redis缓存
-                    Map<Long, List<WbsTreeContract>> collect = addChildNodesAll.stream().filter(f -> new Integer(1).equals(f.getType()) && ObjectUtil.isNotEmpty(f.getParentId())).collect(Collectors.groupingBy(WbsTreeContract::getParentId));
-                    for (Map.Entry<Long, List<WbsTreeContract>> longListEntry : collect.entrySet()) {
-                        informationQueryService.AsyncWbsTree("", longListEntry.getKey().toString(), contractId, "", "1");
+                    if (asyncWbsTreeNodes.size() > 0) {
+                        for (WbsTreeContract asyncWbsTreeNode : asyncWbsTreeNodes) {
+                            informationQueryService.AsyncWbsTree("", asyncWbsTreeNode.getParentId() + "", contractId, "", "1");
+                        }
                     }
                 }
                 //元素表
-                if (addChildNodesTablesAll.size() > 0) {
-                    wbsTreeContractClient.saveBatch(addChildNodesTablesAll);
+                if (addTabList.size() > 0) {
+                    wbsTreeContractClient.saveBatch(addTabList);
 
                     //表单文件附件
                     if (addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
-                        this.addCopyTabFile(addChildNodesTablesAll, addChildNodesTablesOldAll);
+                        this.addCopyTabFile(addTabList, addChildNodesTablesOldAll);
                     }
                 }
                 //实体表数据
@@ -1674,7 +1674,7 @@ public class InformationWriteQueryController extends BladeController {
     /**
      * 新增复制的节点、表的数据构造
      */
-    private void addCopyNodesAndTabsBuildData(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) {
             //判断是否为最下级节点
@@ -1689,54 +1689,66 @@ public class InformationWriteQueryController extends BladeController {
             //构造节点
             Long id = SnowFlakeUtil.getId();
             for (WbsTreeContract needNode : needNodes) {
-                if (isSameNode == 0) {
-                    //跨节点复制,更改父级id
-                    needNode.setParentId(toCopyNode.getId());
+                WbsTreeContract obj = BeanUtil.copyProperties(needNode, WbsTreeContract.class);
+                if (obj != null) {
+                    if (isSameNode == 0) {
+                        //跨节点复制,更改父级id
+                        obj.setParentId(toCopyNode.getId());
+                        //设置祖级id
+                        String[] split = obj.getAncestors().split(",");
+                        String lastId = split[split.length - 1];
+                        obj.setAncestors(obj.getAncestors().replace(lastId, toCopyNode.getId().toString()));
+                    }
+                    obj.setOldId(needNode.getId() + "");
+                    obj.setPKeyId(SnowFlakeUtil.getId());
+                    obj.setId(id);
+                    obj.setNodeName(toCopyNode.getNodeName());
+                    obj.setFullName(toCopyNode.getNodeName());
+                    obj.setPartitionCode(toCopyNode.getPartitionCode());
+                    obj.setCreateTime(new Date());
+                    addNodeList.add(obj);
+                    break;
                 }
-                needNode.setOldId(needNode.getId() + "");
-                needNode.setPKeyId(SnowFlakeUtil.getId());
-                needNode.setId(id);
-                needNode.setNodeName(toCopyNode.getNodeName());
-                needNode.setFullName(toCopyNode.getNodeName());
-                needNode.setPartitionCode(toCopyNode.getPartitionCode());
-                break;
             }
             //构造当前节点下所有元素表
             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());
-                //初始化是否显示表格,默认显示
-                needTab.setIsBussShow(1);
-                //初始化表格是否上传附件,默认未上传
-                needTab.setTabFileType(1);
-                //初始化单表是否可以预览,默认不能
-                needTab.setIsTabPdf(1);
-                //初始化PDF路径
-                needTab.setPdfUrl(null);
-
-                //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
-                if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
-                    //获取实体表列对象
-                    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());
+                WbsTreeContract obj = BeanUtil.copyProperties(needTab, WbsTreeContract.class);
+                if (obj != null) {
+                    Long oldPKeyId = needTab.getPKeyId();
+                    obj.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
+                    obj.setId(SnowFlakeUtil.getId());
+                    obj.setParentId(id);
+                    obj.setPKeyId(SnowFlakeUtil.getId());
+                    //初始化是否显示表格,默认显示
+                    obj.setIsBussShow(1);
+                    //初始化表格是否上传附件,默认未上传
+                    obj.setTabFileType(1);
+                    //初始化单表是否可以预览,默认不能
+                    obj.setIsTabPdf(1);
+                    //初始化PDF路径
+                    obj.setPdfUrl(null);
+                    obj.setCreateTime(new Date());
+                    addTabList.add(obj);
+
+                    //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
+                    if (tabOwner.contains(obj.getTableOwner()) && isCopyData == 1) {
+                        //获取实体表列对象
+                        List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(obj.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 = obj.getInitTableName();
+                            String col = nodeTabColsMap.get(tableName);
+                            String colVal = nodeTabColsMap.get(tableName);
+                            colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + obj.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());
+                        }
                     }
                 }
             }
@@ -1749,70 +1761,81 @@ public class InformationWriteQueryController extends BladeController {
             Map<Long, Long> parentIdToId = new HashMap<>();
             Map<Long, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
 
+            //获取节点下所有表的key
+            List<String> initTabNames = needTabs.stream().map(WbsTreeContract::getInitTableName).distinct().filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
+            String joined = StringUtils.join(initTabNames, ",");
+            joined = "'" + joined.replaceAll(",", "','") + "'";
+            Map<String, QueryProcessDataVO> tabColsAllByTabNameMaps = jdbcTemplate.query("SELECT table_name as queryType, GROUP_CONCAT(COLUMN_name) as ancestors from information_schema.COLUMNS where table_name in (" + joined + ") GROUP BY table_name", new BeanPropertyRowMapper<>(QueryProcessDataVO.class)).stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, Function.identity()));
             for (WbsTreeContract node : needNodes) {
                 Long oldId = node.getId();
-                //构造节点
-                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);
-
-                //构造当前节点下所有元素表
-                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);
-
-                        //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
-                        if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
-                            //获取实体表列对象
-                            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();
+                WbsTreeContract obj = BeanUtil.copyProperties(node, WbsTreeContract.class);
+                if (obj != null) {
+                    //构造节点
+                    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();
+                    }
+                    obj.setPKeyId(SnowFlakeUtil.getId());
+                    obj.setOldId(node.getId().toString());
+                    Long id = SnowFlakeUtil.getId();
+                    //数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
+                    parentIdToId.put(node.getId(), id);
+                    //重设祖级id
+                    this.restoreParent(obj, parentIdToId);
+                    //重设Id
+                    obj.setId(id);
+                    obj.setParentId(newParentId);
+                    obj.setCreateTime(new Date());
+                    addNodeList.add(obj);
+
+                    //构造当前节点下所有元素表
+                    List<WbsTreeContract> tabs = tabMap.get(oldId);
+                    //构造节点下的表
+                    if (tabs != null && tabs.size() > 0) {
+                        for (WbsTreeContract needTab : tabs) {
+                            if (StringUtils.isEmpty(needTab.getInitTableName())) {
+                                continue;
+                            }
+                            WbsTreeContract objTab = BeanUtil.copyProperties(needTab, WbsTreeContract.class);
+                            if (objTab != null) {
+                                Long oldPKeyId = needTab.getPKeyId();
                                 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());
+                                Long tabId = SnowFlakeUtil.getId();
+                                objTab.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
+                                objTab.setId(tabId);
+                                objTab.setParentId(id);
+                                objTab.setPKeyId(SnowFlakeUtil.getId());
+                                //初始化是否显示表格,默认显示
+                                objTab.setIsBussShow(1);
+                                //初始化表格是否上传附件,默认未上传
+                                objTab.setTabFileType(1);
+                                //初始化单表是否可以预览,默认不能
+                                objTab.setIsTabPdf(1);
+                                //初始化PDF路径
+                                objTab.setPdfUrl(null);
+                                objTab.setCreateTime(new Date());
+                                addTabList.add(objTab);
+
+                                //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
+                                if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1 && tabColsAllByTabNameMaps.size() > 0) {
+                                    QueryProcessDataVO queryProcessDataVO = tabColsAllByTabNameMaps.get(tableName);
+                                    //组织复制表的数据的sql
+                                    if (queryProcessDataVO != null) {
+                                        StringBuilder copyDataSql = new StringBuilder();
+                                        String col = queryProcessDataVO.getAncestors();
+                                        String colVal = queryProcessDataVO.getAncestors();
+                                        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());
+                                    }
+                                }
                             }
                         }
                     }
@@ -1827,12 +1850,15 @@ public class InformationWriteQueryController extends BladeController {
             } else {
                 //跨节点
                 toCopyNode.setParentId(toCopyNodeOldId);
+                //重设祖级id
+                toCopyNode.setAncestors(needCopyNode.getAncestors().replace(needCopyNode.getParentId().toString(), toCopyNode.getId().toString()));
             }
             toCopyNode.setPKeyId(SnowFlakeUtil.getId());
             toCopyNode.setNodeName(toCopyNode.getNodeName());
             toCopyNode.setFullName(toCopyNode.getNodeName());
             toCopyNode.setPartitionCode(toCopyNode.getPartitionCode());
             needNodes.add(toCopyNode);
+            addNodeList.add(toCopyNode);
         }
     }
 
@@ -2069,7 +2095,6 @@ public class InformationWriteQueryController extends BladeController {
                             this.createLedger(newData, saveLedger, nodeMap, null);
                         }
                     });
-
                 });
             }
         }
@@ -2941,9 +2966,6 @@ public class InformationWriteQueryController extends BladeController {
         return R.data(wbsTreeContractTreeVOS);
     }
 
-
-    // set的处理
-
     /**
      * 修改
      */

+ 6 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java

@@ -79,4 +79,10 @@ public class InformationQueryClientImpl implements InformationQueryClient {
     public void AsyncWbsTree(String primaryKeyId, String parentId, String contractId, String contractIdRelation, String classifyType) {
         iInformationQueryService.AsyncWbsTree(primaryKeyId,parentId,contractId,contractIdRelation,classifyType);
     }
+
+    @Override
+    public void delAsyncWbsTree(String parentId, String contractId, String classifyType) {
+        iInformationQueryService.delAsyncWbsTree(parentId,contractId,classifyType);
+    }
+
 }

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

@@ -146,7 +146,7 @@
                    WHEN (c.allCount + 1) = c.submitCounts and notExsitChild = 'true' THEN 3
                    WHEN c.allCount = c.appCount and notExsitChild = 'false' THEN 4
                    WHEN (c.allCount + 1) = c.appCount and notExsitChild = 'true' THEN 4
-                   WHEN c.savaCont >= 1 or c.submitCounts >= 1 or c.appCount >= 1 THEN 2
+                   -- WHEN c.savaCont >= 1 or c.submitCounts >= 1 or c.appCount >= 1 THEN 2
                    ELSE 1 END AS colorStatus
         from (
                  SELECT wtc.sort,
@@ -182,7 +182,9 @@
         END AS isFirst,
 			 ( SELECT count(1) from m_wbs_tree_contract where id in(SELECT parent_id from m_wbs_tree_contract a where a.is_deleted=0 and a.type=2 and table_owner in(1,2,3)) and contract_id=wtc.contract_id and type =1 and is_deleted=0 and (FIND_IN_SET(wtc.id,ancestors) or wtc.p_key_id=p_key_id)
 				) as allCount,
-			 (SELECT count(1) from u_information_query b where b.wbs_id in(SELECT p_key_id from m_wbs_tree_contract a where (FIND_IN_SET(wtc.id,a.ancestors) or wtc.p_key_id=a.p_key_id) and a.is_deleted=0 ) and b.`status`='0' and b.is_deleted=0 and b.classify=1 and b.contract_id=wtc.contract_id ) as savaCont,
+			 (SELECT count(1) from u_information_query b where b.wbs_id in(SELECT p_key_id from m_wbs_tree_contract a
+                where (FIND_IN_SET(wtc.id,a.ancestors) or wtc.p_key_id=a.p_key_id) and a.is_deleted=0 ) and b.`status`='0'
+                and b.is_deleted=0 and b.classify=1 and b.contract_id=wtc.contract_id ) as savaCont,
 			 (SELECT count(1) from u_information_query b where b.wbs_id in(SELECT p_key_id from m_wbs_tree_contract a where (FIND_IN_SET(wtc.id,a.ancestors) or wtc.p_key_id=a.p_key_id) and a.is_deleted=0 ) and b.`status`='1' and b.is_deleted=0 and b.classify=1 and b.contract_id=wtc.contract_id) as submitCounts,
 			 (SELECT count(1) from u_information_query b where b.wbs_id in(SELECT p_key_id from m_wbs_tree_contract a where (FIND_IN_SET(wtc.id,a.ancestors) or wtc.p_key_id=a.p_key_id) and a.is_deleted=0 ) and b.`status`='2' and b.is_deleted=0 and b.classify=1 and b.contract_id=wtc.contract_id) as appCount
 				FROM

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

@@ -134,4 +134,8 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
 
     //变更节点
     void  AsyncWbsTree(String primaryKeyId,String parentId,String contractId,String contractIdRelation,String classifyType);
+
+    //删除变更节点
+    void  delAsyncWbsTree(String parentId, String contractId, String classifyType);
+
 }

+ 8 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -105,7 +105,7 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
             }
             if (tableList != null && tableList.size() > 0) {
                 //删除掉无法溯源的数据
-                tableList.removeIf(node -> node.getIsTypePrivatePid() == null || node.getIsTypePrivatePid() <= 0 || StringUtils.isEmpty(node.getIsTypePrivatePid().toString()) || node.getHtmlUrl()==null );
+                tableList.removeIf(node -> node.getIsTypePrivatePid() == null || node.getIsTypePrivatePid() <= 0 || StringUtils.isEmpty(node.getIsTypePrivatePid().toString()) || node.getHtmlUrl() == null);
                 List<Long> privatePIdList = tableList.stream().map(WbsTreeContract::getIsTypePrivatePid).distinct().collect(Collectors.toList());
                 return JSONArray.parseArray(JSONObject.toJSONString(privatePIdList), String.class);
 
@@ -728,4 +728,11 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
         JSONArray array = JSONArray.parseArray(JSON.toJSONString(wbsTreeContractTreeVOS));
         RedisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + dataInfoId, JSON.toJSON(array).toString());
     }
+
+    @Override
+    public void delAsyncWbsTree(String parentId, String contractId, String classifyType) {
+        String dataInfoId = contractId + "_" + parentId + "_" + classifyType;
+        RedisTemplate.delete("blade-manager::contract:wbstree:" + dataInfoId);
+    }
+
 }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreeContractClientImpl.java

@@ -107,7 +107,7 @@ public class WbsTreeContractClientImpl implements WbsTreeContractClient {
 
     @Override
     public Boolean saveBatch(List<WbsTreeContract> list) {
-        return this.wbsTreeContractServiceImpl.saveOrUpdateBatch(list, 1000);
+        return this.wbsTreeContractServiceImpl.insertBatch(list, 1000);
     }
 
     @Override

+ 2 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -152,7 +152,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                     }
                 }
             });
-            if (wbsTreeContractResultData.size()>0){
+            if (wbsTreeContractResultData.size() > 0) {
                 this.insertBatch(wbsTreeContractResultData, 1000);
             }
 
@@ -188,9 +188,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 List<WbsTreeContract> delObjList = list.stream().filter(f -> ids1.contains(f.getId())).collect(Collectors.toList());
                 Map<Long, List<WbsTreeContract>> collect = delObjList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getParentId())).collect(Collectors.groupingBy(WbsTreeContract::getParentId));
                 for (Map.Entry<Long, List<WbsTreeContract>> longListEntry : collect.entrySet()) {
-                    informationQueryClient.AsyncWbsTree(longListEntry.getKey().toString() + "", longListEntry.getKey() + "", pawDTO.getContractId(), "", "1");
+                    informationQueryClient.delAsyncWbsTree(longListEntry.getKey().toString() + "", pawDTO.getContractId() + "", "1");
                 }
-
             }
 
             //TODO ---------新增---------