Browse Source

客户端节点树接口颜色BUG

liuyc 2 năm trước cách đây
mục cha
commit
a0c49e36c4

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

@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.google.common.collect.Lists;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
-import org.jetbrains.annotations.NotNull;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -45,7 +44,6 @@ 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.jdbc.core.RowMapper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.LinkedCaseInsensitiveMap;
@@ -56,8 +54,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
-import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.util.*;
 import java.util.function.Function;
 import java.util.regex.Matcher;
@@ -583,30 +579,35 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                     //获取当前层懒加载节点
                     List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,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 = " + 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) {
+                        //所有节点
+                        List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
+                                .collect(Collectors.collectingAndThen(
+                                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                        ArrayList::new
+                                ));
+                        //所有节点Map
+                        Map<Long, List<WbsTreeContractLazyVO>> allNodesParentGroup = distinctNodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
+
                         //所有最底层节点
-                        List<WbsTreeContractLazyVO> lowestNodesAll = nodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.toList());
+                        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<WbsTreeContractLazyQueryInfoVO> queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
-                        Map<Long, Integer> queryInfoMaps = queryInfoList.stream().distinct().collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus));
+                        Map<Long, Integer> queryInfoMaps = queryInfoList.stream()
+                                .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
                         List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
 
-                        //填报过的所有最底层节点
-                        List<WbsTreeContractLazyVO> lowestNodesTB = lowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
+                        //填报过的所有最底层节点,处理数量
+                        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> resultParentNodesTB = new ArrayList<>();
                         this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
 
-                        //所有父级节点Map
-                        Map<Long, WbsTreeContractLazyVO> nodesAllMap = new HashMap<>();
-                        List<WbsTreeContractLazyVO> collect = resultParentNodesTB.stream().distinct().collect(Collectors.toList());
-                        for (WbsTreeContractLazyVO node : collect) {
-                            nodesAllMap.put(node.getId(), node);
-                        }
-
-                        //最底层节点Map
-                        Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesAll.stream()
+                        //最底层节点颜色构造后Map
+                        Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
                                 .peek(vo -> {
                                     Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
                                     if (colorStatus != null) {
@@ -616,12 +617,17 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                                         //未填报的=颜色1黑色
                                         vo.setColorStatus(1);
                                     }
-                                })
-                                .collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity(), (obj1, obj2) -> obj1));
+                                }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
                         List<WbsTreeContractLazyVO> lowestNodesReList = new ArrayList<>(lowestNodesMap.values());
+                        Map<Long, WbsTreeContractLazyVO> distinctParentNodesTBIdKeyMap = resultParentNodesTB.stream()
+                                .collect(Collectors.collectingAndThen(
+                                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                        ArrayList::new
+                                )).stream().collect(Collectors.toMap(WbsTreeContractLazyVO::getId, Function.identity()));
 
                         //构造完成的所有最底层节点,处理父节点颜色
-                        this.recursiveParentNodeColorStatus(lowestNodesReList, nodesAllMap);
+                        Map<Long, WbsTreeContractLazyVO> nodeColorMap = new HashMap<>();
+                        this.recursiveParentNodeColorStatus(lowestNodesReList, distinctParentNodesTBIdKeyMap, allNodesParentGroup, nodeColorMap);
 
                         //处理最终结果集
                         if (lazyNodes.size() > 0) {
@@ -648,16 +654,20 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
                                 lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
 
-                                WbsTreeContractLazyVO vo = nodesAllMap.get(lazyNodeVO.getId());
+                                /*if(lazyNodeVO.getSubmitCounts() >= 1) {
+                                    lazyNodeVO.setColorStatus(2);
+                                }*/
+                                WbsTreeContractLazyVO vo = nodeColorMap.get(lazyNodeVO.getPKeyId());
                                 if (vo != null) {
                                     lazyNodeVO.setColorStatus(vo.getColorStatus());
                                 } else {
                                     WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
-                                    lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(lowestNode) ? lowestNode.getColorStatus() : 1);
+                                    if (lowestNode != null) {
+                                        lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
+                                    }
                                 }
                             }
                         }
