Răsfoiți Sursa

Merge branch 'master' of http://121.41.40.202:3000/zhuwei/bladex

huangtf 1 an în urmă
părinte
comite
ad73176be0

+ 3 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -706,8 +706,8 @@ public class TaskController extends BladeController {
                                     dto.setProjectAndUserList(list);
                                     //单个保存专家信息
                                     R<Boolean> booleanR = userClient.saveUserDTO(dto);
-                                    if (booleanR.getData() == null ||  booleanR.getData() != true){
-                                        throw new ServiceException("保存专家账号失败");
+                                    if (booleanR.getData() == null ||  booleanR.isSuccess() != true){
+                                        throw new ServiceException(booleanR.getMsg());
                                     }
                                 }
                                 //修改档案类型
@@ -715,7 +715,7 @@ public class TaskController extends BladeController {
                                 if (StringUtils.isNotBlank(archiveIds)){
                                     List<Long> longs = Func.toLongList(archiveIds);
                                     R<Boolean> booleanR = archiveClient.batchUpdateIsApply(1, longs);
-                                    if (booleanR.getData() == null || booleanR.getData() != true){
+                                    if (booleanR.getData() == null || booleanR.isSuccess() != true){
                                         throw new ServiceException("修改档案类型失败");
                                     }
                                 }

+ 92 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -2216,6 +2216,98 @@ public class ExcelTabController extends BladeController {
     }
 
 
+    @PostMapping("/data-batch-refresh")
+    @ApiOperationSupport(order = 100)
+    @ApiOperation(value = "批量重新保存", notes = "批量重新保存")
+    public R saveBussDataBatchRefresh(Long pkeyId){
+        List<Map<String ,Object>> listMaps= this.jdbcTemplate.queryForList("");
+        if(listMaps.size()>0){
+            listMaps.forEach(node->{
+                try {
+                    this.start(node.get("pkeyId").toString());
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+
+            });
+        }
+      return   R.success("无数据");
+    }
+
+
+    public R start(String nodeId) throws Exception {
+        JSONArray dataArray = new JSONArray();
+//        String nodeId = tableInfo1.getString("nodeId");
+        String contractId ="1630017379264610305";
+        String projectId = "1630011899725201410";
+        String classify = "1";
+
+        /*全加载,或者可以优化成依赖加载*/
+
+        List<AppWbsTreeContractVO> tableAll  = wbsTreeContractService.searchNodeAllTable(nodeId, "1", contractId, projectId,null);
+        List<Long> tableAllIds = tableAll.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
+        for (Long pk : tableAllIds) {
+            Map<String, Object> jo = this.excelTabService.getBussDataInfo(pk, 1);
+            if (ObjectUtils.isNotEmpty(jo)) {
+                jo.put("pkeyId", pk);
+                dataArray.add(jo);
+            }
+        }
+        List<TableInfo> tableInfoList = this.excelTabService.getTableInfoList(dataArray);
+        /*默认额外加载的默认不更新,除非有元素数据变动*/
+        tableInfoList.removeIf(e -> e.getPkeyId() == null);
+        tableInfoList.forEach(e -> {
+            e.setToBeUpdated(false);
+            e.setBusinessId(null);
+            e.setContractId(contractId);
+            e.setClassify(classify);
+            e.setProjectId(projectId);
+            e.setGroupId("0");
+        });
+        tableInfoList.sort(Comparator.comparingInt(a -> tableAllIds.indexOf(Long.parseLong(a.getPkeyId()))));
+        //公式填充
+        this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.INSPECTION);
+        //保存数据到数据库
+        R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
+        if (!result.isSuccess()) {
+            return R.fail(result.getMsg());
+        }
+
+
+        List<String> errorPKeyIds = new ArrayList<>();
+        //单个pdf加载
+        if (tableInfoList != null) {
+            for (TableInfo tableInfo : tableInfoList) {
+                R bussPdfInfo = excelTabService.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
+
+                if (ObjectUtil.isEmpty(bussPdfInfo) || bussPdfInfo.getCode() != 200) {
+                    //如果返回的单张pdfUrl为空,那么表示发生异常,返回异常信息
+                    errorPKeyIds.add(tableInfo.getPkeyId());
+                }
+            }
+        }
+
+        //发生异常后直接返回,不进行合并
+        if (errorPKeyIds.size() > 0) {
+            List<AppWbsTreeContractVO> errorTabs = new LinkedList<>();
+            for (AppWbsTreeContractVO appWbsTreeContractVO : tableAll) {
+                if (errorPKeyIds.contains(appWbsTreeContractVO.getPKeyId().toString())) {
+                    errorTabs.add(appWbsTreeContractVO);
+                }
+            }
+            if (errorTabs.size() > 0) {
+                List<String> names = errorTabs.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
+                return R.fail("以下的表在生成pdf文件时发生了异常【" + StringUtils.join(names, "、") + "】");
+            }
+        }
+
+        //合并pdf加载
+        excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
+
+        //更新缓存
+        informationQueryClient.delAsyncWbsTree(contractId);
+        return R.success("OK");
+    }
     /***
      * 覆盖上传-  (修改为上传导入模板)
      */

+ 12 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractServiceImpl.java

@@ -1439,13 +1439,20 @@ public class ArchiveTreeContractServiceImpl extends BaseServiceImpl<ArchiveTreeC
 		if (one == null){
 			throw new ServiceException("未找到当前项目首节点");
 		}
-		Long userId = AuthUtil.getUserId();
-		//判断是否存在当前专家id
-		if (StringUtil.isNotBlank(one.getExpertId()) && one.getExpertId().contains(userId+"")){
-			return false;
+		BladeUser user = AuthUtil.getUser();
+		String roleId = user.getRoleId();
+		//判断当前用户是否为专家
+		if (roleId.contains("1656191696348082177") || roleId.contains("1656191770880864257")){
+			//判断是否存在当前专家id
+			if (StringUtil.isNotBlank(one.getExpertId()) && one.getExpertId().contains(user.getUserId()+"")){
+				return false;
+			}else {
+				return true;
+			}
 		}else {
-			return true;
+			throw new ServiceException("当前用户不是专家,不能抽检");
 		}
+
 	}
 
 

+ 43 - 61
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -482,73 +482,55 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
    }
 
     public void missingFill(List<String> missingList){
-        /*数据池里面没有任何元素匹配和当前依赖匹配*/
-        if(Func.isNotEmpty(missingList)){
-            StaticLog.info("需要挂载的元素{}", String.join(";", missingList));
-            Map<String, Object> elementInfoMap=this.getElementInfoByCodes(String.join(",",missingList));
-            /*1从当前节点其它表格中查找匹配的元素*/
-            List<String> removeList=new ArrayList<>();
-            /*if(false) {*//*全加载后,关闭当前节的搜索,假如后期改成依赖加载可以再次利用*//*
-                for (String r : missingList) {
-                    String tn = r.substring(0, r.indexOf(StringPool.COLON));
-                    String key = r.substring(r.indexOf(StringPool.COLON) + 1);
-                    List<NodeTable> nodeList = this.tec.getTableAll().stream().filter(e -> e.getInitTableName().equals(tn)).collect(Collectors.toList());
-                    if (Func.isNotEmpty(nodeList)) {
-                        removeList.add(r);
-                        @SuppressWarnings("unchecked")
-                        Map<String, Object> elementInfo = (Map<String, Object>) elementInfoMap.get(r);
-                        String tableName = nodeList.get(0).getInitTableName();
-                        if (!this.tec.getCoordinateMap().containsKey(tableName)) {
-                            this.tec.getCoordinateMap().put(tableName, FormulaUtils.getElementCell(nodeList.get(0).getHtmlUrl()));
-                        }
-                        List<Map<String, Object>> tableDatas = this.jdbcTemplate.queryForList("select * from " + tableName + " where p_key_id in(" + nodeList.stream().map(NodeTable::getPKeyId).map(StringUtils::handleNull).collect(Collectors.joining(",")) + ")");
-                        fill(tableDatas, removeList, tn, key, StringUtils.handleNull(elementInfo.get("ename")));
+        try {
+            /*数据池里面没有任何元素匹配和当前依赖匹配*/
+            if (Func.isNotEmpty(missingList)) {
+                StaticLog.info("需要挂载的元素{}", String.join(";", missingList));
+                Map<String, Object> elementInfoMap = this.getElementInfoByCodes(String.join(",", missingList));
+                /*1从当前节点其它表格中查找匹配的元素*/
+                List<String> removeList = new ArrayList<>();
+                if (Func.isNotEmpty(missingList)) {
+                    /*2从当前节点的兄弟节点中查找匹配的元素*/
+                    CurrentNode currentNode = this.tec.getCurrentNode();
+                    /*List<Map<String,Object>> tableNamePkIdsMaps= this.jdbcTemplate.queryForList("select c.init_table_name tableName,c.p_key_id pkId,c.html_url url from (select b.id from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.contract_id=b.contract_id and b.ancestors like CONCAT(a.ancestors,'%')) where a.p_key_id="+currentNode.getPkId()+" and b.is_deleted=0 and b.node_type=6 ORDER BY b.sort) k join m_wbs_tree_contract c on c.parent_id = k.id where  c.contract_id="+tec.getContractId()+" and c.is_deleted=0 ");*/
+                    WbsTreeContract parent = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, currentNode.getParentPkeyId()));
+                    if (parent == null) {
+                        return;
+                    }
+                    List<Map<String, Object>> tableNamePkIdsMaps = this.jdbcTemplate.queryForList(
+                            "select c.init_table_name tableName,c.p_key_id pkId,c.html_url url from" +
+                                    " (select id from m_wbs_tree_contract where contract_id=" + currentNode.getContractId() + " and is_deleted=0 and node_type=6 and tree_code like '" + parent.getTreeCode() + "%' ORDER BY sort) k" +
+                                    " join m_wbs_tree_contract c on c.parent_id = k.id " +
+                                    "where  c.contract_id=" + currentNode.getContractId() + " and c.is_deleted=0 "
+                    );
+                    if (Func.isNotEmpty(tableNamePkIdsMaps)) {
+                        // removeList.clear();
+                        missingList.forEach(miss -> {
+                            @SuppressWarnings("unckecked")
+                            Map<String, Object> elementInfo = (Map<String, Object>) elementInfoMap.get(miss);
+                            String tn = miss.substring(0, miss.indexOf(StringPool.COLON));
+                            String key = miss.substring(miss.indexOf(StringPool.COLON) + 1);
+                            String targetIds = tableNamePkIdsMaps.stream().filter(m -> StringUtils.isEquals(m.get("tableName"), tn)).map(m -> m.get("pkId")).map(StringUtils::handleNull).collect(Collectors.joining(","));
+                            if (Func.isNotEmpty(targetIds)) {
+                                if (!this.tec.getCoordinateMap().containsKey(tn)) {
+                                    tableNamePkIdsMaps.stream().filter(m -> StringUtils.isEquals(m.get("tableName"), tn)).findAny().ifPresent(m -> {
+                                        this.tec.getCoordinateMap().put(tn, FormulaUtils.getElementCell(StringUtils.handleNull(m.get("url"))));
+                                    });
+                                }
+                                List<Map<String, Object>> tableDatas = this.jdbcTemplate.queryForList("select * from " + tn + " where p_key_id in (" + targetIds + ")");
+                                String tmp = elementInfo == null ? "" : StringUtils.handleNull(elementInfo.get("ename"));
+                                fill(tableDatas, removeList, tn, key, tmp);
+                            }
+                        });
                     }
                 }
                 if (Func.isNotEmpty(removeList)) {
-                    *//*移除已经找到的元素数据*//*
+                    /*移除已经找到的元素数据*/
                     missingList.removeIf(removeList::contains);
                 }
-            }*/
-            if(Func.isNotEmpty(missingList)){
-                /*2从当前节点的兄弟节点中查找匹配的元素*/
-                CurrentNode currentNode = this.tec.getCurrentNode();
-                /*List<Map<String,Object>> tableNamePkIdsMaps= this.jdbcTemplate.queryForList("select c.init_table_name tableName,c.p_key_id pkId,c.html_url url from (select b.id from m_wbs_tree_contract a join m_wbs_tree_contract b on (a.contract_id=b.contract_id and b.ancestors like CONCAT(a.ancestors,'%')) where a.p_key_id="+currentNode.getPkId()+" and b.is_deleted=0 and b.node_type=6 ORDER BY b.sort) k join m_wbs_tree_contract c on c.parent_id = k.id where  c.contract_id="+tec.getContractId()+" and c.is_deleted=0 ");*/
-                WbsTreeContract parent = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,currentNode.getParentPkeyId()));
-                if(parent==null){
-                    return;
-                }
-                List<Map<String,Object>> tableNamePkIdsMaps= this.jdbcTemplate.queryForList(
-                        "select c.init_table_name tableName,c.p_key_id pkId,c.html_url url from" +
-                                " (select id from m_wbs_tree_contract where contract_id="+currentNode.getContractId()+" and is_deleted=0 and node_type=6 and tree_code like '"+parent.getTreeCode()+"%' ORDER BY sort) k" +
-                                " join m_wbs_tree_contract c on c.parent_id = k.id " +
-                                "where  c.contract_id="+currentNode.getContractId()+" and c.is_deleted=0 "
-                );
-                if(Func.isNotEmpty(tableNamePkIdsMaps)){
-                   // removeList.clear();
-                    missingList.forEach(miss->{
-                        @SuppressWarnings("unckecked")
-                        Map<String,Object> elementInfo= (Map<String, Object>) elementInfoMap.get(miss);
-                        String tn = miss.substring(0,miss.indexOf(StringPool.COLON));
-                        String key =miss.substring(miss.indexOf(StringPool.COLON)+1);
-                        String targetIds=tableNamePkIdsMaps.stream().filter(m->StringUtils.isEquals(m.get("tableName"),tn)).map(m->m.get("pkId")).map(StringUtils::handleNull).collect(Collectors.joining(","));
-                        if(Func.isNotEmpty(targetIds)){
-                            if(!this.tec.getCoordinateMap().containsKey(tn)){
-                                tableNamePkIdsMaps.stream().filter(m->StringUtils.isEquals(m.get("tableName"),tn)).findAny().ifPresent(m->{
-                                    this.tec.getCoordinateMap().put(tn,FormulaUtils.getElementCell(StringUtils.handleNull(m.get("url"))));
-                                });
-                            }
-                            List<Map<String,Object>> tableDatas= this.jdbcTemplate.queryForList("select * from "+tn+" where p_key_id in ("+targetIds+")");
-                            String tmp =elementInfo==null?"":StringUtils.handleNull(elementInfo.get("ename"));
-                            fill(tableDatas,removeList,tn,key,tmp);
-                        }
-                    });
-                }
-            }
-            if(Func.isNotEmpty(removeList)){
-                /*移除已经找到的元素数据*/
-                missingList.removeIf(removeList::contains);
             }
