Jelajahi Sumber

wbs树节点优化

liuyc 1 tahun lalu
induk
melakukan
5c26e3bd35

+ 3 - 4
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -67,16 +67,15 @@ public interface InformationQueryClient {
     @PostMapping(API_PREFIX + "/updateInformationQuery")
     void updateInformationQuery(@RequestParam String link, @RequestParam String classify, @RequestParam String nodeId, @RequestParam String contractId);
 
-
-    // 更新redis数据
+    //更新redis数据
     @PostMapping(API_PREFIX + "/AsyncWbsTree")
     void AsyncWbsTree(@RequestParam String primaryKeyId, @RequestParam String parentId, @RequestParam String contractId, @RequestParam String contractIdRelation, @RequestParam String classifyType);
 
-    // 删除更新redis数据
+    //删除更新合同段节点树redis缓存
     @PostMapping(API_PREFIX + "/delAsyncWbsTree")
     void delAsyncWbsTree(@RequestParam String contractId);
 
-    // 根据wbsId获取首件填报信息
+    //根据wbsId获取首件填报信息
     @PostMapping(API_PREFIX + "/getFirstInfoByWbsId")
     InformationQuery getFirstInfoByWbsId(@RequestParam String WbsId);
 

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

@@ -1,6 +1,5 @@
 package org.springblade.business.feignClient;
 
-import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -13,7 +12,6 @@ import org.springblade.business.service.IInformationQueryFileService;
 import org.springblade.business.service.IInformationQueryService;
 import org.springblade.business.vo.QueryProcessDataVO;
 import org.springblade.common.utils.SnowFlakeUtil;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;

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

@@ -26,7 +26,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.manager.entity.TabBusstimeInfo;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
-import org.springframework.scheduling.annotation.Async;
 
 import java.util.List;
 import java.util.Map;
@@ -160,4 +159,5 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
 
     //根据wbsTreeContract主键集合获取已经审批的资料
     List<Long> getInfoByNodeIds(List<Long> ids);
+
 }

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