-
                         return lazyNodes;
                     }
 
@@ -691,30 +701,35 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                             //获取当前层懒加载节点
                             List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,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) {
+                                //所有节点
+                                List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
+                                        .collect(Collectors.collectingAndThen(
+                                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                                ArrayList::new
+                                        ));
+                                //所有节点Map
+                                Map<Long, List<WbsTreeContractLazyVO>> allNodesParentGroup = distinctNodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
+
                                 //所有最底层节点
-                                List<WbsTreeContractLazyVO> lowestNodesAll = nodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.toList());
+                                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<WbsTreeContractLazyQueryInfoVO> queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
-                                Map<Long, Integer> queryInfoMaps = queryInfoList.stream().distinct().collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus));
+                                Map<Long, Integer> queryInfoMaps = queryInfoList.stream()
+                                        .collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
                                 List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
 
-                                //填报过的所有最底层节点
-                                List<WbsTreeContractLazyVO> lowestNodesTB = lowestNodesAll.stream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
+                                //填报过的所有最底层节点,处理数量
+                                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> resultParentNodesTB = new ArrayList<>();
                                 this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
 
-                                //所有父级节点Map
-                                Map<Long, WbsTreeContractLazyVO> nodesAllMap = new HashMap<>();
-                                List<WbsTreeContractLazyVO> collect = resultParentNodesTB.stream().distinct().collect(Collectors.toList());
-                                for (WbsTreeContractLazyVO node : collect) {
-                                    nodesAllMap.put(node.getId(), node);
-                                }
-
-                                //最底层节点Map
-                                Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesAll.stream()
+                                //最底层节点颜色构造后Map
+                                Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
                                         .peek(vo -> {
                                             Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
                                             if (colorStatus != null) {
@@ -724,12 +739,17 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                                                 //未填报的=颜色1黑色
                                                 vo.setColorStatus(1);
                                             }
-                                        })
-                                        .collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity(), (obj1, obj2) -> obj1));
+                                        }).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
                                 List<WbsTreeContractLazyVO> lowestNodesReList = new ArrayList<>(lowestNodesMap.values());
+                                Map<Long, WbsTreeContractLazyVO> distinctParentNodesTBIdKeyMap = resultParentNodesTB.stream()
+                                        .collect(Collectors.collectingAndThen(
+                                                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
+                                                ArrayList::new
+                                        )).stream().collect(Collectors.toMap(WbsTreeContractLazyVO::getId, Function.identity()));
 
                                 //构造完成的所有最底层节点,处理父节点颜色
-                                this.recursiveParentNodeColorStatus(lowestNodesReList, nodesAllMap);
+                                Map<Long, WbsTreeContractLazyVO> nodeColorMap = new HashMap<>();
+                                this.recursiveParentNodeColorStatus(lowestNodesReList, distinctParentNodesTBIdKeyMap, allNodesParentGroup, nodeColorMap);
 
                                 //处理最终结果集
                                 if (lazyNodes.size() > 0) {
@@ -755,14 +775,19 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                                             }
                                         }
 
-                                        lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? queryInfoMaps.get(lazyNodeVO.getPKeyId()) : 0));
+                                        lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
 
-                                        WbsTreeContractLazyVO vo = nodesAllMap.get(lazyNodeVO.getId());
+                                        /*if (lazyNodeVO.getSubmitCounts() >= 1) {
+                                            lazyNodeVO.setColorStatus(2);
+                                        }*/
+                                        WbsTreeContractLazyVO vo = nodeColorMap.get(lazyNodeVO.getPKeyId());
                                         if (vo != null) {
                                             lazyNodeVO.setColorStatus(vo.getColorStatus());
                                         } else {
                                             WbsTreeContractLazyVO lowestNode = lowestNodesMap.get(lazyNodeVO.getPKeyId());
-                                            lazyNodeVO.setColorStatus(ObjectUtil.isNotEmpty(lowestNode) ? lowestNode.getColorStatus() : 1);
+                                            if (lowestNode != null) {
+                                                lazyNodeVO.setColorStatus(lowestNode.getColorStatus());
+                                            }
                                         }
                                     }
                                 }