+        }catch (Exception e){
+            e.printStackTrace();
         }
     }
     public void missingFill2(List<String> missingList){

+ 138 - 25
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -57,7 +57,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.io.*;
 import java.math.BigInteger;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.*;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -732,13 +732,22 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             if (contractInfo != null) {
                 /*施工合同段*/
                 if (new Integer(1).equals(contractInfo.getContractType())) {
-                    //获取本地缓存节点信息
-                    List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
-
                     //获取当前层懒加载节点
                     String sql = "select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id and is_deleted = 0 limit 1) AS drawingsId,id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time";
                     List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
-                    if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
+                    if (lazyNodes.size() > 0) {
+
+                        /*根节点直接返回*/
+                        if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
+                            for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
+                                lazyNode.setSubmitCounts(0);
+                                lazyNode.setColorStatus(2);
+                            }
+                            return lazyNodes;
+                        }
+
+                        //获取本地缓存节点信息
+                        List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
                         List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
                                 .collect(Collectors.collectingAndThen(
                                         Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
@@ -764,6 +773,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
                         //获取本地缓存节点数量统计
                         List<WbsTreeContractLazyVO> resultParentNodesTB = this.getCachedParentCountNodes(contractId, lowestNodeParentIdsTB, nodesAll, tableOwner);
+                        //List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
+                        //this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
 
                         //最底层节点颜色构造后Map
                         Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
@@ -795,7 +806,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
                         long endTime = System.currentTimeMillis();
                         long executionTime = endTime - startTime;
-                        logger.info("处理颜色执行时间:" + executionTime + " ms");
+                        logger.info("合同段 " + contractId + " 处理颜色 执行时间:" + executionTime + " ms");
 
                         /*处理最终结果集*/
                         if (lazyNodes.size() > 0) {
@@ -861,10 +872,18 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                     for (String sgContractId : contractIds) {
                         ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
                         if (sgContractInfo != null) {
-                            List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
-
                             List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id and is_deleted = 0 limit 1) AS drawingsId,id,parent_id,node_type,type,wbs_type,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND  b.type = 1 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
-                            if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
+                            if (lazyNodes.size() > 0) {
+
+                                if (lazyNodes.stream().anyMatch(f -> f.getParentId().equals(0L))) {
+                                    for (WbsTreeContractLazyVO lazyNode : lazyNodes) {
+                                        lazyNode.setSubmitCounts(0);
+                                        lazyNode.setColorStatus(2);
+                                    }
+                                    return lazyNodes;
+                                }
+
+                                List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
                                 List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
                                         .collect(Collectors.collectingAndThen(
                                                 Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
@@ -964,21 +983,43 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         //获取本地缓存
         List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
 
-        if (nodesAll == null || nodesAll.size() == 0) {
+        if (nodesAll == null || nodesAll.isEmpty()) {
             //从Redis获取数据
             Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
             if (data != null) {
                 nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
                 //更新本地缓存
                 localCacheNodes.put(contractId, nodesAll);
-
             } else {
                 //返回数据库数据
                 long startTime = System.currentTimeMillis();
-                nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+
+                /*分页查询,每次5000条*/
+                int pageSize = 5000;
+                int pageNumber = 1;
+                int offset;
+
+                nodesAll = new ArrayList<>();
+                List<WbsTreeContractLazyVO> nodesAllPage;
+                do {
+                    offset = (pageNumber - 1) * pageSize;
+                    nodesAllPage = jdbcTemplate.query(
+                            "SELECT p_key_id, id, parent_id FROM m_wbs_tree_contract " +
+                                    "WHERE type = 1 " +
+                                    "AND status = 1 " +
+                                    "AND is_deleted = 0 " +
+                                    "AND contract_id = ? " +
+                                    "LIMIT ? OFFSET ?",
+                            new Object[]{contractId, pageSize, offset},
+                            new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class)
+                    );
+                    nodesAll.addAll(nodesAllPage);
+                    pageNumber++;
+                } while (nodesAllPage.size() == pageSize);
+
                 long endTime = System.currentTimeMillis();
                 long executionTime = endTime - startTime;
-                logger.info("查询合同段 " + contractId + " 所有树执行时间:" + executionTime + " ms");
+                logger.info("合同段 " + contractId + " 查询所有wbs节点 执行时间:" + executionTime + " ms");
 
                 if (nodesAll.size() > 0) {
                     //判断是否有子级,赋值
@@ -994,6 +1035,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             vo.setHasChildren(0);
                         }
                     }
+
                     //存储到Redis中
                     JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
                     redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
@@ -1033,10 +1075,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 /*重新计算,进行递归获取父节点计数统计*/
                 resultParentNodesTB = new ArrayList<>();
                 long startTime = System.currentTimeMillis();
+
                 this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
+
                 long endTime = System.currentTimeMillis();
                 long executionTime = endTime - startTime;
-                logger.info("节点树数量统计计算耗时:" + executionTime + " ms");
+                logger.info("合同段 " + contractId + " wbs节点树 数量计算 耗时:" + executionTime + " ms");
 
                 if (resultParentNodesTB.size() > 0) {
                     //存储到Redis中
@@ -1072,7 +1116,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         //从Redis获取数据
         Object dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey);
 
-        List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+        List<WbsTreeContractLazyQueryInfoVO> queryInfoList = new ArrayList<>();
         if (dataInformationQuery != null) {
             queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
             //更新本地缓存
@@ -1081,13 +1125,33 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         } else {
             //返回数据库数据
             long startTime = System.currentTimeMillis();
-            String querySql = "select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner;
-            queryInfoList = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+
+            /*分页查询,每次5000条*/
+            int pageSize = 5000;
+            int pageNumber = 1;
+            int offset;
+
+            List<WbsTreeContractLazyQueryInfoVO> queryInfoListPage;
+
+            do {
+                offset = (pageNumber - 1) * pageSize;
+                queryInfoListPage = jdbcTemplate.query(
+                        "SELECT wbs_id, status FROM u_information_query " +
+                                "WHERE type = 1 " +
+                                "AND contract_id = ? " +
+                                "AND classify = ? " +
+                                "LIMIT ? OFFSET ?",
+                        new Object[]{contractId, tableOwner, pageSize, offset},
+                        new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                queryInfoList.addAll(queryInfoListPage);
+                pageNumber++;
+            } while (queryInfoListPage.size() == pageSize);
+
             long endTime = System.currentTimeMillis();
             long executionTime = endTime - startTime;
-            logger.info("合同段资料信息查询耗时:" + executionTime + " ms");
+            logger.info("合同段 " + contractId + " 查询所有资料信息 执行时间:" + executionTime + " ms");
 
-            if (!queryInfoList.isEmpty()) {
+            if (queryInfoList.size() > 0) {
                 JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
 
                 //存储到Redis中
@@ -1479,26 +1543,26 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
      * @param lowestNodeParentIds 最底层节点ParentIds
      * @param nodesAll            所有节点
      */
-    public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
+    /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
         if (lowestNodeParentIds.isEmpty()) {
             return;
         }
 
         //父级Id与出现的次数Map
-        Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
+        Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
                 .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
 
         //批量查询单次节点
-        List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().parallelStream()
+        List<WbsTreeContractLazyVO> parentNodes = parentIdGroup.entrySet().stream()
                 .filter(entry -> entry.getValue() == 1L)
-                .flatMap(entry -> nodesAll.parallelStream()
+                .flatMap(entry -> nodesAll.stream()
                         .filter(f -> entry.getKey().equals(f.getId())))
                 .collect(Collectors.toList());
 
         //批量查询多次节点
-        List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().parallelStream()
+        List<WbsTreeContractLazyVO> multipleParentNodes = parentIdGroup.entrySet().stream()
                 .filter(entry -> entry.getValue() > 1L)
-                .flatMap(entry -> nodesAll.parallelStream()
+                .flatMap(entry -> nodesAll.stream()
                         .filter(f -> entry.getKey().equals(f.getId()))
                         .limit(1)
                         .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream()))
@@ -1514,6 +1578,51 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             result.addAll(multipleParentNodes);
             this.recursiveGetParentNodes(result, collect, nodesAll);
         }
+    }*/
+
+    public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
+        if (lowestNodeParentIds.isEmpty()) {
+            return;
+        }
+
+        //并行粒度4
+        ForkJoinPool customThreadPool = new ForkJoinPool(2);
+
+        //父级Id与出现的次数Map
+        Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
+                .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
+
+        //批量查询单次节点
+        CompletableFuture<List<WbsTreeContractLazyVO>> parentNodesFuture = CompletableFuture.supplyAsync(() ->
+                parentIdGroup.entrySet().parallelStream()
+                        .filter(entry -> entry.getValue() == 1L)
+                        .flatMap(entry -> nodesAll.parallelStream()
+                                .filter(f -> entry.getKey().equals(f.getId())))
+                        .collect(Collectors.toList()), customThreadPool);
+
+        //批量查询多次节点
+        CompletableFuture<List<WbsTreeContractLazyVO>> multipleParentNodesFuture = CompletableFuture.supplyAsync(() ->
+                parentIdGroup.entrySet().parallelStream()
+                        .filter(entry -> entry.getValue() > 1L)
+                        .flatMap(entry -> nodesAll.parallelStream()
+                                .filter(f -> entry.getKey().equals(f.getId()))
+                                .limit(1)
+                                .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).parallelStream()))
+                        .collect(Collectors.toList()), customThreadPool);
+
+        //结果集
+        CompletableFuture<List<Long>> collectFuture = parentNodesFuture.thenCombine(multipleParentNodesFuture, (parentNodes, multipleParentNodes) ->
+                Stream.concat(parentNodes.parallelStream(), multipleParentNodes.parallelStream())
+                        .map(WbsTreeContractLazyVO::getParentId)
+                        .collect(Collectors.toList()));
+
+        List<Long> collect = collectFuture.join();
+
+        if (!collect.isEmpty()) {
+            result.addAll(parentNodesFuture.join());
+            result.addAll(multipleParentNodesFuture.join());
+            this.recursiveGetParentNodes(result, collect, nodesAll);
+        }
     }
 
     @Override
@@ -2677,6 +2786,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 iterator_2.remove();
             }
         }
+
+        /*更新缓存,主动清理后,重新加载进本地缓存中*/
+        this.getNodeAll(contractId);
+
     }
 
 }

+ 5 - 1
blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java

@@ -132,7 +132,11 @@ public class UserClient implements IUserClient {
 
     @Override
     public R<Boolean> saveUserDTO(UserDTO user) {
-        service.submit2(user);
+        try {
+            service.submit2(user);
+        }catch (Exception e){
+            return R.data(false);
+        }
         return R.data(true);
     }