Parcourir la source

合同段搜索接口

liuyc il y a 2 ans
Parent
commit
653bf89f55

+ 3 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java

@@ -722,9 +722,9 @@ public class ContractInfoController extends BladeController {
      */
     @GetMapping("/getTreeNodeByQueryValueAndContractId")
     @ApiOperationSupport(order = 23)
-    @ApiOperation(value = "资料填报(资料查询)节点搜索输入框查询接口", notes = "传入合同段id、输入框搜索的queryValue")
-    public R getTreeNodeByValueAndContractId(@RequestParam String queryValue, @RequestParam String contractId) {
-        R list = contractInfoService.getTreeNodeByValueAndContractId(queryValue, contractId);
+    @ApiOperation(value = "资料填报(资料查询)节点搜索输入框查询接口", notes = "传入合同段id、输入框搜索的queryValue、表单所属方tableOwner")
+    public R getTreeNodeByValueAndContractId(@RequestParam String queryValue, @RequestParam String contractId, @RequestParam String tableOwner) {
+        R list = contractInfoService.getTreeNodeByValueAndContractId(queryValue, contractId, tableOwner);
         if (ObjectUtil.isNotEmpty(list) && ObjectUtil.isNotEmpty(list.getData())) {
             Object data = list.getData();
             ContractInfo contractInfo = contractInfoService.getBaseMapper().selectById(contractId);

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

@@ -79,7 +79,7 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     List<ContractInfo> getContractListByProjectId(Long projectId);
 
-    R getTreeNodeByValueAndContractId(String queryValue, String contractId);
+    R getTreeNodeByValueAndContractId(String queryValue, String contractId, String tableOwner);
 
     void updateIsArchivesAutoById(Long id, Integer isArchivesAuto);
 

+ 221 - 96
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -1,5 +1,7 @@
 package org.springblade.manager.service.impl;
 
+import cn.hutool.core.lang.hash.Hash;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -30,6 +32,8 @@ import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 import org.springblade.system.user.vo.UserContractInfoVO;
 import org.springblade.system.user.vo.UserVO2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
@@ -37,6 +41,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.IOException;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -48,11 +53,14 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
     private final SaveUserInfoByProjectServiceImpl saveUserInfoByProjectService;
     private final WbsTreeContractMapper wbsTreeContractMapper;
+    private final WbsTreeContractServiceImpl wbsTreeContractServiceImpl;
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
     private final JdbcTemplate jdbcTemplate;
     private final IUserClient iUserClient;
     private final InformationQueryClient informationQueryClient;
     private final ArchiveTreeContractMapper archiveTreeContractMapper;
+    @Autowired
+    StringRedisTemplate redisTemplate;
 
     @Override
     public List<String> getProcessContractByJLContractId(String contractId) {
@@ -308,118 +316,215 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     }
 
     @Override
-    public R getTreeNodeByValueAndContractId(String queryValue, String contractId) {
+    public R getTreeNodeByValueAndContractId(String queryValue, String contractId, String tableOwner) {
         Map<Long, List<WbsTreeContractTreeAllVO>> resultMaps = new LinkedHashMap<>();
         if (StringUtils.isNotEmpty(queryValue) && StringUtils.isNotEmpty(contractId)) {
             ContractInfo contractInfo = contractInfoMapper.selectById(contractId);
             if (contractInfo != null) {
-                //质检
+                //TODO 质检
                 if (contractInfo.getContractType().equals(1)) {
                     //获取查询的有效节点信息,以及所有上级父级节点
                     LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
+                    queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
                     queryWrapper.like(WbsTreeContract::getFullName, queryValue);
                     queryWrapper.eq(WbsTreeContract::getContractId, contractId);
                     queryWrapper.eq(WbsTreeContract::getType, 1);
+                    //所有匹配节点
                     List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
-                    Set<WbsTreeContract> resultNodes = new LinkedHashSet<>();
-                    this.recursiveGetParentNodes(resultNodes, nodes, contractId);
-                    resultNodes.addAll(nodes);
-                    List<String> nodePkeyIds = resultNodes.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-
-                    //获取填报过的资料信息Map
-                    Set<InformationQuery> informationQuerySet = new HashSet<>();
-                    List<List<String>> partition = Lists.partition(nodePkeyIds, 500);
-                    for (List<String> wbsIds : partition) {
-                        List<InformationQuery> informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where wbs_id in(" + org.apache.commons.lang.StringUtils.join(wbsIds, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
-                        informationQuerySet.addAll(informationQueryList);
-                    }
-                    Map<Long, Integer> informationQueryMaps = informationQuerySet.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
-
-                    //构造vo
-                    List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = resultNodes.stream().map(node -> {
-                        WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
-                        if (vo != null) {
-                            vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
-                            vo.setTitle(node.getFullName());
-                            vo.setPrimaryKeyId(node.getPKeyId());
-                            if (ObjectUtils.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId()))) {
-                                vo.setSubmitCounts(1L); //如果存在资料填报信息,那么计数
-                                vo.setColorStatus(informationQueryMaps.get(vo.getPrimaryKeyId())); //颜色
-                            } else {
-                                vo.setSubmitCounts(0L);
-                                vo.setColorStatus(null); //没填报就是null
+                    if (nodes.size() > 0) {
+                        //获取当前合同段所有缓存节点信息
+                        List<WbsTreeContractLazyVO> nodesAllTemp;
+                        Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
+                        if (data != null) {
+                            nodesAllTemp = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
+                        } else {
+                            nodesAllTemp = 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 = " + contractId + " 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 = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                            if (nodesAllTemp.size() > 0) {
+                                JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAllTemp));
+                                redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
                             }
                         }
-                        return vo;
-                    }).collect(Collectors.toList());
-
-                    //构造树形结构
-                    List<WbsTreeContractTreeAllVO> reNodes = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
 
-                    //获取构造完的List集合
-                    LinkedList<WbsTreeContractTreeAllVO> resultNodesAll = new LinkedList<>();
-                    this.getNodesAll(reNodes, resultNodesAll);
-                    resultNodesAll.addAll(0, reNodes);
-
-                    //处理父级节点计数、颜色问题
-                    this.reSetSubmitCountsAndColorStatus(resultNodesAll);
-                    return R.data(reNodes);
+                        //去重
+                        List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
+                                .collect(Collectors.collectingAndThen(
+                                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                        ArrayList::new
+                                ));
+                        //所有最底层节点
+                        List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
+                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                ArrayList::new
+                        ));
+
+                        List<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
+                        List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
+                        //所有匹配的PKeyIds
+                        Set<Long> resultNodesPKeyIds = new LinkedHashSet<>();
+                        //获取所有匹配节点的父级
+                        this.recursiveGetParentNodes(resultNodesPKeyIds, parentIds, nodesAllTemp);
+                        //获取所有匹配节点的子级
+                        this.recursiveGetChildNodes(resultNodesPKeyIds, ids, nodesAllTemp);
+
+                        //获取结果集节点
+                        resultNodesPKeyIds.addAll(nodes.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList()));
+                        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));
+                        } 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));
+                        }
+                        Map<Long, Integer> informationQueryMaps = informationQueryList.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
+                        List<Long> pKeyIdList = new ArrayList<>(informationQueryMaps.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
+                        Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
+                                .peek(vo -> {
+                                    Integer colorStatus = informationQueryMaps.get(vo.getPKeyId());
+                                    if (colorStatus != null) {
+                                        //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色、任务状态3=已废除=颜色1黑色
+                                        vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 1)));
+                                    } else {
+                                        //未填报的=颜色1黑色
+                                        vo.setColorStatus(1);
+                                    }
+                                }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
 