@@ -920,10 +920,16 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
 
     @Override
     public void delAsyncWbsTree(String contractId) {
-        //模糊匹配所有以contractId开头的所有key值
-        Set<String> keys = RedisTemplate.keys("blade-manager::contract:wbstree:" + contractId + "*");
-        if (keys != null) {
-            RedisTemplate.delete(keys);
+        //模糊匹配所有以contractId开头的所有合同段节点key值
+        Set<String> keysByNodes = RedisTemplate.keys("blade-manager::contract:wbstree:" + contractId + "*");
+        if (keysByNodes != null) {
+            RedisTemplate.delete(keysByNodes);
+        }
+
+        //模糊匹配所有以contractId开头的所有资料填报key值
+        Set<String> keysByInformationQuery = RedisTemplate.keys("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "*");
+        if (keysByInformationQuery != null) {
+            RedisTemplate.delete(keysByInformationQuery);
         }
     }
 

+ 9 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/bean/NodeVO.java

@@ -27,6 +27,7 @@ public class NodeVO {
      * DFS
      *
      * @param nodeList
+     * @param nodeParentGroupToIdMap
      */
     public static void calculateStatusToDFS(List<NodeVO> nodeList, Map<Long, NodeVO> nodeParentGroupToIdMap) {
         NodeVO rootNode = findRootNode(nodeList);
@@ -42,19 +43,20 @@ public class NodeVO {
      * @param nodeParentGroupToIdMap
      */
     public static void calculateStatusToBFS(List<NodeVO> nodeList, Map<Long, NodeVO> nodeParentGroupToIdMap) {
-        //计算根节点的颜色
         NodeVO rootNode = findRootNode(nodeList);
         if (rootNode != null) {
             calculateNodeStatusToBFS(rootNode);
-
-            Queue<NodeVO> queue = new LinkedList<>();
-            queue.addAll(rootNode.getChildren());
-
+            Queue<NodeVO> queue = new LinkedList<>(rootNode.getChildren());
             while (!queue.isEmpty()) {
                 NodeVO node = queue.poll();
                 if (node != null) {
                     calculateNodeStatusToBFS(node);
 
+                    //将子节点逐个加入队列
+                    if (node.getChildren() != null) {
+                        queue.addAll(node.getChildren());
+                    }
+
                     if (node.getParentId() != null) {
                         NodeVO nodeVO = nodeParentGroupToIdMap.get(node.getParentId());
                         if (nodeVO != null) {
@@ -89,6 +91,7 @@ public class NodeVO {
      * DFS 判断节点状态
      *
      * @param node
+     * @param nodeParentGroupToIdMap
      */
     private static void calculateNodeStatusToDFS(NodeVO node, Map<Long, NodeVO> nodeParentGroupToIdMap) {
         //最底层节点直接返回
@@ -107,7 +110,7 @@ public class NodeVO {
         //如果子节点都是相同的状态,则父节点状态也为该状态
         if (childStatusList.stream().distinct().count() == 1) {
             node.setStatus(childStatusList.get(0));
-            // 更新父节点的状态
+            //更新父节点的状态
             if (node.getParentId() != null) {
                 NodeVO parentNode = nodeParentGroupToIdMap.get(node.getParentId());
                 if (parentNode != null) {

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

@@ -2201,6 +2201,7 @@ public class ExcelTabController extends BladeController {
 
         //合并pdf加载
         excelTabService.getBussPdfs(nodeId, classify, contractId, projectId);
+
         //更新缓存
         informationQueryClient.delAsyncWbsTree(contractId);
 

+ 59 - 16
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -399,14 +399,34 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                         List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
 
                         //获取当前合同段填报过的资料信息Map
-                        List<InformationQuery> informationQueryList;
-                        if (ObjectUtil.isEmpty(tableOwner)) {
-                            informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(InformationQuery.class));
+                        //获取当前合同段所有填报资料缓存信息
+                        List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+                        Object dataInformationQuery;
+                        if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
                         } else {
-                            informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(InformationQuery.class));
+                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
                         }
-                        Map<Long, Integer> informationQueryMaps = informationQueryList.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
-                        List<Long> pKeyIdList = new ArrayList<>(informationQueryMaps.keySet());
+                        if (dataInformationQuery != null) {
+                            queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
+                        } else {
+                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                if (queryInfoList.size() > 0) {
+                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
+                                }
+                            } else {
+                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                if (queryInfoList.size() > 0) {
+                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
+                                }
+                            }
+                        }
+                        Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
+                                .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
+                        List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
 
                         //TODO 处理数量
                         //填报过的所有最底层节点
@@ -418,7 +438,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                         //最底层节点颜色构造后Map
                         Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
                                 .peek(vo -> {
-                                    Integer colorStatus = informationQueryMaps.get(vo.getPKeyId());
+                                    Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
                                     if (colorStatus != null) {
                                         //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色
                                         ///*任务状态3=已废除=颜色1黑色*/(2023年10月16日13:59:00 已废除改为=颜色2蓝色)
@@ -465,7 +485,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                             vo.setPrimaryKeyId(node.getPKeyId());
 
                                             //设置数量
-                                            vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
+                                            vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
 
                                             //设置颜色
                                             Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
@@ -483,6 +503,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                             return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
                         }
                     }
+
                 } else if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
                     //TODO 监理、指挥部
                     Map<Long, List<WbsTreeContractTreeAllVO>> resultMaps = new LinkedHashMap<>();
@@ -541,22 +562,43 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                             resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
                             List<WbsTreeContract> wbsTreeContractList = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().in(WbsTreeContract::getPKeyId, resultNodesPKeyIds));
 
-                            List<InformationQuery> informationQueryList;
-                            if (ObjectUtil.isEmpty(tableOwner)) {
-                                informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractRelationJlyz.getContractIdSg(), new BeanPropertyRowMapper<>(InformationQuery.class));
+                            //资料信息缓存
+                            List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+                            Object dataInformationQuery;
+                            if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1");
                             } else {
-                                informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractRelationJlyz.getContractIdSg() + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(InformationQuery.class));
+                                dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner);
+                            }
+                            if (dataInformationQuery != null) {
+                                queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
+                            } else {
+                                if (cn.hutool.core.util.ObjectUtil.isEmpty(tableOwner)) {
+                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractRelationJlyz.getContractIdSg(), new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                    if (queryInfoList.size() > 0) {
+                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_1", JSON.toJSON(array).toString());
+                                    }
+                                } else {
+                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractRelationJlyz.getContractIdSg() + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                    if (queryInfoList.size() > 0) {
+                                        JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                        redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractRelationJlyz.getContractIdSg() + "_" + tableOwner, JSON.toJSON(array).toString());
+                                    }
+                                }
                             }
-                            Map<Long, Integer> informationQueryMaps = informationQueryList.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
-                            List<Long> pKeyIdList = new ArrayList<>(informationQueryMaps.keySet());
+                            Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> cn.hutool.core.util.ObjectUtil.isNotEmpty(f.getWbsId()))
+                                    .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
+                            List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
 
+                            //数量
                             List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId()) && resultNodesPKeyIds.contains(f.getPKeyId())).collect(Collectors.toList());
                             List<Long> lowestNodeParentIdsTB = lowestNodesTB.stream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
                             List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
                             wbsTreeContractServiceImpl.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAllTemp);
                             Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
                                     .peek(vo -> {
-                                        Integer colorStatus = informationQueryMaps.get(vo.getPKeyId());
+                                        Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
                                         if (colorStatus != null) {
                                             ///*任务状态3=已废除=颜色1黑色*/(2023年10月16日13:59:00 已废除改为=颜色2蓝色)
                                             vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
@@ -565,6 +607,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                         }
                                     }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
 
+                            //颜色
                             List<NodeVO> nodeVOList = distinctNodesAll.stream().map(wbsTreeContractServiceImpl::convertToNodeVO).collect(Collectors.toList());
                             Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
                             List<NodeVO> treeNodeVOList = wbsTreeContractServiceImpl.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
@@ -590,7 +633,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                                                 vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
                                                 vo.setTitle(ObjectUtil.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
                                                 vo.setPrimaryKeyId(node.getPKeyId());
-                                                vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
+                                                vo.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(vo.getPrimaryKeyId())) ? countMap.get(vo.getPrimaryKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(vo.getPrimaryKeyId())) ? 1L : 0L));
 
                                                 Integer parentColorStatus = nodeColorStatusMap.get(vo.getPrimaryKeyId());
                                                 if (parentColorStatus != null) {

+ 99 - 23
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -58,6 +58,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -78,7 +79,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
     @Autowired
     StringRedisTemplate redisTemplate;
 
-    
+
     @Override
     public List<WbsTreeContract> selectQueryCurrentNodeByAncestors(List<String> ids, String contractId) {
         return this.baseMapper.selectQueryCurrentNodeByAncestors(ids, contractId);
@@ -710,6 +711,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
                         }
                     }
+
                     //获取当前层懒加载节点
                     List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) 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", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
                     if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
@@ -726,12 +728,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                                 ArrayList::new
                         ));
 
-                        //获取当前合同段所有填报资料信息
+                        //获取当前合同段所有填报资料缓存信息
                         List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+                        Object dataInformationQuery;
                         if (ObjectUtil.isEmpty(tableOwner)) {
-                            queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
+                        } else {
+                            dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
+                        }
+                        if (dataInformationQuery != null) {
+                            queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
                         } else {
-                            queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                            if (ObjectUtil.isEmpty(tableOwner)) {
+                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                if (queryInfoList.size() > 0) {
+                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
+                                }
+                            } else {
+                                queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                if (queryInfoList.size() > 0) {
+                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
+                                }
+                            }
                         }
                         Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
                                 .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
@@ -739,8 +759,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
                         //TODO 处理数量
                         //填报过的所有最底层节点
-                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
-                        List<Long> lowestNodeParentIdsTB = lowestNodesTB.stream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
+                        List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
+                        List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
                         List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
                         this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
 
@@ -831,19 +851,6 @@ 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;
-                            Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
-                            if (data != null) {
-                                nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
-                            } else {
-                                nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND type = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where type = 1 and status = 1 and is_deleted = 0 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
-                                if (nodesAll.size() > 0) {
-                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
-                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + sgContractId, JSON.toJSON(array).toString());
-                                }
-                            }*/
-
                             //获取当前合同段所有缓存节点信息
                             List<WbsTreeContractLazyVO> nodesAll;
                             Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
@@ -886,12 +893,30 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                                         ArrayList::new
                                 ));
 
