From 6b021add6aea01eddadb0cdd062d1753cf19aa49 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Fri, 31 Oct 2025 15:57:15 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9F=A9=E9=98=B5=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1544248732647424]自定义矩阵导入导出失败 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1544248732647424 --- ...CiEntityDataToMongoDBForBalantFlowApi.java | 3 + .../handler/MatrixCmdbCiAttrTypeHandler.java | 97 ++++++++++--------- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/synccientity/BatchSyncCiEntityDataToMongoDBForBalantFlowApi.java b/src/main/java/neatlogic/module/cmdb/api/synccientity/BatchSyncCiEntityDataToMongoDBForBalantFlowApi.java index b69574d0..9e9afe58 100644 --- a/src/main/java/neatlogic/module/cmdb/api/synccientity/BatchSyncCiEntityDataToMongoDBForBalantFlowApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/synccientity/BatchSyncCiEntityDataToMongoDBForBalantFlowApi.java @@ -138,6 +138,9 @@ public class BatchSyncCiEntityDataToMongoDBForBalantFlowApi extends PrivateApiCo @Param(name = "pageSize", type = ApiParamType.INTEGER, defaultValue = "1000", desc = "common.pagesize"), @Param(name = "integrationRequestMaxCount", type = ApiParamType.INTEGER, defaultValue = "10000", desc = "集成请求最大次数,默认是10000"), @Param(name = "needSyncData", type = ApiParamType.BOOLEAN, defaultValue = "false", desc = "是否需要同步数据,值为false时只同步mongodb中的dictionary数据"), + @Param(name = "collectionName", type = ApiParamType.STRING, desc = "保存配置项数据集合名称"), + @Param(name = "needDeleteCollection", type = ApiParamType.BOOLEAN, defaultValue = "false", desc = "是否需要删除配置项数据集合,值为true时会先删除集合再重新创建集合"), + @Param(name = "expireAfterHours", type = ApiParamType.INTEGER, defaultValue = "24", desc = "配置项数据过期时间,单位小时,默认是24小时"), }) @Output({ diff --git a/src/main/java/neatlogic/module/cmdb/matrix/attrtype/handler/MatrixCmdbCiAttrTypeHandler.java b/src/main/java/neatlogic/module/cmdb/matrix/attrtype/handler/MatrixCmdbCiAttrTypeHandler.java index 32997f2d..2b978dca 100644 --- a/src/main/java/neatlogic/module/cmdb/matrix/attrtype/handler/MatrixCmdbCiAttrTypeHandler.java +++ b/src/main/java/neatlogic/module/cmdb/matrix/attrtype/handler/MatrixCmdbCiAttrTypeHandler.java @@ -53,53 +53,56 @@ public class MatrixCmdbCiAttrTypeHandler extends MatrixAttrTypeBase { @Override public Set getRealValueBatch(MatrixAttributeVo matrixAttributeVo, Map valueMap) { - JSONObject config = matrixAttributeVo.getConfig(); - String label = null; - Long ciId = null; - try { - if (MapUtils.isNotEmpty(config)) { - JSONObject cmdbCi = config.getJSONObject("cmdbCi"); - label = cmdbCi.getString("label"); - ciId = cmdbCi.getLong("ciId"); - } - - if (label == null || ciId == null) { - return Collections.emptySet(); - } - Object component = PrivateApiComponentFactory.getInstance("neatlogic.module.cmdb.api.cientity.ListCiEntityDataForSelectApi"); - Method method = component.getClass().getMethod("myDoService", JSONObject.class); - JSONObject param = new JSONObject(); - param.put("ciId", ciId); - param.put("label", label); - param.put("defaultValue", new ArrayList<>(valueMap.keySet())); - Object resultObj = method.invoke(component, param); - if (resultObj != null) { - JSONObject result = JSON.parseObject(JSON.toJSONString(resultObj)); - JSONArray dataList = result.getJSONArray("tbodyList"); - if (CollectionUtils.isNotEmpty(dataList)) { - for (Map.Entry entry : valueMap.entrySet()) { - String key = entry.getKey(); - for (int i = 0; i < dataList.size(); i++) { - JSONObject data = dataList.getJSONObject(i); - String value = data.getString("value"); - if (Objects.equals(key, value)) { - valueMap.put(value, value); - } - } - if (StringUtils.isBlank(entry.getValue())) { - valueMap.remove(key); - } - } - } - } - } catch (Exception ex) { - Throwable target = ex; - //如果是反射抛得异常,则需循环拆包,把真实得异常类找出来 - while (target instanceof InvocationTargetException) { - target = ((InvocationTargetException) target).getTargetException(); - } - String error = ex.getMessage() == null ? ExceptionUtils.getStackTrace(ex) : ex.getMessage(); - logger.error(error); +// JSONObject config = matrixAttributeVo.getConfig(); +// String label = null; +// Long ciId = null; +// try { +// if (MapUtils.isNotEmpty(config)) { +// JSONObject cmdbCi = config.getJSONObject("cmdbCi"); +// label = cmdbCi.getString("label"); +// ciId = cmdbCi.getLong("ciId"); +// } +// +// if (label == null || ciId == null) { +// return Collections.emptySet(); +// } +// Object component = PrivateApiComponentFactory.getInstance("neatlogic.module.cmdb.api.cientity.ListCiEntityDataForSelectApi"); +// Method method = component.getClass().getMethod("myDoService", JSONObject.class); +// JSONObject param = new JSONObject(); +// param.put("ciId", ciId); +// param.put("label", label); +// param.put("defaultValue", new ArrayList<>(valueMap.keySet())); +// Object resultObj = method.invoke(component, param); +// if (resultObj != null) { +// JSONObject result = JSON.parseObject(JSON.toJSONString(resultObj)); +// JSONArray dataList = result.getJSONArray("tbodyList"); +// if (CollectionUtils.isNotEmpty(dataList)) { +// for (Map.Entry entry : valueMap.entrySet()) { +// String key = entry.getKey(); +// for (int i = 0; i < dataList.size(); i++) { +// JSONObject data = dataList.getJSONObject(i); +// String value = data.getString("value"); +// if (Objects.equals(key, value)) { +// valueMap.put(value, value); +// } +// } +// if (StringUtils.isBlank(entry.getValue())) { +// valueMap.remove(key); +// } +// } +// } +// } +// } catch (Exception ex) { +// Throwable target = ex; +// //如果是反射抛得异常,则需循环拆包,把真实得异常类找出来 +// while (target instanceof InvocationTargetException) { +// target = ((InvocationTargetException) target).getTargetException(); +// } +// String error = ex.getMessage() == null ? ExceptionUtils.getStackTrace(ex) : ex.getMessage(); +// logger.error(error); +// } + for (Map.Entry entry : valueMap.entrySet()) { + valueMap.put(entry.getKey(), entry.getKey()); } return Collections.emptySet(); } -- Gitee