+                        //构造vo
+                        if (wbsTreeContractList.size() > 0) {
+                            //处理填报数量
+                            Map<Long, Long> countMap = new HashMap<>();
+                            for (WbsTreeContractLazyVO node : resultParentNodesTB) {
+                                Long key = node.getPKeyId();
+                                if (countMap.containsKey(key)) {
+                                    countMap.put(key, countMap.get(key) + 1L);
+                                } else {
+                                    countMap.put(key, 1L);
+                                }
+                            }
+                            List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream().map(node -> {
+                                WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
+                                if (vo != null) {
+                                    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));
+                                    if (vo.getSubmitCounts() >= 1L) {
+                                        vo.setColorStatus(2);
+                                    }
+                                    WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
+                                    if (lowestNode != null) {
+                                        vo.setColorStatus(lowestNode.getColorStatus());
+                                    }
+                                }
+                                return vo;
+                            }).collect(Collectors.toList());
+                            return R.data(this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
+                        }
+                    }
                 } else if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
-                    //监理、指挥部
+                    //TODO 监理、指挥部
                     List<ContractRelationJlyz> relationJLYZList = jdbcTemplate.query("select * from m_contract_relation_jlyz where contract_id_jlyz = " + contractId, new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
-
                     for (ContractRelationJlyz contractRelationJlyz : relationJLYZList) {
-                        //获取查询的有效节点信息,以及所有上级父级节点
                         LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
+                        queryWrapper.select(WbsTreeContract::getParentId, WbsTreeContract::getId, WbsTreeContract::getPKeyId);
                         queryWrapper.like(WbsTreeContract::getFullName, queryValue);
                         queryWrapper.eq(WbsTreeContract::getContractId, contractRelationJlyz.getContractIdSg());
                         queryWrapper.eq(WbsTreeContract::getType, 1);
                         List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
-                        Set<WbsTreeContract> resultNodes = new LinkedHashSet<>();
-                        this.recursiveGetParentNodes(resultNodes, nodes, contractRelationJlyz.getContractIdSg() + "");
-                        resultNodes.addAll(nodes);
-                        List<String> nodePkeyIds = resultNodes.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
-
-                        //获取填报过的资料信息Map
-                        Set<InformationQuery> informationQuerySet = new HashSet<>();
-                        List<List<String>> partition = Lists.partition(nodePkeyIds, 500);
-                        for (List<String> wbsIds : partition) {
-                            List<InformationQuery> informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where wbs_id in(" + org.apache.commons.lang.StringUtils.join(wbsIds, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
-                            informationQuerySet.addAll(informationQueryList);
-                        }
-                        Map<Long, Integer> informationQueryMaps = informationQuerySet.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
-
-                        //构造vo
-                        List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = resultNodes.stream().map(node -> {
-                            WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
-                            if (vo != null) {
-                                vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
-                                vo.setTitle(node.getFullName());
-                                vo.setPrimaryKeyId(node.getPKeyId());
-                                if (ObjectUtils.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId()))) {
-                                    vo.setSubmitCounts(1L); //如果存在资料填报信息,那么计数
-                                    vo.setColorStatus(informationQueryMaps.get(vo.getPrimaryKeyId())); //颜色
-                                } else {
-                                    vo.setSubmitCounts(0L);
-                                    vo.setColorStatus(null); //没填报就是null
+                        if (nodes.size() > 0) {
+                            List<WbsTreeContractLazyVO> nodesAllTemp;
+                            Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractRelationJlyz.getContractIdSg());
+                            if (data != null) {
+                                nodesAllTemp = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
+                            } else {
+                                nodesAllTemp = 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 = " + contractRelationJlyz.getContractIdSg() + " 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 = " + contractRelationJlyz.getContractIdSg(), new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
+                                if (nodesAllTemp.size() > 0) {
+                                    JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAllTemp));
+                                    redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
                                 }
                             }
-                            return vo;
-                        }).collect(Collectors.toList());
-
-                        //构造树形结构
-                        List<WbsTreeContractTreeAllVO> reNodes = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
 
-                        //获取构造完的List集合
-                        LinkedList<WbsTreeContractTreeAllVO> resultNodesAll = new LinkedList<>();
-                        this.getNodesAll(reNodes, resultNodesAll);
-                        resultNodesAll.addAll(0, reNodes);
-
-                        //处理父级节点计数、颜色问题
-                        this.reSetSubmitCountsAndColorStatus(resultNodesAll);
-                        //返回结果集
-                        resultMaps.put(contractRelationJlyz.getContractIdSg(), reNodes);
+                            List<WbsTreeContractLazyVO> distinctNodesAll = nodesAllTemp.stream()
+                                    .collect(Collectors.collectingAndThen(
+                                            Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                            ArrayList::new
+                                    ));
+                            List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
+                                    Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                    ArrayList::new
+                            ));
+
+                            List<Long> parentIds = nodes.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList());
+                            List<Long> ids = nodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
+                            Set<Long> resultNodesPKeyIds = new LinkedHashSet<>();
+                            this.recursiveGetParentNodes(resultNodesPKeyIds, parentIds, nodesAllTemp);
+                            this.recursiveGetChildNodes(resultNodesPKeyIds, ids, nodesAllTemp);
+                            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));
+                            } 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));
+                            }
+                            Map<Long, Integer> informationQueryMaps = informationQueryList.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
+                            List<Long> pKeyIdList = new ArrayList<>(informationQueryMaps.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());
+                                        if (colorStatus != null) {
+                                            vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 1)));
+                                        } else {
+                                            vo.setColorStatus(1);
+                                        }
+                                    }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
+
+                            if (wbsTreeContractList.size() > 0) {
+                                Map<Long, Long> countMap = new HashMap<>();
+                                for (WbsTreeContractLazyVO node : resultParentNodesTB) {
+                                    Long key = node.getPKeyId();
+                                    if (countMap.containsKey(key)) {
+                                        countMap.put(key, countMap.get(key) + 1L);
+                                    } else {
+                                        countMap.put(key, 1L);
+                                    }
+                                }
+                                List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = wbsTreeContractList.stream().map(node -> {
+                                    WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
+                                    if (vo != null) {
+                                        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));
+                                        if (vo.getSubmitCounts() >= 1L) {
+                                            vo.setColorStatus(2);
+                                        }
+                                        WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(vo.getPrimaryKeyId());
+                                        if (lowestNode != null) {
+                                            vo.setColorStatus(lowestNode.getColorStatus());
+                                        }
+                                    }
+                                    return vo;
+                                }).collect(Collectors.toList());
+                                resultMaps.put(contractRelationJlyz.getContractIdSg(), this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS));
+                            }
+                        }
                     }
                     return R.data(resultMaps);
                 }
