From 787b561771b1f68c9e64e11a057cde5ccaf5c972 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 25 Apr 2024 20:26:18 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E4=BF=AE=E6=94=B9=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=E6=98=A0=E5=B0=84=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E5=B1=9E=E6=80=A7=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E7=9A=84=E5=AF=B9=E8=B1=A1=E6=98=AF?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E7=B1=BB=E5=9E=8B=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=B8=A6=E5=87=BA=E5=BC=95=E7=94=A8=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1136252433170432]视图管理-修改视图属性的映射对象,选择属性类型,选择的对象是下拉框类型,没有带出引用模型的属性下拉框 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1136252433170432 --- .../api/attr/GetCiAttrListForViewApi.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListForViewApi.java b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListForViewApi.java index dfdb0c3a..a883968c 100644 --- a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListForViewApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListForViewApi.java @@ -28,12 +28,15 @@ import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.ci.AttrMapper; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Service @AuthAction(action = CMDB_BASE.class) @@ -90,6 +93,7 @@ public class GetCiAttrListForViewApi extends PrivateApiComponentBase { } List resultList = new ArrayList<>(); List attrNameList = new ArrayList<>(); + List targetCiIdList = new ArrayList<>(); List upwardCiList = ciMapper.getUpwardCiListByLR(ciVo.getLft(), ciVo.getRht()); for (CiVo ci : upwardCiList) { List attrList = attrMapper.getDeclaredAttrListByCiId(ci.getId()); @@ -98,10 +102,25 @@ public class GetCiAttrListForViewApi extends PrivateApiComponentBase { continue; } attrNameList.add(attr.getName()); + if (attr.getTargetCiId() != null) { + targetCiIdList.add(attr.getTargetCiId()); + } resultList.add(attr); } } - + if (CollectionUtils.isNotEmpty(targetCiIdList)) { + List targetCiList = ciMapper.getAllCi(targetCiIdList); + Map targetCiMap = targetCiList.stream().collect(Collectors.toMap(CiVo::getId, e -> e)); + for (AttrVo attr : resultList) { + if (attr.getTargetCiId() == null) { + continue; + } + CiVo targetCi = targetCiMap.get(attr.getTargetCiId()); + if (targetCi != null) { + attr.setTargetCiName(targetCi.getName()); + } + } + } return resultList; } } -- Gitee