-                                //获取当前合同段所有填报资料信息
+                                //获取当前合同段所有填报资料缓存信息
                                 List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
+                                Object dataInformationQuery;
                                 if (ObjectUtil.isEmpty(tableOwner)) {
-                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                    dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1");
                                 } else {
-                                    queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                    dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner);
+                                }
+                                if (dataInformationQuery != null) {
+                                    queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
+                                } else {
+                                    if (ObjectUtil.isEmpty(tableOwner)) {
+                                        queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                        if (queryInfoList.size() > 0) {
+                                            JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                            redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1", JSON.toJSON(array).toString());
+                                        }
+                                    } else {
+                                        queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
+                                        if (queryInfoList.size() > 0) {
+                                            JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
+                                            redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner, JSON.toJSON(array).toString());
+                                        }
+                                    }
                                 }
                                 Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
                                         .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
@@ -1374,7 +1399,7 @@ 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;
         }
@@ -1412,6 +1437,57 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
             }
         }
 
+        //结果集
+        List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
+                .map(WbsTreeContractLazyVO::getParentId)
+                .collect(Collectors.toList());
+
+        if (!collect.isEmpty()) {
+            result.addAll(parentNodes);
+            result.addAll(multipleParentNodes);
+            this.recursiveGetParentNodes(result, collect, 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()
+                .collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
+
+        Set<Long> keysWithValueOne = new HashSet<>(); //单次
+        Map<Long, Long> keysWithValueSome = new ConcurrentHashMap<>(); //多次
+
+        parentIdGroup.forEach((key, value) -> {
+            if (value == 1L) {
+                keysWithValueOne.add(key);
+            } else {
+                keysWithValueSome.put(key, value);
+            }
+        });
+
+        //批量查询单次节点
+        List<WbsTreeContractLazyVO> parentNodes = new ArrayList<>();
+        if (!keysWithValueOne.isEmpty()) {
+            parentNodes = nodesAll.parallelStream()
+                    .filter(f -> keysWithValueOne.contains(f.getId()))
+                    .collect(Collectors.toList());
+        }
+
+        //批量查询多次节点
+        List<WbsTreeContractLazyVO> multipleParentNodes = new ArrayList<>();
+        keysWithValueSome.forEach((key, count) -> {
+            List<WbsTreeContractLazyVO> nodes = nodesAll.parallelStream()
+                    .filter(f -> key.equals(f.getId()))
+                    .limit(1)  //限制只取一个
+                    .collect(Collectors.toList());
+            if (!nodes.isEmpty()) {
+                multipleParentNodes.addAll(Collections.nCopies(count.intValue(), nodes.get(0)));
+            }
+        });
+
         //结果集
         List<Long> collect = Stream.concat(parentNodes.stream(), multipleParentNodes.stream())
                 .map(WbsTreeContractLazyVO::getParentId)