From 04877ecc6eb6b082aace17df5ebcd5cc1fda85db Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Tue, 27 Feb 2024 19:31:34 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E6=B5=81=E7=A8=8B=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1081086489100288]流程管理-流程导入异常 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1081086489100288 --- .../handler/ProcessImportExportHandler.java | 81 ++++++++++++++++--- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/src/main/java/neatlogic/module/process/importexport/handler/ProcessImportExportHandler.java b/src/main/java/neatlogic/module/process/importexport/handler/ProcessImportExportHandler.java index 53c8fb264..d9de8de2c 100644 --- a/src/main/java/neatlogic/module/process/importexport/handler/ProcessImportExportHandler.java +++ b/src/main/java/neatlogic/module/process/importexport/handler/ProcessImportExportHandler.java @@ -2,12 +2,17 @@ package neatlogic.module.process.importexport.handler; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.exception.core.ApiRuntimeException; import neatlogic.framework.importexport.constvalue.FrameworkImportExportHandlerType; +import neatlogic.framework.importexport.core.ImportExportHandler; import neatlogic.framework.importexport.core.ImportExportHandlerBase; +import neatlogic.framework.importexport.core.ImportExportHandlerFactory; import neatlogic.framework.importexport.core.ImportExportHandlerType; import neatlogic.framework.importexport.dto.ImportExportBaseInfoVo; import neatlogic.framework.importexport.dto.ImportExportPrimaryChangeVo; import neatlogic.framework.importexport.dto.ImportExportVo; +import neatlogic.framework.importexport.exception.DependencyNotFoundException; +import neatlogic.framework.importexport.exception.ImportExportHandlerNotFoundException; import neatlogic.framework.process.constvalue.ProcessImportExportHandlerType; import neatlogic.framework.process.dto.ProcessVo; import neatlogic.framework.process.exception.process.ProcessNotFoundException; @@ -20,10 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.zip.ZipOutputStream; @Component @@ -412,6 +414,7 @@ public class ProcessImportExportHandler extends ImportExportHandlerBase { JSONObject ciEntityConfig = stepConfig.getJSONObject("ciEntityConfig"); JSONArray configList = ciEntityConfig.getJSONArray("configList"); if (CollectionUtils.isNotEmpty(configList)) { + List messageList = new ArrayList<>(); for (int j = 0; j < configList.size(); j++) { JSONObject configObj = configList.getJSONObject(j); if (MapUtils.isEmpty(configObj)) { @@ -425,15 +428,71 @@ public class ProcessImportExportHandler extends ImportExportHandlerBase { if (ciId == null) { continue; } - if (action == IMPORT) { - Object newPrimaryKey = getNewPrimaryKey(FrameworkImportExportHandlerType.CMDB_CI, ciId, primaryChangeList); - if (newPrimaryKey != null) { - configObj.put("ciId", newPrimaryKey); - } - } else if (action == EXPORT) { - doExportData(FrameworkImportExportHandlerType.CMDB_CI, ciId, dependencyList, zipOutputStream); +// if (action == IMPORT) { +// Object newPrimaryKey = getNewPrimaryKey(FrameworkImportExportHandlerType.CMDB_CI, ciId, primaryChangeList); +// if (newPrimaryKey != null) { +// configObj.put("ciId", newPrimaryKey); +// } +// } else if (action == EXPORT) { +// doExportData(FrameworkImportExportHandlerType.CMDB_CI, ciId, dependencyList, zipOutputStream); +// } + String ciName = configObj.getString("ciName"); + String ciLabel = configObj.getString("ciLabel"); + // 配置项模型不做一起导入导出,只检查其是否存在 + ImportExportHandler importExportHandler = ImportExportHandlerFactory.getHandler(FrameworkImportExportHandlerType.CMDB_CI.getValue()); + if (importExportHandler == null) { + throw new ImportExportHandlerNotFoundException(FrameworkImportExportHandlerType.CMDB_CI.getText()); + } + ImportExportBaseInfoVo importExportBaseInfoVo = new ImportExportBaseInfoVo(); + importExportBaseInfoVo.setPrimaryKey(ciId); + importExportBaseInfoVo.setName(ciLabel + "(" + ciName + ")"); + importExportBaseInfoVo.setType(FrameworkImportExportHandlerType.CMDB_CI.getValue()); + + try { + importExportHandler.checkIsExists(importExportBaseInfoVo); + } catch (ApiRuntimeException e) { + messageList.add(e.getMessage()); } } + if (CollectionUtils.isNotEmpty(messageList)) { + throw new DependencyNotFoundException(messageList); + } + } + } else if (Objects.equals(handler, "dataconversion")) { + JSONObject ciEntityConfig = stepConfig.getJSONObject("dataConversionConfig"); + JSONArray configList = ciEntityConfig.getJSONArray("configList"); + if (CollectionUtils.isNotEmpty(configList)) { + List messageList = new ArrayList<>(); + for (int j = 0; j < configList.size(); j++) { + JSONObject configObj = configList.getJSONObject(j); + if (MapUtils.isEmpty(configObj)) { + continue; + } + Long ciId = configObj.getLong("ciId"); + if (ciId == null) { + continue; + } + String ciName = configObj.getString("ciName"); + String ciLabel = configObj.getString("ciLabel"); + // 配置项模型不做一起导入导出,只检查其是否存在 + ImportExportHandler importExportHandler = ImportExportHandlerFactory.getHandler(FrameworkImportExportHandlerType.CMDB_CI.getValue()); + if (importExportHandler == null) { + throw new ImportExportHandlerNotFoundException(FrameworkImportExportHandlerType.CMDB_CI.getText()); + } + ImportExportBaseInfoVo importExportBaseInfoVo = new ImportExportBaseInfoVo(); + importExportBaseInfoVo.setPrimaryKey(ciId); + importExportBaseInfoVo.setName(ciLabel + "(" + ciName + ")"); + importExportBaseInfoVo.setType(FrameworkImportExportHandlerType.CMDB_CI.getValue()); + + try { + importExportHandler.checkIsExists(importExportBaseInfoVo); + } catch (ApiRuntimeException e) { + messageList.add(e.getMessage()); + } + } + if (CollectionUtils.isNotEmpty(messageList)) { + throw new DependencyNotFoundException(messageList); + } } } else if (Objects.equals(handler, "eoa")) { JSONObject eoaConfig = stepConfig.getJSONObject("eoaConfig"); -- Gitee