diff --git a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar index 70606f64..c8c21699 100644 Binary files a/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar and b/com.actionsoft.apps.coe.pal.datamigration/lib/com.actionsoft.apps.coe.pal.datamigration.jar differ diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java index 06324030..f0c80da8 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/constant/ArisConstant.java @@ -15,4 +15,6 @@ public class ArisConstant { public final static String IMPORT_LOG_FILE_WARN = "warnErrImport.log";// 错误&警告日志,单独记录错误&警告日志,同时详细日志中也有记录 + public final static String ARIS_ROOT_PATH = "\\伊利集团业务流程管理平台"; + } diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/ArisXmlUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/ArisXmlUtil.java new file mode 100644 index 00000000..8f3d801a --- /dev/null +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/util/ArisXmlUtil.java @@ -0,0 +1,33 @@ +package com.actionsoft.apps.coe.pal.datamigration.aris.util; + +import com.actionsoft.apps.coe.pal.datamigration.aris.model.ModelModel; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ArisXmlUtil { + + /** + * 获取aris文件中的epc模型列表 + * @param modelMap 解析出的模型map + * @param sortByPath 是否按照路径进行排序 + * @return + */ + public static List getArisEpcModelList(Map modelMap, boolean sortByPath) { + List result = new ArrayList<>(); + for (Map.Entry entry : modelMap.entrySet()) { + ModelModel arisModel = entry.getValue(); + if ("MT_EEPC".equals(arisModel.getType())) { + result.add(arisModel); + } + } + if (sortByPath) { + // 按照路径排序 + result.sort((a1, a2)-> { + return a1.getModelPath().compareTo(a2.getModelPath()); + }); + } + return result; + } +} diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java index 945073f2..cffa7f1b 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportRun.java @@ -1,8 +1,10 @@ package com.actionsoft.apps.coe.pal.datamigration.aris.web; import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant; import com.actionsoft.apps.coe.pal.datamigration.aris.mapping.ModelMappingAPIManager; import com.actionsoft.apps.coe.pal.datamigration.aris.model.*; +import com.actionsoft.apps.coe.pal.datamigration.aris.util.ArisXmlUtil; import com.actionsoft.apps.coe.pal.datamigration.constant.Constant; import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache; import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel; @@ -126,25 +128,15 @@ public class ArisXmlImportRun { String rolefolderId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);// 创建/获取角色文件夹ID,作为角色的顶级文件夹 // 获取所有PAL EPC的模型 - Map palArisPropValMap = getPalRepositoryXmlPathMap(wsId); + Map palArisPropValMap = ProcessUtil.getPalRepositoryArisPathMap(wsId); - List arisEpcModelList = new ArrayList<>(); - for (Map.Entry entry : modelMap.entrySet()) { - ModelModel arisModel = entry.getValue(); - if ("MT_EEPC".equals(arisModel.getType())) { - arisEpcModelList.add(arisModel); - } - } - // 按照路径排序 - arisEpcModelList.sort((a1, a2)-> { - return a1.getModelPath().compareTo(a2.getModelPath()); - }); + // 获取所有ARISEPC的模型 + List arisEpcModelList = ArisXmlUtil.getArisEpcModelList(modelMap, true); - String arisRootPath = "\\伊利集团业务流程管理平台"; int totalCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount(); for (int i = 0; i < arisEpcModelList.size(); i++) { ModelModel arisModel = arisEpcModelList.get(i); - String arisPath = arisRootPath + arisModel.getModelPath(); + String arisPath = ArisConstant.ARIS_ROOT_PATH + arisModel.getModelPath(); int importingCount = i + 1;// 当前是导入的第几个 LogRealTimeCountCache.getCache().get(logId).setImportingCount(importingCount);// 当前记录缓存 // 当前正在导入的流程全部日志记录,方便对照 @@ -163,22 +155,19 @@ public class ArisXmlImportRun { continue; } - // PAL过程链图与ARIS流程进行匹配 + // PAL过程链图与ARIS流程进行匹配,只进行路径匹配 boolean flag = false; PALRepositoryModel palModel = null; for (Map.Entry entry : palArisPropValMap.entrySet()) { if (arisPath.equals(entry.getValue())) { String palId = entry.getKey(); - PALRepositoryModel plModel = PALRepositoryCache.getCache().get(palId); - if (arisModel.getName().trim().equals(plModel.getName().trim())) { - palModel = plModel; - flag = true; - // 匹配成功不记录到警告日志中 - LogUtil.appendLog(Constant.LOG_END + "ARIS流程" + "[" + arisModel.getName() + "]与PAL过程链图" + "[" + palModel.getName() + "]匹配", simpleLogFile, fullLogFile); - LogUtil.appendLog(Constant.LOG_DESC + "ARIS流程所属路径:" + arisPath, simpleLogFile, fullLogFile); - LogUtil.appendLog(Constant.LOG_DESC + "PAL过程链图所属路径:" + ProcessUtil.getRepositoryPath(palModel.getId()), simpleLogFile, fullLogFile); - break; - } + palModel = PALRepositoryCache.getCache().get(palId); + flag = true; + // 匹配成功不记录到警告日志中 + LogUtil.appendLog(Constant.LOG_END + "ARIS流程" + "[" + arisModel.getName() + "]与PAL过程链图" + "[" + palModel.getName() + "]匹配", simpleLogFile, fullLogFile); + LogUtil.appendLog(Constant.LOG_DESC + "ARIS流程所属路径:" + arisPath, simpleLogFile, fullLogFile); + LogUtil.appendLog(Constant.LOG_DESC + "PAL过程链图所属路径:" + ProcessUtil.getRepositoryPath(palModel.getId()), simpleLogFile, fullLogFile); + break; } } // 未匹配成功 @@ -395,38 +384,6 @@ public class ArisXmlImportRun { return timeMsg; } - - /** - * 获取所有epc模型,key:epc-id,value:arisUrl - * @return - */ - private Map getPalRepositoryXmlPathMap(String wsId) { - Map propValMap = new HashMap<>(); - Iterator iterator = PALRepositoryCache.getByWsId(wsId); - List list = new ArrayList<>(); - - while (iterator.hasNext()) { - // 无多版本情况,不考虑 - PALRepositoryModel model = iterator.next(); - if (Constant.PROCESS_EPC.equals(model.getMethodId())) { - list.add(model); - } - } - PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao(); - List propertyModels = dao.queryByWsId(wsId); - propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList()); - Map map = new HashMap<>(); - for (PALRepositoryPropertyModel prop : propertyModels) { - map.put(prop.getPlId(), prop.getPropertyValue().replace(" ", ""));// 去除空格 - } - for (PALRepositoryModel model : list) { - if (map.containsKey(model.getId())) { - propValMap.put(model.getId(), map.get(model.getId())); - } - } - return propValMap; - } - /** * 校验和创建角色模型文件夹 * @param coeProcessLevel diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java index f4c6b25b..b5a1ca5a 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/aris/web/ArisXmlImportWeb.java @@ -3,17 +3,21 @@ package com.actionsoft.apps.coe.pal.datamigration.aris.web; import com.actionsoft.apps.coe.pal.constant.CoEConstant; import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant; import com.actionsoft.apps.coe.pal.datamigration.aris.model.*; +import com.actionsoft.apps.coe.pal.datamigration.aris.util.ArisXmlUtil; import com.actionsoft.apps.coe.pal.datamigration.aris.util.XMLUtil; import com.actionsoft.apps.coe.pal.datamigration.constant.Constant; import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache; import com.actionsoft.apps.coe.pal.datamigration.log.model.LogModel; import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel; import com.actionsoft.apps.coe.pal.datamigration.util.LogUtil; +import com.actionsoft.apps.coe.pal.datamigration.util.ProcessUtil; import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.bpms.commons.mvc.view.ActionWeb; import com.actionsoft.bpms.commons.mvc.view.ResponseObject; @@ -223,14 +227,83 @@ public class ArisXmlImportWeb extends ActionWeb { } LogUtil.appendLog(Constant.LOG_END + "解析XML文件内容", simpleLogFile, fullLogFile); - // 统计epc流程图的个数,用以进度展示 - int totalCount = countProcessMainInfo(handleWeb.modelMap); + // 获取所有aris xml epc模型列表 + List arisEpcModelList = ArisXmlUtil.getArisEpcModelList(handleWeb.modelMap, true); + + // 统计aris xml epc流程图的个数,用以进度展示 + int totalCount = arisEpcModelList.size(); if (totalCount == 0) { msg = Constant.LOG_ERROR + "上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC) + "," + Constant.IMPORT_STOP_MSG; updateErrLog(msg, msg); ro.err("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC)); return ro.toString(); } + + // 统计Aris xml 路径是否有重复 + + Map> arisEpcPathMap = new HashMap<>(); + for (ModelModel model : arisEpcModelList) { + if (!arisEpcPathMap.containsKey(model.getModelPath())) { + arisEpcPathMap.put(model.getModelPath(), new HashSet<>()); + } + arisEpcPathMap.get(model.getModelPath()).add(model.getId()); + } + + LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][校验ARIS EPC流程路径唯一性]Aris xml EPC流程所属目录唯一性************", simpleLogFile, fullLogFile); + + boolean flag = false; + for (Map.Entry> entry : arisEpcPathMap.entrySet()) { + if (entry.getValue().size() > 1) { + Set modelIds = entry.getValue(); + for (String arisModelId : modelIds) { + ModelModel model = handleWeb.modelMap.get(arisModelId); + String name = model.getName(); + String path = ArisConstant.ARIS_ROOT_PATH + model.getModelPath(); + LogUtil.appendLog(Constant.LOG_ERROR + "ARIS XML中流程[" + name + "]所属目录重复,所属目录[" + path + "]", simpleLogFile, fullLogFile, warnLogFile); + } + flag = true; + } + } + if (flag) { + ro.err("Aris xml文件中存在多个流程同属于一个架构路径,详情查看日志"); + return ro.toString(); + } + LogUtil.appendLog(Constant.LOG_END + "[执行阶段][校验Aris EPC流程路径唯一性]", simpleLogFile, fullLogFile); + + // 校验pal aris地址属性路径是否存在重复问题 + // 获取所有PAL EPC的模型 + Map palArisPropValMap = ProcessUtil.getPalRepositoryArisPathMap(wsId); + Map> palEpcArisPathMap = new HashMap<>(); + + for (Map.Entry entry : palArisPropValMap.entrySet()) { + if (!palEpcArisPathMap.containsKey(entry.getValue())) { + palEpcArisPathMap.put(entry.getValue(), new HashSet<>()); + } + palEpcArisPathMap.get(entry.getValue()).add(entry.getKey()); + } + + LogUtil.appendLog("\n" + Constant.LOG_START + "************[执行阶段][校验PAL EPC文件属性ARIS地址唯一性]PAL EPC流程文件属性ARIS地址唯一性************", simpleLogFile, fullLogFile); + + flag = false; + for (Map.Entry> entry : palEpcArisPathMap.entrySet()) { + if (entry.getValue().size() > 1) { + Set ids = entry.getValue(); + for (String id : ids) { + PALRepositoryModel plModel = PALRepositoryCache.getCache().get(id); + String name = plModel.getName(); + String path = ProcessUtil.getRepositoryPath(id); + LogUtil.appendLog(Constant.LOG_ERROR + "PAL中流程[" + name + "][V" + plModel.getVersion() + "]文件属性ARIS地址属性内容重复,属性内容[" + path + "]", simpleLogFile, fullLogFile, warnLogFile); + } + flag = true; + } + } + if (flag) { + ro.err("PAL 文件属性ARIS地址内容存在重复,详情查看日志"); + return ro.toString(); + } + LogUtil.appendLog(Constant.LOG_END + "[执行阶段][校验PAL EPC文件属性ARIS地址唯一性]", simpleLogFile, fullLogFile); + + // 存储缓存,导入计数 LogRealTimeCountModel countModel = new LogRealTimeCountModel(); countModel.setTotalCount(totalCount); diff --git a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java index 39b2ddfa..3b7ac0d1 100644 --- a/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java +++ b/com.actionsoft.apps.coe.pal.datamigration/src/com/actionsoft/apps/coe/pal/datamigration/util/ProcessUtil.java @@ -2,13 +2,17 @@ package com.actionsoft.apps.coe.pal.datamigration.util; import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.constant.CoEConstant; +import com.actionsoft.apps.coe.pal.datamigration.constant.Constant; import com.actionsoft.apps.coe.pal.pal.method.PALMethodManager; import com.actionsoft.apps.coe.pal.pal.method.cache.PALMethodCache; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; import com.actionsoft.apps.lifecycle.api.AppsAPIManager; import com.actionsoft.apps.resource.AppContext; @@ -19,6 +23,7 @@ import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang.StringUtils; import java.util.*; +import java.util.stream.Collectors; public class ProcessUtil { @@ -213,5 +218,37 @@ public class ProcessUtil { } return StringUtils.join(list, "\\"); } + + /** + * 获取所有epc模型,key:epc-id,value:arisUrl + * @param wsId + * @return + */ + public static Map getPalRepositoryArisPathMap(String wsId) { + Map propValMap = new HashMap<>(); + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + List list = new ArrayList<>(); + + while (iterator.hasNext()) { + // 无多版本情况,不考虑 + PALRepositoryModel model = iterator.next(); + if (Constant.PROCESS_EPC.equals(model.getMethodId())) { + list.add(model); + } + } + PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao(); + List propertyModels = dao.queryByWsId(wsId); + propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList()); + Map map = new HashMap<>(); + for (PALRepositoryPropertyModel prop : propertyModels) { + map.put(prop.getPlId(), prop.getPropertyValue().replace(" ", ""));// 去除空格 + } + for (PALRepositoryModel model : list) { + if (map.containsKey(model.getId())) { + propValMap.put(model.getId(), map.get(model.getId())); + } + } + return propValMap; + } }