From 60d1e2151686cbba5beb91bdcc30955cbdb6de8c Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 19 Dec 2023 11:54:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-C?= =?UTF-8?q?MDB-=E6=A8=A1=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E3=80=81=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=9F=A5=E8=AF=A2=E7=9A=84?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=91=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1047056406249472]后端-CMDB-模型详情页面、配置项查询的详情页面,增加树目录 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1047056406249472 --- .../ListCiCatalogAndCiForTreeApi.java | 16 +++++++++++----- .../api/cicatalog/ListCiCatalogForTreeApi.java | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java index 3a02dbec..77dab803 100644 --- a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogAndCiForTreeApi.java @@ -66,6 +66,7 @@ public class ListCiCatalogAndCiForTreeApi extends PrivateApiComponentBase { } } } + List noCatalogCiNodeList = new ArrayList<>(); List ciNodeList = new ArrayList<>(); List ciList = ciMapper.getAllCi(null); for (CiVo ciVo : ciList) { @@ -74,21 +75,23 @@ public class ListCiCatalogAndCiForTreeApi extends PrivateApiComponentBase { continue; } } + CiCatalogNodeVo ciNode = new CiCatalogNodeVo(); + ciNode.setId(ciVo.getId()); + ciNode.setName(ciVo.getLabel() + "(" + ciVo.getName() + ")"); + ciNode.setParentId(ciVo.getCatalogId()); + ciNode.setType(CiCatalogNodeVo.CI); if (ciVo.getCatalogId() == null) { + noCatalogCiNodeList.add(ciNode); continue; } CiCatalogNodeVo node = id2NodeMap.get(ciVo.getCatalogId()); if (node == null) { + noCatalogCiNodeList.add(ciNode); continue; } if (StringUtils.isNotBlank(keyword)) { matchKeywordCiCatalogNodeList.add(node); } - CiCatalogNodeVo ciNode = new CiCatalogNodeVo(); - ciNode.setId(ciVo.getId()); - ciNode.setName(ciVo.getLabel() + "(" + ciVo.getName() + ")"); - ciNode.setParentId(ciVo.getCatalogId()); - ciNode.setType(CiCatalogNodeVo.CI); ciNodeList.add(ciNode); } List catalogList = new ArrayList<>(); @@ -116,6 +119,9 @@ public class ListCiCatalogAndCiForTreeApi extends PrivateApiComponentBase { parent.addChild(node); } } + for (CiCatalogNodeVo node : noCatalogCiNodeList) { + rootNode.addChild(node); + } return rootNode.getChildren(); } diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java index 5c5b424f..6ef69345 100644 --- a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java @@ -3,16 +3,20 @@ package neatlogic.module.cmdb.api.cicatalog; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.auth.label.CMDB_BASE; +import neatlogic.framework.cmdb.dto.ci.CiVo; import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogNodeVo; import neatlogic.framework.cmdb.dto.cicatalog.CiCatalogVo; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.service.cicatalog.CiCatalogService; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -22,6 +26,9 @@ import java.util.stream.Collectors; @OperationType(type = OperationTypeEnum.SEARCH) public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { + @Resource + private CiMapper ciMapper; + @Resource private CiCatalogService ciCatalogService; @@ -41,10 +48,21 @@ public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { if (CollectionUtils.isEmpty(allNodeList)) { return allNodeList; } + Map> catalogId2CiListMap = new HashMap<>(); + List ciList = ciMapper.getAllCi(null); + for (CiVo ciVo : ciList) { + if (ciVo.getCatalogId() != null) { + catalogId2CiListMap.computeIfAbsent(ciVo.getCatalogId(), key -> new ArrayList<>()).add(ciVo); + } + } CiCatalogNodeVo rootNode = allNodeList.get(0); Map id2NodeMap = allNodeList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e)); for (CiCatalogNodeVo node : allNodeList) { node.setType(CiCatalogNodeVo.CATALOG); + List ciVoList = catalogId2CiListMap.get(node.getId()); + if (CollectionUtils.isNotEmpty(ciVoList)) { + node.setChildrenCount(ciVoList.size()); + } CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); if (parent != null) { parent.addChild(node); -- Gitee From 63329704843c6b1df0f417d756aeb218279086bd Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 19 Dec 2023 12:03:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-C?= =?UTF-8?q?MDB-=E6=A8=A1=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E3=80=81=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=9F=A5=E8=AF=A2=E7=9A=84?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=91=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1047056406249472]后端-CMDB-模型详情页面、配置项查询的详情页面,增加树目录 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1047056406249472 --- .../cicatalog/ListCiCatalogForTreeApi.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java index 6ef69345..b839158f 100644 --- a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java @@ -48,6 +48,16 @@ public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { if (CollectionUtils.isEmpty(allNodeList)) { return allNodeList; } + CiCatalogNodeVo rootNode = allNodeList.get(0); + Map id2NodeMap = allNodeList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e)); + for (CiCatalogNodeVo node : allNodeList) { + node.setType(CiCatalogNodeVo.CATALOG); + + CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); + if (parent != null) { + parent.addChild(node); + } + } Map> catalogId2CiListMap = new HashMap<>(); List ciList = ciMapper.getAllCi(null); for (CiVo ciVo : ciList) { @@ -55,17 +65,12 @@ public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { catalogId2CiListMap.computeIfAbsent(ciVo.getCatalogId(), key -> new ArrayList<>()).add(ciVo); } } - CiCatalogNodeVo rootNode = allNodeList.get(0); - Map id2NodeMap = allNodeList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e)); for (CiCatalogNodeVo node : allNodeList) { - node.setType(CiCatalogNodeVo.CATALOG); List ciVoList = catalogId2CiListMap.get(node.getId()); if (CollectionUtils.isNotEmpty(ciVoList)) { - node.setChildrenCount(ciVoList.size()); - } - CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); - if (parent != null) { - parent.addChild(node); + Integer childrenCount = node.getChildrenCount(); + childrenCount = childrenCount + ciVoList.size(); + node.setChildrenCount(childrenCount); } } return rootNode.getChildren(); -- Gitee From c58318ff21dbc3ef1d845f9e9cfb9d8ed2a2709b Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 19 Dec 2023 12:04:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-C?= =?UTF-8?q?MDB-=E6=A8=A1=E5=9E=8B=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E3=80=81=E9=85=8D=E7=BD=AE=E9=A1=B9=E6=9F=A5=E8=AF=A2=E7=9A=84?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=91=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1047056406249472]后端-CMDB-模型详情页面、配置项查询的详情页面,增加树目录 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1047056406249472 --- .../module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java index b839158f..f2723451 100644 --- a/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/cicatalog/ListCiCatalogForTreeApi.java @@ -52,7 +52,6 @@ public class ListCiCatalogForTreeApi extends PrivateApiComponentBase { Map id2NodeMap = allNodeList.stream().collect(Collectors.toMap(e -> e.getId(), e -> e)); for (CiCatalogNodeVo node : allNodeList) { node.setType(CiCatalogNodeVo.CATALOG); - CiCatalogNodeVo parent = id2NodeMap.get(node.getParentId()); if (parent != null) { parent.addChild(node); -- Gitee