From 2e1bcde9d4028b04dd6ac63f5122cd6c9c614be1 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 18 Jul 2022 16:44:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=94=A8=E4=BE=8B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/service/NodeTreeService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/NodeTreeService.java b/backend/src/main/java/io/metersphere/service/NodeTreeService.java index cd2ecc2737..d9ea693571 100644 --- a/backend/src/main/java/io/metersphere/service/NodeTreeService.java +++ b/backend/src/main/java/io/metersphere/service/NodeTreeService.java @@ -83,18 +83,18 @@ public class NodeTreeService { return nodeTree; } - List children = Optional.ofNullable(nodeTree.getChildren()).orElse(new ArrayList<>()); + List children = new ArrayList<>(); lowerNodes.forEach(node -> { if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) { children.add(buildNodeTree(nodeLevelMap, node, countMap)); - if (countMap != null) { - Integer childrenCount = children.stream().map(TreeNodeDTO::getCaseNum).reduce(Integer::sum).get(); - nodeTree.setCaseNum(nodeTree.getCaseNum() + childrenCount); - } nodeTree.setChildren(children); } }); + if (countMap != null && CollectionUtils.isNotEmpty(children)) { + Integer childrenCount = children.stream().map(TreeNodeDTO::getCaseNum).reduce(Integer::sum).get(); + nodeTree.setCaseNum(nodeTree.getCaseNum() + childrenCount); + } return nodeTree; }