From 940d7f590bf7884d9f3e2ba01793feefe6ba6e23 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 9 Jan 2024 17:29:04 +0800 Subject: [PATCH 1/2] =?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=E5=88=86=E6=B4=BE=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1065220494032896]后端-CMDB模型分派器 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1065220494032896 --- .../cmdb/api/attr/GetCiAttrListApi.java | 12 +- .../api/customview/GetCustomViewAttrApi.java | 25 +- .../mapper/customview/CustomViewMapper.java | 2 + .../mapper/customview/CustomViewMapper.xml | 28 ++ .../service/cientity/CiEntityServiceImpl.java | 25 +- ...CmdbDispatcherDispatchFailedException.java | 43 ++ .../handler/CiEntityFormDispatcher.java | 64 --- .../handler/CmdbDispatcher.java | 451 ++++++++++++++++++ 8 files changed, 579 insertions(+), 71 deletions(-) create mode 100644 src/main/java/neatlogic/module/cmdb/workerdispatcher/exception/CmdbDispatcherDispatchFailedException.java delete mode 100644 src/main/java/neatlogic/module/cmdb/workerdispatcher/handler/CiEntityFormDispatcher.java create mode 100644 src/main/java/neatlogic/module/cmdb/workerdispatcher/handler/CmdbDispatcher.java diff --git a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java index b7e3a111..6613192c 100644 --- a/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/attr/GetCiAttrListApi.java @@ -16,6 +16,7 @@ package neatlogic.module.cmdb.api.attr; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.attrvaluehandler.core.AttrValueHandlerFactory; @@ -33,6 +34,7 @@ import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.ci.AttrMapper; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.dao.mapper.ci.CiViewMapper; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -76,7 +78,9 @@ public class GetCiAttrListApi extends PrivateApiComponentBase { @Param(name = "showType", type = ApiParamType.ENUM, rule = "all,list,detail", desc = "common.displaytype"), @Param(name = "allowEdit", type = ApiParamType.INTEGER, rule = "1,0", desc = "term.cmdb.allowedit"), @Param(name = "isRequired", type = ApiParamType.INTEGER, rule = "1,0", desc = "common.isrequired"), - @Param(name = "isSimple", type = ApiParamType.BOOLEAN, rule = "true,false", desc = "term.cmdb.issimpleattribute") + @Param(name = "isSimple", type = ApiParamType.BOOLEAN, rule = "true,false", desc = "term.cmdb.issimpleattribute"), + @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue") + }) @Output({ @Param(name = "Return", explode = AttrVo[].class) @@ -84,6 +88,12 @@ public class GetCiAttrListApi extends PrivateApiComponentBase { @Description(desc = "nmcaa.getciattrlistapi.getname") @Override public Object myDoService(JSONObject jsonObj) throws Exception { + JSONArray defaultValue = jsonObj.getJSONArray("defaultValue"); + if (CollectionUtils.isNotEmpty(defaultValue)) { + List idList = defaultValue.toJavaList(Long.class); + List attrList = attrMapper.getAttrByIdList(idList); + return attrList; + } Long ciId = jsonObj.getLong("ciId"); if (ciId == null) { String ciName = jsonObj.getString("ciName"); diff --git a/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java b/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java index 4f2b9e5b..d2151d4a 100644 --- a/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/customview/GetCustomViewAttrApi.java @@ -16,16 +16,19 @@ package neatlogic.module.cmdb.api.customview; +import com.alibaba.fastjson.JSONArray; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.dto.customview.CustomViewAttrVo; import neatlogic.framework.cmdb.dto.customview.CustomViewConstAttrVo; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.exception.type.ParamNotExistsException; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.framework.cmdb.auth.label.CMDB_BASE; import neatlogic.module.cmdb.dao.mapper.customview.CustomViewMapper; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -49,12 +52,30 @@ public class GetCustomViewAttrApi extends PrivateApiComponentBase { return null; } - @Input({@Param(name = "id", type = ApiParamType.LONG, desc = "视图id", isRequired = true), @Param(name = "isHidden", type = ApiParamType.INTEGER, desc = "属性是否隐藏,1是,0否")}) - @Output({@Param(name = "attrList", explode = CustomViewAttrVo[].class), @Param(name = "constAttrList", explode = CustomViewConstAttrVo[].class)}) + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "视图id"), + @Param(name = "isHidden", type = ApiParamType.INTEGER, desc = "属性是否隐藏,1是,0否"), + @Param(name = "defaultValue", type = ApiParamType.JSONARRAY, desc = "common.defaultvalue") + }) + @Output({ + @Param(name = "attrList", explode = CustomViewAttrVo[].class), + @Param(name = "constAttrList", explode = CustomViewConstAttrVo[].class) + }) @Description(desc = "获取自定义视图属性列表接口") @Override public Object myDoService(JSONObject paramObj) throws Exception { + JSONArray defaultValue = paramObj.getJSONArray("defaultValue"); + if (CollectionUtils.isNotEmpty(defaultValue)) { + List uuidList = defaultValue.toJavaList(String.class); + List attrList = customViewMapper.getCustomViewAttrByUuidList(uuidList); + JSONObject returnObj = new JSONObject(); + returnObj.put("attrList", attrList); + return returnObj; + } Long id = paramObj.getLong("id"); + if (id == null) { + throw new ParamNotExistsException("id"); + } Integer isHidden = paramObj.getInteger("isHidden"); CustomViewConstAttrVo customViewConstAttrVo = new CustomViewConstAttrVo(id); CustomViewAttrVo customViewAttrVo = new CustomViewAttrVo(id); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java index c048eab7..319e30f3 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.java @@ -42,6 +42,8 @@ public interface CustomViewMapper { List getCustomViewAttrByCustomViewId(CustomViewAttrVo customViewAttrVo); + List getCustomViewAttrByUuidList(List uuidList); + List getCustomViewConstAttrByCustomViewId(CustomViewConstAttrVo customViewConstAttrVo); List getCustomViewLinkByCustomViewId(Long customViewId); diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml index f4a78ce0..6fbc90d8 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/customview/CustomViewMapper.xml @@ -177,6 +177,34 @@ ORDER BY a.sort + +