@@ -836,57 +861,76 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
 
     /**
      * 反向递归处理父节点颜色
-     *
-     * @param childNodeList 子级节点List
-     * @param nodeMap       所有节点Map
      */
-    private void recursiveParentNodeColorStatus(List<WbsTreeContractLazyVO> childNodeList, Map<Long, WbsTreeContractLazyVO> nodeMap) {
-        if (childNodeList.size() > 0) {
+    private void recursiveParentNodeColorStatus(List<WbsTreeContractLazyVO> childNodeTBList, Map<Long, WbsTreeContractLazyVO> distinctParentNodesTBIdKeyMap, Map<Long, List<WbsTreeContractLazyVO>> allNodesParentGroup, Map<Long, WbsTreeContractLazyVO> nodeColorMap) {
+        if (childNodeTBList.size() > 0) {
             List<WbsTreeContractLazyVO> parentNodeList = new ArrayList<>();
-            Map<Long, List<WbsTreeContractLazyVO>> lowestNodesParentGroup = childNodeList.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
-            for (Map.Entry<Long, List<WbsTreeContractLazyVO>> oneParentGroups : lowestNodesParentGroup.entrySet()) {
-                Long parentId = oneParentGroups.getKey(); //父节点id
-                List<WbsTreeContractLazyVO> oneLevel = oneParentGroups.getValue(); //子节点分组
-                if (parentId != null && oneLevel.size() > 0) {
-                    WbsTreeContractLazyVO parentNode = nodeMap.get(parentId); //获取父节点
+            Map<Long, List<WbsTreeContractLazyVO>> lowestNodesParentGroup = childNodeTBList.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
+            Map<Long, WbsTreeContractLazyVO> lowestNodesPKeyIdGroup = childNodeTBList.stream().collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
+
+            for (Map.Entry<Long, List<WbsTreeContractLazyVO>> lowestNodesParentGroupOne : lowestNodesParentGroup.entrySet()) {
+                Long parentId = lowestNodesParentGroupOne.getKey();
+
+                List<WbsTreeContractLazyVO> oneLevel = allNodesParentGroup.get(parentId); //根据填报的父级id,获取对应的父级id下面的所有子级,包括未填报的
+                if (oneLevel != null && oneLevel.size() > 0) {
+                    oneLevel.forEach(f -> {
+                        WbsTreeContractLazyVO tbNode = lowestNodesPKeyIdGroup.get(f.getPKeyId());
+                        if (tbNode != null) {
+                            f.setColorStatus(tbNode.getColorStatus());
+                        } else {
+                            f.setColorStatus(1);
+                        }
+                    });
+
+                    WbsTreeContractLazyVO parentNode = distinctParentNodesTBIdKeyMap.get(parentId); //获取父节点
                     if (parentNode != null) {
-                        boolean allThree = true; //是否所有子节点的getColorStatus都等于3
-                        boolean allFour = true; //是否所有子节点的getColorStatus都等于4
-                        boolean hasTwo = false; //是否存在子节点的getColorStatus等于2
-                        boolean hasOne = false; //是否存在子节点的getColorStatus等于1
-                        boolean hasThreeOrFour = false; //是否存在子节点的getColorStatus等于3或4
-                        for (WbsTreeContractLazyVO node : oneLevel) {
-                            if (node.getColorStatus() != 3) {
-                                allThree = false;
-                            }
-                            if (node.getColorStatus() != 4) {
-                                allFour = false;
-                            }
-                            if (node.getColorStatus() == 2) {
-                                hasTwo = true;
-                            }
-                            if (node.getColorStatus() == 1) {
-                                hasOne = true;
-                            }
-                            if (node.getColorStatus() == 3 || node.getColorStatus() == 4) {
-                                hasThreeOrFour = true;
-                            }
+
+                        int parentColor = 0; //定义上级颜色
+                        boolean all_1 = oneLevel.stream().allMatch(node -> node.getColorStatus() == 1); // 全部是1
+                        boolean all_2 = oneLevel.stream().allMatch(node -> node.getColorStatus() == 2); // 全部是2
+                        boolean all_3 = oneLevel.stream().allMatch(node -> node.getColorStatus() == 3); // 全部是3
+                        boolean all_4 = oneLevel.stream().allMatch(node -> node.getColorStatus() == 4); // 全部是4
+
+                        boolean hasOnly_1_and_3 = oneLevel.stream()
+                                .anyMatch(node -> node.getColorStatus() == 1)
+                                && oneLevel.stream().anyMatch(node -> node.getColorStatus() == 3)
+                                && oneLevel.stream().noneMatch(node -> node.getColorStatus() != 1 && node.getColorStatus() != 3); //同时只存在1、3 == 2
+
+                        boolean hasNotAll_1 = oneLevel.stream()
+                                .anyMatch(node -> node.getColorStatus() == 1)
+                                && oneLevel.stream().anyMatch(node -> node.getColorStatus() != 1); //有1 但不全部都是1 == 2 (12、13、14、123、124、134、1234)
+                        boolean hasNotAll_2 = oneLevel.stream()
+                                .anyMatch(node -> node.getColorStatus() == 2)
+                                && oneLevel.stream().anyMatch(node -> node.getColorStatus() != 2); //有2 但不全部都是2 == 2 (12、123、1234、23、24、234)
+                        boolean hasNotAll_3 = oneLevel.stream()
+                                .anyMatch(node -> node.getColorStatus() == 3)
+                                && oneLevel.stream().anyMatch(node -> node.getColorStatus() != 3)
+                                && oneLevel.stream().noneMatch(node -> node.getColorStatus() != 3 && node.getColorStatus() != 4); //有3 但不全部都是3,且不包含34这种情况 == 2 (13、123、1234、23、234)
+                        boolean hasOnly_3_and_4 = oneLevel.stream()
+                                .anyMatch(node -> node.getColorStatus() == 3)
+                                && oneLevel.stream().anyMatch(node -> node.getColorStatus() == 4)
+                                && oneLevel.stream().noneMatch(node -> node.getColorStatus() != 3 && node.getColorStatus() != 4); //同时只存在3、4 == 3
+
+                        if (all_1) {
+                            parentColor = 1;
+                        } else if (all_3 || hasOnly_3_and_4) {
+                            parentColor = 3;
+                        } else if (hasOnly_1_and_3 || all_2 || hasNotAll_2 || hasNotAll_1 || hasNotAll_3) {
+                            parentColor = 2;
+                        } else if (all_4) {
+                            parentColor = 4;
                         }
-                        if (allThree) {
-                            parentNode.setColorStatus(3);
-                        } else if (allFour) {
-                            parentNode.setColorStatus(4);
-                        } else if (hasTwo || (hasOne && hasThreeOrFour)) {
-                            parentNode.setColorStatus(2);
-                        } else {
-                            parentNode.setColorStatus(1);
+
+                        parentNode.setColorStatus(parentColor);
+                        if (ObjectUtil.isEmpty(nodeColorMap.get(parentNode.getPKeyId()))) {
+                            nodeColorMap.put(parentNode.getPKeyId(), parentNode);
                         }
                         parentNodeList.add(parentNode);
                     }
                 }
             }
             if (parentNodeList.size() > 0) { //递归处理父级颜色,当前父级作为下次循环子级
-                this.recursiveParentNodeColorStatus(parentNodeList, nodeMap);
+                this.recursiveParentNodeColorStatus(parentNodeList, distinctParentNodesTBIdKeyMap, allNodesParentGroup, nodeColorMap);
             }
         }
     }