@@ -511,7 +616,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         for (WbsTreeContractTreeAllVO node : reNodes) {
             if (node.getChildren() != null && !node.getChildren().isEmpty()) {
                 result.addAll(node.getChildren());
-                getNodesAll(node.getChildren(), result);
+                this.getNodesAll(node.getChildren(), result);
             }
         }
     }
@@ -519,17 +624,37 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     /**
      * 反向递归获取父级
      *
-     * @param resultNodes
-     * @param nodes
-     * @param contractId
+     * @param resultPKeyIds  结果集PKeyIds
+     * @param nodesParentIds 父级节点ids
+     * @param nodesAllTemp   当合同段所有节点缓存
      */
-    private void recursiveGetParentNodes(Set<WbsTreeContract> resultNodes, List<WbsTreeContract> nodes, String contractId) {
-        Set<String> parentIds = nodes.stream().map(WbsTreeContract::getParentId).map(String::valueOf).filter(ObjectUtils::isNotEmpty).collect(Collectors.toSet());
-        if (parentIds.size() > 0) {
-            List<WbsTreeContract> parentNodes = jdbcTemplate.query("select * from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id in(" + org.apache.commons.lang.StringUtils.join(parentIds, ",") + ") and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+    private void recursiveGetParentNodes(Set<Long> resultPKeyIds, List<Long> nodesParentIds, List<WbsTreeContractLazyVO> nodesAllTemp) {
+        if (nodesParentIds.size() > 0) {
+            List<WbsTreeContractLazyVO> parentNodes = nodesAllTemp.stream().filter(f -> nodesParentIds.contains(f.getId())).collect(Collectors.toList());
             if (parentNodes.size() > 0) {
-                resultNodes.addAll(parentNodes);
-                this.recursiveGetParentNodes(resultNodes, parentNodes, contractId);
+                List<Long> pKeyIds = parentNodes.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
+                List<Long> parentIds = parentNodes.stream().map(WbsTreeContractLazyVO::getParentId).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                resultPKeyIds.addAll(pKeyIds);
+                this.recursiveGetParentNodes(resultPKeyIds, parentIds, nodesAllTemp);
+            }
+        }
+    }
+
+    /**
+     * 递归获取子级
+     *
+     * @param resultPKeyIds 结果集PKeyIds
+     * @param nodesIds      子级节点ids
+     * @param nodesAllTemp  当合同段所有节点缓存
+     */
+    private void recursiveGetChildNodes(Set<Long> resultPKeyIds, List<Long> nodesIds, List<WbsTreeContractLazyVO> nodesAllTemp) {
+        if (nodesIds.size() > 0) {
+            List<WbsTreeContractLazyVO> childNodes = nodesAllTemp.stream().filter(f -> nodesIds.contains(f.getParentId())).collect(Collectors.toList());
+            if (childNodes.size() > 0) {
+                List<Long> pKeyIds = childNodes.stream().map(WbsTreeContractLazyVO::getPKeyId).collect(Collectors.toList());
+                List<Long> ids = childNodes.stream().map(WbsTreeContractLazyVO::getId).filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
+                resultPKeyIds.addAll(pKeyIds);
+                this.recursiveGetChildNodes(resultPKeyIds, ids, nodesAllTemp);
             }
         }
     }

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

@@ -859,7 +859,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
      * @param lowestNodeParentIds 最底层节点ParentIds
      * @param nodesAll            所有节点
      */
-    private 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;
         }