diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml index e832fb766e1883859f589979dada32da7f67ff66..424d3f6a90c65b92e1889209a5796fa23853c52c 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/cientity/CiEntityMapper.xml @@ -1361,7 +1361,7 @@ DELETE - a,b,c,d,e,f + a,b,c,e,f FROM cmdb_cientity a LEFT JOIN cmdb_attrentity b ON a.id = @@ -1369,8 +1369,7 @@ LEFT JOIN cmdb_relentity c ON a.id = c.`from_cientity_id` - LEFT JOIN cmdb_relentity d - ON a.id = + OR a.id = c.`to_cientity_id` LEFT JOIN cmdb_cientity_group e ON a.id = diff --git a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java index 61a15802947058aad4a33baf6a0718b66e1d0eea..3e6f877313b884e91f80f504224d2065cdfea7c8 100644 --- a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java +++ b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java @@ -16,6 +16,8 @@ package neatlogic.module.cmdb.service.resourcecenter.resource; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.asynchronization.threadlocal.TenantContext; import neatlogic.framework.asynchronization.threadlocal.UserContext; import neatlogic.framework.cmdb.dto.ci.AttrVo; @@ -34,9 +36,12 @@ import neatlogic.framework.cmdb.exception.resourcecenter.AppModuleNotFoundExcept import neatlogic.framework.cmdb.exception.resourcecenter.AppSystemNotFoundException; import neatlogic.framework.cmdb.exception.resourcecenter.ResourceViewFieldMappingException; import neatlogic.framework.cmdb.utils.ResourceViewGenerateSqlUtil; +import neatlogic.framework.cmdb.utils.ResourceViewGenerateSqlUtilForTiDB; import neatlogic.framework.dao.mapper.DataBaseViewInfoMapper; import neatlogic.framework.dao.mapper.SchemaMapper; import neatlogic.framework.dto.DataBaseViewInfoVo; +import neatlogic.framework.store.mysql.DatabaseVendor; +import neatlogic.framework.store.mysql.DatasourceManager; import neatlogic.framework.transaction.core.EscapeTransactionJob; import neatlogic.framework.util.Md5Util; import neatlogic.framework.util.TableResultUtil; @@ -47,8 +52,6 @@ import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceAccountMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceEntityMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceTagMapper; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import neatlogic.module.cmdb.utils.ResourceEntityFactory; import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.create.table.ColDataType; @@ -634,9 +637,15 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc } catch (ResourceViewFieldMappingException e) { return e.getMessage(); } - ResourceViewGenerateSqlUtil resourceViewGenerateSqlUtil = new ResourceViewGenerateSqlUtil(config); - String selectSql = resourceViewGenerateSqlUtil.getSql(); - String md5 = Md5Util.encryptMD5(selectSql); + String select = null; + if (Objects.equals(DatasourceManager.getDatabaseId(), DatabaseVendor.TIDB.getDatabaseId())) { + ResourceViewGenerateSqlUtilForTiDB resourceViewGenerateSqlUtilForTiDB = new ResourceViewGenerateSqlUtilForTiDB(config); + select = resourceViewGenerateSqlUtilForTiDB.getSql(); + } else { + ResourceViewGenerateSqlUtil resourceViewGenerateSqlUtil = new ResourceViewGenerateSqlUtil(config); + select = resourceViewGenerateSqlUtil.getSql(); + } + String md5 = Md5Util.encryptMD5(select); String tableType = schemaMapper.checkTableOrViewIsExists(TenantContext.get().getDataDbName(), viewName); if (tableType != null) { if (Objects.equals(tableType, "SYSTEM VIEW")) { @@ -652,6 +661,7 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc } } try { + String selectSql = select; EscapeTransactionJob.State s = new EscapeTransactionJob(() -> { if (Objects.equals(tableType, "BASE TABLE")) { schemaMapper.deleteTable(TenantContext.get().getDataDbName() + "." + viewName);