diff --git a/src/main/java/neatlogic/framework/cmdb/annotation/ResourceType.java b/src/main/java/neatlogic/framework/cmdb/annotation/ResourceType.java index d7bf2871bc8ddeec2d6e42cdb2b93340b6f25681..15a20c97ac44649767fb22818d0f8ccdc1c8d7c4 100644 --- a/src/main/java/neatlogic/framework/cmdb/annotation/ResourceType.java +++ b/src/main/java/neatlogic/framework/cmdb/annotation/ResourceType.java @@ -31,5 +31,9 @@ public @interface ResourceType { String ciName() default ""; + boolean isMultiple() default false; + + String moduleId() default ""; + String[] functionPathList() default {}; } diff --git a/src/main/java/neatlogic/framework/cmdb/crossover/IAppSystemMapper.java b/src/main/java/neatlogic/framework/cmdb/crossover/IAppSystemMapper.java index 75a1258e1eca30568fda3df092eedbf353b0e33a..b129323bc753a87b019b3f3bcfc351e2820ac800 100644 --- a/src/main/java/neatlogic/framework/cmdb/crossover/IAppSystemMapper.java +++ b/src/main/java/neatlogic/framework/cmdb/crossover/IAppSystemMapper.java @@ -15,11 +15,9 @@ along with this program. If not, see .*/ package neatlogic.framework.cmdb.crossover; -import neatlogic.framework.cmdb.dto.resourcecenter.entity.AppEnvironmentVo; import neatlogic.framework.cmdb.dto.resourcecenter.entity.AppModuleVo; import neatlogic.framework.cmdb.dto.resourcecenter.entity.AppSystemVo; import neatlogic.framework.crossover.ICrossoverService; -import org.apache.ibatis.annotations.Param; import java.util.List; @@ -36,5 +34,4 @@ public interface IAppSystemMapper extends ICrossoverService { List getAppModuleListByIdList(List idList); - List getAppEnvListByAppSystemIdAndModuleIdList(@Param("appSystemId") Long appSystemId, @Param("appModuleIdList") List appModuleIdList); } diff --git a/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCenterResourceCrossoverService.java b/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCenterResourceCrossoverService.java index c00b58eac8aad1aac57bf18bfae83a2060c7f9d9..65881124b4c1ee80d816380ee9a7fe3443cad676 100644 --- a/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCenterResourceCrossoverService.java +++ b/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCenterResourceCrossoverService.java @@ -15,16 +15,12 @@ along with this program. If not, see .*/ package neatlogic.framework.cmdb.crossover; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.cmdb.dto.resourcecenter.AccountVo; -import neatlogic.framework.cmdb.dto.resourcecenter.AppEnvVo; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo; -import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo; import neatlogic.framework.cmdb.dto.tag.TagVo; import neatlogic.framework.crossover.ICrossoverService; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -71,45 +67,5 @@ public interface IResourceCenterResourceCrossoverService extends ICrossoverServi */ Map> getResourceTagByResourceIdList(List idList); - /** - * 补充资产的账号信息 - * - * @param idList 资产id列表 - * @param resourceVoList 资产列表 - */ - void addResourceAccount(List idList, List resourceVoList); - - /** - * 补充资产的标签信息 - * - * @param idList 资产id列表 - * @param resourceVoList 资产列表 - */ - void addResourceTag(List idList, List resourceVoList); - - /** - * 获取对应模块的应用清单列表 - * 其中清单列表有 系统 存储设备 网络设备 应用实例 应用实例集群 DB实例 DB实例集群 访问入口 - * - * @param searchVo resourceSearchVo - * @return tableList - */ - JSONArray getAppModuleResourceList(ResourceSearchVo searchVo); - - /** - * 获取模块列表 - * - * @param searchVo resourceSearchVo - * @return 模块列表 - */ - List getAppModuleList(ResourceSearchVo searchVo); - - /** - * 获取应用巡检批量巡检时的环境列表(环境会包含模块列表,模块还会包含模型列表) - * - * @param searchVo resourceSearchVo - * @return 应用巡检批量巡检时的环境列表 - */ - Collection getAppEnvList(ResourceSearchVo searchVo); } diff --git a/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCrossoverMapper.java b/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCrossoverMapper.java index 5552eeb65d5cbf0b1e83358ca57721c9c25ef271..daec649d7dc492b80b775d8f197a864d7c41dff4 100644 --- a/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCrossoverMapper.java +++ b/src/main/java/neatlogic/framework/cmdb/crossover/IResourceCrossoverMapper.java @@ -41,24 +41,6 @@ public interface IResourceCrossoverMapper extends ICrossoverService { List getResourceListByIdList(List idList); - List getAppSystemModuleIdListByAppSystemIdAndAppModuleIdListAndEnvId(@Param("appSystemId") Long appSystemId, @Param("envId") Long envId, @Param("appModuleIdList") JSONArray appModuleIdList); - - int getIpObjectResourceCountByAppSystemIdAndAppModuleIdAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - List getIpObjectResourceIdListByAppSystemIdAndAppModuleIdAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - int getOsResourceCountByAppSystemIdAndAppModuleIdAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - List getOsResourceIdListByAppSystemIdAndAppModuleIdAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - int getOsResourceCountByAppSystemIdAndAppModuleIdListAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - List getOsResourceIdListByAppSystemIdAndAppModuleIdListAndEnvIdAndTypeId(ResourceSearchVo searchVo); - - List getAppInstanceResourceListByIdList(List idList); - - List getAppInstanceResourceListByIdListAndKeyword(@Param("idList") List idList, @Param("keyword") String keyword); - List getAppInstanceResourceListByIdListSimple(List idList); Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo); @@ -71,12 +53,12 @@ public interface IResourceCrossoverMapper extends ICrossoverService { int checkResourceIsExists(Long id); + Long getResourceIdByResourceId(Long id); + List checkResourceIdListIsExists(List idList); List getHasModuleAppSystemIdListByAppSystemIdList(@Param("appSystemIdList") List appSystemIdList); - List getHasEnvAppSystemIdListByAppSystemIdList(@Param("appSystemIdList") List appSystemIdList); - List getAppSystemModuleIdListByAppSystemId(Long appSystemId); List getAppSystemModuleIdListByAppSystemIdAndAppModuleIdList(@Param("appSystemId") Long appSystemId, @Param("appModuleIdList") JSONArray appModuleIdList); @@ -85,25 +67,11 @@ public interface IResourceCrossoverMapper extends ICrossoverService { List getAppModuleListByIdListSimple(@Param("idList") List idList, @Param("needOrder") boolean needOrder); - Set getIpObjectResourceTypeIdListByAppSystemIdAndEnvId(ResourceSearchVo searchVo); - - Set getOsResourceTypeIdListByAppSystemIdAndEnvId(ResourceSearchVo searchVo); - - Set getResourceAppSystemIdListByResourceId(Long id); - - List getResourceAppSystemListByResourceIdList(List id); - List getResourceListByResourceVoList(@Param("resourceList") List resourceList,@Param("searchVo") ResourceSearchVo searchVo); - Long getAppSystemIdByResourceId(Long id); - Set getResourceTypeIdListByAppSystemIdAndModuleIdAndEnvIdAndInspectStatusList(ResourceSearchVo searchVo); List getResourceIdListByAppSystemIdAndModuleIdAndEnvId(ResourceVo resourceVo); - - List getAppInstanceResourceIdListByAppSystemIdAndModuleIdAndEnvId(ResourceVo resourceVo); - - Integer getAppInstanceResourceIdCountByAppSystemIdAndModuleIdAndEnvId(ResourceVo resourceVo); /** * 根据类型和IP列表查询资源 * @@ -141,9 +109,5 @@ public interface IResourceCrossoverMapper extends ICrossoverService { List searchAppSystemListByIdList(List idList); - List getOsResourceListenPortListByResourceIdList(List resourceIdList); - - List getSoftwareResourceListenPortListByResourceIdList(List resourceIdList); - List getOsResourceListByResourceIdList(List resourceIdList); } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AppModuleVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AppModuleVo.java index 7acbbe7b1ce35d161843a4bcd216969cfcd4b638..e2cb71789d5f821f56fcabea9d8696f1e5605f44 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AppModuleVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AppModuleVo.java @@ -15,12 +15,10 @@ along with this program. If not, see .*/ package neatlogic.framework.cmdb.dto.resourcecenter; -import neatlogic.framework.cmdb.dto.ci.CiVo; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.restful.annotation.EntityField; import java.io.Serializable; -import java.util.List; public class AppModuleVo implements Serializable { private static final long serialVersionUID = 3794860793337591802L; @@ -36,9 +34,6 @@ public class AppModuleVo implements Serializable { @EntityField(name = "term.cmdb.ishasenv", type = ApiParamType.INTEGER) private Integer isHasEnv = 0; - @EntityField(name = "term.cmdb.cilist", type = ApiParamType.JSONARRAY) - private List ciList; - public Long getId() { return id; } @@ -79,11 +74,4 @@ public class AppModuleVo implements Serializable { this.isHasEnv = isHasEnv; } - public List getCiList() { - return ciList; - } - - public void setCiList(List ciList) { - this.ciList = ciList; - } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ApplicationListDisplayVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ApplicationListDisplayVo.java new file mode 100644 index 0000000000000000000000000000000000000000..d9b6fcc6aa296e4dacd6a028c19eda3cec0d735e --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ApplicationListDisplayVo.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.dto.resourcecenter; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.annotation.JSONField; + +public class ApplicationListDisplayVo { + private Long id; + + private Long appSystemId; + + private Long appModuleId; + + private Long envId; + + private JSONObject config; + + @JSONField(serialize = false) + private String configStr; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getAppSystemId() { + return appSystemId; + } + + public void setAppSystemId(Long appSystemId) { + this.appSystemId = appSystemId; + } + + public Long getAppModuleId() { + return appModuleId; + } + + public void setAppModuleId(Long appModuleId) { + this.appModuleId = appModuleId; + } + + public Long getEnvId() { + return envId; + } + + public void setEnvId(Long envId) { + this.envId = envId; + } + + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSON.parseObject(configStr); + } + return config; + } + + public void setConfig(JSONObject config) { + this.config = config; + } + + public String getConfigStr() { + if (config != null) { + return config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AssetListDisplayVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AssetListDisplayVo.java new file mode 100644 index 0000000000000000000000000000000000000000..549d9b44a4fa9efdb448995f4ef3138e8281cb74 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/AssetListDisplayVo.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.dto.resourcecenter; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.annotation.JSONField; + +public class AssetListDisplayVo { + private Long id; + + private String rootCiName; + + private JSONObject config; + + @JSONField(serialize = false) + private String configStr; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getRootCiName() { + return rootCiName; + } + + public void setRootCiName(String rootCiName) { + this.rootCiName = rootCiName; + } + + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSON.parseObject(configStr); + } + return config; + } + + public void setConfig(JSONObject config) { + this.config = config; + } + + public String getConfigStr() { + if (config != null) { + return config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceSearchVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceSearchVo.java index 59e41289e27cc61c215da77012277084f99167a3..51597bbfb422eaa6a37e53a62e5f345634ff1c28 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceSearchVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceSearchVo.java @@ -107,6 +107,8 @@ public class ResourceSearchVo extends ConditionConfigVo { private Long ipFieldAttrId; @EntityField(name = "name字段映射的属性ID", type = ApiParamType.LONG) private Long nameFieldAttrId; + @EntityField(name = "视图名称", type = ApiParamType.STRING) + private String viewName; public ResourceSearchVo() { } @@ -442,4 +444,12 @@ public class ResourceSearchVo extends ConditionConfigVo { public boolean isCustomCondition(){ return CollectionUtils.isNotEmpty(conditionGroupList); } + + public String getViewName() { + return viewName; + } + + public void setViewName(String viewName) { + this.viewName = viewName; + } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceVo.java index ec88fe94454b7124b3043cd3f2d10c51c28888ed..5918b248fa905a8b71d31806fb984eb5e6b83c89 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/ResourceVo.java @@ -55,6 +55,12 @@ public class ResourceVo extends BaseEditorVo { private String stateName; @EntityField(name = "状态描述", type = ApiParamType.STRING) private String stateLabel; + @EntityField(name = "厂商id", type = ApiParamType.LONG) + private Long vendorId; + @EntityField(name = "厂商名称", type = ApiParamType.STRING) + private String vendorName; + @EntityField(name = "厂商描述", type = ApiParamType.STRING) + private String vendorLabel; @EntityField(name = "应用系统id", type = ApiParamType.LONG) private Long appSystemId; @EntityField(name = "应用系统名称", type = ApiParamType.STRING) @@ -152,6 +158,9 @@ public class ResourceVo extends BaseEditorVo { this.stateId = resourceVo.stateId; this.stateName = resourceVo.stateName; this.stateLabel = resourceVo.stateLabel; + this.vendorId = resourceVo.vendorId; + this.vendorName = resourceVo.vendorName; + this.vendorLabel = resourceVo.vendorLabel; this.appSystemId = resourceVo.appSystemId; this.appSystemName = resourceVo.appSystemName; this.appSystemAbbrName = resourceVo.appSystemAbbrName; @@ -277,6 +286,30 @@ public class ResourceVo extends BaseEditorVo { this.stateLabel = stateLabel; } + public Long getVendorId() { + return vendorId; + } + + public void setVendorId(Long vendorId) { + this.vendorId = vendorId; + } + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getVendorLabel() { + return vendorLabel; + } + + public void setVendorLabel(String vendorLabel) { + this.vendorLabel = vendorLabel; + } + public Long getAppSystemId() { return appSystemId; } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityAttrVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityAttrVo.java deleted file mode 100644 index 3519feb347c572f36430fd523cc24f4103e9cd08..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityAttrVo.java +++ /dev/null @@ -1,128 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.config; - -import com.alibaba.fastjson.annotation.JSONField; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -import java.util.Objects; - -public class ResourceEntityAttrVo { - @EntityField(name = "资源实体名称", type = ApiParamType.STRING) - private String entity; - @EntityField(name = "视图字段名", type = ApiParamType.STRING) - private String field; - @EntityField(name = "模型属性名", type = ApiParamType.STRING) - private String attr; - @EntityField(name = "模型属性id", type = ApiParamType.LONG) - private Long attrId; - @EntityField(name = "模型id", type = ApiParamType.LONG) - private Long ciId; - @EntityField(name = "模型名称", type = ApiParamType.STRING) - private String ciName; - @JSONField(serialize = false) - private String tableAlias;//表别名 - @EntityField(name = "关联类型,attr或rel,不同类型join的表不一样", type = ApiParamType.ENUM, member = JoinType.class) - private JoinType joinType; - private CiVo ci; - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ResourceEntityAttrVo that = (ResourceEntityAttrVo) o; - return Objects.equals(field, that.field) && Objects.equals(ciId, that.ciId); - } - - @Override - public int hashCode() { - return Objects.hash(field, ciId); - } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public String getAttr() { - return attr; - } - - public void setAttr(String attr) { - this.attr = attr; - } - - public Long getAttrId() { - return attrId; - } - - public void setAttrId(Long attrId) { - this.attrId = attrId; - } - - public Long getCiId() { - return ciId; - } - - public void setCiId(Long ciId) { - this.ciId = ciId; - } - - public String getCiName() { - return ciName; - } - - public void setCiName(String ciName) { - this.ciName = ciName; - } - - public JoinType getJoinType() { - return joinType; - } - - public void setJoinType(JoinType joinType) { - this.joinType = joinType; - } - - public String getTableAlias() { - return tableAlias; - } - - public void setTableAlias(String tableAlias) { - this.tableAlias = tableAlias; - } - - public String getEntity() { - return entity; - } - - public void setEntity(String entity) { - this.entity = entity; - } - - public CiVo getCi() { - return ci; - } - - public void setCi(CiVo ci) { - this.ci = ci; - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityConfigVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityConfigVo.java index 531908789fb134f6e72f13a22c1b8629551f8154..4d1f458bfbedbef69e2c3c616ba8c1654f46ab46 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityConfigVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityConfigVo.java @@ -26,8 +26,16 @@ public class ResourceEntityConfigVo { @JSONField(serialize = false) private CiVo mainCiVo; + private ResourceEntityRelNodeVo relNode; + + private List relLinkList; + + List leftJoinList; + private List fieldMappingList; + private String sceneTemplateName; + public String getMainCi() { return mainCi; } @@ -44,6 +52,30 @@ public class ResourceEntityConfigVo { this.mainCiVo = mainCiVo; } + public ResourceEntityRelNodeVo getRelNode() { + return relNode; + } + + public void setRelNode(ResourceEntityRelNodeVo relNode) { + this.relNode = relNode; + } + + public List getRelLinkList() { + return relLinkList; + } + + public void setRelLinkList(List relLinkList) { + this.relLinkList = relLinkList; + } + + public List getLeftJoinList() { + return leftJoinList; + } + + public void setLeftJoinList(List leftJoinList) { + this.leftJoinList = leftJoinList; + } + public List getFieldMappingList() { return fieldMappingList; } @@ -51,4 +83,12 @@ public class ResourceEntityConfigVo { public void setFieldMappingList(List fieldMappingList) { this.fieldMappingList = fieldMappingList; } + + public String getSceneTemplateName() { + return sceneTemplateName; + } + + public void setSceneTemplateName(String sceneTemplateName) { + this.sceneTemplateName = sceneTemplateName; + } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityFieldMappingVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityFieldMappingVo.java index a8ac910b4dc050a1c386c8bbc4e675d5224ca9c2..3baef6d8d0c8b8c4c41791a91d00647b3f971dfc 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityFieldMappingVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityFieldMappingVo.java @@ -22,10 +22,15 @@ public class ResourceEntityFieldMappingVo { private String field; private String type; private String fromCi; + private String fromCiAlias; private String fromAttr; private String toCi; + private String toCiAlias; private String toAttr; private String direction; + private String uuid; + private String ciName; + private String attr; @JSONField(serialize = false) private Long fromCiId; @JSONField(serialize = false) @@ -162,4 +167,44 @@ public class ResourceEntityFieldMappingVo { public void setToCiIsVirtual(Integer toCiIsVirtual) { this.toCiIsVirtual = toCiIsVirtual; } + + public String getFromCiAlias() { + return fromCiAlias; + } + + public void setFromCiAlias(String fromCiAlias) { + this.fromCiAlias = fromCiAlias; + } + + public String getToCiAlias() { + return toCiAlias; + } + + public void setToCiAlias(String toCiAlias) { + this.toCiAlias = toCiAlias; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCiName() { + return ciName; + } + + public void setCiName(String ciName) { + this.ciName = ciName; + } + + public String getAttr() { + return attr; + } + + public void setAttr(String attr) { + this.attr = attr; + } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityJoinVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityJoinVo.java deleted file mode 100644 index 0bd01d91c207af093de6cc1f5785d40e4685c53b..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityJoinVo.java +++ /dev/null @@ -1,95 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.config; - -import com.alibaba.fastjson.annotation.JSONField; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.enums.RelDirectionType; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; - -import java.util.Objects; - -public class ResourceEntityJoinVo { - private final JoinType joinType; - private String field; - private String ciName; - private String direction = RelDirectionType.FROM.getValue(); - @JSONField(serialize = false) - private CiVo ci; - private String joinAttrName; - public ResourceEntityJoinVo(JoinType _joinType) { - joinType = _joinType; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ResourceEntityJoinVo that = (ResourceEntityJoinVo) o; - return joinType == that.joinType && Objects.equals(ciName, that.ciName) && direction.equals(that.direction); - } - - @Override - public int hashCode() { - return Objects.hash(joinType, ciName, direction); - } - - public JoinType getJoinType() { - return joinType; - } - - - public String getCiName() { - return ciName; - } - - public void setCiName(String ciName) { - this.ciName = ciName; - } - - public CiVo getCi() { - return ci; - } - - public void setCi(CiVo ci) { - this.ci = ci; - } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public String getJoinAttrName() { - return joinAttrName; - } - - public void setJoinAttrName(String joinAttrName) { - this.joinAttrName = joinAttrName; - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityLeftJoinVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityLeftJoinVo.java new file mode 100644 index 0000000000000000000000000000000000000000..2b26fdbcb8b60396f934e580284343c635e3851b --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityLeftJoinVo.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.dto.resourcecenter.config; + +public class ResourceEntityLeftJoinVo { + + private String fromCi; + + private String fromCiAlias; + + private Long fromCiId; + + private String toCi; + + private String toCiAlias; + + private Long toCiId; + + private String direction; + + public String getFromCi() { + return fromCi; + } + + public void setFromCi(String fromCi) { + this.fromCi = fromCi; + } + + public String getToCi() { + return toCi; + } + + public void setToCi(String toCi) { + this.toCi = toCi; + } + + public Long getFromCiId() { + return fromCiId; + } + + public void setFromCiId(Long fromCiId) { + this.fromCiId = fromCiId; + } + + public Long getToCiId() { + return toCiId; + } + + public void setToCiId(Long toCiId) { + this.toCiId = toCiId; + } + + public String getFromCiAlias() { + return fromCiAlias; + } + + public void setFromCiAlias(String fromCiAlias) { + this.fromCiAlias = fromCiAlias; + } + + public String getToCiAlias() { + return toCiAlias; + } + + public void setToCiAlias(String toCiAlias) { + this.toCiAlias = toCiAlias; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelLinkVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelLinkVo.java new file mode 100644 index 0000000000000000000000000000000000000000..20406b3f64389de519619a71e64e48559e644b3e --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelLinkVo.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.dto.resourcecenter.config; + +public class ResourceEntityRelLinkVo { + private String leftCi; + + private String rightCi; + + private String leftCiAlias; + + private String rightCiAlias; + + private String direction; + + private String rightUuid; + + public String getLeftCi() { + return leftCi; + } + + public void setLeftCi(String leftCi) { + this.leftCi = leftCi; + } + + public String getRightCi() { + return rightCi; + } + + public void setRightCi(String rightCi) { + this.rightCi = rightCi; + } + + public String getLeftCiAlias() { + return leftCiAlias; + } + + public void setLeftCiAlias(String leftCiAlias) { + this.leftCiAlias = leftCiAlias; + } + + public String getRightCiAlias() { + return rightCiAlias; + } + + public void setRightCiAlias(String rightCiAlias) { + this.rightCiAlias = rightCiAlias; + } + + public String getRightUuid() { + return rightUuid; + } + + public void setRightUuid(String rightUuid) { + this.rightUuid = rightUuid; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelNodeVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelNodeVo.java new file mode 100644 index 0000000000000000000000000000000000000000..7614bd798087a0b2f327abf748994949170a7793 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityRelNodeVo.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.dto.resourcecenter.config; + +import java.util.ArrayList; +import java.util.List; + +public class ResourceEntityRelNodeVo { + private String uuid; + private String ciName; + private String ciLabel; + private String direction; + private List children = new ArrayList<>(); + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getCiName() { + return ciName; + } + + public void setCiName(String ciName) { + this.ciName = ciName; + } + + public String getCiLabel() { + return ciLabel; + } + + public void setCiLabel(String ciLabel) { + this.ciLabel = ciLabel; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityVo.java index 9972cebf4c4bdeb1011c27b5c86a123129c56e0b..669f7778cae18c76b49abb333173ed03c2a26cfd 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceEntityVo.java @@ -33,10 +33,6 @@ public class ResourceEntityVo { private String label; @EntityField(name = "term.cmdb.ciinfo", type = ApiParamType.JSONOBJECT) private CiVo ci;//对应的模型 - @EntityField(name = "common.attributelist", type = ApiParamType.JSONARRAY) - private Set attrList; - @EntityField(name = "term.cmdb.joinlist", type = ApiParamType.JSONARRAY) - private Set joinList; @EntityField(name = "common.status", type = ApiParamType.ENUM, member = Status.class) private String status = ""; @EntityField(name = "common.statusname", type = ApiParamType.STRING) @@ -54,6 +50,12 @@ public class ResourceEntityVo { private List fieldList; @EntityField(name = "common.config", type = ApiParamType.JSONOBJECT) private ResourceEntityConfigVo config; + @EntityField(name = "是否支持创建多张视图", type = ApiParamType.BOOLEAN) + private Boolean isMultiple; + @EntityField(name = "所属模块ID", type = ApiParamType.STRING) + private String moduleId; + @EntityField(name = "所属模块名", type = ApiParamType.STRING) + private String moduleName; @JSONField(serialize = false) private String configStr; @@ -70,20 +72,6 @@ public class ResourceEntityVo { return Objects.hash(name); } - public void addJoin(ResourceEntityJoinVo join) { - if (joinList == null) { - joinList = new HashSet<>(); - } - joinList.add(join); - } - - public void addAttr(ResourceEntityAttrVo attr) { - if (attrList == null) { - attrList = new HashSet<>(); - } - attrList.add(attr); - } - public String getName() { return name; } @@ -120,14 +108,6 @@ public class ResourceEntityVo { this.statusText = statusText; } - public Set getAttrList() { - return attrList; - } - - public void setAttrList(Set attrList) { - this.attrList = attrList; - } - public String getError() { return error; } @@ -136,15 +116,6 @@ public class ResourceEntityVo { this.error = error; } - public Set getJoinList() { - return joinList; - } - - public void setJoinList(Set joinList) { - this.joinList = joinList; - } - - public CiVo getCi() { return ci; } @@ -216,4 +187,28 @@ public class ResourceEntityVo { public void setConfigStr(String configStr) { this.configStr = configStr; } + + public Boolean getIsMultiple() { + return isMultiple; + } + + public void setIsMultiple(Boolean isMultiple) { + this.isMultiple = isMultiple; + } + + public String getModuleId() { + return moduleId; + } + + public void setModuleId(String moduleId) { + this.moduleId = moduleId; + } + + public String getModuleName() { + return moduleName; + } + + public void setModuleName(String moduleName) { + this.moduleName = moduleName; + } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceInfo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceInfo.java deleted file mode 100644 index de88a8dfd7fcb1e63648da108b8b01600c9a6624..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/ResourceInfo.java +++ /dev/null @@ -1,161 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.config; - -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; - -public class ResourceInfo { - private final String resourceName; - private final String columnName; - private final boolean left; - - private String joinAttrName; - private Long joinAttrId; - - private Long resourceCiId; - private String resourceCiName; - private String attrCiName; - private Long attrCiId; - private Integer attrCiIsVirtual; - - private Long attrId; - private String attrName; - private Long attrFromCiId; - - private JoinType joinType; - private String direction; - - - public ResourceInfo(String resourceName, String columnName) { - this.resourceName = resourceName; - this.columnName = columnName; - this.left = true; - } - public ResourceInfo(String resourceName, String columnName, boolean left) { - this.resourceName = resourceName; - this.columnName = columnName; - this.left = left; - } - - public String getResourceName() { - return resourceName; - } - - public String getColumnName() { - return columnName; - } - - public Long getAttrId() { - return attrId; - } - - public void setAttrId(Long attrId) { - this.attrId = attrId; - } - - public String getAttrName() { - return attrName; - } - - public void setAttrName(String attrName) { - this.attrName = attrName; - } - - public String getAttrCiName() { - return attrCiName; - } - - public void setAttrCiName(String attrCiName) { - this.attrCiName = attrCiName; - } - - public Long getAttrCiId() { - return attrCiId; - } - - public void setAttrCiId(Long attrCiId) { - this.attrCiId = attrCiId; - } - - public JoinType getJoinType() { - return joinType; - } - - public void setJoinType(JoinType joinType) { - this.joinType = joinType; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public Long getResourceCiId() { - return resourceCiId; - } - - public void setResourceCiId(Long resourceCiId) { - this.resourceCiId = resourceCiId; - } - - public String getResourceCiName() { - return resourceCiName; - } - - public void setResourceCiName(String fromTableAlias) { - this.resourceCiName = fromTableAlias; - } - - - public Long getAttrFromCiId() { - return attrFromCiId; - } - - public void setAttrFromCiId(Long attrfromCiId) { - this.attrFromCiId = attrfromCiId; - } - - public Integer getAttrCiIsVirtual() { - return attrCiIsVirtual; - } - - public void setAttrCiIsVirtual(Integer attrCiIsVirtual) { - this.attrCiIsVirtual = attrCiIsVirtual; - } - - public boolean getLeft() { - return left; - } - - public String getJoinAttrName() { - return joinAttrName; - } - - public void setJoinAttrName(String joinAttrName) { - this.joinAttrName = joinAttrName; - } - - public Long getJoinAttrId() { - return joinAttrId; - } - - public void setJoinAttrId(Long joinAttrId) { - this.joinAttrId = joinAttrId; - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityAttrVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityAttrVo.java deleted file mode 100644 index 1280b18c72ea738ca0497c5e18e2342d939584eb..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityAttrVo.java +++ /dev/null @@ -1,252 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.config; - -import com.alibaba.fastjson.annotation.JSONField; -import neatlogic.framework.cmdb.dto.ci.AttrVo; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; - -import java.util.Objects; - -public class SceneEntityAttrVo { - -// private String resource; - private String field; - private String direction; - private JoinType joinType; - - private String fromCi; - private String toCi; - private String fromAttr; - private String toAttr; - - private Long fromAttrId; - private Long toAttrId; - private Long toAttrCiId; - private Long fromAttrCiId; - private String toAttrCiName; - private String fromAttrCiName; - private Integer toCiIsVirtual; - private Long fromCiId; - private Long toCiId; - - @JSONField(serialize = false) - private CiVo fromCiVo; - @JSONField(serialize = false) - private CiVo toCiVo; - @JSONField(serialize = false) - private AttrVo fromAttrVo; - @JSONField(serialize = false) - private AttrVo toAttrVo; - -// public String getResource() { -// return resource; -// } -// -// public void setResource(String resource) { -// this.resource = resource; -// } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public JoinType getJoinType() { - return joinType; - } - - public void setJoinType(JoinType joinType) { - this.joinType = joinType; - } - - public String getFromCi() { - if (fromCi == null && fromCiVo != null) { - fromCi = fromCiVo.getName(); - } - return fromCi; - } - - public void setFromCi(String fromCi) { - this.fromCi = fromCi; - } - - public String getToCi() { - if (toCi == null && toCiVo != null) { - toCi = toCiVo.getName(); - } - return toCi; - } - - public void setToCi(String toCi) { - this.toCi = toCi; - } - - public String getFromAttr() { - if (fromAttr == null && fromAttrVo != null) { - fromAttr = fromAttrVo.getName(); - } - return fromAttr; - } - - public void setFromAttr(String fromAttr) { - this.fromAttr = fromAttr; - } - - public String getToAttr() { - if (toAttr == null && toAttrVo != null) { - toAttr = toAttrVo.getName(); - } - return toAttr; - } - - public void setToAttr(String toAttr) { - this.toAttr = toAttr; - } - - public Long getFromAttrId() { - if (fromAttrId == null && fromAttrVo != null) { - fromAttrId = fromAttrVo.getId(); - } - return fromAttrId; - } - - public void setFromAttrId(Long fromAttrId) { - this.fromAttrId = fromAttrId; - } - - public Long getToAttrId() { - if (toAttrId == null && toAttrVo != null) { - toAttrId = toAttrVo.getId(); - } - return toAttrId; - } - - public Long getToAttrCiId() { - if (toAttrCiId == null && toAttrVo != null) { - toAttrCiId = toAttrVo.getCiId(); - } - return toAttrCiId; - } - - public void setToAttrCiId(Long toAttrCiId) { - this.toAttrCiId = toAttrCiId; - } - - public Long getFromAttrCiId() { - if (fromAttrCiId == null && fromAttrVo != null) { - fromAttrCiId = fromAttrVo.getCiId(); - } - return fromAttrCiId; - } - - public String getToAttrCiName() { - if (toAttrCiName == null && toAttrVo != null) { - toAttrCiName = toAttrVo.getCiName(); - } - return toAttrCiName; - } - - public void setToAttrCiName(String toAttrCiName) { - this.toAttrCiName = toAttrCiName; - } - - public String getFromAttrCiName() { - if (fromAttrCiName == null && fromAttrVo != null) { - fromAttrCiName = fromAttrVo.getCiName(); - } - return fromAttrCiName; - } - - public Integer getToCiIsVirtual() { - if (toCiIsVirtual == null && toCiVo != null) { - toCiIsVirtual = toCiVo.getIsVirtual(); - } - return toCiIsVirtual; - } - - public Long getFromCiId() { - if (fromCiId == null && fromCiVo != null) { - fromCiId = fromCiVo.getId(); - } - return fromCiId; - } - - public Long getToCiId() { - if (toCiId == null && toCiVo != null) { - toCiId = toCiVo.getId(); - } - return toCiId; - } - - public CiVo getFromCiVo() { - return fromCiVo; - } - - public void setFromCiVo(CiVo fromCiVo) { - this.fromCiVo = fromCiVo; - } - - public CiVo getToCiVo() { - return toCiVo; - } - - public void setToCiVo(CiVo toCiVo) { - this.toCiVo = toCiVo; - } - - public AttrVo getFromAttrVo() { - return fromAttrVo; - } - - public void setFromAttrVo(AttrVo fromAttrVo) { - this.fromAttrVo = fromAttrVo; - } - - public AttrVo getToAttrVo() { - return toAttrVo; - } - - public void setToAttrVo(AttrVo toAttrVo) { - this.toAttrVo = toAttrVo; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SceneEntityAttrVo that = (SceneEntityAttrVo) o; - return Objects.equals(field, that.field); - } - - @Override - public int hashCode() { - return Objects.hash(field); - } - -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityJoinVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityJoinVo.java deleted file mode 100644 index 918c6abcecc21ee3f263963a6098a2279ba37a1c..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityJoinVo.java +++ /dev/null @@ -1,149 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.config; - -import com.alibaba.fastjson.annotation.JSONField; -import neatlogic.framework.cmdb.dto.ci.AttrVo; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; - -import java.util.Objects; - -public class SceneEntityJoinVo { - private final JoinType joinType; -// private String resource; - private String field; - private String direction; - private String fromAttr; - private String fromCi; - private String toAttr; - private String toCi; - @JSONField(serialize = false) - private CiVo fromCiVo; - @JSONField(serialize = false) - private CiVo toCiVo; - @JSONField(serialize = false) - private AttrVo fromAttrVo; - - public SceneEntityJoinVo(JoinType _joinType) { - joinType = _joinType; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SceneEntityJoinVo that = (SceneEntityJoinVo) o; - return Objects.equals(field, that.field); - } - - @Override - public int hashCode() { - return Objects.hash(field); - } - - public JoinType getJoinType() { - return joinType; - } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public String getFromAttr() { - return fromAttr; - } - - public void setFromAttr(String fromAttr) { - this.fromAttr = fromAttr; - } - -// public String getResource() { -// return resource; -// } -// -// public void setResource(String resource) { -// this.resource = resource; -// } - - public String getFromCi() { - if (fromCi == null && fromCiVo != null) { - fromCi = fromCiVo.getName(); - } - return fromCi; - } - - public void setFromCi(String fromCi) { - this.fromCi = fromCi; - } - - public String getToAttr() { - return toAttr; - } - - public void setToAttr(String toAttr) { - this.toAttr = toAttr; - } - - public String getToCi() { - if (toCi == null && toCiVo != null) { - toCi = toCiVo.getName(); - } - return toCi; - } - - public void setToCi(String toCi) { - this.toCi = toCi; - } - - public CiVo getFromCiVo() { - return fromCiVo; - } - - public void setFromCiVo(CiVo fromCiVo) { - this.fromCiVo = fromCiVo; - } - - public CiVo getToCiVo() { - return toCiVo; - } - - public void setToCiVo(CiVo toCiVo) { - this.toCiVo = toCiVo; - } - - - public AttrVo getFromAttrVo() { - return fromAttrVo; - } - - public void setFromAttrVo(AttrVo fromAttrVo) { - this.fromAttrVo = fromAttrVo; - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityVo.java index b503a34c32f8bd2eb1ef7e17b8d0f5ebb8d2c249..2ab58506bcca2af53b63de170d882f8f4f65ecdc 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/config/SceneEntityVo.java @@ -22,7 +22,6 @@ import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.restful.annotation.EntityField; import java.util.Date; -import java.util.List; public class SceneEntityVo { @EntityField(name = "对象唯一标识(视图名)", type = ApiParamType.STRING) @@ -31,10 +30,6 @@ public class SceneEntityVo { private String label; @JSONField(serialize = false) private CiVo ci;//对应的模型 - @EntityField(name = "属性列表", type = ApiParamType.JSONARRAY) - private List attrList; - @EntityField(name = "连接列表", type = ApiParamType.JSONARRAY) - private List joinList; @EntityField(name = "状态", type = ApiParamType.ENUM, member = Status.class) private String status = ""; @EntityField(name = "状态名称", type = ApiParamType.STRING) @@ -47,6 +42,10 @@ public class SceneEntityVo { private Long ciId; @EntityField(name = "描述", type = ApiParamType.STRING) private String description; + @EntityField(name = "是否支持创建多张视图", type = ApiParamType.BOOLEAN) + private Boolean isMultiple; + @EntityField(name = "所属模块ID", type = ApiParamType.STRING) + private String moduleId; public String getName() { return name; @@ -72,22 +71,6 @@ public class SceneEntityVo { this.ci = ci; } - public List getAttrList() { - return attrList; - } - - public void setAttrList (List attrList) { - this.attrList = attrList; - } - - public List getJoinList() { - return joinList; - } - - public void setJoinList(List joinList) { - this.joinList = joinList; - } - public String getStatus() { return status; } @@ -138,4 +121,20 @@ public class SceneEntityVo { public void setDescription(String description) { this.description = description; } + + public Boolean getIsMultiple() { + return isMultiple; + } + + public void setIsMultiple(Boolean isMultiple) { + this.isMultiple = isMultiple; + } + + public String getModuleId() { + return moduleId; + } + + public void setModuleId(String moduleId) { + this.moduleId = moduleId; + } } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/entity/ResourceEntityBaseVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/entity/ResourceEntityBaseVo.java deleted file mode 100644 index 1b83385846decaa3c6a46fcff8cc073f221e23d8..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/entity/ResourceEntityBaseVo.java +++ /dev/null @@ -1,47 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.entity; - -import neatlogic.framework.asynchronization.threadlocal.TenantContext; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.cmdb.exception.resourcecenter.ResourceEntityViewNameNotFoundException; -import neatlogic.framework.common.dto.BasePageVo; -import org.apache.commons.lang3.StringUtils; - -import java.lang.annotation.Annotation; - -public class ResourceEntityBaseVo extends BasePageVo { - public final String getSchemaName() { - return TenantContext.get().getDataDbName(); - } - - public final String getViewName() { - String viewName = ""; - Annotation[] annotations = this.getClass().getDeclaredAnnotations(); - for (Annotation annotation : annotations) { - if (annotation instanceof ResourceType) { - viewName = TenantContext.get().getDataDbName() + "." + ((ResourceType) annotation).name(); - break; - } - } - if (StringUtils.isNotBlank(viewName)) { - return viewName; - } else { - throw new ResourceEntityViewNameNotFoundException(); - } - - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceEnvAppModuleAppSystemVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceEnvAppModuleAppSystemVo.java deleted file mode 100644 index f27ab053b97d10846271609b372bf41a42da139c..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceEnvAppModuleAppSystemVo.java +++ /dev/null @@ -1,80 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_appinstance_env_appmodule_appsystem", label = "应用实例环境和模块及应用场景") -public class AppInstanceEnvAppModuleAppSystemVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "IP地址", type = ApiParamType.STRING) - @ResourceField(name = "ip") - private String ip; - - @EntityField(name = "端口", type = ApiParamType.INTEGER) - @ResourceField(name = "port") - private Integer port; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; - - @EntityField(name = "应用系统ID", type = ApiParamType.LONG) - @ResourceField(name = "app_system_id") - private Long appSystemId; - @EntityField(name = "应用系统名", type = ApiParamType.STRING) - @ResourceField(name = "app_system_name") - private String appSystemName; - @EntityField(name = "应用系统简称", type = ApiParamType.STRING) - @ResourceField(name = "app_system_abbr_name") - private String appSystemAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceIpPortEnvAppModuleVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceIpPortEnvAppModuleVo.java deleted file mode 100644 index ba00d77f69d379dbf3ec7419a528151550037ad7..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceIpPortEnvAppModuleVo.java +++ /dev/null @@ -1,71 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_database_ip_port_env_appmodule", label = "DB库IP端口环境和模块场景") -@ResourceType(name = "scence_appinstance_ip_port_env_appmodule", label = "应用实例IP端口环境和模块场景") -public class AppInstanceIpPortEnvAppModuleVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "IP地址", type = ApiParamType.STRING) - @ResourceField(name = "ip") - private String ip; - - @EntityField(name = "端口", type = ApiParamType.INTEGER) - @ResourceField(name = "port") - private Integer port; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppModuleAppSystemVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppModuleAppSystemVo.java index a8969925ca010954c29d978502b09de1a4dac745..3bc1fa79e31e0c02216beedcdae1689014e0061b 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppModuleAppSystemVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppModuleAppSystemVo.java @@ -22,7 +22,7 @@ import neatlogic.framework.restful.annotation.EntityField; import java.util.Date; -@ResourceType(name = "scence_appmodule_appsystem", label = "应用模块和应用系统场景") +@ResourceType(name = "scence_appmodule_appsystem", label = "应用模块和应用系统场景", moduleId= "cmdb") public class AppModuleAppSystemVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemAppModuleVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemAppModuleVo.java index 6a5c781e07f73476af760e92d6ce276c71bd00a6..1d23f9d7f5eb2ab08a6ba01c6ac28a4579637471 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemAppModuleVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemAppModuleVo.java @@ -20,7 +20,7 @@ import neatlogic.framework.cmdb.annotation.ResourceType; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.restful.annotation.EntityField; -@ResourceType(name = "scence_appsystem_appmodule", label = "应用系统和应用模块场景", functionPathList = {"配置管理/应用清单"}) +@ResourceType(name = "scence_appsystem_appmodule", label = "应用系统和应用模块场景", moduleId= "cmdb", functionPathList = {"配置管理/应用清单"}) public class AppSystemAppModuleVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemVo.java index f6f4daf190b90e3a531c2652967e663738ee1938..e96b2375ab6a2410afaf97cf4faee6590b83d2e4 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppSystemVo.java @@ -22,8 +22,8 @@ import neatlogic.framework.restful.annotation.EntityField; import java.util.Date; -@ResourceType(name = "scence_appsystem", label = "应用系统场景", functionPathList = {"配置管理/应用清单"}) -@ResourceType(name = "scence_appmodule", label = "应用模块场景") +@ResourceType(name = "scence_appsystem", label = "应用系统场景", moduleId= "cmdb", functionPathList = {"配置管理/应用清单"}) +@ResourceType(name = "scence_appmodule", label = "应用模块场景", moduleId= "cmdb") public class AppSystemVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceDetailClusterVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/ApplicationAssetListDetailVo.java similarity index 72% rename from src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceDetailClusterVo.java rename to src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/ApplicationAssetListDetailVo.java index a115b34d7e21d2725dda3aa0cb3eb0696ea9db5a..92829bc42514a15ba5f73dec4afb0faebe7fb1e9 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/AppInstanceDetailClusterVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/ApplicationAssetListDetailVo.java @@ -22,9 +22,8 @@ import neatlogic.framework.restful.annotation.EntityField; import java.util.Date; -@ResourceType(name = "scence_appinstance_detail_cluster", label = "应用实例详情及集群场景", functionPathList = {"配置管理/应用清单"}) -@ResourceType(name = "scence_dbinstance_detail_cluster", label = "DB实例详情及集群场景", functionPathList = {"配置管理/应用清单"}) -public class AppInstanceDetailClusterVo { +@ResourceType(name = "scence_application_asset_list_detail", label = "应用清单资产详情", isMultiple = true, moduleId= "cmdb", functionPathList = {"配置管理/应用清单"}) +public class ApplicationAssetListDetailVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") private Long id; @@ -95,6 +94,16 @@ public class AppInstanceDetailClusterVo { @ResourceField(name = "bg_name") private String bgName; + @EntityField(name = "IP列表的ID", type = ApiParamType.LONG) + @ResourceField(name = "allip_id") + private Long allIpId; + @EntityField(name = "IP列表的IP地址", type = ApiParamType.STRING) + @ResourceField(name = "allip_ip") + private String allIpIp; + @EntityField(name = "IP列表的描述", type = ApiParamType.STRING) + @ResourceField(name = "allip_label") + private String allIpLabel; + @EntityField(name = "用户ID", type = ApiParamType.LONG) @ResourceField(name = "user_id") private Long userId; @@ -115,6 +124,16 @@ public class AppInstanceDetailClusterVo { @ResourceField(name = "state_label") private String stateLabel; + @EntityField(name = "厂商ID", type = ApiParamType.LONG) + @ResourceField(name = "vendor_id") + private Long vendorId; + @EntityField(name = "厂商名称", type = ApiParamType.STRING) + @ResourceField(name = "vendor_name") + private String vendorName; + @EntityField(name = "厂商描述", type = ApiParamType.STRING) + @ResourceField(name = "vendor_label") + private String vendorLabel; + @EntityField(name = "数据中心ID", type = ApiParamType.LONG) @ResourceField(name = "datacenter_id") private Long dataCenterId; @@ -132,13 +151,23 @@ public class AppInstanceDetailClusterVo { @ResourceField(name = "env_seq_no") private Integer envSeqNo; - @EntityField(name = "集群id", type = ApiParamType.LONG) - @ResourceField(name = "cluster_id") - private Long clusterId; - @EntityField(name = "集群名称", type = ApiParamType.STRING) - @ResourceField(name = "cluster_name") - private String clusterName; - @EntityField(name = "集群类型ID", type = ApiParamType.LONG) - @ResourceField(name = "cluster_type_id") - private Long clusterTypeId; + @EntityField(name = "应用模块ID", type = ApiParamType.LONG) + @ResourceField(name = "app_module_id") + private Long appModuleId; + @EntityField(name = "应用模块名", type = ApiParamType.STRING) + @ResourceField(name = "app_module_name") + private String appModuleName; + @EntityField(name = "应用模块简称", type = ApiParamType.STRING) + @ResourceField(name = "app_module_abbr_name") + private String appModuleAbbrName; + + @EntityField(name = "应用系统ID", type = ApiParamType.LONG) + @ResourceField(name = "app_system_id") + private Long appSystemId; + @EntityField(name = "应用系统名", type = ApiParamType.STRING) + @ResourceField(name = "app_system_name") + private String appSystemName; + @EntityField(name = "应用系统简称", type = ApiParamType.STRING) + @ResourceField(name = "app_system_abbr_name") + private String appSystemAbbrName; } diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/EnvVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/EnvVo.java deleted file mode 100644 index 5c378f04903f8f4285997fa5ba3fa3aca10abac5..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/EnvVo.java +++ /dev/null @@ -1,39 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -//@ResourceType(name = "scence_env", label = "环境场景", functionPathList = {"配置管理/应用清单"}) -public class EnvVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "序号", type = ApiParamType.STRING) - @ResourceField(name = "env_seq_no") - private String envSeqNo; - - @EntityField(name = "描述", type = ApiParamType.STRING) - @ResourceField(name = "description") - private String description; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectDetailVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectDetailVo.java index c7d5da8e4eecee3f56a3abdde47d98f6cd4e7380..a20150c74bf62bc9ce876a3957241e200cfb833a 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectDetailVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectDetailVo.java @@ -22,7 +22,7 @@ import neatlogic.framework.restful.annotation.EntityField; import java.util.Date; -@ResourceType(name = "scence_ipobject_detail", label = "资产清单视图", functionPathList = {"配置管理/资产清单"}) +@ResourceType(name = "scence_ipobject_detail", label = "资产清单视图", moduleId= "cmdb", functionPathList = {"配置管理/资产清单"}) public class IpObjectDetailVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleAppSystemVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleAppSystemVo.java deleted file mode 100644 index eb5e11e795323e0f7cf3302b9319a41f25f19c02..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleAppSystemVo.java +++ /dev/null @@ -1,76 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_ipobject_env_appmodule_appsystem", label = "IP软硬件环境和模块及应用场景", functionPathList = {"配置管理/应用清单"}) -public class IpObjectEnvAppModuleAppSystemVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "巡检状态", type = ApiParamType.STRING) - @ResourceField(name = "inspect_status") - private String inspectStatus; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; - - @EntityField(name = "应用系统ID", type = ApiParamType.LONG) - @ResourceField(name = "app_system_id") - private Long appSystemId; - @EntityField(name = "应用系统名", type = ApiParamType.STRING) - @ResourceField(name = "app_system_name") - private String appSystemName; - @EntityField(name = "应用系统简称", type = ApiParamType.STRING) - @ResourceField(name = "app_system_abbr_name") - private String appSystemAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleVo.java deleted file mode 100644 index cce04aaee6e4a8fa15a8a195c9cd4b456583feb2..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectEnvAppModuleVo.java +++ /dev/null @@ -1,66 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_ipobject_env_appmodule", label = "IP软硬件环境和模块场景") -public class IpObjectEnvAppModuleVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "巡检状态", type = ApiParamType.STRING) - @ResourceField(name = "inspect_status") - private String inspectStatus; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIdVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIdVo.java deleted file mode 100644 index 9986049ab9cc57026a88f10d96fee162c5e4a4cb..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIdVo.java +++ /dev/null @@ -1,38 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_ipobject_id", label = "IP软硬件ID场景") -public class IpObjectIdVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIpPortVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIpPortVo.java deleted file mode 100644 index a38328686193eb3693e1a1fdcf7238c60a92ef83..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/IpObjectIpPortVo.java +++ /dev/null @@ -1,50 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_ipobject_ip_port", label = "IP软硬件IP和端口场景") -public class IpObjectIpPortVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "IP地址", type = ApiParamType.STRING) - @ResourceField(name = "ip") - private String ip; - - @EntityField(name = "端口", type = ApiParamType.INTEGER) - @ResourceField(name = "port") - private Integer port; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsDetailClusterVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsDetailClusterVo.java deleted file mode 100644 index 143688b2dd220c389d09c6540abe3f85ba67a06d..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsDetailClusterVo.java +++ /dev/null @@ -1,139 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -import java.util.Date; - -@ResourceType(name = "scence_os_detail_cluster", label = "操作系统详情及集群场景", functionPathList = {"配置管理/应用清单"}) -public class OsDetailClusterVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "IP地址", type = ApiParamType.STRING) - @ResourceField(name = "ip") - private String ip; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "创建者", type = ApiParamType.STRING) - @ResourceField(name = "fcu") - private String fcu; - @EntityField(name = "创建日期", type = ApiParamType.LONG) - @ResourceField(name = "fcd") - private Date fcd; - @EntityField(name = "修改者", type = ApiParamType.STRING) - @ResourceField(name = "lcu") - private String lcu; - @EntityField(name = "修改日期", type = ApiParamType.LONG) - @ResourceField(name = "lcd") - private Date lcd; - - @EntityField(name = "维护窗口", type = ApiParamType.STRING) - @ResourceField(name = "maintenance_window") - private String maintenanceWindow; - - @EntityField(name = "描述", type = ApiParamType.STRING) - @ResourceField(name = "description") - private String description; - @EntityField(name = "网络区域", type = ApiParamType.STRING) - @ResourceField(name = "network_area") - private String networkArea; - - @EntityField(name = "巡检状态", type = ApiParamType.STRING) - @ResourceField(name = "inspect_status") - private String inspectStatus; - @EntityField(name = "巡检时间", type = ApiParamType.LONG) - @ResourceField(name = "inspect_time") - private Date inspectTime; - @EntityField(name = "监控状态", type = ApiParamType.STRING) - @ResourceField(name = "monitor_status") - private String monitorStatus; - @EntityField(name = "监控时间", type = ApiParamType.LONG) - @ResourceField(name = "monitor_time") - private Date monitorTime; - - @EntityField(name = "分组ID", type = ApiParamType.LONG) - @ResourceField(name = "bg_id") - private Long bgId; - @EntityField(name = "分组名称", type = ApiParamType.STRING) - @ResourceField(name = "bg_name") - private String bgName; - - @EntityField(name = "用户ID", type = ApiParamType.LONG) - @ResourceField(name = "user_id") - private Long userId; - @EntityField(name = "用户UUID", type = ApiParamType.STRING) - @ResourceField(name = "user_uuid") - private String uuid; - @EntityField(name = "用户名", type = ApiParamType.STRING) - @ResourceField(name = "user_name") - private String userName; - - @EntityField(name = "状态ID", type = ApiParamType.LONG) - @ResourceField(name = "state_id") - private Long stateId; - @EntityField(name = "状态名", type = ApiParamType.STRING) - @ResourceField(name = "state_name") - private String stateName; - @EntityField(name = "状态描述", type = ApiParamType.STRING) - @ResourceField(name = "state_label") - private String stateLabel; - - @EntityField(name = "数据中心ID", type = ApiParamType.LONG) - @ResourceField(name = "datacenter_id") - private Long dataCenterId; - @EntityField(name = "数据中心名称", type = ApiParamType.STRING) - @ResourceField(name = "datacenter_name") - private String dataCenterName; - - @EntityField(name = "集群id", type = ApiParamType.LONG) - @ResourceField(name = "cluster_id") - private Long clusterId; - @EntityField(name = "集群名称", type = ApiParamType.STRING) - @ResourceField(name = "cluster_name") - private String clusterName; - @EntityField(name = "集群类型ID", type = ApiParamType.LONG) - @ResourceField(name = "cluster_type_id") - private Long clusterTypeId; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleAppSystemVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleAppSystemVo.java deleted file mode 100644 index a4b198e7e635645e8710fcf239ea1cb9a7f3490b..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleAppSystemVo.java +++ /dev/null @@ -1,75 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; -@ResourceType(name = "scence_os_softwareservice_env_appmodule_appsystem", label = "操作系统与软件服务、环境、模块及应用场景", functionPathList = {"配置管理/应用清单"}) -public class OsSoftwareServiceEnvAppModuleAppSystemVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "资产id", type = ApiParamType.LONG) - @ResourceField(name = "resource_id") - private Long resourceId; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; - - @EntityField(name = "应用系统ID", type = ApiParamType.LONG) - @ResourceField(name = "app_system_id") - private Long appSystemId; - @EntityField(name = "应用系统名", type = ApiParamType.STRING) - @ResourceField(name = "app_system_name") - private String appSystemName; - @EntityField(name = "应用系统简称", type = ApiParamType.STRING) - @ResourceField(name = "app_system_abbr_name") - private String appSystemAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleVo.java deleted file mode 100644 index b5827129ea7677eaaba0339e02f03f3df7073272..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/OsSoftwareServiceEnvAppModuleVo.java +++ /dev/null @@ -1,66 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_os_softwareservice_env_appmodule", label = "操作系统与软件服务、环境、模块场景") -public class OsSoftwareServiceEnvAppModuleVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "资产id", type = ApiParamType.LONG) - @ResourceField(name = "resource_id") - private Long resourceId; - - @EntityField(name = "环境ID", type = ApiParamType.LONG) - @ResourceField(name = "env_id") - private Long envId; - @EntityField(name = "环境名称", type = ApiParamType.STRING) - @ResourceField(name = "env_name") - private String envName; - @EntityField(name = "环境序号", type = ApiParamType.INTEGER) - @ResourceField(name = "env_seq_no") - private Integer envSeqNo; - - @EntityField(name = "应用模块ID", type = ApiParamType.LONG) - @ResourceField(name = "app_module_id") - private Long appModuleId; - @EntityField(name = "应用模块名", type = ApiParamType.STRING) - @ResourceField(name = "app_module_name") - private String appModuleName; - @EntityField(name = "应用模块简称", type = ApiParamType.STRING) - @ResourceField(name = "app_module_abbr_name") - private String appModuleAbbrName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServiceOsVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServiceOsVo.java deleted file mode 100644 index 8660435d152a41402baf0402e45058dd6f7947dd..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServiceOsVo.java +++ /dev/null @@ -1,49 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_softwareservice_os", label = "软件服务与操作系统场景") -public class SoftwareServiceOsVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - - @EntityField(name = "类型ID", type = ApiParamType.LONG) - @ResourceField(name = "type_id") - private Long typeId; - @EntityField(name = "类型名称", type = ApiParamType.STRING) - @ResourceField(name = "type_name") - private String typeName; - @EntityField(name = "类型Label", type = ApiParamType.STRING) - @ResourceField(name = "type_label") - private String typeLabel; - - @EntityField(name = "系统ID", type = ApiParamType.LONG) - @ResourceField(name = "os_id") - private Long osId; - @EntityField(name = "系统名称", type = ApiParamType.STRING) - @ResourceField(name = "os_name") - private String osName; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServicePortsVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServicePortsVo.java deleted file mode 100644 index 2e8e82a9a3dccdea7ddea1eb57f093647fef849e..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/SoftwareServicePortsVo.java +++ /dev/null @@ -1,38 +0,0 @@ -/*Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.dto.resourcecenter.sceneviewfielddeclare; - -import neatlogic.framework.cmdb.annotation.ResourceField; -import neatlogic.framework.cmdb.annotation.ResourceType; -import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.restful.annotation.EntityField; - -@ResourceType(name = "scence_softwareservice_ports", label = "软件服务服务端口场景") -@ResourceType(name = "scence_osservice_ports", label = "操作系统服务端口场景") -public class SoftwareServicePortsVo { - @EntityField(name = "ID", type = ApiParamType.LONG) - @ResourceField(name = "id") - private Long id; - @EntityField(name = "service_ports_id", type = ApiParamType.LONG) - @ResourceField(name = "service_ports_id") - private Long servicePortsId; - @EntityField(name = "名称", type = ApiParamType.STRING) - @ResourceField(name = "name") - private String name; - @EntityField(name = "listen_port", type = ApiParamType.INTEGER) - @ResourceField(name = "listen_port") - private Integer listenPort; -} diff --git a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/StateVo.java b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/StateVo.java index fffa487539b7bfa3c302960518ffeb2308b2faa3..aa3296ef8d823356badeda1ababaf5d5eb9921a0 100644 --- a/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/StateVo.java +++ b/src/main/java/neatlogic/framework/cmdb/dto/resourcecenter/sceneviewfielddeclare/StateVo.java @@ -20,8 +20,8 @@ import neatlogic.framework.cmdb.annotation.ResourceType; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.restful.annotation.EntityField; -@ResourceType(name = "scence_state", label = "资产状态基本信息场景") -@ResourceType(name = "scence_vendor", label = "厂商基本信息场景") +@ResourceType(name = "scence_state", label = "资产状态基本信息场景", moduleId= "cmdb") +@ResourceType(name = "scence_vendor", label = "厂商基本信息场景", moduleId= "cmdb") public class StateVo { @EntityField(name = "ID", type = ApiParamType.LONG) @ResourceField(name = "id") diff --git a/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/AppModuleResourceType.java b/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/AppModuleResourceType.java deleted file mode 100644 index bd7d90abb5b4660570fba0dbea09d1f07c22bf52..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/AppModuleResourceType.java +++ /dev/null @@ -1,68 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.enums.resourcecenter; - -import java.util.ArrayList; -import java.util.List; - -/** - * 应用清单中需要显示的模型 - * @author linbq - * @since 2022/3/7 10:10 - **/ -public enum AppModuleResourceType { - OS("OS","OS"), - APP_INSTANCE("APPIns","APPIns"), - APP_INSTANCE_CLUSTER("APPInsCluster","ipObject"), - DB_INSTANCE("DBIns","DBIns"), - DB_CLUSTER("DBCluster","ipObject"), - ACCESS_ENDPOINT("AccessEndPoint","ipObject"), - DATABASE("Database","ipObject") - ; - private final String name; - private final String action; - - AppModuleResourceType(String name, String action) { - this.name = name; - this.action = action; - } - - public String getName() { - return name; - } - - public String getAction() { - return action; - } - - public static List getNameList() { - List resultList = new ArrayList<>(); - for (AppModuleResourceType type : values()) { - resultList.add(type.name); - } - return resultList; - } - - public static String getAction(String name) { - for (AppModuleResourceType type : values()) { - if (type.name.equals(name)) { - return type.action; - } - } - return null; - } - -} diff --git a/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/ScenceView.java b/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/ScenceView.java deleted file mode 100644 index 781ebcdf9406ba54111511c64c9fef2b10ca4223..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/enums/resourcecenter/ScenceView.java +++ /dev/null @@ -1,61 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.enums.resourcecenter; - -import neatlogic.framework.util.$; -@Deprecated -public enum ScenceView { - SCENCE_IPOBJECT_DETAIL("scence_ipobject_detail", "资产清单场景"), - SCENCE_IPOBJECT_ID("scence_ipobject_id", "IP软硬件ID场景"), - SCENCE_IPOBJECT_IP_PORT("scence_ipobject_ip_port", "IP软硬件IP和端口场景"), - SCENCE_SOFTWARESERVICE_IP_PORT("scence_softwareservice_ip_port", "软件服务IP和端口场景"), - SCENCE_IPOBJECT_ENV_APPMODULE("scence_ipobject_env_appmodule", "IP软硬件环境和模块场景"), - SCENCE_DATABASE_ENV_APPMODULE("scence_database_ip_port_env_appmodule", "DB库IP端口环境和模块场景"), - SCENCE_APPINSTANCE_IP_PORT_ENV_APPMODULE("scence_appinstance_ip_port_env_appmodule", "应用实例IP端口环境和模块场景"), - SCENCE_APPINSTANCE_DETAIL_CLUSTER("scence_appinstance_detail_cluster", "应用实例详情及集群场景"), - SCENCE_DBINSTANCE_DETAIL_CLUSTER("scence_dbinstance_detail_cluster", "DB实例详情及集群场景"), - SCENCE_IPOBJECT_ENV_APPMODULE_APPSYSTEM("scence_ipobject_env_appmodule_appsystem", "IP软硬件环境和模块及应用场景"), - SCENCE_APPINSTANCE_ENV_APPMODULE_APPSYSTEM("scence_appinstance_env_appmodule_appsystem", "应用实例环境和模块及应用场景"), - SCENCE_APPSYSTEM_APPMODULE("scence_appsystem_appmodule", "应用和模块场景"), - SCENCE_APPMODULE_APPSYSTEM("scence_appmodule_appsystem", "模块和应用场景"), - SCENCE_APPSYSTEM_PRODUCTIONTIMEPERIOD("scence_appsystem_productiontimeperiod", "应用系统投产时段场景"), - SCENCE_APPSYSTEM("scence_appsystem", "应用基本信息场景"), - SCENCE_APPMODULE("scence_appmodule", "模块基本信息场景"), - SCENCE_STATE("scence_state", "资产状态基本信息场景"), - SCENCE_VENDOR("scence_vendor", "厂商基本信息场景"), - SCENCE_ENV("scence_env", "环境基本信息场景"), - SCENCE_OS_DETAIL_CLUSTER("scence_os_detail_cluster", "操作系统详情及集群场景"), - SCENCE_OS_SOFTWARESERVICE_ENV_APPMODULE("scence_os_softwareservice_env_appmodule", "操作系统与软件服务、环境、模块场景"), - SCENCE_OS_SOFTWARESERVICE_ENV_APPMODULE_APPSYSTEM("scence_os_softwareservice_env_appmodule_appsystem", "操作系统与软件服务、环境、模块及应用场景"), - SCENCE_SOFTWARESERVICE_PORTS("scence_softwareservice_ports","软件服务服务端口场景"), - SCENCE_SOFTWARESERVICE_OS("scence_softwareservice_os","软件服务与操作系统场景"), - SCENCE_OSSERVICE_PORTS("scence_osservice_ports","操作系统服务端口场景"); - private final String value; - private final String text; - - ScenceView(String value, String text) { - this.value = value; - this.text = text; - } - - public String getValue() { - return value; - } - - public String getText() { - return $.t(text); - } -} diff --git a/src/main/java/neatlogic/framework/cmdb/exception/resourcecenter/ResourceEntityNameRepeatException.java b/src/main/java/neatlogic/framework/cmdb/exception/resourcecenter/ResourceEntityNameRepeatException.java new file mode 100644 index 0000000000000000000000000000000000000000..908d671745d31f4080bfd4c49ac1fd97c0cda931 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/exception/resourcecenter/ResourceEntityNameRepeatException.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.exception.resourcecenter; + +import neatlogic.framework.exception.core.ApiRuntimeException; + +public class ResourceEntityNameRepeatException extends ApiRuntimeException { + + private static final long serialVersionUID = -4617724920030245148L; + + public ResourceEntityNameRepeatException(String msg) { + super("资源中心视图:“{0}”已存在", msg); + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/IResourceCenterDataSource.java b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/IResourceCenterDataSource.java new file mode 100644 index 0000000000000000000000000000000000000000..98a7af5d30e811c365710cf679dcfe01926171b0 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/IResourceCenterDataSource.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.resourcecenter.datasource.core; + +import com.alibaba.fastjson.JSONArray; +import neatlogic.framework.cmdb.dto.resourcecenter.*; +import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityVo; +import neatlogic.framework.common.dto.BasePageVo; +import neatlogic.framework.common.dto.ValueTextVo; +import org.springframework.lang.Nullable; + +import java.util.List; +import java.util.Map; + +public interface IResourceCenterDataSource { + + /** + * 优先级,默认是最高优先级,该接口默认实现类会把该字段设置为最低优先级,客户模块如果实现该接口,则以客户模块的实现类逻辑 + * @return + */ + default Ordered getOrdered() { + return Ordered.HIGHEST_PRECEDENCE; + } + + JSONArray getAppResourceList(@Nullable Long appSystemId, @Nullable Long appModuleId, @Nullable Long envId, @Nullable List inspectStatusList, @Nullable String viewName, @Nullable Integer currentPage, @Nullable Integer pageSize); + + List getAppResourceList(ResourceSearchVo searchVo, boolean needPage); + + List getAppResourceIdList(ResourceSearchVo searchVo, boolean needPage); + + JSONArray getTbodyList(List fieldList, List resourceList, ResourceEntityVo resourceEntityVo); + + List getResourceList(ResourceSearchVo searchVo); + + List getResourceTypeTree(String keyword); + + List getResourceTypeListTree(String keyword); + + JSONArray getTheadList(List fieldNameList); + + List getAssertAllTheadList(); + + List getAppAssertAllTheadList(); + + List getAppSystemListForTree(BasePageVo searchVo); + + List getAppSystemListForSelect(BasePageVo searchVo); + + List getAppModuleListForTree(Long appSystemId); + + List getAppModuleList(ResourceSearchVo searchVo); + + List getAppEnvListForSelect(BasePageVo searchVo); + + List getAppEnvListByAppSystemId(Long appSystemId); + + List getStateListForSelect(BasePageVo searchVo); + + List getVendorListForSelect(BasePageVo searchVo); + + Map> getAppResourceTypeIdListByAppSystemId(Long appSystemId); + + Map> getAppResourceTypeIdListByAppSystemIdAndAppModuleIdAndEnvId(Long appSystemId, Long appModuleId, Long envId); + + List getAppSystemIdListById(Long id); +} diff --git a/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/Ordered.java b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/Ordered.java new file mode 100644 index 0000000000000000000000000000000000000000..af49641cda4da4671b160b5d7dffb9508dd31cff --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/Ordered.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.resourcecenter.datasource.core; + +public enum Ordered { + HIGHEST_PRECEDENCE(Integer.MAX_VALUE, "最高优先级"), + LOWEST_PRECEDENCE(Integer.MIN_VALUE, "最低优先级"); + + final int value; + final String text; + Ordered(int value, String text) { + this.value = value; + this.text = text; + } + + public int getValue() { + return value; + } + + public String getText() { + return text; + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/ResourceCenterDataSourceFactory.java b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/ResourceCenterDataSourceFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..99323a7ad3f55016e5ad4eb08d3b790acec63f23 --- /dev/null +++ b/src/main/java/neatlogic/framework/cmdb/resourcecenter/datasource/core/ResourceCenterDataSourceFactory.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.cmdb.resourcecenter.datasource.core; + +import neatlogic.framework.applicationlistener.core.ModuleInitializedListenerBase; +import neatlogic.framework.bootstrap.NeatLogicWebApplicationContext; +import neatlogic.framework.common.RootComponent; + +import java.util.Map; + +@RootComponent +public class ResourceCenterDataSourceFactory extends ModuleInitializedListenerBase { + + private static IResourceCenterDataSource resourceCenterDataSource = null; + + public static IResourceCenterDataSource getResourceCenterDataSource() { + return resourceCenterDataSource; + } + + @Override + protected void onInitialized(NeatLogicWebApplicationContext context) { + Map myMap = context.getBeansOfType(IResourceCenterDataSource.class); + for (Map.Entry entry : myMap.entrySet()) { + IResourceCenterDataSource value = entry.getValue(); + IResourceCenterDataSource other = resourceCenterDataSource; + if (other != null) { + if (other.getOrdered().getValue() < value.getOrdered().getValue()) { + resourceCenterDataSource = value; + } + } else { + resourceCenterDataSource = value; + } + } + } + + @Override + protected void myInit() { + + } +} diff --git a/src/main/java/neatlogic/framework/cmdb/utils/ResourceSearchGenerateSqlUtil.java b/src/main/java/neatlogic/framework/cmdb/utils/ResourceSearchGenerateSqlUtil.java deleted file mode 100644 index 79fbea86688ffdf92c92623d68d5c6c0f23a31d1..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/utils/ResourceSearchGenerateSqlUtil.java +++ /dev/null @@ -1,618 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.utils; - -import neatlogic.framework.asynchronization.threadlocal.TenantContext; -import neatlogic.framework.cmdb.dto.ci.AttrVo; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityAttrVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityJoinVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceInfo; -import neatlogic.framework.cmdb.enums.RelDirectionType; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; -import neatlogic.framework.cmdb.exception.sql.ResourceSearchGenerateSqlTypeException; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.StringValue; -import net.sf.jsqlparser.expression.operators.conditional.AndExpression; -import net.sf.jsqlparser.expression.operators.relational.*; -import net.sf.jsqlparser.schema.Column; -import net.sf.jsqlparser.schema.Table; -import net.sf.jsqlparser.statement.select.Join; -import net.sf.jsqlparser.statement.select.PlainSelect; -import net.sf.jsqlparser.statement.select.SelectExpressionItem; -import net.sf.jsqlparser.statement.select.SubSelect; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - -import java.util.*; - -public class ResourceSearchGenerateSqlUtil { - - //保存资源中心数据初始化信息 - private final List resourceEntityList; - //sql语句中已经存在的表 - private Map joinedTableMap; - //sql语句关联表中相等的列 - private Map equalColumnMap; - - public ResourceSearchGenerateSqlUtil(List resourceEntityList) { - this.resourceEntityList = resourceEntityList; - } - - private void addJoinTable(Table table) { - String key = table.getName(); - Alias alias = table.getAlias(); - if (alias != null) { - key = alias.getName(); - } - joinedTableMap.put(key, table); - } - - private Table getTableByAlias(String alias) { - return joinedTableMap.get(alias); - } - - private void addEqualColumn(Column left, Column right) { - equalColumnMap.put(left.toString(), right); - } - - private Column getEqualColumn(Column left) { - Column result = left; - for(int i = 0; i < 10; i++) { - Column right = equalColumnMap.get(left.toString()); - if (right == null) { - return result; - } - result = right; - } - return result; - } - - /** - * 根据主资源id,初始化sql语句,例如SELECT * FROM cmdb_cientity IPObject JOIN cmdb_ci ci_IPObject ON ci_IPObject.id = IPObject.ci_id - * @param mainResourceId - * @return - */ - public PlainSelect initPlainSelectByMainResourceId(String mainResourceId) { - CiVo mainCiVo = getCiByResourceId(mainResourceId); - if (mainCiVo == null) { - return null; - } - joinedTableMap = new HashMap<>(); - equalColumnMap = new HashMap<>(); - String mainTableAlias = mainCiVo.getName(); - Table mainTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + mainTableAlias).withUseAs(false)); - PlainSelect plainSelect = new PlainSelect() - .withFromItem(mainTable); - addJoinTable(mainTable); - Table cmdbCi = new Table("cmdb_ci").withAlias(new Alias("cientity_" + mainTableAlias + "_ci").withUseAs(false)); - Column cmdbCiIdColumn = new Column(cmdbCi, "id"); - Column mainTableCiIdColumn = new Column(mainTable, "ci_id"); - EqualsTo equalsTo = new EqualsTo(cmdbCiIdColumn, mainTableCiIdColumn); - Column cmdbCiLftColumn = new Column(cmdbCi, "lft"); - Column cmdbCiRhtColumn = new Column(cmdbCi, "rht"); - GreaterThanEquals greaterThanEquals = new GreaterThanEquals(">=").withLeftExpression(cmdbCiLftColumn).withRightExpression(new LongValue(mainCiVo.getLft())); - MinorThanEquals minorThanEquals = new MinorThanEquals("<=").withLeftExpression(cmdbCiRhtColumn).withRightExpression(new LongValue(mainCiVo.getRht())); - AndExpression andExpression = new AndExpression(greaterThanEquals, minorThanEquals); - Join joinCmdbCi = new Join().withRightItem(cmdbCi).addOnExpression(new AndExpression(equalsTo, andExpression)); - plainSelect.addJoins(joinCmdbCi); - addJoinTable(cmdbCi); - addEqualColumn(cmdbCiIdColumn, mainTableCiIdColumn); - return plainSelect; - } - - /** - * 根据资源id,从数据初始化配置信息中找到对应的模型 - * @param resourceId - * @return - */ - private CiVo getCiByResourceId(String resourceId) { - for (ResourceEntityVo resourceEntityVo : resourceEntityList) { - if (Objects.equals(resourceEntityVo.getName(), resourceId)) { - return resourceEntityVo.getCi(); - } - } - return null; - } - - /** - * 从数据初始化信息中ResourceInfo补充信息 - * @param resourceInfo - */ - public boolean additionalInformation(ResourceInfo resourceInfo) { - for (ResourceEntityVo resourceEntityVo : resourceEntityList) { - if (Objects.equals(resourceEntityVo.getName(), resourceInfo.getResourceName())) { - if (StringUtils.isNotBlank(resourceEntityVo.getError())) { - return false; - } - CiVo ciVo = resourceEntityVo.getCi(); - if (ciVo == null) { - return false; - } - resourceInfo.setResourceCiName(ciVo.getName()); - resourceInfo.setResourceCiId(ciVo.getId()); - Set attrList = resourceEntityVo.getAttrList(); - for (ResourceEntityAttrVo resourceEntityAttrVo : attrList) { - if (Objects.equals(resourceEntityAttrVo.getField(), resourceInfo.getColumnName())) { - CiVo attrCiVo = resourceEntityAttrVo.getCi(); - if (attrCiVo == null) { - attrCiVo = ciVo; - } - resourceInfo.setAttrCiName(attrCiVo.getName()); - resourceInfo.setAttrCiId(attrCiVo.getId()); - resourceInfo.setAttrCiIsVirtual(attrCiVo.getIsVirtual()); - String attr = resourceEntityAttrVo.getAttr(); - if ("_id".equals(attr)) { - resourceInfo.setAttrName("id"); - } else if ("_uuid".equals(attr)) { - resourceInfo.setAttrName("uuid"); - } else if ("_name".equals(attr)) { - resourceInfo.setAttrName("name"); - } else if ("_fcu".equals(attr)) { - resourceInfo.setAttrName("fcu"); - } else if ("_fcd".equals(attr)) { - resourceInfo.setAttrName("fcd"); - } else if ("_lcu".equals(attr)) { - resourceInfo.setAttrName("lcu"); - } else if ("_lcd".equals(attr)) { - resourceInfo.setAttrName("lcd"); - } else if ("_inspectStatus".equals(attr)) { - resourceInfo.setAttrName("inspect_status"); - } else if ("_inspectTime".equals(attr)) { - resourceInfo.setAttrName("inspect_time"); - } else if ("_monitorStatus".equals(attr)) { - resourceInfo.setAttrName("monitor_status"); - } else if ("_monitorTime".equals(attr)) { - resourceInfo.setAttrName("monitor_time"); - } else if ("_typeId".equals(attr)) { - resourceInfo.setResourceCiName(resourceEntityAttrVo.getCiName()); - resourceInfo.setAttrName("ci_id"); - } else if ("_typeName".equals(attr)) { - resourceInfo.setResourceCiName(resourceEntityAttrVo.getCiName() + "_ci"); - resourceInfo.setAttrName("name"); - } else if ("_typeLabel".equals(attr)) { - resourceInfo.setResourceCiName(resourceEntityAttrVo.getCiName() + "_ci"); - resourceInfo.setAttrName("label"); - } else { - resourceInfo.setAttrName(attr); - if (resourceEntityAttrVo.getAttrId() != null) { - resourceInfo.setAttrId(resourceEntityAttrVo.getAttrId()); - List attrVoList = attrCiVo.getAttrList(); - for (AttrVo attrVo : attrVoList) { - if (Objects.equals(attrVo.getId(), resourceEntityAttrVo.getAttrId())) { - resourceInfo.setAttrFromCiId(attrVo.getCiId()); - } - } - } - } - Set joinList = resourceEntityVo.getJoinList(); - if (CollectionUtils.isNotEmpty(joinList)) { - for (ResourceEntityJoinVo joinVo : joinList) { - if (Objects.equals(joinVo.getCiName(), attrCiVo.getName())) { - resourceInfo.setJoinType(joinVo.getJoinType()); - CiVo joinCiVo = joinVo.getCi(); - String joinAttrName = joinVo.getJoinAttrName(); - resourceInfo.setJoinAttrName(joinAttrName); - if (joinVo.getJoinType() == JoinType.ATTR) { - List attrVoList = ciVo.getAttrList(); - for (AttrVo attrVo : attrVoList) { - if (Objects.equals(attrVo.getName(), joinAttrName) && Objects.equals(attrVo.getTargetCiId(), joinCiVo.getId())) { - resourceInfo.setJoinAttrName(joinAttrName); - resourceInfo.setJoinAttrId(attrVo.getId()); - } - } - } else{ - resourceInfo.setDirection(joinVo.getDirection()); - } - } - } - } - return true; - } - } - } - } - return false; - } - - /** - * 根据需要查询或过滤的列信息join表 - * @param resourceInfo - * @param plainSelect - * @return - */ - public Column addJoinTableByResourceInfo(ResourceInfo resourceInfo, PlainSelect plainSelect) { - Table mainTable = (Table) plainSelect.getFromItem(); - String attrCiName = resourceInfo.getAttrCiName(); - Long attrCiId = resourceInfo.getAttrCiId(); - String columnName = resourceInfo.getColumnName(); - Long attrId = resourceInfo.getAttrId(); - boolean left = resourceInfo.getLeft(); - if (resourceInfo.getJoinType() == JoinType.ATTR) { - // 下拉框类型属 - // 例如状态属性state AS state_id -// -// -// -// -// -// -// -// -// (left) join cmdb_cientity IPObject ON IPObject.id = IPObject.id -// (left) join cmdb_attrentity cmdb_attrentity_state ON cmdb_attrentity_state.from_cientity_id = IPObject.id and cmdb_attrentity_state.attr_id = #{attrId} -// (left) join cmdb_cientity CIState ON CIState.id = cmdb_attrentity_state.to_cientity_id - //负责人属性owner AS user_id -// -// -// -// -// -// -// -// -// (left) join cmdb_cientity IPObject ON IPObject.id = IPObject.id -// (left) join cmdb_attrentity cmdb_attrentity_owner ON cmdb_attrentity_owner.from_cientity_id = IPObject.id and cmdb_attrentity_owner.attr_id = #{attrId} -// (LEFT) JOIN neatlogic_develop_data.cmdb_479643459133440 cmdb_479643459133440_User ON cmdb_479643459133440_User.id = cmdb_attrentity_owner.to_cientity_id - String resourceCiName = resourceInfo.getResourceCiName(); - Table resourceCiTable = getTableByAlias("cientity_" + resourceCiName); - if (resourceCiTable == null) { - resourceCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + resourceCiName).withUseAs(false)); - Column resourceCiTableIdColumn = new Column(resourceCiTable, "id"); - Column mainTableIdColumn = new Column(mainTable, "id"); - EqualsTo equalsTo = new EqualsTo(resourceCiTableIdColumn, mainTableIdColumn); - Join join = new Join().withLeft(left).withRightItem(resourceCiTable).addOnExpression(equalsTo); - plainSelect.addJoins(join); - addJoinTable(resourceCiTable); - addEqualColumn(resourceCiTableIdColumn, mainTableIdColumn); - } - String joinAttrName = resourceInfo.getJoinAttrName(); - Table cmdbAttrentityTable = joinedTableMap.get("cmdb_attrentity_" + joinAttrName); - if (cmdbAttrentityTable == null) { - cmdbAttrentityTable = new Table("cmdb_attrentity").withAlias(new Alias("cmdb_attrentity_" + joinAttrName).withUseAs(false)); - Column cmdbAttrentityTableFromCientityIdColumn = new Column(cmdbAttrentityTable, "from_cientity_id"); - Column resourceCiTableIdColumn = new Column(resourceCiTable, "id"); - EqualsTo equalsTo1 = new EqualsTo(cmdbAttrentityTableFromCientityIdColumn, resourceCiTableIdColumn); - EqualsTo equalsTo2 = new EqualsTo(new Column(cmdbAttrentityTable, "attr_id"), new LongValue(resourceInfo.getJoinAttrId())); - Expression onExpression = new AndExpression(equalsTo1, equalsTo2); - Join join = new Join().withLeft(left).withRightItem(cmdbAttrentityTable).addOnExpression(onExpression); - plainSelect.addJoins(join); - addJoinTable(cmdbAttrentityTable); - addEqualColumn(cmdbAttrentityTableFromCientityIdColumn, resourceCiTableIdColumn); - } - - if (Objects.equals(resourceInfo.getAttrCiIsVirtual(), 1)) { - //属性模型是虚拟模型时 -// Long attrCiId = resourceInfo.getAttrCiId(); - Table cmdbCiIdTable = joinedTableMap.get("cmdb_" + attrCiId + "_" + attrCiName); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), "cmdb_" + attrCiId) - .withAlias(new Alias("cmdb_" + attrCiId + "_" + attrCiName).withUseAs(false)); - addJoinTable(cmdbCiIdTable); - Column cmdbCiIdTableIdColumn = new Column(cmdbCiIdTable, "id"); - Column cmdbAttrentityTableToCientityIdColumn = new Column(cmdbAttrentityTable, "to_cientity_id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableIdColumn, cmdbAttrentityTableToCientityIdColumn)); - plainSelect.addJoins(join); - addEqualColumn(cmdbCiIdTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - } - if (attrId == null) { - Column column = new Column(cmdbCiIdTable, resourceInfo.getAttrName()); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } else { - Column column = new Column(cmdbCiIdTable, "`" + attrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } - } else { - //属性模型是非虚拟模型时 - Table attrCiTable = joinedTableMap.get("cientity_" + attrCiName); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + attrCiName).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbAttrentityTableToCientityIdColumn = new Column(cmdbAttrentityTable, "to_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(equalsTo); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - } - if (attrId == null) { - Column column = new Column(attrCiTable, resourceInfo.getAttrName()); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } else { - String tableName = "cmdb_" + resourceInfo.getAttrFromCiId(); - String tableAlias = tableName + "_" + attrCiName; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column table3IdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, table3IdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, table3IdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + attrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } - } - } else if (resourceInfo.getJoinType() == JoinType.REL) { - //关系 - if (Objects.equals(resourceInfo.getDirection(), RelDirectionType.FROM.getValue())) { - Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + attrCiName); - if (cmdbRelentityTable == null) { - cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + attrCiName).withUseAs(false)); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - Column fromTableIdColumn = new Column(new Table("cientity_" + resourceInfo.getResourceCiName()), "id"); - EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableFromCientityIdColumn, fromTableIdColumn); - - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + attrCiId); - SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); - InExpression inExpression = new InExpression(cmdbRelentityTableToCientityIdColumn, subSelect); - - Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); - plainSelect.addJoins(join); - addJoinTable(cmdbRelentityTable); - addEqualColumn(cmdbRelentityTableFromCientityIdColumn, fromTableIdColumn); - } - - Table attrCiTable = joinedTableMap.get("cientity_" + attrCiName); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + attrCiName).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(equalsTo); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); - } - if (attrId == null) { - Column column = new Column(attrCiTable, resourceInfo.getAttrName()); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } else { - String tableName = "cmdb_" + resourceInfo.getAttrFromCiId(); - String tableAlias = tableName + "_" + attrCiName; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + attrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } - } else { - //模块 -// -// -// -// -// -// -// -// - -// LEFT JOIN cmdb_relentity cmdb_relentity_APPComponent ON cmdb_relentity_APPComponent.to_cientity_id = IPObject.id -// LEFT JOIN cmdb_rel cmdb_rel_APPComponent ON cmdb_rel_APPComponent.id = cmdb_relentity_APPComponent.rel_id AND cmdb_rel_APPComponent.from_ci_id = 479610550624256 -// LEFT JOIN cmdb_cientity APPComponent ON APPComponent.id = cmdb_relentity_APPComponent.from_cientity_id - -// LEFT JOIN neatlogic_develop_data.cmdb_441087512551424 cmdb_441087512551424_APPComponent ON cmdb_441087512551424_APPComponent.cientity_id = APPComponent.id -// LEFT JOIN neatlogic_develop_data.cmdb_479610550624256 cmdb_479610550624256_APPComponent ON cmdb_479610550624256_APPComponent.cientity_id = APPComponent.id - Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + attrCiName); - if (cmdbRelentityTable == null) { - cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + attrCiName).withUseAs(false)); - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - Column fromTableIdColumn = new Column(new Table("cientity_" + resourceInfo.getResourceCiName()), "id"); - EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableToCientityIdColumn, fromTableIdColumn); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + attrCiId); - SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); - InExpression inExpression = new InExpression(cmdbRelentityTableFromCientityIdColumn, subSelect); - - Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); - plainSelect.addJoins(join); - addJoinTable(cmdbRelentityTable); - addEqualColumn(cmdbRelentityTableToCientityIdColumn, fromTableIdColumn); - } - - Table attrCiTable = joinedTableMap.get("cientity_" + attrCiName); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + attrCiName).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(equalsTo); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); - } - if (attrId == null) { - Column column = new Column(attrCiTable, resourceInfo.getAttrName()); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } else { - String tableName = "cmdb_" + resourceInfo.getAttrFromCiId(); - String tableAlias = tableName + "_" + attrCiName; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + attrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } - } - } else { - //非下拉框属性 -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// - //例如ip属性 -// LEFT JOIN neatlogic_develop_data.cmdb_442011534499840 cmdb_442011534499840_IPObject ON cmdb_442011534499840_IPObject.cientity_id = IPObject.id - if (attrId == null) { - Column column = new Column(new Table("cientity_" + resourceInfo.getResourceCiName()), resourceInfo.getAttrName()); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } else { - Table attrCiTable = joinedTableMap.get("cientity_" + attrCiName); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + attrCiName).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column fromTableIdColumn = new Column(mainTable, "id"); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(new EqualsTo(attrCiTableIdColumn, fromTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, fromTableIdColumn); - } - - String tableName = "cmdb_" + resourceInfo.getAttrFromCiId(); - String tableAlias = tableName + "_" + resourceInfo.getAttrCiName(); - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + attrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(columnName))); - return column; - } - } - } - - /** - * 向sql语句where后添加过滤条件 - * @param plainSelect - * @param expression - * @return - */ - public PlainSelect addWhere(PlainSelect plainSelect, Expression expression) { - Expression where = plainSelect.getWhere(); - if (where == null) { - plainSelect.setWhere(expression); - } else { - plainSelect.setWhere(new AndExpression(where, expression)); - } - return plainSelect; - } - - /** - * 向sql语句where后添加过滤条件 - * @param plainSelect - * @param column - * @param expression - * @return - */ - public PlainSelect addWhere(PlainSelect plainSelect, Column column, Expression expression) { - return addWhere(plainSelect, column, expression, null); - } - - /** - * 向sql语句where后添加过滤条件 - * @param plainSelect - * @param column - * @param expression - * @param value - * @return - */ - public PlainSelect addWhere(PlainSelect plainSelect, Column column, Expression expression, Object value) { - if (expression instanceof EqualsTo) { - Expression rightExpression = null; - if (value instanceof Long) { - rightExpression = new LongValue((Long)value); - } else if (value instanceof Integer) { - rightExpression = new LongValue((Integer)value); - } else if (value instanceof String) { - rightExpression = new StringValue((String)value); - } else { - throw new ResourceSearchGenerateSqlTypeException(value.getClass().getName()); - } - ((EqualsTo) expression).withLeftExpression(column).withRightExpression(rightExpression); - } else if (expression instanceof InExpression) { - if (value == null) { - return plainSelect; - } - if (value instanceof List) { - List list = (List) value; - if (CollectionUtils.isNotEmpty(list)) { - ExpressionList expressionList = new ExpressionList(); - for (Object val : list) { - if (val instanceof Long) { - expressionList.addExpressions(new LongValue((Long)val)); - } else if (val instanceof Integer) { - expressionList.addExpressions(new LongValue((Integer)val)); - } else if (val instanceof String) { - expressionList.addExpressions(new StringValue((String)val)); - } else { - throw new ResourceSearchGenerateSqlTypeException(val.getClass().getName()); - } - } - ((InExpression) expression).withLeftExpression(column).setRightItemsList(expressionList); - } - } else if (value instanceof SubSelect) { - ((InExpression) expression).withLeftExpression(column).withRightExpression((SubSelect) value); - } else { - throw new ResourceSearchGenerateSqlTypeException(value.getClass().getName()); - } - } else if (expression instanceof IsNullExpression) { - ((IsNullExpression) expression).setLeftExpression(column); - } else { - throw new ResourceSearchGenerateSqlTypeException(expression.getClass().getName()); - } - return addWhere(plainSelect, expression); - } - -} diff --git a/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtil.java b/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtil.java index 958093b58c5be5ef3825bfbde4f442ec7130b5fd..a1ce3acd5f0edd79252c8662c0d7629e6bda1064 100644 --- a/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtil.java +++ b/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtil.java @@ -19,10 +19,14 @@ import neatlogic.framework.asynchronization.threadlocal.TenantContext; import neatlogic.framework.cmdb.dto.ci.CiVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityConfigVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityFieldMappingVo; +import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityLeftJoinVo; import neatlogic.framework.cmdb.enums.RelDirectionType; import net.sf.jsqlparser.expression.*; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; -import net.sf.jsqlparser.expression.operators.relational.*; +import net.sf.jsqlparser.expression.operators.relational.EqualsTo; +import net.sf.jsqlparser.expression.operators.relational.ExistsExpression; +import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals; +import net.sf.jsqlparser.expression.operators.relational.InExpression; import net.sf.jsqlparser.schema.Column; import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.select.Join; @@ -30,6 +34,7 @@ import net.sf.jsqlparser.statement.select.PlainSelect; import net.sf.jsqlparser.statement.select.SelectExpressionItem; import net.sf.jsqlparser.statement.select.SubSelect; import net.sf.jsqlparser.util.cnfexpression.MultiOrExpression; +import org.apache.commons.lang3.StringUtils; import java.util.*; @@ -37,6 +42,7 @@ public class ResourceViewGenerateSqlUtil { private CiVo mainCiVo; private List fieldMappingList; + private List leftJoinList; //sql语句中已经存在的表 private Map joinedTableMap; //sql语句关联表中相等的列 @@ -45,10 +51,14 @@ public class ResourceViewGenerateSqlUtil { public ResourceViewGenerateSqlUtil(ResourceEntityConfigVo config) { this.mainCiVo = config.getMainCiVo(); this.fieldMappingList = config.getFieldMappingList(); + this.leftJoinList = config.getLeftJoinList(); } public String getSql() { PlainSelect plainSelect = initPlainSelectByMainResourceId(mainCiVo); + for (ResourceEntityLeftJoinVo leftJoinVo : leftJoinList) { + addJoinTable(leftJoinVo, plainSelect); + } for (ResourceEntityFieldMappingVo fieldMappingVo : fieldMappingList) { addJoinTableByFieldMapping(fieldMappingVo, plainSelect, mainCiVo); } @@ -124,11 +134,93 @@ public class ResourceViewGenerateSqlUtil { Column cmdbCiIdColumn = new Column( cmdbCiTable.getAlias().getName() + ".id"); Join joinCmdbCi = new Join().withRightItem(cmdbCiTable).addOnExpression(new EqualsTo(cmdbCiIdColumn, mainTableCiIdColumn)); plainSelect.addJoins(joinCmdbCi); + addJoinTable(cmdbCiTable); addEqualColumn(cmdbCiIdColumn, mainTableCiIdColumn); plainSelect.withWhere(getExpiredExpression(mainTable)); return plainSelect; } + private void addJoinTable(ResourceEntityLeftJoinVo leftJoinVo, PlainSelect plainSelect) { + String fromCi = leftJoinVo.getFromCi(); + Long fromCiId = leftJoinVo.getFromCiId(); + String fromCiAlias = leftJoinVo.getFromCiAlias(); + String toCi = leftJoinVo.getToCi(); + Long toCiId = leftJoinVo.getToCiId(); + String toCiAlias = leftJoinVo.getToCiAlias(); + String direction = leftJoinVo.getDirection(); + boolean left = true; + if (StringUtils.isNotBlank(fromCiAlias)) { + fromCi += fromCiAlias; + } + if (StringUtils.isNotBlank(toCiAlias)) { + toCi += toCiAlias; + } + //上游关系 + if (Objects.equals(direction, RelDirectionType.FROM.getValue())) { + Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + fromCi); + if (cmdbRelentityTable == null) { + cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + fromCi).withUseAs(false)); + Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); + Column toTableIdColumn = new Column(new Table("cientity_" + toCi), "id"); + EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableToCientityIdColumn, toTableIdColumn); + + Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); + Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + fromCiId); + SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); + InExpression inExpression = new InExpression(cmdbRelentityTableFromCientityIdColumn, subSelect); + + Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); + plainSelect.addJoins(join); + addJoinTable(cmdbRelentityTable); + addEqualColumn(cmdbRelentityTableToCientityIdColumn, toTableIdColumn); + } + + Table attrCiTable = joinedTableMap.get("cientity_" + fromCi); + if (attrCiTable == null) { + attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + fromCi).withUseAs(false)); + Column attrCiTableIdColumn = new Column(attrCiTable, "id"); + Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); + EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); + AndExpression andExpression = new AndExpression(equalsTo, getExpiredExpression(attrCiTable)); + Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(andExpression); + plainSelect.addJoins(join); + addJoinTable(attrCiTable); + addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); + } + } else { + //下游关系 + Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + toCi); + if (cmdbRelentityTable == null) { + cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + toCi).withUseAs(false)); + Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); + Column toTableIdColumn = new Column(new Table("cientity_" + fromCi), "id"); + EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableFromCientityIdColumn, toTableIdColumn); + Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); + Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + toCiId); + SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); + InExpression inExpression = new InExpression(cmdbRelentityTableToCientityIdColumn, subSelect); + + Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); + plainSelect.addJoins(join); + addJoinTable(cmdbRelentityTable); + addEqualColumn(cmdbRelentityTableFromCientityIdColumn, toTableIdColumn); + } + + Table attrCiTable = joinedTableMap.get("cientity_" + toCi); + if (attrCiTable == null) { + attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + toCi).withUseAs(false)); + Column attrCiTableIdColumn = new Column(attrCiTable, "id"); + Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); + EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); + AndExpression andExpression = new AndExpression(equalsTo, getExpiredExpression(attrCiTable)); + Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(andExpression); + plainSelect.addJoins(join); + addJoinTable(attrCiTable); + addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); + } + } + } + /** * 根据需要查询或过滤的列信息join表 * @param fieldMappingVo @@ -139,6 +231,7 @@ public class ResourceViewGenerateSqlUtil { Table mainTable = getTableByAlias("cientity_" + mainCiVo.getName()); String field = fieldMappingVo.getField(); String fromCi = fieldMappingVo.getFromCi(); + String fromCiAlias = fieldMappingVo.getFromCiAlias(); Long fromCiId = fieldMappingVo.getFromCiId(); String fromAttr = fieldMappingVo.getFromAttr(); Long fromAttrId = fieldMappingVo.getFromAttrId(); @@ -147,10 +240,17 @@ public class ResourceViewGenerateSqlUtil { Long toAttrCiId = fieldMappingVo.getToAttrCiId(); Long toCiId = fieldMappingVo.getToCiId(); String toCi = fieldMappingVo.getToCi(); + String toCiAlias = fieldMappingVo.getToCiAlias(); Long toAttrId = fieldMappingVo.getToAttrId(); String toAttr = fieldMappingVo.getToAttr(); Integer attrCiIsVirtual = fieldMappingVo.getToCiIsVirtual(); String direction = fieldMappingVo.getDirection(); + if (StringUtils.isNotBlank(fromCiAlias)) { + fromCi += fromCiAlias; + } + if (StringUtils.isNotBlank(toCiAlias)) { + toCi += toCiAlias; + } boolean left = true; String type = fieldMappingVo.getType(); if (Objects.equals(type, "attr")) { diff --git a/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtilForTiDB.java b/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtilForTiDB.java index ab834a5f5df30ca3c3edb8614a7185df5637665b..3c2a60ee23c890f80eef74eeccc8cd10dc1f8356 100644 --- a/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtilForTiDB.java +++ b/src/main/java/neatlogic/framework/cmdb/utils/ResourceViewGenerateSqlUtilForTiDB.java @@ -19,20 +19,19 @@ import neatlogic.framework.asynchronization.threadlocal.TenantContext; import neatlogic.framework.cmdb.dto.ci.CiVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityConfigVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityFieldMappingVo; +import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityLeftJoinVo; import neatlogic.framework.cmdb.enums.RelDirectionType; import net.sf.jsqlparser.expression.*; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.expression.operators.conditional.OrExpression; -import net.sf.jsqlparser.expression.operators.relational.EqualsTo; -import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals; -import net.sf.jsqlparser.expression.operators.relational.IsNullExpression; -import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals; +import net.sf.jsqlparser.expression.operators.relational.*; import net.sf.jsqlparser.schema.Column; import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.select.Join; import net.sf.jsqlparser.statement.select.PlainSelect; import net.sf.jsqlparser.statement.select.SelectExpressionItem; import net.sf.jsqlparser.statement.select.SubSelect; +import org.apache.commons.lang3.StringUtils; import java.util.HashMap; import java.util.List; @@ -43,6 +42,7 @@ public class ResourceViewGenerateSqlUtilForTiDB { private CiVo mainCiVo; private List fieldMappingList; + private List leftJoinList; //sql语句中已经存在的表 private Map joinedTableMap; private Map joinedSubSelectMap; @@ -52,12 +52,16 @@ public class ResourceViewGenerateSqlUtilForTiDB { public ResourceViewGenerateSqlUtilForTiDB(ResourceEntityConfigVo config) { this.mainCiVo = config.getMainCiVo(); this.fieldMappingList = config.getFieldMappingList(); + this.leftJoinList = config.getLeftJoinList(); } public String getSql() { PlainSelect plainSelect = initPlainSelectByMainResourceId(mainCiVo); + for (ResourceEntityLeftJoinVo leftJoinVo : leftJoinList) { + addJoinTable(leftJoinVo, plainSelect); + } for (ResourceEntityFieldMappingVo fieldMappingVo : fieldMappingList) { - addJoinTableByFieldMapping(fieldMappingVo, plainSelect); + addJoinTableByFieldMapping(fieldMappingVo, plainSelect, mainCiVo); } return plainSelect.toString(); } @@ -114,45 +118,125 @@ public class ResourceViewGenerateSqlUtilForTiDB { joinedTableMap = new HashMap<>(); equalColumnMap = new HashMap<>(); joinedSubSelectMap = new HashMap<>(); + String tableName = "cmdb_" + mainCiVo.getId(); + String tableAlias = tableName + "_" + mainCiVo.getName(); + Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); + PlainSelect plainSelect = new PlainSelect() + .withFromItem(cmdbCiIdTable); + addJoinTable(cmdbCiIdTable); + String mainTableAlias = mainCiVo.getName(); SubSelect mainTable = getExpiredSubSelect(mainTableAlias); - PlainSelect plainSelect = new PlainSelect() - .withFromItem(mainTable); + Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); + Column mainTableIdColumn = new Column(mainTable.getAlias().getName() + ".id"); + Join joinMainTable = new Join().withRightItem(mainTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, mainTableIdColumn)); + plainSelect.addJoins(joinMainTable); addJoinSubSelect(mainTable); - Table a = new Table("cmdb_ci").withAlias(new Alias("a").withUseAs(false)); - Column aLftColumn = new Column(a, "lft"); - Column aRhtColumn = new Column(a, "rht"); - - Table b = new Table("cmdb_ci").withAlias(new Alias("b").withUseAs(false)); - Column bLftColumn = new Column(b, "lft"); - Column bRhtColumn = new Column(b, "rht"); - GreaterThanEquals greaterThanEquals = new GreaterThanEquals(">=").withLeftExpression(bLftColumn).withRightExpression(aLftColumn); - MinorThanEquals minorThanEquals = new MinorThanEquals("<=").withLeftExpression(bRhtColumn).withRightExpression(aRhtColumn); - Join join = new Join().withRightItem(b).addOnExpression(new AndExpression(greaterThanEquals, minorThanEquals)); - - SubSelect subSelect = new SubSelect().withSelectBody( - new PlainSelect().withFromItem(a).addJoins(join) - .addSelectItems(new SelectExpressionItem(new Column( b, "*"))) - .withWhere(new EqualsTo(new Column(a, "id"), new LongValue(mainCiVo.getId()))) - ).withAlias(new Alias("cientity_" + mainTableAlias + "_ci").withUseAs(false)); + Table cmdbCiTable = new Table("cmdb_ci").withAlias(new Alias("cientity_" + mainTableAlias + "_ci").withUseAs(false)); Column mainTableCiIdColumn = new Column(mainTable.getAlias().getName() + ".ci_id"); - addJoinSubSelect(subSelect); - Column cmdbCiIdColumn = new Column( subSelect.getAlias().getName() + ".id"); - Join joinCmdbCi = new Join().withRightItem(subSelect).addOnExpression(new EqualsTo(cmdbCiIdColumn, mainTableCiIdColumn)); + Column cmdbCiIdColumn = new Column( cmdbCiTable.getAlias().getName() + ".id"); + Join joinCmdbCi = new Join().withRightItem(cmdbCiTable).addOnExpression(new EqualsTo(cmdbCiIdColumn, mainTableCiIdColumn)); plainSelect.addJoins(joinCmdbCi); + addJoinTable(cmdbCiTable); addEqualColumn(cmdbCiIdColumn, mainTableCiIdColumn); return plainSelect; } + private void addJoinTable(ResourceEntityLeftJoinVo leftJoinVo, PlainSelect plainSelect) { + String fromCi = leftJoinVo.getFromCi(); + Long fromCiId = leftJoinVo.getFromCiId(); + String fromCiAlias = leftJoinVo.getFromCiAlias(); + String toCi = leftJoinVo.getToCi(); + Long toCiId = leftJoinVo.getToCiId(); + String toCiAlias = leftJoinVo.getToCiAlias(); + String direction = leftJoinVo.getDirection(); + boolean left = true; + if (StringUtils.isNotBlank(fromCiAlias)) { + fromCi += fromCiAlias; + } + if (StringUtils.isNotBlank(toCiAlias)) { + toCi += toCiAlias; + } + //上游关系 + if (Objects.equals(direction, RelDirectionType.FROM.getValue())) { + SubSelect cmdbRelentityTable = joinedSubSelectMap.get("cmdb_relentity_" + fromCi); + if (cmdbRelentityTable == null) { + Table a = new Table("cmdb_relentity").withAlias(new Alias("a").withUseAs(false)); + Column aFromCiEntityIdColumn = new Column(a, "from_cientity_id"); + + Table b = new Table(TenantContext.get().getDataDbName(),"cmdb_" + fromCiId).withAlias(new Alias("b").withUseAs(false)); + Column bCiEntityIdColumn = new Column(b, "cientity_id"); + + Join join2 = new Join().withRightItem(b).addOnExpression(new EqualsTo(bCiEntityIdColumn, aFromCiEntityIdColumn)); + cmdbRelentityTable = new SubSelect().withSelectBody(new PlainSelect().withFromItem(a).addJoins(join2).addSelectItems(new SelectExpressionItem(new Column(a, "*")))).withAlias(new Alias("cmdb_relentity_" + fromCi)); + + Column cmdbRelEntityTableToCiEntityIdColumn = new Column(cmdbRelentityTable.getAlias().getName() + ".to_cientity_id"); + Column toTableIdColumn = new Column(new Table("cientity_" + toCi), "id"); + EqualsTo equalsTo = new EqualsTo(cmdbRelEntityTableToCiEntityIdColumn, toTableIdColumn); + + Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(equalsTo); + plainSelect.addJoins(join); + addJoinSubSelect(cmdbRelentityTable); + addEqualColumn(cmdbRelEntityTableToCiEntityIdColumn, toTableIdColumn); + } + + SubSelect attrCiTable = joinedSubSelectMap.get("cientity_" + fromCi); + if (attrCiTable == null) { + attrCiTable = getExpiredSubSelect(fromCi); + Column attrCiTableIdColumn = new Column(attrCiTable.getAlias().getName() + ".id"); + Column cmdbRelEntityTableFromCiEntityIdColumn = new Column(cmdbRelentityTable.getAlias().getName() + ".from_cientity_id"); + EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelEntityTableFromCiEntityIdColumn); + Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(equalsTo); + plainSelect.addJoins(join); + addJoinSubSelect(attrCiTable); + addEqualColumn(attrCiTableIdColumn, cmdbRelEntityTableFromCiEntityIdColumn); + } + } else { + //下游关系 + SubSelect cmdbRelentityTable = joinedSubSelectMap.get("cmdb_relentity_" + toCi); + if (cmdbRelentityTable == null) { + Table a = new Table("cmdb_relentity").withAlias(new Alias("a").withUseAs(false)); + Column aToCiEntityIdColumn = new Column(a, "to_cientity_id"); + + Table b = new Table(TenantContext.get().getDataDbName(),"cmdb_" + toCiId).withAlias(new Alias("b").withUseAs(false)); + Column bCiEntityIdColumn = new Column(b, "cientity_id"); + + Join join2 = new Join().withRightItem(b).addOnExpression(new EqualsTo(bCiEntityIdColumn, aToCiEntityIdColumn)); + cmdbRelentityTable = new SubSelect().withSelectBody(new PlainSelect().withFromItem(a).addJoins(join2).addSelectItems(new SelectExpressionItem(new Column(a, "*")))).withAlias(new Alias("cmdb_relentity_" + toCi)); + + Column cmdbRelEntityTableFromCiEntityIdColumn = new Column(cmdbRelentityTable.getAlias().getName() + ".from_cientity_id"); + Column toTableIdColumn = new Column(new Table("cientity_" + fromCi), "id"); + EqualsTo equalsTo = new EqualsTo(cmdbRelEntityTableFromCiEntityIdColumn, toTableIdColumn); + + Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(equalsTo); + plainSelect.addJoins(join); + addJoinSubSelect(cmdbRelentityTable); + addEqualColumn(cmdbRelEntityTableFromCiEntityIdColumn, toTableIdColumn); + } + + SubSelect attrCiTable = joinedSubSelectMap.get("cientity_" + toCi); + if (attrCiTable == null) { + attrCiTable = getExpiredSubSelect(toCi); + Column attrCiTableIdColumn = new Column(attrCiTable.getAlias().getName() + ".id"); + Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable.getAlias().getName() + ".to_cientity_id"); + EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); + Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(equalsTo); + plainSelect.addJoins(join); + addJoinSubSelect(attrCiTable); + addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); + } + } + } + /** * 根据需要查询或过滤的列信息join表 * @param fieldMappingVo * @param plainSelect * @return */ - private Column addJoinTableByFieldMapping(ResourceEntityFieldMappingVo fieldMappingVo, PlainSelect plainSelect) { - SubSelect mainTable = (SubSelect) plainSelect.getFromItem(); + private Column addJoinTableByFieldMapping(ResourceEntityFieldMappingVo fieldMappingVo, PlainSelect plainSelect, CiVo mainCiVo) { + SubSelect mainTable = getSubSelectByAlias("cientity_" + mainCiVo.getName()); String field = fieldMappingVo.getField(); String fromCi = fieldMappingVo.getFromCi(); Long fromCiId = fieldMappingVo.getFromCiId(); diff --git a/src/main/java/neatlogic/framework/cmdb/utils/SceneEntityGenerateSqlUtil.java b/src/main/java/neatlogic/framework/cmdb/utils/SceneEntityGenerateSqlUtil.java deleted file mode 100644 index 2b638f28aa8d9c948b3f0cf654cf4de64b84a6b1..0000000000000000000000000000000000000000 --- a/src/main/java/neatlogic/framework/cmdb/utils/SceneEntityGenerateSqlUtil.java +++ /dev/null @@ -1,511 +0,0 @@ -/*Copyright (C) $today.year 深圳极向量科技有限公司 All Rights Reserved. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see .*/ - -package neatlogic.framework.cmdb.utils; - -import neatlogic.framework.asynchronization.threadlocal.TenantContext; -import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.SceneEntityAttrVo; -import neatlogic.framework.cmdb.dto.resourcecenter.config.SceneEntityVo; -import neatlogic.framework.cmdb.enums.RelDirectionType; -import neatlogic.framework.cmdb.enums.resourcecenter.JoinType; -import net.sf.jsqlparser.expression.Alias; -import net.sf.jsqlparser.expression.Expression; -import net.sf.jsqlparser.expression.Function; -import net.sf.jsqlparser.expression.LongValue; -import net.sf.jsqlparser.expression.operators.conditional.AndExpression; -import net.sf.jsqlparser.expression.operators.relational.*; -import net.sf.jsqlparser.schema.Column; -import net.sf.jsqlparser.schema.Table; -import net.sf.jsqlparser.statement.select.Join; -import net.sf.jsqlparser.statement.select.PlainSelect; -import net.sf.jsqlparser.statement.select.SelectExpressionItem; -import net.sf.jsqlparser.statement.select.SubSelect; -import net.sf.jsqlparser.util.cnfexpression.MultiOrExpression; - -import java.util.*; - -public class SceneEntityGenerateSqlUtil { - - private final SceneEntityVo sceneEntityVo; - //sql语句中已经存在的表 - private Map joinedTableMap; - //sql语句关联表中相等的列 - private Map equalColumnMap; - - public SceneEntityGenerateSqlUtil(SceneEntityVo sceneEntityVo) { - this.sceneEntityVo = sceneEntityVo; - } - - public String getSql() { - PlainSelect plainSelect = initPlainSelectByMainResourceId(sceneEntityVo.getCi()); - for (SceneEntityAttrVo sceneEntityAttrVo : sceneEntityVo.getAttrList()) { - addJoinTableBySceneEntityAttr(sceneEntityAttrVo, plainSelect); - } - return plainSelect.toString(); - } - - private void addJoinTable(Table table) { - String key = table.getName(); - Alias alias = table.getAlias(); - if (alias != null) { - key = alias.getName(); - } - joinedTableMap.put(key, table); - } - - private Table getTableByAlias(String alias) { - return joinedTableMap.get(alias); - } - - private void addEqualColumn(Column left, Column right) { - equalColumnMap.put(left.toString(), right); - } - - private Column getEqualColumn(Column left) { - Column result = left; - for(int i = 0; i < 10; i++) { - Column right = equalColumnMap.get(left.toString()); - if (right == null) { - return result; - } - result = right; - } - return result; - } - - /** - * 根据主资源id,初始化sql语句,例如SELECT * FROM cmdb_cientity IPObject JOIN cmdb_ci ci_IPObject ON ci_IPObject.id = IPObject.ci_id - * @param mainCiVo - * @return - */ - private PlainSelect initPlainSelectByMainResourceId(CiVo mainCiVo) { - joinedTableMap = new HashMap<>(); - equalColumnMap = new HashMap<>(); - String mainTableAlias = mainCiVo.getName(); - Table mainTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + mainTableAlias).withUseAs(false)); - PlainSelect plainSelect = new PlainSelect() - .withFromItem(mainTable); - addJoinTable(mainTable); - Table cmdbCi = new Table("cmdb_ci").withAlias(new Alias("cientity_" + mainTableAlias + "_ci").withUseAs(false)); - Column cmdbCiIdColumn = new Column(cmdbCi, "id"); - Column mainTableCiIdColumn = new Column(mainTable, "ci_id"); - EqualsTo equalsTo = new EqualsTo(cmdbCiIdColumn, mainTableCiIdColumn); - Column cmdbCiLftColumn = new Column(cmdbCi, "lft"); - Column cmdbCiRhtColumn = new Column(cmdbCi, "rht"); -// GreaterThanEquals greaterThanEquals = new GreaterThanEquals(">=").withLeftExpression(cmdbCiLftColumn).withRightExpression(new LongValue(mainCiVo.getLft())); -// MinorThanEquals minorThanEquals = new MinorThanEquals("<=").withLeftExpression(cmdbCiRhtColumn).withRightExpression(new LongValue(mainCiVo.getRht())); - Table cmdbCiTable = new Table("cmdb_ci"); - SubSelect subSelectLft = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiTable).addSelectItems(new SelectExpressionItem(new Column( "lft"))).withWhere(new EqualsTo(new Column("id"), new LongValue(mainCiVo.getId())))); - SubSelect subSelectRht = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiTable).addSelectItems(new SelectExpressionItem(new Column( "rht"))).withWhere(new EqualsTo(new Column("id"), new LongValue(mainCiVo.getId())))); - GreaterThanEquals greaterThanEquals = new GreaterThanEquals(">=").withLeftExpression(cmdbCiLftColumn).withRightExpression(subSelectLft); - MinorThanEquals minorThanEquals = new MinorThanEquals("<=").withLeftExpression(cmdbCiRhtColumn).withRightExpression(subSelectRht); - AndExpression andExpression = new AndExpression(greaterThanEquals, minorThanEquals); - Join joinCmdbCi = new Join().withRightItem(cmdbCi).addOnExpression(new AndExpression(equalsTo, andExpression)); - plainSelect.addJoins(joinCmdbCi); - addJoinTable(cmdbCi); - addEqualColumn(cmdbCiIdColumn, mainTableCiIdColumn); - plainSelect.withWhere(getExpiredExpression(mainTable)); - return plainSelect; - } - - /** - * 根据需要查询或过滤的列信息join表 - * @param sceneEntityAttrVo - * @param plainSelect - * @return - */ - private Column addJoinTableBySceneEntityAttr(SceneEntityAttrVo sceneEntityAttrVo, PlainSelect plainSelect) { - Table mainTable = (Table) plainSelect.getFromItem(); - String field = sceneEntityAttrVo.getField(); - String fromCi = sceneEntityAttrVo.getFromCi(); - Long fromCiId = sceneEntityAttrVo.getFromCiId(); - String fromAttr = sceneEntityAttrVo.getFromAttr(); - Long fromAttrId = sceneEntityAttrVo.getFromAttrId(); - Long fromAttrCiId = sceneEntityAttrVo.getFromAttrCiId(); - String toAttrCiName = sceneEntityAttrVo.getToAttrCiName(); - Long toAttrCiId = sceneEntityAttrVo.getToAttrCiId(); - Long toCiId = sceneEntityAttrVo.getToCiId(); - String toCi = sceneEntityAttrVo.getToCi(); - Long toAttrId = sceneEntityAttrVo.getToAttrId(); - String toAttr = sceneEntityAttrVo.getToAttr(); - Integer attrCiIsVirtual = sceneEntityAttrVo.getToCiIsVirtual(); - String direction = sceneEntityAttrVo.getDirection(); - boolean left = true; - JoinType joinType = sceneEntityAttrVo.getJoinType(); - if (joinType == JoinType.ATTR) { - // 下拉框类型属 - // 例如状态属性state AS state_id -// -// -// -// -// -// -// -// -// (left) join cmdb_cientity IPObject ON IPObject.id = IPObject.id -// (left) join cmdb_attrentity cmdb_attrentity_state ON cmdb_attrentity_state.from_cientity_id = IPObject.id and cmdb_attrentity_state.attr_id = #{attrId} -// (left) join cmdb_cientity CIState ON CIState.id = cmdb_attrentity_state.to_cientity_id - //负责人属性owner AS user_id -// -// -// -// -// -// -// -// -// (left) join cmdb_cientity IPObject ON IPObject.id = IPObject.id -// (left) join cmdb_attrentity cmdb_attrentity_owner ON cmdb_attrentity_owner.from_cientity_id = IPObject.id and cmdb_attrentity_owner.attr_id = #{attrId} -// (LEFT) JOIN neatlogic_develop_data.cmdb_479643459133440 cmdb_479643459133440_User ON cmdb_479643459133440_User.id = cmdb_attrentity_owner.to_cientity_id - Table resourceCiTable = getTableByAlias("cientity_" + fromCi); - if (resourceCiTable == null) { - resourceCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + fromCi).withUseAs(false)); - Column resourceCiTableIdColumn = new Column(resourceCiTable, "id"); - Column mainTableIdColumn = new Column(mainTable, "id"); - EqualsTo equalsTo = new EqualsTo(resourceCiTableIdColumn, mainTableIdColumn); - Join join = new Join().withLeft(left).withRightItem(resourceCiTable).addOnExpression(equalsTo); - plainSelect.addJoins(join); - addJoinTable(resourceCiTable); - addEqualColumn(resourceCiTableIdColumn, mainTableIdColumn); - } - Table cmdbAttrentityTable = joinedTableMap.get("cmdb_attrentity_" + fromAttr); - if (cmdbAttrentityTable == null) { - cmdbAttrentityTable = new Table("cmdb_attrentity").withAlias(new Alias("cmdb_attrentity_" + fromAttr).withUseAs(false)); - Column cmdbAttrentityTableFromCientityIdColumn = new Column(cmdbAttrentityTable, "from_cientity_id"); - Column resourceCiTableIdColumn = new Column(resourceCiTable, "id"); - EqualsTo equalsTo1 = new EqualsTo(cmdbAttrentityTableFromCientityIdColumn, resourceCiTableIdColumn); - EqualsTo equalsTo2 = new EqualsTo(new Column(cmdbAttrentityTable, "attr_id"), new LongValue(fromAttrId)); - Expression onExpression = new AndExpression(equalsTo1, equalsTo2); - Join join = new Join().withLeft(left).withRightItem(cmdbAttrentityTable).addOnExpression(onExpression); - plainSelect.addJoins(join); - addJoinTable(cmdbAttrentityTable); - addEqualColumn(cmdbAttrentityTableFromCientityIdColumn, resourceCiTableIdColumn); - } - if (Objects.equals(attrCiIsVirtual, 1)) { - //属性模型是虚拟模型时 - Table cmdbCiIdTable = joinedTableMap.get("cmdb_" + toAttrCiId + "_" + toAttrCiName); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), "cmdb_" + toAttrCiId) - .withAlias(new Alias("cmdb_" + toAttrCiId + "_" + toAttrCiName).withUseAs(false)); - addJoinTable(cmdbCiIdTable); - Column cmdbCiIdTableIdColumn = new Column(cmdbCiIdTable, "id"); - Column cmdbAttrentityTableToCientityIdColumn = new Column(cmdbAttrentityTable, "to_cientity_id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableIdColumn, cmdbAttrentityTableToCientityIdColumn)); - plainSelect.addJoins(join); - addEqualColumn(cmdbCiIdTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - } - if (toAttrId == null) { - if (toAttr.startsWith("_")) { - toAttr = toAttr.substring(1); - } - Column column = new Column(cmdbCiIdTable, toAttr); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } else { - Column column = new Column(cmdbCiIdTable, "`" + toAttrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } - } else { - //属性模型是非虚拟模型时 - Table attrCiTable = joinedTableMap.get("cientity_" + toCi); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + toCi).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbAttrentityTableToCientityIdColumn = new Column(cmdbAttrentityTable, "to_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - AndExpression andExpression = new AndExpression(equalsTo, getExpiredExpression(attrCiTable)); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(andExpression); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbAttrentityTableToCientityIdColumn); - } - if (toAttrId == null) { - if (toAttr.startsWith("_")) { - toAttr = toAttr.substring(1); - } - Column column = new Column(attrCiTable, toAttr); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } else { - String tableName = "cmdb_" + toAttrCiId; - String tableAlias = tableName + "_" + toCi; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column table3IdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, table3IdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, table3IdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + toAttrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } - } - } else if (joinType == JoinType.REL) { - //关系 - if (Objects.equals(direction, RelDirectionType.FROM.getValue())) { - Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + toCi); - if (cmdbRelentityTable == null) { - cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + toCi).withUseAs(false)); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - Column fromTableIdColumn = new Column(new Table("cientity_" + fromCi), "id"); - EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableFromCientityIdColumn, fromTableIdColumn); - - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + toCiId); - SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); - InExpression inExpression = new InExpression(cmdbRelentityTableToCientityIdColumn, subSelect); - - Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); - plainSelect.addJoins(join); - addJoinTable(cmdbRelentityTable); - addEqualColumn(cmdbRelentityTableFromCientityIdColumn, fromTableIdColumn); - } - - Table attrCiTable = joinedTableMap.get("cientity_" + toCi); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + toCi).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); - AndExpression andExpression = new AndExpression(equalsTo, getExpiredExpression(attrCiTable)); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(andExpression); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableToCientityIdColumn); - } - if (toAttrId == null) { - if (toAttr.startsWith("_")) { - if ("_typeId".equals(toAttr)) { - toAttr = "ci_id"; - } else { - toAttr = toAttr.substring(1); - } - } - Column column = new Column(attrCiTable, toAttr); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } else { - String tableName = "cmdb_" + toAttrCiId; - String tableAlias = tableName + "_" + toCi; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + toAttrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } - } else { - //模块 -// -// -// -// -// -// -// -// - -// LEFT JOIN cmdb_relentity cmdb_relentity_APPComponent ON cmdb_relentity_APPComponent.to_cientity_id = IPObject.id -// LEFT JOIN cmdb_rel cmdb_rel_APPComponent ON cmdb_rel_APPComponent.id = cmdb_relentity_APPComponent.rel_id AND cmdb_rel_APPComponent.from_ci_id = 479610550624256 -// LEFT JOIN cmdb_cientity APPComponent ON APPComponent.id = cmdb_relentity_APPComponent.from_cientity_id - -// LEFT JOIN neatlogic_develop_data.cmdb_441087512551424 cmdb_441087512551424_APPComponent ON cmdb_441087512551424_APPComponent.cientity_id = APPComponent.id -// LEFT JOIN neatlogic_develop_data.cmdb_479610550624256 cmdb_479610550624256_APPComponent ON cmdb_479610550624256_APPComponent.cientity_id = APPComponent.id - Table cmdbRelentityTable = joinedTableMap.get("cmdb_relentity_" + fromCi); - if (cmdbRelentityTable == null) { - cmdbRelentityTable = new Table("cmdb_relentity").withAlias(new Alias("cmdb_relentity_" + fromCi).withUseAs(false)); - Column cmdbRelentityTableToCientityIdColumn = new Column(cmdbRelentityTable, "to_cientity_id"); - Column fromTableIdColumn = new Column(new Table("cientity_" + toCi), "id"); - EqualsTo equalsTo = new EqualsTo(cmdbRelentityTableToCientityIdColumn, fromTableIdColumn); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - Table cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(),"cmdb_" + fromCiId); - SubSelect subSelect = new SubSelect().withSelectBody(new PlainSelect().withFromItem(cmdbCiIdTable).addSelectItems(new SelectExpressionItem(new Column(cmdbCiIdTable, "cientity_id")))); - InExpression inExpression = new InExpression(cmdbRelentityTableFromCientityIdColumn, subSelect); - - Join join = new Join().withLeft(left).withRightItem(cmdbRelentityTable).addOnExpression(new AndExpression(equalsTo, inExpression)); - plainSelect.addJoins(join); - addJoinTable(cmdbRelentityTable); - addEqualColumn(cmdbRelentityTableToCientityIdColumn, fromTableIdColumn); - } - - Table attrCiTable = joinedTableMap.get("cientity_" + fromCi); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + fromCi).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column cmdbRelentityTableFromCientityIdColumn = new Column(cmdbRelentityTable, "from_cientity_id"); - EqualsTo equalsTo = new EqualsTo(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); - AndExpression andExpression = new AndExpression(equalsTo, getExpiredExpression(attrCiTable)); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(andExpression); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, cmdbRelentityTableFromCientityIdColumn); - } - if (fromAttrId == null) { - if (fromAttr.startsWith("_")) { - if ("_typeId".equals(fromAttr)) { - fromAttr = "ci_id"; - } else { - fromAttr = fromAttr.substring(1); - } - } - Column column = new Column(attrCiTable, fromAttr); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } else { - String tableName = "cmdb_" + fromAttrCiId; - String tableAlias = tableName + "_" + fromCi; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + fromAttrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } - } - } else { - //非下拉框属性 -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// - //例如ip属性 -// LEFT JOIN neatlogic_develop_data.cmdb_442011534499840 cmdb_442011534499840_IPObject ON cmdb_442011534499840_IPObject.cientity_id = IPObject.id - if (fromAttrId == null) { - if ("_id".equals(fromAttr)) { - fromAttr = "id"; - } else if ("_uuid".equals(fromAttr)) { - fromAttr = "uuid"; - } else if ("_name".equals(fromAttr)) { - fromAttr = "name"; - } else if ("_fcu".equals(fromAttr)) { - fromAttr = "fcu"; - } else if ("_fcd".equals(fromAttr)) { - fromAttr = "fcd"; - } else if ("_lcu".equals(fromAttr)) { - fromAttr = "lcu"; - } else if ("_lcd".equals(fromAttr)) { - fromAttr = "lcd"; - } else if ("_inspectStatus".equals(fromAttr)) { - fromAttr = "inspect_status"; - } else if ("_inspectTime".equals(fromAttr)) { - fromAttr = "inspect_time"; - } else if ("_monitorStatus".equals(fromAttr)) { - fromAttr = "monitor_status"; - } else if ("_monitorTime".equals(fromAttr)) { - fromAttr = "monitor_time"; - } else if ("_typeId".equals(fromAttr)) { - fromAttr = "ci_id"; - } else if ("_typeName".equals(fromAttr)) { - fromCi = fromCi + "_ci"; - fromAttr = "name"; - } else if ("_typeLabel".equals(fromAttr)) { - fromCi = fromCi + "_ci"; - fromAttr = "label"; - } else { - - } - Column column = new Column(new Table("cientity_" + fromCi), fromAttr); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } else { - Table attrCiTable = joinedTableMap.get("cientity_" + fromCi); - if (attrCiTable == null) { - attrCiTable = new Table("cmdb_cientity").withAlias(new Alias("cientity_" + fromCi).withUseAs(false)); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Column fromTableIdColumn = new Column(mainTable, "id"); - Join join = new Join().withLeft(left).withRightItem(attrCiTable).addOnExpression(new EqualsTo(attrCiTableIdColumn, fromTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(attrCiTable); - addEqualColumn(attrCiTableIdColumn, fromTableIdColumn); - } - - String tableName = "cmdb_" + fromAttrCiId; - String tableAlias = tableName + "_" + fromCi; - Table cmdbCiIdTable = joinedTableMap.get(tableAlias); - if (cmdbCiIdTable == null) { - cmdbCiIdTable = new Table(TenantContext.get().getDataDbName(), tableName).withAlias(new Alias(tableAlias).withUseAs(false)); - Column cmdbCiIdTableCientityIdColumn = new Column(cmdbCiIdTable, "cientity_id"); - Column attrCiTableIdColumn = new Column(attrCiTable, "id"); - Join join = new Join().withLeft(left).withRightItem(cmdbCiIdTable).addOnExpression(new EqualsTo(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn)); - plainSelect.addJoins(join); - addJoinTable(cmdbCiIdTable); - addEqualColumn(cmdbCiIdTableCientityIdColumn, attrCiTableIdColumn); - } - Column column = new Column(cmdbCiIdTable, "`" + fromAttrId + "`"); - plainSelect.addSelectItems(new SelectExpressionItem(column).withAlias(new Alias(field))); - return column; - } - } - } - private Expression getExpiredExpression(Table mainTable) { - /* - (not exists (select 1 from cmdb_cientity_expiredtime xx where xx.cientity_id = `ci_base`.id) or exists - (select 1 from cmdb_cientity_expiredtime xx where xx.cientity_id = `ci_base`.id - and xx.expired_time >= NOW())) - */ - - List expressionList = new ArrayList<>(); - expressionList.add(new ExistsExpression() - .withNot(true) - .withRightExpression(new SubSelect() - .withSelectBody(new PlainSelect() - .withFromItem(new Table("cmdb_cientity_expiredtime").withAlias(new Alias("ex"))) - .addSelectItems(new SelectExpressionItem(new Column("1"))) - .withWhere(new EqualsTo(new Column("ex.cientity_id"), new Column(mainTable,"id")))))); - expressionList.add(new ExistsExpression().withRightExpression(new SubSelect() - .withSelectBody((new PlainSelect() - .withFromItem(new Table("cmdb_cientity_expiredtime").withAlias(new Alias("ex"))) - .addSelectItems(new SelectExpressionItem(new Column("1"))) - .withWhere(new AndExpression().withLeftExpression(new EqualsTo(new Column("ex.cientity_id"), new Column(mainTable,"id"))) - .withRightExpression(new GreaterThanEquals().withLeftExpression(new Column("ex.expired_time")).withRightExpression(new Function().withName("now")))))))); - return new MultiOrExpression(expressionList); - } -}