Aris流程数据迁移日志记录处理

This commit is contained in:
446052889@qq.com 2022-07-02 13:33:09 +08:00
parent 7d9d5ed35d
commit 13b80bf501
13 changed files with 465 additions and 277 deletions

View File

@ -1 +1 @@
CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME VARCHAR(100), FILLPATH VARCHAR(500), LOGPATH VARCHAR(500), CREATEUSER VARCHAR(20),CREATEUSERNAME VARCHAR(20),CREATEDATE DATETIME, STARTDATE DATETIME, ENDTIME DATETIME, RESULTSTATUS SMALLINT(1), MAININFO VARCHAR(500), EXT1 VARCHAR(64),EXT2 VARCHAR(128),EXT3 VARCHAR(255),EXT4 VARCHAR(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID)); CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME VARCHAR(100), FILEPATH VARCHAR(500), LOGPATH VARCHAR(500), CREATEUSER VARCHAR(20),CREATEUSERNAME VARCHAR(20),CREATEDATE DATETIME, STARTDATE DATETIME, ENDDATE DATETIME, RESULTSTATUS SMALLINT(1), MAININFO VARCHAR(500), EXT1 VARCHAR(64),EXT2 VARCHAR(128),EXT3 VARCHAR(255),EXT4 VARCHAR(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID));

View File

@ -1 +1 @@
CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME NVARCHAR2(100), FILLPATH NVARCHAR2(500), LOGPATH NVARCHAR2(500), CREATEUSER NVARCHAR2(20),CREATEUSERNAME NVARCHAR2(20), CREATEDATE DATE, STARTDATE DATE, ENDTIME DATE, RESULTSTATUS NUMBER(1), MAININFO NVARCHAR2(500), EXT1 NVARCHAR2(64),EXT2 NVARCHAR2(128),EXT3 NVARCHAR2(255),EXT4 NVARCHAR2(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID)); CREATE TABLE APP_ACT_COE_PAL_DATAM_LOG(ID CHAR(36) NOT NULL ,WSID CHAR(36),FILENAME NVARCHAR2(100), FILEPATH NVARCHAR2(500), LOGPATH NVARCHAR2(500), CREATEUSER NVARCHAR2(20),CREATEUSERNAME NVARCHAR2(20), CREATEDATE DATE, STARTDATE DATE, ENDDATE DATE, RESULTSTATUS NUMBER(1), MAININFO NVARCHAR2(500), EXT1 NVARCHAR2(64),EXT2 NVARCHAR2(128),EXT3 NVARCHAR2(255),EXT4 NVARCHAR2(255) ,CONSTRAINT APP_ACT_COE_PAL_DATAM_LOG_PK PRIMARY KEY (ID));

View File

@ -1,9 +1,13 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.web; 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.mapping.ModelMappingAPIManager; 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.model.*;
import com.actionsoft.apps.coe.pal.datamigration.cache.DataMigrationCache;
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant; 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;
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.datamigration.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodAttributeModel; 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.PALRepositoryAPIManager;
@ -25,8 +29,10 @@ import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelI
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilString; import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSException; import com.actionsoft.exception.AWSException;
import com.actionsoft.i18n.I18nRes;
import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -49,8 +55,11 @@ public class ArisXmlImportRun {
private File warnLogFile; private File warnLogFile;
private String filePath; private String filePath;
private String fileName; private String fileName;
private long startTime;
public ArisXmlImportRun(UserContext uc, String wsId, String logId, String logPath, File simpleLogFile, File fullLogFile, File warnLogFile, String filePath, String fileName) { private long endTime;
public ArisXmlImportRun(UserContext uc, String wsId, String logId, String logPath, File simpleLogFile, File fullLogFile, File warnLogFile, String filePath, String fileName, long startTime) {
this.uc = uc; this.uc = uc;
this.wsId = wsId; this.wsId = wsId;
this.logId = logId; this.logId = logId;
@ -60,6 +69,7 @@ public class ArisXmlImportRun {
this.warnLogFile = warnLogFile; this.warnLogFile = warnLogFile;
this.filePath = filePath; this.filePath = filePath;
this.fileName = fileName; this.fileName = fileName;
this.startTime = startTime;
} }
public void execute(ArisXmlHandleWeb handleWeb) { public void execute(ArisXmlHandleWeb handleWeb) {
@ -79,46 +89,88 @@ public class ArisXmlImportRun {
Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();// 属性存储 Map<String, Map<String, JSONObject>> methodAttrsMap = new HashMap<>();// 属性存储
// 获取所有IT系统图并查询所有IT系统形状
Map<String, JSONObject> itShapeMap = new HashMap<>();
Set<String> ids = new HashSet<>();
List<PALRepositoryModel> itModels = new ArrayList<>();
PALRepositoryCache.getAllChildrenModelsByPid(wsId, "itsystem", itModels, ids);
for (PALRepositoryModel itModel : itModels) {
String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, itModel.getId());
List<JSONObject> list = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.getShapeJsonToJsonObject(definition);
for (JSONObject shape: list) {
JSONObject obj = new JSONObject();
obj.put("shapeId", shape.getString("id"));
obj.put("plId", itModel.getId());
obj.put("shapeName", shape.getString("text"));
itShapeMap.put(shape.getString("text"), obj);
}
}
PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
// 存储匹配到与未匹配到的模型信息 try {
List<ModelModel> matchModels = new ArrayList<>(); // 获取所有IT系统图并查询所有IT系统形状
List<ModelModel> unMatchModels = new ArrayList<>(); Map<String, JSONObject> itShapeMap = new HashMap<>();
// 存储已经匹配上但是文件里已经有内容可能导入重复的模型信息 Set<String> ids = new HashSet<>();
List<ModelModel> repeatModels = new ArrayList<>(); List<PALRepositoryModel> itModels = new ArrayList<>();
// 存储不包含图形的流程无任何形状的流程不进行导入 PALRepositoryCache.getAllChildrenModelsByPid(wsId, "itsystem", itModels, ids);
List<ModelModel> currentModelNoShape = new ArrayList<>(); for (PALRepositoryModel itModel : itModels) {
for (Map.Entry<String, ModelModel> entry : modelMap.entrySet()) { String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, itModel.getId());
ModelModel arisModel = entry.getValue(); List<JSONObject> list = com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil.getShapeJsonToJsonObject(definition);
// 创建角色模型 for (JSONObject shape: list) {
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId()); JSONObject obj = new JSONObject();
if (objOccModels == null || objOccModels.size() == 0) { obj.put("shapeId", shape.getString("id"));
currentModelNoShape.add(arisModel); obj.put("plId", itModel.getId());
printMsg("流程" + arisModel.getName() + arisModel.getId() + "无任何模型,导入忽略"); obj.put("shapeName", shape.getString("text"));
continue; itShapeMap.put(shape.getString("text"), obj);
}
} }
// 匹配模型 String rolefolderId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);// 创建/获取角色文件夹ID作为角色的顶级文件夹
PALRepositoryModel palModel = matchPalModel(arisModel, wsId);
if (palModel != null) { // 获取所有PAL EPC的模型
matchModels.add(arisModel); Map<String, String> palArisPropValMap = getPalRepositoryXmlPathMap(wsId);
List<ModelModel> arisEpcModelList = new ArrayList<>();
for (Map.Entry<String, ModelModel> 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());
});
String arisRootPath = "\\伊利集团业务流程管理平台";
int totalArisCount = LogRealTimeCountCache.getCache().get(logId).getTotalCount();
for (int i = 0; i < arisEpcModelList.size(); i++) {
ModelModel arisModel = arisEpcModelList.get(i);
String arisPath = arisRootPath + arisModel.getModelPath();
int importingCount = i + 1;// 当前是导入的第几个
LogRealTimeCountCache.getCache().get(logId).setImportingCount(importingCount);// 当前记录缓存
// 当前正在导入的流程全部日志记录方便对照
LogUtil.appendLog("-----------------【" + importingCount + "/" + totalArisCount + "】-----------------", simpleLogFile, fullLogFile, warnLogFile);
// 校验Aris是否空模型
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId());
if (objOccModels == null || objOccModels.size() == 0) {
// 空模型当作警告处理全部记录
LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "" + arisModel.getName() + "】内容为空,导入忽略", simpleLogFile, fullLogFile, warnLogFile);
LogUtil.appendLog(Constant.LOG_DESC + "该流程所属路径:" + arisPath);
LogRealTimeCountCache.getCache().get(logId).setArisBlankCount(LogRealTimeCountCache.getCache().get(logId).getArisBlankCount() + 1);
continue;
}
// PAL流程与Aris流程进行匹配
boolean flag = false;
PALRepositoryModel palModel = null;
for (Map.Entry<String, String> 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_SUCCESS + "Aris流程" + "" + arisModel.getName() + "】与PAL流程" + "" + palModel.getName() + "", simpleLogFile, fullLogFile);
LogUtil.appendLog(Constant.LOG_DESC + "Aris流程所属路径" + arisPath);
LogUtil.appendLog(Constant.LOG_DESC + "PAL流程所属路径" + ProcessUtil.getRepositoryPath(palModel.getId()));
break;
}
}
}
// 未匹配成功
if (!flag) {
LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "" + arisModel.getName() + "】未匹配到PAL流程", simpleLogFile, fullLogFile, warnLogFile);
LogUtil.appendLog(Constant.LOG_DESC + "Aris流程所属路径" + arisPath, simpleLogFile, fullLogFile, warnLogFile);
LogRealTimeCountCache.getCache().get(logId).setMatchFieldCount(LogRealTimeCountCache.getCache().get(logId).getMatchFieldCount() + 1);
continue;
}
// 判断计划导入到的PAL流程是否已经存在数据
String plId = palModel.getId(); String plId = palModel.getId();
// 模型是否可导入 // 模型是否可导入
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plId, 0); BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(plId, 0);
@ -132,17 +184,17 @@ public class ArisXmlImportRun {
JSONObject definition = JSONObject.parseObject(define); JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements"); JSONObject elements = definition.getJSONObject("elements");
if (elements != null && !elements.isEmpty()) { if (elements != null && !elements.isEmpty()) {
// 导入模型已存在数据不允许导入 todo LogUtil.appendLog(Constant.LOG_WARNING + "匹配到的PAL流程模型已存在数据不允许导入忽略", simpleLogFile, fullLogFile, warnLogFile);
repeatModels.add(arisModel); LogRealTimeCountCache.getCache().get(logId).setPalExistsCount(LogRealTimeCountCache.getCache().get(logId).getPalExistsCount() + 1);
printMsg("[" + arisModel.getName() + "] 导入流程模型已存在数据,不允许导入,对同名角色模型进行忽略处理");
continue; continue;
} }
String rolefolderId = checkAndCreatePalRoleFolderModel(coeProcessLevel, wsId);// 创建/获取角色文件夹ID作为角色的顶级文件夹 LogUtil.appendLog(Constant.LOG_START + "导入Aris流程" + "" + arisModel.getName() + "", simpleLogFile, fullLogFile, warnLogFile);
Map<String, String> arisFunIdRelationPalRoleMap = new HashMap<>();// aris功能模型与aris角色模型的id映射keyaris fun shape idvaluepal role id Map<String, String> arisFunIdRelationPalRoleMap = new HashMap<>();// aris功能模型与aris角色模型的id映射keyaris fun shape idvaluepal role id
Map<String, String> palRoleIdRelationNameMap = new HashMap<>();// key pal role shape id ,value:pal role shape text Map<String, String> palRoleIdRelationNameMap = new HashMap<>();// key pal role shape id ,value:pal role shape text
// 创建角色模型和角色元素并且获取aris角色与pal角色映射关系 // 创建角色模型和角色元素并且获取aris角色与pal角色映射关系
String roleMdoelId = createRoleModelAndElements(coeProcessLevel, rolefolderId, wsId, currentModelNoShape, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, objDefLinkerMap, arisFunIdRelationPalRoleMap, methodAttrsMap, palRoleIdRelationNameMap); String roleMdoelId = createRoleModelAndElements(coeProcessLevel, rolefolderId, wsId, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, objDefLinkerMap, arisFunIdRelationPalRoleMap, methodAttrsMap, palRoleIdRelationNameMap);
// 存储当前模型下ARIS图形ID与PAL图形ID映射关系 // 存储当前模型下ARIS图形ID与PAL图形ID映射关系
Map<String, String> idRelationMap = new HashMap<>(); Map<String, String> idRelationMap = new HashMap<>();
@ -160,7 +212,8 @@ public class ArisXmlImportRun {
// 处理流程关联属性IT系统 // 处理流程关联属性IT系统
this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap, objDefLinkerMap, itShapeMap); this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap, objDefLinkerMap, itShapeMap);
this.handleProcessAttrLeadOrRearProcess(wsId, currentModelNoShape, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap); // 前后置流程处理
this.handleProcessAttrLeadOrRearProcess(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap);
// 增加其他默认的属性值默认为空 by孙连辉 20220626 // 增加其他默认的属性值默认为空 by孙连辉 20220626
this.handleShapeDefaultAttr(wsId, palModel, newElements, methodAttrsMap); this.handleShapeDefaultAttr(wsId, palModel, newElements, methodAttrsMap);
@ -172,13 +225,89 @@ public class ArisXmlImportRun {
// 保存文件 // 保存文件
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作
} else { // 记录结束日志
unMatchModels.add(arisModel); endTime = System.currentTimeMillis();
} Timestamp endDate = new Timestamp(System.currentTimeMillis());
}
LogRealTimeCountCache.getCache().get(logId).setSuccessCount(LogRealTimeCountCache.getCache().get(logId).getSuccessCount() + 1);
LogUtil.appendLog(Constant.LOG_END + "保存PAL流程【" + palModel.getName() + "】的形状和连线", simpleLogFile, fullLogFile);
LogUtil.appendLog(Constant.LOG_END + "导入Aris流程" + "" + arisModel.getName() + "", simpleLogFile, fullLogFile, warnLogFile);
}
Timestamp endDate = new Timestamp(System.currentTimeMillis());
LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
String takeTimeText = takeTime(endTime, startTime);
String resultMsg = "导入完成,总耗时【" + takeTimeText + "ArisXML流程总共【" + model.getTotalCount() + "】,导入成功【" + model.getSuccessCount() + "】条,导入失败【" + (model.getTotalCount() - model.getSuccessCount())
+ "】条PAL已存在的数据【" + model.getPalExistsCount() + "】条Aris流程为空模型的数据【" + model.getArisBlankCount() + "】条Aris与PAL匹配失败的数据【" + model.getMatchFieldCount() + "】条)";
LogUtil.appendLog(Constant.LOG_END + "" + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
LogUtil.appendLog("Aris XML流程导入 End " + UtilDate.datetimeFormat(endDate), simpleLogFile, fullLogFile, warnLogFile);
LogUtil.appendLog("--------------------------------", simpleLogFile, fullLogFile, warnLogFile);
} catch (Exception e) {
e.printStackTrace();
// 记录结束日志
endTime = System.currentTimeMillis();
Timestamp endDate = new Timestamp(System.currentTimeMillis());
LogRealTimeCountModel model = LogRealTimeCountCache.getCache().get(logId);
String takeTimeText = takeTime(endTime, startTime);
String resultMsg = "导入失败,报错信息:" + e.getMessage() + ",总耗时【" + takeTimeText + "】,导入成功【" + model.getSuccessCount() + "】条,导入失败【" + (model.getTotalCount() - model.getSuccessCount())
+ "】条PAL已存在的数据【" + model.getPalExistsCount() + "】条Aris流程为空模型的数据【" + model.getArisBlankCount() + "】条Aris与PAL匹配失败的数据【" + model.getMatchFieldCount() + "】条)";
LogUtil.updateLog(logId, endDate, Constant.LOG_RESULT_StATUS_ERROR, resultMsg);
LogUtil.appendLog(Constant.LOG_ERROR + "" + resultMsg, simpleLogFile, fullLogFile, warnLogFile);
}
} }
/**
* 计算使用时间
* @param endTime
* @param startTime
* @return
*/
private String takeTime(long endTime, long startTime) {
long time = endTime - startTime;
String timeMsg = "";
if (time > 1000 * 60) {
timeMsg = "" + (time / 1000 / 60) + "】分钟";
} else if (time > 1000) {
timeMsg = "" + (time / 1000) + "】秒";
} else {
timeMsg = "" + time + "】毫秒";
}
return timeMsg;
}
/**
* 获取所有epc模型,key:epc-id,value:arisUrl
* @return
*/
private Map<String, String> getPalRepositoryXmlPathMap(String wsId) {
Map<String, String> propValMap = new HashMap<>();
Iterator<PALRepositoryModel> iterator = PALRepositoryCache.getByWsId(wsId);
List<PALRepositoryModel> 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<PALRepositoryPropertyModel> propertyModels = dao.queryByWsId(wsId);
propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList());
Map<String, String> map = new HashMap<>();
for (PALRepositoryPropertyModel prop : propertyModels) {
map.put(prop.getPlId(), prop.getPropertyValue());
}
for (PALRepositoryModel model : list) {
if (map.containsKey(model.getId())) {
propValMap.put(model.getId(), map.get(model.getId()));
}
}
return propValMap;
}
/** /**
* 校验和创建角色模型文件夹 * 校验和创建角色模型文件夹
@ -202,10 +331,10 @@ public class ArisXmlImportRun {
null, null, null, null, null, -1); null, null, null, null, null, -1);
coeProcessLevel.insert(defaultModel); coeProcessLevel.insert(defaultModel);
defaultModels.add(defaultModel); defaultModels.add(defaultModel);
printMsg("角色模型文件夹创建成功 " + defaultModel.getId()); LogUtil.appendLog(Constant.LOG_SUCCESS + "角色模型文件夹创建", simpleLogFile, fullLogFile);
return defaultModel.getId(); return defaultModel.getId();
} else { } else {
printMsg("角色模型文件夹已存在,不再重复创建"); LogUtil.appendLog(Constant.LOG_WARNING + "角色模型文件夹已存在,不再重复创建", simpleLogFile, fullLogFile, warnLogFile);
return defaultModels.get(0).getId(); return defaultModels.get(0).getId();
} }
} }
@ -218,6 +347,7 @@ public class ArisXmlImportRun {
* @param methodAttrsMap * @param methodAttrsMap
*/ */
private void handleShapeDefaultAttr(String wsId, PALRepositoryModel palModel, JSONObject elements, Map<String, Map<String, JSONObject>> methodAttrsMap) { private void handleShapeDefaultAttr(String wsId, PALRepositoryModel palModel, JSONObject elements, Map<String, Map<String, JSONObject>> methodAttrsMap) {
LogUtil.appendLog(Constant.LOG_START + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "" + palModel.getName() + "】中形状属性按照属性配置进行属性完善", simpleLogFile, fullLogFile);
for (String key : elements.keySet()) { for (String key : elements.keySet()) {
JSONObject shape = elements.getJSONObject(key); JSONObject shape = elements.getJSONObject(key);
if ("linker".equals(shape.getString("name"))) { if ("linker".equals(shape.getString("name"))) {
@ -253,6 +383,7 @@ public class ArisXmlImportRun {
for (String attrId : attrs.keySet()) { for (String attrId : attrs.keySet()) {
if (!attrIds.contains(attrId)) { if (!attrIds.contains(attrId)) {
JSONObject eleAttrObj = getDefaultAttrObj(attrs.getJSONObject(attrId)); JSONObject eleAttrObj = getDefaultAttrObj(attrs.getJSONObject(attrId));
LogUtil.appendLog(Constant.LOG_END + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "" + palModel.getName() + "】中形状【" + shape.getString("text") + "】完善【" + eleAttrObj.getString("name") + "】属性配置", simpleLogFile, fullLogFile);
attributesJsonArray.add(eleAttrObj); attributesJsonArray.add(eleAttrObj);
} }
} }
@ -260,6 +391,7 @@ public class ArisXmlImportRun {
} }
} }
} }
LogUtil.appendLog(Constant.LOG_END + "PAL" + I18nRes.findValue(CoEConstant.APP_ID, palModel.getMethodId()) + "" + palModel.getName() + "】中形状属性按照属性配置进行属性完善", simpleLogFile, fullLogFile);
} }
/** /**
@ -272,6 +404,7 @@ public class ArisXmlImportRun {
* @return * @return
*/ */
private JSONObject createShapeElement(String wsId, Map<String, String> idRelationMap, PALRepositoryModel palModel, ModelModel arisModel, Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, Map<String, ObjOccModel> objOccMap, Map<String, List<CxnOccModel>> cxnOccMap, Map<String, String> palShapeIdRelationArisOccIdMap) { private JSONObject createShapeElement(String wsId, Map<String, String> idRelationMap, PALRepositoryModel palModel, ModelModel arisModel, Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, Map<String, ObjOccModel> objOccMap, Map<String, List<CxnOccModel>> cxnOccMap, Map<String, String> palShapeIdRelationArisOccIdMap) {
LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + arisModel.getName() + "】相关形状", simpleLogFile, fullLogFile);
// aris中该模型所有形状 // aris中该模型所有形状
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId()); List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId());
int zindex = 1; int zindex = 1;
@ -307,6 +440,12 @@ public class ArisXmlImportRun {
} }
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeName); JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(shapeMethodId, shapeName);
// 定义位置大小
if (shape == null) {
// pal形状不存在记录日志
LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "" + arisModel.getName() + " 】的形状【 " + objDefModel.getName() + " 】形状类型在PAL中缺失忽略导入该形状", simpleLogFile, fullLogFile, warnLogFile);
continue;
}
String shapeId = UUIDGener.getObjectId(); String shapeId = UUIDGener.getObjectId();
palShapeIdRelationArisOccIdMap.put(shapeId, objOccModel.getId()); palShapeIdRelationArisOccIdMap.put(shapeId, objOccModel.getId());
idRelationMap.put(objOccModel.getId(), shapeId);// 记录形状aris形状id与pal形状id idRelationMap.put(objOccModel.getId(), shapeId);// 记录形状aris形状id与pal形状id
@ -315,9 +454,6 @@ public class ArisXmlImportRun {
if (objDefModel.getAttrData().containsKey("AT_PROC_CODE")) { if (objDefModel.getAttrData().containsKey("AT_PROC_CODE")) {
List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod()); List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_NUMBER.equals(item.getKey())).collect(Collectors.toList()); attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_NUMBER.equals(item.getKey())).collect(Collectors.toList());
if (attributeModels.size() == 0) {
throw new AWSException("请打开建模管理应用,查看当前【过程链】建模分类下是否存在【编号/" + Constant.METHOD_NUMBER + "】建模属性");
}
PALMethodAttributeModel attributeModel = attributeModels.get(0); PALMethodAttributeModel attributeModel = attributeModels.get(0);
JSONObject attrNumberObj = new JSONObject(); JSONObject attrNumberObj = new JSONObject();
attrNumberObj.put("value", objDefModel.getAttrData().getString("AT_PROC_CODE")); attrNumberObj.put("value", objDefModel.getAttrData().getString("AT_PROC_CODE"));
@ -342,16 +478,13 @@ public class ArisXmlImportRun {
} }
} }
} }
LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + palModel.getName() + "】的形状【" + shape.getString("text") + "】的编号属性内容【" + objDefModel.getAttrData().getString("AT_PROC_CODE") + "", fullLogFile);
} }
// 处理活动节点描述 --by shang // 处理活动节点描述 --by shang
if (objDefModel.getAttrData().containsKey("AT_DESC")) { if (objDefModel.getAttrData().containsKey("AT_DESC")) {
List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), "process", objDefMappingModel.getShapeMethod()); List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), "process", objDefMappingModel.getShapeMethod());
attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_DESC.equals(item.getKey())).collect(Collectors.toList()); attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_DESC.equals(item.getKey())).collect(Collectors.toList());
if (attributeModels.size() == 0) {
throw new AWSException("请打开建模管理应用,查看当前【过程链】建模分类下是否存在【活动描述/" + Constant.METHOD_DESC + "】建模属性");
}
PALMethodAttributeModel attributeModel = attributeModels.get(0); PALMethodAttributeModel attributeModel = attributeModels.get(0);
JSONObject attrDescObj = new JSONObject(); JSONObject attrDescObj = new JSONObject();
attrDescObj.put("value", objDefModel.getAttrData().getString("AT_DESC")); attrDescObj.put("value", objDefModel.getAttrData().getString("AT_DESC"));
@ -371,9 +504,6 @@ public class ArisXmlImportRun {
for (Object attribute : dataAttributes) { for (Object attribute : dataAttributes) {
JSONObject obj = (JSONObject) attribute; JSONObject obj = (JSONObject) attribute;
if (obj.containsKey("attributesJsonArray")) { if (obj.containsKey("attributesJsonArray")) {
// 处理图形上默认勾选的属性没有值的属性置空 --by shang
// List<PALMethodAttributeModel> allValidAndUseShapeAttributeModels = CoeDesignerShapeAPIManager.getInstance().getAllValidAndUseShapeAttributeModels(wsId, objDefMappingModel.getShapeMethod());
List<PALMethodAttributeModel> usedAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod()); List<PALMethodAttributeModel> usedAttributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAndUseAttributeModels(wsId, objDefMappingModel.getShapeMethod(), shapeName, objDefMappingModel.getShapeMethod());
usedAttributeModels.forEach(item -> { usedAttributeModels.forEach(item -> {
attrDescObj.put("id", item.getKey()); attrDescObj.put("id", item.getKey());
@ -385,19 +515,14 @@ public class ArisXmlImportRun {
} }
} }
} }
LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + palModel.getName() + "】的形状【" + shape.getString("text") + "】的描述属性内容【" + objDefModel.getAttrData().getString("AT_DESC") + "", fullLogFile);
} }
// 定义位置大小
if (shape == null) {
// pal形状不存在记录日志 todo
printMsg("pal没有对应形状定义");
continue;
}
if (shape.containsKey("attribute") && shape.getJSONObject("attribute").containsKey("editable") && !shape.getJSONObject("attribute").getBooleanValue("editable")) {// 不可编辑名称 if (shape.containsKey("attribute") && shape.getJSONObject("attribute").containsKey("editable") && !shape.getJSONObject("attribute").getBooleanValue("editable")) {// 不可编辑名称
} else {// 重命名名称 } else {// 重命名名称
String name = objDefMap.get(objOccModel.getDefId()).getName();// 形状名称 String name = objDefModel.getName();// 形状名称
shape.put("text", name); shape.put("text", name);
} }
@ -408,11 +533,10 @@ public class ArisXmlImportRun {
props.put("w", objOccModel.getW()); props.put("w", objOccModel.getW());
props.put("h", objOccModel.getH()); props.put("h", objOccModel.getH());
elements.put(shapeId, shape); elements.put(shapeId, shape);
LogUtil.appendLog(Constant.LOG_END + "创建PAL流程" + "" + palModel.getName() + " 】的形状【 " + shape.getString("text") + "", fullLogFile);
} else { } else {
// pal缺少对应的形状 // pal缺少对应的形状
printMsg("pal缺少对应的形状" + objDefModel.getName()); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程" + "" + arisModel.getName() + " 】的形状【" + objDefModel.getName() + "】在PAL中缺失忽略导入该形状", simpleLogFile, fullLogFile, warnLogFile);
System.out.println(objDefModel.getTypeNum() + "-" + objDefModel.getSymbolNum());
System.out.println(objDefMappingMap.containsKey(objDefModel.getTypeNum() + "-" + objDefModel.getSymbolNum()));
} }
} }
// 形状连线处理 // 形状连线处理
@ -442,12 +566,17 @@ public class ArisXmlImportRun {
to.put("y", positionModels.get(positionModels.size() - 1).getY()); to.put("y", positionModels.get(positionModels.size() - 1).getY());
linkerObj.put("to", to); linkerObj.put("to", to);
elements.put(linkerId, linkerObj); elements.put(linkerId, linkerObj);
String fromName = UtilString.isEmpty(elements.getJSONObject(from.getString("id")).getString("text")) ? elements.getJSONObject(from.getString("id")).getString("title") : elements.getJSONObject(from.getString("id")).getString("text");
String toName = UtilString.isEmpty(elements.getJSONObject(to.getString("id")).getString("text")) ? elements.getJSONObject(to.getString("id")).getString("title") : elements.getJSONObject(to.getString("id")).getString("text");
LogUtil.appendLog(Constant.LOG_END + "创建PAL流程" + "" + arisModel.getName() + " 】的形状连线,从【 " + fromName + " 】到【 " + toName + "", fullLogFile);
} else { } else {
// 不包含的连线 // 不包含的连线
} }
} }
} }
} }
LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + arisModel.getName() + "】相关形状/连线", simpleLogFile, fullLogFile);
return elements; return elements;
} }
@ -455,6 +584,7 @@ public class ArisXmlImportRun {
* 在现有输出的图形结构上转化输入 输出活动属性并将图上输入输出及连线删除 * 在现有输出的图形结构上转化输入 输出活动属性并将图上输入输出及连线删除
*/ */
private void handleShapeInputOutAttr(PALRepositoryModel palModel, JSONObject elements) { private void handleShapeInputOutAttr(PALRepositoryModel palModel, JSONObject elements) {
LogUtil.appendLog(Constant.LOG_START + "创建PAL流程【" + palModel.getName() + "】相关形状的输入输出属性", simpleLogFile, fullLogFile);
// 存放待删除图形的KEY // 存放待删除图形的KEY
List<String> removeKey = new ArrayList<>(); List<String> removeKey = new ArrayList<>();
@ -543,7 +673,7 @@ public class ArisXmlImportRun {
} }
// 删除画布上的输入输出和其连线 // 删除画布上的输入输出和其连线
removeKey.stream().forEach(key -> elements.remove(key)); removeKey.stream().forEach(key -> elements.remove(key));
LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + palModel.getName() + "】相关输入输出形状和其连线", simpleLogFile, fullLogFile);
Map<String, JSONObject> attrMap = new HashMap<>(); Map<String, JSONObject> attrMap = new HashMap<>();
JSONObject attrs1 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node"); JSONObject attrs1 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node");
attrMap.put("method_service_node", attrs1); attrMap.put("method_service_node", attrs1);
@ -573,12 +703,12 @@ public class ArisXmlImportRun {
if (obj.containsKey("attributesJsonArray")) { if (obj.containsKey("attributesJsonArray")) {
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
attributesJsonArray.add(attrObj); attributesJsonArray.add(attrObj);
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输入属性内容" + attrObj.getString("value")); LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】的输入属性内容是【" + attrObj.getString("value") + "", simpleLogFile, fullLogFile);
} }
} }
} }
} else { } else {
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输入属性"); LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "没有配置输入属性,忽略输入属性赋值", simpleLogFile, fullLogFile, warnLogFile);
} }
} }
if (shapeOutMap.containsKey(key)) {// 有输出属性 if (shapeOutMap.containsKey(key)) {// 有输出属性
@ -595,25 +725,25 @@ public class ArisXmlImportRun {
if (obj.containsKey("attributesJsonArray")) { if (obj.containsKey("attributesJsonArray")) {
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray"); JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
attributesJsonArray.add(attrObj); attributesJsonArray.add(attrObj);
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输出属性内容" + attrObj.getString("value")); LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "】没有配置输出属性,忽略输出属性赋值", simpleLogFile, fullLogFile, warnLogFile);
} }
} }
} }
} else { } else {
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输出属性"); LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + palModel.getName() + "】形状【" + shapeObj.getString("text") + "没有配置输出属性,忽略输出属性赋值", simpleLogFile, fullLogFile, warnLogFile);
} }
} }
} }
} }
} }
LogUtil.appendLog(Constant.LOG_END + "创建PAL流程【" + palModel.getName() + "】相关形状的输入输出属性", simpleLogFile, fullLogFile);
} }
/** /**
* 处理流程属性前后置流程 * 处理流程属性前后置流程
* *
* @param wsId * @param wsId
* @param currentModelNoShape
* @param idRelationMap * @param idRelationMap
* @param repositoryModelId * @param repositoryModelId
* @param elements * @param elements
@ -621,14 +751,11 @@ public class ArisXmlImportRun {
* @param modelObjOccMap * @param modelObjOccMap
* @param objDefMap * @param objDefMap
*/ */
private void handleProcessAttrLeadOrRearProcess(String wsId, List<ModelModel> currentModelNoShape, Map<String, String> idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel, private void handleProcessAttrLeadOrRearProcess(String wsId, Map<String, String> idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap) { Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap) {
LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关前置流程/后置流程进行处理关联", simpleLogFile, fullLogFile);
// 如果当前流程下无图形信息 直接返回 // 如果当前流程下无图形信息 直接返回
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId()); List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId());
if (objOccModels == null || objOccModels.size() == 0) {
currentModelNoShape.add(arisModel);
return;
}
// 获取ARIS图形定义与PAL图形定义关系 // 获取ARIS图形定义与PAL图形定义关系
Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap(); Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_FUNC-ST_PRCS_IF"); ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_FUNC-ST_PRCS_IF");
@ -641,8 +768,6 @@ public class ArisXmlImportRun {
PALMethodAttributeModel rearAttrModel = rearProcess.get(0); PALMethodAttributeModel rearAttrModel = rearProcess.get(0);
// 存放待删除图形的KEY // 存放待删除图形的KEY
List<String> removeKey = new ArrayList<>(); List<String> removeKey = new ArrayList<>();
// 流程关联属性结果集
List<DesignerShapeRelationModel> relationList = new ArrayList<>();
for (ObjOccModel objOccModel : objOccModels) { for (ObjOccModel objOccModel : objOccModels) {
ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义 ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
// 根据ARIS图形定义信息判断当前模型下的所有形状里是否有系统形状 // 根据ARIS图形定义信息判断当前模型下的所有形状里是否有系统形状
@ -680,6 +805,7 @@ public class ArisXmlImportRun {
propertyDao.insert(propertyModel); propertyDao.insert(propertyModel);
removeKey.add(key); removeKey.add(key);
removeKey.add(shapeId); removeKey.add(shapeId);
LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关前置流程进行处理关联,前置属性内容【" + repositoryModels.get(0).getName() + "", fullLogFile);
break; break;
} else if (tempShapeObj.getJSONObject("to").getString("id").equals(shapeId)) { } else if (tempShapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
// rear_process // rear_process
@ -708,6 +834,7 @@ public class ArisXmlImportRun {
propertyDao.insert(propertyModel); propertyDao.insert(propertyModel);
removeKey.add(key); removeKey.add(key);
removeKey.add(shapeId); removeKey.add(shapeId);
LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关后置流程进行处理关联,后置属性内容【" + repositoryModels.get(0).getName() + "", fullLogFile);
break; break;
} else { } else {
continue; continue;
@ -717,6 +844,7 @@ public class ArisXmlImportRun {
} }
} }
removeKey.stream().forEach(key -> elements.remove(key)); removeKey.stream().forEach(key -> elements.remove(key));
LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关前置流程/后置流程进行处理关联", simpleLogFile, fullLogFile);
} }
/** /**
@ -734,6 +862,7 @@ public class ArisXmlImportRun {
private void handleProcessAttrItSystemRelation(String wsId, Map<String, String> idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel, private void handleProcessAttrItSystemRelation(String wsId, Map<String, String> idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, List<ObjOccModel>> modelObjOccMap,
Map<String, ObjDefModel> objDefMap, Map<String, Set<String>> objDefLinkerMap, Map<String, JSONObject> itShapeMap) { Map<String, ObjDefModel> objDefMap, Map<String, Set<String>> objDefLinkerMap, Map<String, JSONObject> itShapeMap) {
LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关信息系统与形状进行关联", simpleLogFile, fullLogFile);
// 获取ARIS图形定义与PAL图形定义关系 // 获取ARIS图形定义与PAL图形定义关系
Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap(); Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE"); ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE");
@ -776,17 +905,18 @@ public class ArisXmlImportRun {
m.setRelationShapeText(itShapeMap.get(itShapeName).getString("shapeName")); m.setRelationShapeText(itShapeMap.get(itShapeName).getString("shapeName"));
m.setAttrId(Constant.METHOD_INFO_SYSTEM); m.setAttrId(Constant.METHOD_INFO_SYSTEM);
relationList.add(m); relationList.add(m);
} else { } else {
// todo warn LogUtil.appendLog(Constant.LOG_WARNING + "流程【" + arisModel.getName() + "】中的活动节点【" + elements.getJSONObject(shapeId).getString("text") + "】未找到IT系统【" + itShapeName + "", simpleLogFile, fullLogFile, warnLogFile);
printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + elements.getJSONObject(shapeId).getString("text") + "】未找到IT系统【" + itShapeName + "");
} }
} }
} }
// 保存关联关系 // 保存关联关系
if (relationList.size() > 0) { if (relationList.size() > 0) {
DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
relationList.stream().forEach(item -> printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下IT系统【" + item.getRelationShapeText() + "")); relationList.stream().forEach(item -> LogUtil.appendLog(Constant.LOG_END + "流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联IT系统【" + item.getRelationShapeText() + "", simpleLogFile, fullLogFile));
relationDao.barchInsert(relationList); relationDao.barchInsert(relationList);
LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关信息系统与形状进行关联", simpleLogFile, fullLogFile);
} }
} }
@ -806,6 +936,8 @@ public class ArisXmlImportRun {
*/ */
private void handleProcessAttrRoleRelation(String wsId, String repositoryModelId, Map<String, String> arisFunIdRelationPalRoleMap, Map<String, String> palShapeIdRelationArisOccIdMap, JSONObject elements, ModelModel arisModel, private void handleProcessAttrRoleRelation(String wsId, String repositoryModelId, Map<String, String> arisFunIdRelationPalRoleMap, Map<String, String> palShapeIdRelationArisOccIdMap, JSONObject elements, ModelModel arisModel,
Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, String roleMdoelId, Map<String, String> palRoleIdRelationNameMap) throws AWSException { Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, String roleMdoelId, Map<String, String> palRoleIdRelationNameMap) throws AWSException {
LogUtil.appendLog(Constant.LOG_START + "PAL流程【" + arisModel.getName() + "】相关角色与形状进行关联,并删除流程图上多余的角色和连线", simpleLogFile, fullLogFile);
// 获取ARIS图形定义与PAL图形定义关系 // 获取ARIS图形定义与PAL图形定义关系
Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap(); Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_PERS_TYPE-ST_EMPL_TYPE"); ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_PERS_TYPE-ST_EMPL_TYPE");
@ -857,7 +989,7 @@ public class ArisXmlImportRun {
removeKey.add(key); removeKey.add(key);
removeKey.add(tempShapeObj.getJSONObject("to").getString("id")); removeKey.add(tempShapeObj.getJSONObject("to").getString("id"));
} }
printMsg("流程" + arisModel.getName() + "删除角色形状" + text + "和其连线"); LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "" + "角色形状【" +text + "和其连线", fullLogFile);
} }
} }
@ -866,17 +998,19 @@ public class ArisXmlImportRun {
JSONObject tempShapeObj = elements.getJSONObject(key); JSONObject tempShapeObj = elements.getJSONObject(key);
if ("role".equals(tempShapeObj.getString("name")) && !removeKey.contains(tempShapeObj.getString("id"))) { if ("role".equals(tempShapeObj.getString("name")) && !removeKey.contains(tempShapeObj.getString("id"))) {
removeKey.add(key); removeKey.add(key);
printMsg("流程" + arisModel.getName() + "删除角色形状" + tempShapeObj.getString("text") + ",该角色无连线连接到活动"); LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "" + "角色形状【" + tempShapeObj.getString("text") + ",该角色无连线连接到活动(角色图中已包含该角色图标)", fullLogFile);
} }
} }
// 保存关联关系 // 保存关联关系
if (relationList.size() > 0) { if (relationList.size() > 0) {
DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao(); DesignerShapeRelationDao relationDao = new DesignerShapeRelationDao();
relationList.stream().forEach(item -> printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下角色【" + item.getRelationShapeText() + "")); relationList.stream().forEach(item -> LogUtil.appendLog(Constant.LOG_END + "保存PAL流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下角色【" + item.getRelationShapeText() + ""));
relationDao.barchInsert(relationList); relationDao.barchInsert(relationList);
} }
removeKey.stream().forEach(key -> elements.remove(key)); removeKey.stream().forEach(key -> elements.remove(key));
LogUtil.appendLog(Constant.LOG_END + "删除PAL流程【" + arisModel.getName() + "】的相关角色形状和其连线", simpleLogFile, fullLogFile);
LogUtil.appendLog(Constant.LOG_END + "PAL流程【" + arisModel.getName() + "】相关角色与形状进行关联,并删除流程图上多余的角色和连线", simpleLogFile, fullLogFile);
} }
/** /**
@ -990,7 +1124,6 @@ public class ArisXmlImportRun {
* @param coeProcessLevel * @param coeProcessLevel
* @param parentId * @param parentId
* @param wsId * @param wsId
* @param currentModelNoShape
* @param palModel * @param palModel
* @param arisModel * @param arisModel
* @param modelObjOccMap * @param modelObjOccMap
@ -1002,7 +1135,9 @@ public class ArisXmlImportRun {
* @param methodAttrsMap * @param methodAttrsMap
* @return * @return
*/ */
private String createRoleModelAndElements(PALRepository coeProcessLevel, String parentId, String wsId, List<ModelModel> currentModelNoShape, PALRepositoryModel palModel, ModelModel arisModel, Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, Map<String, ObjOccModel> objOccMap, Map<String, List<CxnOccModel>> cxnOccMap, Map<String, Set<String>> objDefLinkerMap, Map<String, String> arisFunIdRelationPalRoleMap, Map<String, Map<String, JSONObject>> methodAttrsMap, Map<String, String> palRoleIdRelationNameMap) { private String createRoleModelAndElements(PALRepository coeProcessLevel, String parentId, String wsId, PALRepositoryModel palModel, ModelModel arisModel, Map<String, List<ObjOccModel>> modelObjOccMap, Map<String, ObjDefModel> objDefMap, Map<String, ObjOccModel> objOccMap, Map<String, List<CxnOccModel>> cxnOccMap, Map<String, Set<String>> objDefLinkerMap, Map<String, String> arisFunIdRelationPalRoleMap, Map<String, Map<String, JSONObject>> methodAttrsMap, Map<String, String> palRoleIdRelationNameMap) {
LogUtil.appendLog(Constant.LOG_START + "创建流程模型对应的角色模型", simpleLogFile, fullLogFile);
// 统计模型内的角色信息创建角色与形状的关联关系提前创建活动与角色的id关联关系建立角色的角色图角色图中处理岗位为文本属性内容 // 统计模型内的角色信息创建角色与形状的关联关系提前创建活动与角色的id关联关系建立角色的角色图角色图中处理岗位为文本属性内容
// 统计模型内所有的角色形状 // 统计模型内所有的角色形状
@ -1016,7 +1151,7 @@ public class ArisXmlImportRun {
} }
} }
if (roleObjOccModels.size() == 0) { if (roleObjOccModels.size() == 0) {
printMsg("流程模型" + palModel.getName() + "无任何角色模型,忽略角色与岗位导入"); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "无任何角色模型,忽略角色与岗位导入", simpleLogFile, fullLogFile, warnLogFile);
return null; return null;
} }
@ -1029,7 +1164,7 @@ public class ArisXmlImportRun {
List<CxnOccModel> list = cxnOccMap.get(roleOccModel.getId()); List<CxnOccModel> list = cxnOccMap.get(roleOccModel.getId());
// list为null该角色在该模型中没有连接任何的活动忽略导入该角色 // list为null该角色在该模型中没有连接任何的活动忽略导入该角色
if (list == null) { if (list == null) {
printMsg("流程模型" + palModel.getName() + "检测到角色" + objDefMap.get(roleOccModel.getDefId()).getName() + "尚未连接到任何活动上,忽略该角色"); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "检测到角色" + objDefMap.get(roleOccModel.getDefId()).getName() + "尚未连接到任何活动上,该角色可能不与任何流程活动相关联", simpleLogFile, fullLogFile, warnLogFile);
noneRelationRole.add(objDefMap.get(roleOccModel.getDefId()).getName()); noneRelationRole.add(objDefMap.get(roleOccModel.getDefId()).getName());
continue; continue;
} }
@ -1040,8 +1175,7 @@ public class ArisXmlImportRun {
} }
} }
if (roleCxnOccModels.size() == 0) { if (roleCxnOccModels.size() == 0) {
printMsg("流程模型" + palModel.getName() + "无任何角色模型与流程活动进行连接,忽略角色与岗位导入"); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到无任何角色模型与流程活动进行连接,该流程与对应的角色图没有关联关系", simpleLogFile, fullLogFile, warnLogFile);
return null;
} }
// 记录重复的角色根据名称进行记录 // 记录重复的角色根据名称进行记录
@ -1087,11 +1221,11 @@ public class ArisXmlImportRun {
ObjDefModel roleObjDefModel = objDefMap.get(roleOccModel.getDefId()); ObjDefModel roleObjDefModel = objDefMap.get(roleOccModel.getDefId());
String linkedModelIds = roleObjDefModel.getLinkedModelIds(); String linkedModelIds = roleObjDefModel.getLinkedModelIds();
if (UtilString.isEmpty(linkedModelIds)) {// 角色无关联角色图 if (UtilString.isEmpty(linkedModelIds)) {// 角色无关联角色图
printMsg("流程模型" + palModel.getName() + roleObjDefModel.getName() + "角色无任何关联岗位,忽略该角色岗位"); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到角色【" + roleObjDefModel.getName() + "角色无任何关联岗位,忽略该角色岗位", simpleLogFile, fullLogFile, warnLogFile);
} else {// 角色有关联角色图 } else {// 角色有关联角色图
List<ObjOccModel> relationPositonList = modelObjOccMap.get(linkedModelIds);// linkedModelIds按照单个值对待暂无发现多值 List<ObjOccModel> relationPositonList = modelObjOccMap.get(linkedModelIds);// linkedModelIds按照单个值对待暂无发现多值
if (relationPositonList == null || relationPositonList.size() == 0) {// 角色有关联图但是关联的角色图查询不到 if (relationPositonList == null || relationPositonList.size() == 0) {// 角色有关联图但是关联的角色图查询不到
printMsg("流程模型" + palModel.getName() + roleObjDefModel.getName() + "角色存在关联LinkedModels.IdRefs" + linkedModelIds + " 但无法查询对应Model内容"); LogUtil.appendLog(Constant.LOG_WARNING + "Aris流程【" + arisModel.getName() + "】检测到角色【" + roleObjDefModel.getName() + "】角色存在关联的角色图【" + linkedModelIds + "】,但无法查询对应角色图内容,忽略该角色的岗位", simpleLogFile, fullLogFile, warnLogFile);
} else { } else {
for (ObjOccModel objOccModel: relationPositonList) { for (ObjOccModel objOccModel: relationPositonList) {
ObjDefModel positionDefModel = objDefMap.get(objOccModel.getDefId()); ObjDefModel positionDefModel = objDefMap.get(objOccModel.getDefId());
@ -1116,7 +1250,7 @@ public class ArisXmlImportRun {
id, false, "org.role", "0", 1, null, null, uc.getUID(), uc.getUID(), nowTime, null, null, null, null, id, false, "org.role", "0", 1, null, null, uc.getUID(), uc.getUID(), nowTime, null, null, null, null,
null, null, null, null, null, -1); null, null, null, null, null, -1);
coeProcessLevel.insert(model); coeProcessLevel.insert(model);
printMsg("与流程同名的角色空模型创建完成【文件ID】" + model.getId()); LogUtil.appendLog(Constant.LOG_END + "创建与Aris流程同名的角色图【" + arisModel.getName() + "】【" + model.getId() + "", simpleLogFile, fullLogFile);
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0); BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0);
if (baseModel == null) { if (baseModel == null) {
baseModel = CoeDesignerUtil.createModel(model.getId(), 0); baseModel = CoeDesignerUtil.createModel(model.getId(), 0);
@ -1143,11 +1277,13 @@ public class ArisXmlImportRun {
} }
JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6); JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 6);
for (int i = 0; i < newShapes.size(); i++) { for (int i = 0; i < newShapes.size(); i++) {
JSONObject shapeObj = newShapes.getJSONObject(i); JSONObject shapeObj = newShapes.getJSONObject(i);
elements.put(shapeObj.getString("id"), shapeObj); elements.put(shapeObj.getString("id"), shapeObj);
printMsg("生成角色图 角色" + shapeObj.getString("text") + ""); LogUtil.appendLog(Constant.LOG_END + "创建角色图【" + arisModel.getName() + "】角色形状图标" + shapeObj.getString("text") + "", simpleLogFile);
} }
LogUtil.appendLog(Constant.LOG_END + "创建角色图【" + arisModel.getName() + "】角色形状图标【" + elements.size() + "】个", simpleLogFile, fullLogFile);
// 设置角色图形状默认属性配置 // 设置角色图形状默认属性配置
this.handleShapeDefaultAttr(wsId, palModel, elements, methodAttrsMap); this.handleShapeDefaultAttr(wsId, palModel, elements, methodAttrsMap);
@ -1177,26 +1313,28 @@ public class ArisXmlImportRun {
if (attrId.equals(attributesJsonArray.getJSONObject(i).getString("id"))) { if (attrId.equals(attributesJsonArray.getJSONObject(i).getString("id"))) {
flag = true; flag = true;
attributesJsonArray.getJSONObject(i).put("value", postTextVal); attributesJsonArray.getJSONObject(i).put("value", postTextVal);
printMsg("角色图" + model.getName() + "角色" + shapeText + "岗位属性值为" + postTextVal); LogUtil.appendLog(Constant.LOG_END + "设置角色图【" + arisModel.getName() + "角色形状图标【" + shapeText + "】的岗位属性值为" + "" + postTextVal + "", fullLogFile);
} }
} }
} }
if (!flag) { if (!flag) {
printMsg("角色图" + model.getName() + "角色" + shapeText + "没有岗位属性配置" + Constant.METHOD_POST_TEXT); LogUtil.appendLog(Constant.LOG_WARNING + "角色图【" + arisModel.getName() + "角色形状图标【" + shapeText + "】没有岗位属性配置", simpleLogFile, fullLogFile, warnLogFile);
} }
} }
} }
} }
} else { } else {
printMsg("角色图" + model.getName() + "角色" + shapeText + "无岗位属性内容值"); LogUtil.appendLog(Constant.LOG_WARNING + "角色图【" + arisModel.getName() + "角色形状图标【" + shapeText + "无岗位属性内容值", simpleLogFile, fullLogFile, warnLogFile);
} }
} }
LogUtil.appendLog(Constant.LOG_END + "角色图【" + arisModel.getName() + "】角色形状图标关联岗位内容", simpleLogFile, fullLogFile, warnLogFile);
definition.put("elements", elements); definition.put("elements", elements);
// 设置画布大小 // 设置画布大小
setDiagramHeightWidth(definition, elements); setDiagramHeightWidth(definition, elements);
baseModel.setDefinition(definition.toString()); baseModel.setDefinition(definition.toString());
// 保存文件 // 保存文件
CoeDesignerAPIManager.getInstance().storeDefinition(baseModel);// dao操作 CoeDesignerAPIManager.getInstance().storeDefinition(baseModel);// dao操作
LogUtil.appendLog(Constant.LOG_END + "角色图【" + arisModel.getName() + "】新增保存", simpleLogFile, fullLogFile, warnLogFile);
return id; return id;
} }
@ -1290,41 +1428,20 @@ public class ArisXmlImportRun {
} }
/** /**
* Aris模型匹配PAL模型 * 根据级别排序
*
* @param arisModel
* @return
*/ */
private PALRepositoryModel matchPalModel(ModelModel arisModel, String wsId) { private class Comparator1 implements Comparator<PALRepositoryModel> {
// 查询当前资产库中建模类型是EPC的所有流程文件属性 @Override
PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao(); public int compare(PALRepositoryModel model1, PALRepositoryModel model2) {
List<PALRepositoryPropertyModel> propertyModels = dao.queryByWsId(wsId); Integer level1 = model1.getLevel();
propertyModels = propertyModels.stream().filter(item -> Constant.METHOD_ARIS_URL.equals(item.getPropertyId())).collect(Collectors.toList()); Integer level2 = model2.getLevel();
String modelPath = "\\伊利集团业务流程管理平台" + arisModel.getModelPath(); int result = level1.compareTo(level2);
boolean flag = false; if (result == 0) {
PALRepositoryModel repositoryModel = null; Integer index1 = model1.getOrderIndex();
// printMsg("MODEL PATH "+modelPath); Integer index2 = model2.getOrderIndex();
for (PALRepositoryPropertyModel propertyModel : propertyModels) { result = index1.compareTo(index2);
if (propertyModel.getPropertyValue().equals(modelPath)) {
// printMsg("ARIS路径 "+propertyModel.getPropertyValue());
repositoryModel = new PALRepository().getInstance(propertyModel.getPlId());
if (arisModel.getName().trim().equals(repositoryModel.getName())) {
printMsg("匹配到的MODEL PATH " + modelPath + "\\" + arisModel.getName());
flag = true;
break;
} else {
repositoryModel = null;
}
} }
return result;
} }
if (!flag) {
// 未匹配出结果记录日志 todo
printMsg("未匹配出结果MODEL PATH " + modelPath + "\\" + arisModel.getName());
}
return repositoryModel;
}
private void printMsg(String msg) {
SDK.getLogAPI().consoleInfo(msg);
} }
} }

View File

@ -1,34 +1,19 @@
package com.actionsoft.apps.coe.pal.datamigration.aris.web; package com.actionsoft.apps.coe.pal.datamigration.aris.web;
import com.actionsoft.apps.coe.pal.batch.web.create.shape.ImportShapeExcel;
import com.actionsoft.apps.coe.pal.constant.CoEConstant; 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.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.model.*;
import com.actionsoft.apps.coe.pal.datamigration.aris.util.XMLUtil; import com.actionsoft.apps.coe.pal.datamigration.aris.util.XMLUtil;
import com.actionsoft.apps.coe.pal.datamigration.cache.DataMigrationCache;
import com.actionsoft.apps.coe.pal.datamigration.constant.Constant; 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.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.LogUtil;
import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil; 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.method.model.PALMethodAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryAPIManager; 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.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.constant.CoeDesignerConstant;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
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.model.impl.PALRepositoryModelImpl;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
import com.actionsoft.bpms.commons.mvc.view.ActionWeb; import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
@ -38,12 +23,8 @@ import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilDate; import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilString; import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSException;
import com.actionsoft.i18n.I18nRes; import com.actionsoft.i18n.I18nRes;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
@ -53,7 +34,6 @@ import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
public class ArisXmlImportWeb extends ActionWeb { public class ArisXmlImportWeb extends ActionWeb {
@ -73,8 +53,9 @@ public class ArisXmlImportWeb extends ActionWeb {
private File warnLogFile; private File warnLogFile;
private String filePath; private String filePath;
private String fileName; private String fileName;
private long startTime = System.currentTimeMillis();
Timestamp startDate = new Timestamp(System.currentTimeMillis()); // Timestamp startDate = new Timestamp(System.currentTimeMillis());
public void initParams () { public void initParams () {
@ -128,12 +109,26 @@ public class ArisXmlImportWeb extends ActionWeb {
model.setCreateUserName(_uc.getUserName()); model.setCreateUserName(_uc.getUserName());
model.setCreateDate(createDate); model.setCreateDate(createDate);
model.setStartDate(createDate); model.setStartDate(createDate);
model.setResultType(Constant.LOG_RESULT_TYPE_RUN); model.setResultStatus(Constant.LOG_RESULT_StATUS_RUN);
model.setMainInfo("导入进行中"); model.setMainInfo("导入进行中");
// 存储日志db // 存储日志db
LogUtil.createLog(model); LogUtil.createLog(model);
} }
/**
* 导入停止时更新日志db状态
* @param logFileMsg
* @param logDbMsg
*/
private void updateErrLog(String logFileMsg, String logDbMsg) {
// 记录日志
LogUtil.appendLog(logFileMsg, simpleLogFile, fullLogFile, warnLogFile);
// 日志表记录导入结果
LogUtil.updateLog(logId, new Timestamp(System.currentTimeMillis()), Constant.LOG_RESULT_StATUS_ERROR, logDbMsg);
// 清空缓存
LogRealTimeCountCache.getCache().remove(logId);
}
/** /**
* 迁移测试 * 迁移测试
* *
@ -143,6 +138,12 @@ public class ArisXmlImportWeb extends ActionWeb {
public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) { public String dataMigrate(String wsId, String groupValue, String fileValue, String fileName) {
// 初始化一些参数 // 初始化一些参数
initParams(); initParams();
// 读取dc
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, "migration");// repositoryName要调整新的路径配合前端 todo
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, groupValue, fileValue, fileName);
this.fileName = fileName;
this.filePath = dc.getFilePath();
Timestamp startDate = new Timestamp(startTime);
// 创建日志信息db // 创建日志信息db
createLogModel(logId, wsId, fileName, filePath, startDate); createLogModel(logId, wsId, fileName, filePath, startDate);
LogUtil.appendLog("注:该日志文件存储简要日志信息", simpleLogFile); LogUtil.appendLog("注:该日志文件存储简要日志信息", simpleLogFile);
@ -151,10 +152,14 @@ public class ArisXmlImportWeb extends ActionWeb {
LogUtil.appendLog("Aris XML流程导入 Begin " + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile, warnLogFile); LogUtil.appendLog("Aris XML流程导入 Begin " + UtilDate.datetimeFormat(startDate), simpleLogFile, fullLogFile, warnLogFile);
String msg;
// 校验资产库是否存在可用 // 校验资产库是否存在可用
boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId); boolean isActive = PALRepositoryQueryAPIManager.getInstance().isActiveWorkSpace(wsId);
if (!isActive) { if (!isActive) {
LogUtil.appendLog(Constant.LOG_ERROR + "资产库不存在或已停用," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "资产库不存在或已停用," + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("资产库不存在或已停用").toString();
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "校验资产库存在并可用", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "校验资产库存在并可用", simpleLogFile, fullLogFile);
@ -164,17 +169,17 @@ public class ArisXmlImportWeb extends ActionWeb {
return checkRo.toString(); return checkRo.toString();
} }
// 校验文件是否存在 // 校验文件是否存在
DCPluginProfile dcProfile = DCProfileManager.getDCProfile(Constant.APP_ID, "migration");// repositoryName要调整新的路径配合前端 todo
DCContext dc = new DCContext(_uc, dcProfile, Constant.APP_ID, groupValue, fileValue, fileName);
File file = new File(dc.getFilePath()); File file = new File(dc.getFilePath());
if (!file.exists()) { if (!file.exists()) {
LogUtil.appendLog(Constant.LOG_ERROR + "上传文件不存在," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "上传文件不存在," + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("上传文件不存在").toString(); return ResponseObject.newErrResponse("上传文件不存在").toString();
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否存在", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否存在", simpleLogFile, fullLogFile);
if (!".xml".equals(fileName.substring(fileName.lastIndexOf(".")))) { if (!".xml".equals(fileName.substring(fileName.lastIndexOf(".")))) {
LogUtil.appendLog(Constant.LOG_ERROR + "上传文件名称格式不正确," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "上传文件名称格式不正确," + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("上传文件名称格式不正确请上传XML文件").toString(); return ResponseObject.newErrResponse("上传文件名称格式不正确请上传XML文件").toString();
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否为XML格式", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "校验上传文件是否为XML格式", simpleLogFile, fullLogFile);
@ -185,7 +190,8 @@ public class ArisXmlImportWeb extends ActionWeb {
// XMLUtil.writeXml(d, toFilePath + fileName); // XMLUtil.writeXml(d, toFilePath + fileName);
// 解析xml文件 // 解析xml文件
if (doc == null) { if (doc == null) {
LogUtil.appendLog(Constant.LOG_ERROR + "解析XML文件结构" + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "解析XML文件结构" + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("解析XML文件错误详情见日志").toString(); return ResponseObject.newErrResponse("解析XML文件错误详情见日志").toString();
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件结构", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件结构", simpleLogFile, fullLogFile);
@ -195,26 +201,36 @@ public class ArisXmlImportWeb extends ActionWeb {
handleWeb.handleXmlDoc(doc); handleWeb.handleXmlDoc(doc);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
LogUtil.appendLog(Constant.LOG_ERROR + "解析XML文件内容异常异常信息" + e.getMessage() + "" + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "解析XML文件内容异常异常信息" + e.getMessage() + "" + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件内容", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "解析XML文件内容", simpleLogFile, fullLogFile);
// 统计epc流程图的个数用以进度展示 // 统计epc流程图的个数用以进度展示
int totalEpcCount = countProcessMainInfo(handleWeb.modelMap); int totalEpcCount = countProcessMainInfo(handleWeb.modelMap);
if (totalEpcCount == 0) { if (totalEpcCount == 0) {
LogUtil.appendLog(Constant.LOG_ERROR + "上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC) + "" + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); msg = Constant.LOG_ERROR + "上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC) + "" + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC)).toString(); return ResponseObject.newErrResponse("上传文件不包含任何" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC)).toString();
} }
// 存储缓存导入计数 // 存储缓存导入计数
DataMigrationCache.getCache().put(logId, 0, true); LogRealTimeCountModel countModel = new LogRealTimeCountModel();
// 开始执行导入 countModel.setTotalCount(totalEpcCount);
new Thread(()->{new ArisXmlImportRun(_uc, wsId, logId, logPath, simpleLogFile, fullLogFile, warnLogFile, filePath, fileName).execute(handleWeb);}) .start(); countModel.setSuccessCount(0);
countModel.setArisBlankCount(0);
countModel.setPalExistsCount(0);
countModel.setImportingCount(0);
countModel.setMatchFieldCount(0);
LogRealTimeCountCache.getCache().put(logId, countModel, true);
ResponseObject ro = ResponseObject.newOkResponse("处理完毕"); LogUtil.appendLog(Constant.LOG_START + "导入" + I18nRes.findValue(CoEConstant.APP_ID, Constant.PROCESS_EPC + ",共【" + totalEpcCount + "】条流程"));
// ro.put("matchModels", matchModels); // 开始执行导入
// ro.put("unMatchModels", unMatchModels); new Thread(()->{new ArisXmlImportRun(_uc, wsId, logId, logPath, simpleLogFile, fullLogFile, warnLogFile, this.filePath, this.fileName, startTime).execute(handleWeb);}) .start();
// ro.put("repeatModels", repeatModels);
// ro.put("currentModelNoShape", currentModelNoShape); ResponseObject ro = ResponseObject.newOkResponse();
ro.put("logId", logId);
ro.put("path", logPath);
ro.put("endLog", Constant.END_LOG);
return ro.toString(); return ro.toString();
} }
@ -245,10 +261,12 @@ public class ArisXmlImportWeb extends ActionWeb {
d = XMLUtil.readXML(path, true); d = XMLUtil.readXML(path, true);
} catch (DocumentException e) { } catch (DocumentException e) {
e.printStackTrace(); e.printStackTrace();
LogUtil.appendLog(Constant.LOG_ERROR + "解析XML文件结构出错错误信息" + e.getMessage() + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); String msg = Constant.LOG_ERROR + "解析XML文件结构出错错误信息" + e.getMessage() + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
LogUtil.appendLog(Constant.LOG_ERROR + "解析XML文件结构出错错误信息" + e.getMessage() + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); String msg = Constant.LOG_ERROR + "解析XML文件结构出错错误信息" + e.getMessage() + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
} }
return d; return d;
} }
@ -261,7 +279,7 @@ public class ArisXmlImportWeb extends ActionWeb {
private ResponseObject checkMethodConfig(String wsId) { private ResponseObject checkMethodConfig(String wsId) {
// 校验EPC图的文件属性 // 校验EPC图的文件属性
// 校验前置流程后置流程 // 校验前置流程后置流程
ResponseObject checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, null, Constant.METHOD_PRE_PROCESS, Constant.METHOD_NEXT_PROCESS); ResponseObject checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, null, Constant.METHOD_PRE_PROCESS, Constant.METHOD_NEXT_PROCESS, Constant.METHOD_ARIS_URL);
if (checkRo.isErr()) { if (checkRo.isErr()) {
return checkRo; return checkRo;
} }
@ -276,19 +294,16 @@ public class ArisXmlImportWeb extends ActionWeb {
if (checkRo.isErr()) { if (checkRo.isErr()) {
return checkRo; return checkRo;
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "【EPC流程图】形状【线下审批】的属性【编号】【输入】【输出】【描述】【角色】【信息系统】", simpleLogFile, fullLogFile);
// 校验系统任务的编号输入输出描述角色信息系统 // 校验系统任务的编号输入输出描述角色信息系统
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE3, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM); checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_APPROVAL_NODE3, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
if (checkRo.isErr()) { if (checkRo.isErr()) {
return checkRo; return checkRo;
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "【EPC流程图】形状【系统任务】的属性【编号】【输入】【输出】【描述】【角色】【信息系统】", simpleLogFile, fullLogFile);
// 校验人工任务的编号输入输出描述角色信息系统 // 校验人工任务的编号输入输出描述角色信息系统
checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE4, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM); checkRo = checkMethodAttrExist(wsId, Constant.PROCESS_EPC, Constant.METHOD_SERVICE_NODE4, Constant.METHOD_NUMBER, Constant.METHOD_INPUT, Constant.METHOD_OUTPUT, Constant.METHOD_DESC, Constant.METHOD_ROLE, Constant.METHOD_INFO_SYSTEM);
if (checkRo.isErr()) { if (checkRo.isErr()) {
return checkRo; return checkRo;
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "【EPC流程图】形状【人工任务】的属性【编号】【输入】【输出】【描述】【角色】【信息系统】", simpleLogFile, fullLogFile);
// 校验角色图的岗位属性 // 校验角色图的岗位属性
// 校验角色的岗位文本 // 校验角色的岗位文本
checkRo = checkMethodAttrExist(wsId, Constant.ORG_ROLE, Constant.METHOD_ROLE, Constant.METHOD_POST_TEXT); checkRo = checkMethodAttrExist(wsId, Constant.ORG_ROLE, Constant.METHOD_ROLE, Constant.METHOD_POST_TEXT);
@ -311,7 +326,8 @@ public class ArisXmlImportWeb extends ActionWeb {
if (UtilString.isNotEmpty(shapeName)) { if (UtilString.isNotEmpty(shapeName)) {
JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(methodId, shapeName); JSONObject shape = ShapeUtil.getProcessShapeDefinitionByName(methodId, shapeName);
if (isEmptyJsonOject(shape)) { if (isEmptyJsonOject(shape)) {
LogUtil.appendLog(Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeName + "】不存在," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); String msg = Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeName + "】不存在," + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeName + "】不存在"); return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeName + "】不存在");
} }
String shapeText = shape.getString("text"); String shapeText = shape.getString("text");
@ -322,8 +338,9 @@ public class ArisXmlImportWeb extends ActionWeb {
} }
for (String attrId : attrs) { for (String attrId : attrs) {
if (!attrMap.containsKey(attrId)) { if (!attrMap.containsKey(attrId)) {
LogUtil.appendLog(Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); String msg = Constant.LOG_ERROR + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeName + "】属性【" + attrId + "】不存在"); updateErrLog(msg, msg);
return ResponseObject.newErrResponse("模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "】不存在");
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】中的形状【" + shapeText + "】属性【" + attrId + "", simpleLogFile, fullLogFile);
} }
@ -336,7 +353,8 @@ public class ArisXmlImportWeb extends ActionWeb {
} }
for (String attrId : attrs) { for (String attrId : attrs) {
if (!attrMap.containsKey(attrId)) { if (!attrMap.containsKey(attrId)) {
LogUtil.appendLog(Constant.LOG_ERROR + "模型【" + methodName + "】的文件属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG, simpleLogFile, fullLogFile, warnLogFile); String msg = Constant.LOG_ERROR + "模型【" + methodName + "】的文件属性【" + attrId + "】不存在,请检查相应属性配置," + Constant.IMPORT_STOP_MSG;
updateErrLog(msg, msg);
return ResponseObject.newErrResponse("模型【" + methodName + "】的文件属性【" + attrId + "】不存在"); return ResponseObject.newErrResponse("模型【" + methodName + "】的文件属性【" + attrId + "】不存在");
} }
LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】的文件属性【" + attrId + "", simpleLogFile, fullLogFile); LogUtil.appendLog(Constant.LOG_SUCCESS + "模型【" + methodName + "】的文件属性【" + attrId + "", simpleLogFile, fullLogFile);
@ -345,37 +363,6 @@ public class ArisXmlImportWeb extends ActionWeb {
return ResponseObject.newOkResponse(); return ResponseObject.newOkResponse();
} }
/**
* 校验一些必备的建模属性
* @param wsId
* @param shapeMethodId
* @param shapeMethodName
* @param methodId
* @param categoryName
* @param methodName
* @param methodCode
* @return
*/
private String checkMethodInfo(String wsId, String shapeMethodId, String shapeMethodName, String methodId, String categoryName, String methodName, String methodCode) {
// 一些环境提前校验 比如必备的建模属性
List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance().getValidAttributeModels(wsId, shapeMethodId, shapeMethodName, methodId);
attributeModels = attributeModels.stream().filter(item -> methodCode.equals(item.getKey())).collect(Collectors.toList());
if (attributeModels.size() == 0) {
return ResponseObject.newErrResponse("请打开建模管理应用,查看当前建模分类【" + categoryName + "】下是否存在【" + methodName + "/" + methodCode + "】建模属性").toString();
}
return "";
}
/** /**
* 校验是否为空的对象 * 校验是否为空的对象
* @param o * @param o
@ -385,9 +372,4 @@ public class ArisXmlImportWeb extends ActionWeb {
return o == null || o.isEmpty(); return o == null || o.isEmpty();
} }
}
}

View File

@ -1,26 +0,0 @@
package com.actionsoft.apps.coe.pal.datamigration.cache;
import com.actionsoft.apps.resource.plugin.profile.CachePluginProfile;
import com.actionsoft.bpms.commons.cache.Cache;
import com.actionsoft.bpms.commons.cache.CacheManager;
/**
* 存储导入数据
* @author sunlh
*
*/
public class DataMigrationCache extends Cache<String, Integer>{
public DataMigrationCache(CachePluginProfile configuration) {
super(configuration);
}
@Override
protected void load() {
}
public static DataMigrationCache getCache() {
return CacheManager.getCache(DataMigrationCache.class);
}
}

View File

@ -64,14 +64,24 @@ public class Constant {
public static final String LOG_SUCCESS = "【成功】"; public static final String LOG_SUCCESS = "【成功】";
public static final String LOG_WARNING = "【警告】"; public static final String LOG_WARNING = "【警告】";
public static final String LOG_ERROR = "【错误】"; public static final String LOG_ERROR = "【错误】";
// 日志导入开始节点
public static final String LOG_START = "【开始】";
// 日志导入完成节点
public static final String LOG_END = "【完成】";
public static final String LOG_DESC = "【说明】";
// 日志表resultType字段常量codeß
public static final int LOG_RESULT_TYPE_RUN = 0;// 进行中 // 日志表resultType字段常量code
public static final int LOG_RESULT_TYPE_SUCCESS = 1;// 完成 public static final int LOG_RESULT_StATUS_RUN = 0;// 进行中
public static final int LOG_RESULT_TYPE_ERROR = 2;// 失败 public static final int LOG_RESULT_StATUS_SUCCESS = 1;// 完成
public static final int LOG_RESULT_StATUS_ERROR = 2;// 失败
public static final String IMPORT_STOP_MSG = "导入停止"; public static final String IMPORT_STOP_MSG = "导入停止";
// 日志结束语
public static final String END_LOG = "**建议下载本次输出日志做备忘";
public static final String PROCESS_EPC = "process.epc"; public static final String PROCESS_EPC = "process.epc";
public static final String ORG_ROLE = "org.role"; public static final String ORG_ROLE = "org.role";

View File

@ -0,0 +1,27 @@
package com.actionsoft.apps.coe.pal.datamigration.log.cache;
import com.actionsoft.apps.coe.pal.datamigration.log.model.LogRealTimeCountModel;
import com.actionsoft.apps.resource.plugin.profile.CachePluginProfile;
import com.actionsoft.bpms.commons.cache.Cache;
import com.actionsoft.bpms.commons.cache.CacheManager;
/**
* 存储导入数据
* @author sunlh
*
*/
public class LogRealTimeCountCache extends Cache<String, LogRealTimeCountModel>{
public LogRealTimeCountCache(CachePluginProfile configuration) {
super(configuration);
}
@Override
protected void load() {
}
public static LogRealTimeCountCache getCache() {
return CacheManager.getCache(LogRealTimeCountCache.class);
}
}

View File

@ -38,7 +38,7 @@ public class LogDao extends DaoObject<LogModel> {
paraMap.put(LogModel.CREATEDATE, model.getCreateDate()); paraMap.put(LogModel.CREATEDATE, model.getCreateDate());
paraMap.put(LogModel.STARTDATE, model.getStartDate()); paraMap.put(LogModel.STARTDATE, model.getStartDate());
paraMap.put(LogModel.ENDDATE, model.getEndDate()); paraMap.put(LogModel.ENDDATE, model.getEndDate());
paraMap.put(LogModel.RESULTTYPE, model.getResultType()); paraMap.put(LogModel.RESULTSTATUS, model.getResultStatus());
paraMap.put(LogModel.MAININFO, model.getMainInfo()); paraMap.put(LogModel.MAININFO, model.getMainInfo());
paraMap.put(LogModel.EXT1, model.getExt1()); paraMap.put(LogModel.EXT1, model.getExt1());
paraMap.put(LogModel.EXT2, model.getExt2()); paraMap.put(LogModel.EXT2, model.getExt2());
@ -62,7 +62,7 @@ public class LogDao extends DaoObject<LogModel> {
+ LogModel.CREATEDATE +"=?, " + LogModel.CREATEDATE +"=?, "
+ LogModel.STARTDATE +"=?, " + LogModel.STARTDATE +"=?, "
+ LogModel.ENDDATE +"=?, " + LogModel.ENDDATE +"=?, "
+ LogModel.RESULTTYPE +"=?, " + LogModel.RESULTSTATUS +"=?, "
+ LogModel.MAININFO +"=?, " + LogModel.MAININFO +"=?, "
+ LogModel.EXT1 +"=?, " + LogModel.EXT1 +"=?, "
+ LogModel.EXT2 +"=?, " + LogModel.EXT2 +"=?, "
@ -70,7 +70,7 @@ public class LogDao extends DaoObject<LogModel> {
+ LogModel.EXT4 +"=? " + LogModel.EXT4 +"=? "
+ "WHERE "+ LogModel.ID +"=? "; + "WHERE "+ LogModel.ID +"=? ";
return DBSql.update(updateSql, new Object[] {model.getWsId(), model.getFileName(), model.getFilePath(), model.getLogPath(), model.getCreateUser(), model.getCreateUserName(), return DBSql.update(updateSql, new Object[] {model.getWsId(), model.getFileName(), model.getFilePath(), model.getLogPath(), model.getCreateUser(), model.getCreateUserName(),
model.getCreateDate(), model.getStartDate(), model.getEndDate(), model.getResultType(), model.getMainInfo(), model.getExt1(), model.getExt2(), model.getExt3(), model.getExt4(), model.getId()}); model.getCreateDate(), model.getStartDate(), model.getEndDate(), model.getResultStatus(), model.getMainInfo(), model.getExt1(), model.getExt2(), model.getExt3(), model.getExt4(), model.getId()});
} }
/** /**
@ -84,7 +84,7 @@ public class LogDao extends DaoObject<LogModel> {
public int update(String id, Timestamp endDate, int resultType, String mainInfo) { public int update(String id, Timestamp endDate, int resultType, String mainInfo) {
String updateSql = "UPDATE "+ entityName() String updateSql = "UPDATE "+ entityName()
+ " SET "+ LogModel.ENDDATE +"=?, " + " SET "+ LogModel.ENDDATE +"=?, "
+ LogModel.RESULTTYPE +"=?, " + LogModel.RESULTSTATUS +"=?, "
+ LogModel.MAININFO +"=? " + LogModel.MAININFO +"=? "
+ "WHERE "+ LogModel.ID +"=? "; + "WHERE "+ LogModel.ID +"=? ";
return DBSql.update(updateSql, new Object[] {endDate, resultType, mainInfo, id}); return DBSql.update(updateSql, new Object[] {endDate, resultType, mainInfo, id});
@ -152,7 +152,7 @@ public class LogDao extends DaoObject<LogModel> {
model.setCreateDate(rset.getTimestamp(LogModel.CREATEDATE)); model.setCreateDate(rset.getTimestamp(LogModel.CREATEDATE));
model.setStartDate(rset.getTimestamp(LogModel.STARTDATE)); model.setStartDate(rset.getTimestamp(LogModel.STARTDATE));
model.setEndDate(rset.getTimestamp(LogModel.ENDDATE)); model.setEndDate(rset.getTimestamp(LogModel.ENDDATE));
model.setResultType(rset.getInt(LogModel.RESULTTYPE)); model.setResultStatus(rset.getInt(LogModel.RESULTSTATUS));
model.setMainInfo(rset.getString(LogModel.MAININFO)); model.setMainInfo(rset.getString(LogModel.MAININFO));
model.setExt1(rset.getString(LogModel.EXT1)); model.setExt1(rset.getString(LogModel.EXT1));
model.setExt2(rset.getString(LogModel.EXT2)); model.setExt2(rset.getString(LogModel.EXT2));

View File

@ -18,7 +18,7 @@ public class LogModel {
public static final String CREATEDATE = "CREATEDATE"; public static final String CREATEDATE = "CREATEDATE";
public static final String STARTDATE = "STARTDATE"; public static final String STARTDATE = "STARTDATE";
public static final String ENDDATE = "ENDDATE"; public static final String ENDDATE = "ENDDATE";
public static final String RESULTTYPE = "RESULTTYPE"; public static final String RESULTSTATUS = "RESULTSTATUS";
public static final String MAININFO = "MAININFO"; public static final String MAININFO = "MAININFO";
public static final String EXT1 = "EXT1"; public static final String EXT1 = "EXT1";
public static final String EXT2 = "EXT2"; public static final String EXT2 = "EXT2";
@ -37,7 +37,7 @@ public class LogModel {
private Timestamp createDate;// 上传时间程序开始导入时间 private Timestamp createDate;// 上传时间程序开始导入时间
private Timestamp startDate;// 上传时间程序开始导入时间 private Timestamp startDate;// 上传时间程序开始导入时间
private Timestamp endDate;// 最终结束时间成功/失败都需要记录 private Timestamp endDate;// 最终结束时间成功/失败都需要记录
private int resultType;// 结果0进行中1成功2失败 private int resultStatus;// 结果状态0进行中1成功2失败
private String mainInfo;// 一句话简介整个上传结果内容无限制示例若是进行中可描述为正在上传若是失败可描述为具体的异常信息若是成功可描述为上传多少条成功多少条信息 private String mainInfo;// 一句话简介整个上传结果内容无限制示例若是进行中可描述为正在上传若是失败可描述为具体的异常信息若是成功可描述为上传多少条成功多少条信息
private String ext1;// 扩展字段 private String ext1;// 扩展字段
private String ext2;// 扩展字段 private String ext2;// 扩展字段
@ -127,12 +127,12 @@ public class LogModel {
this.endDate = endDate; this.endDate = endDate;
} }
public int getResultType() { public int getResultStatus() {
return resultType; return resultStatus;
} }
public void setResultType(int resultType) { public void setResultStatus(int resultStatus) {
this.resultType = resultType; this.resultStatus = resultStatus;
} }
public String getMainInfo() { public String getMainInfo() {

View File

@ -0,0 +1,67 @@
package com.actionsoft.apps.coe.pal.datamigration.log.model;
import com.actionsoft.bpms.commons.mvc.model.ModelBean;
public class LogRealTimeCountModel extends ModelBean {
private int totalCount;// 总共条数
private int successCount;// 成功条数
private int importingCount;// 当前正在导入的第几条数据
private int palExistsCount;// pal已存在条数针对Aris xml流程导入
private int arisBlankCount;// aris没有模型的条数针对Aris xml流程导入
private int matchFieldCount;// aris与PAL匹配失败的数据条数针对Aris xml流程导入
// 可自定义其他类型数据导入/迁移计数对象
public LogRealTimeCountModel() {
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getSuccessCount() {
return successCount;
}
public void setSuccessCount(int successCount) {
this.successCount = successCount;
}
public int getPalExistsCount() {
return palExistsCount;
}
public void setPalExistsCount(int palExistsCount) {
this.palExistsCount = palExistsCount;
}
public int getArisBlankCount() {
return arisBlankCount;
}
public void setArisBlankCount(int arisBlankCount) {
this.arisBlankCount = arisBlankCount;
}
public int getImportingCount() {
return importingCount;
}
public void setImportingCount(int importingCount) {
this.importingCount = importingCount;
}
public int getMatchFieldCount() {
return matchFieldCount;
}
public void setMatchFieldCount(int matchFieldCount) {
this.matchFieldCount = matchFieldCount;
}
}

View File

@ -1,7 +1,7 @@
package com.actionsoft.apps.coe.pal.datamigration.plugin; package com.actionsoft.apps.coe.pal.datamigration.plugin;
import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant; import com.actionsoft.apps.coe.pal.datamigration.aris.constant.ArisConstant;
import com.actionsoft.apps.coe.pal.datamigration.cache.DataMigrationCache; import com.actionsoft.apps.coe.pal.datamigration.log.cache.LogRealTimeCountCache;
import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb; import com.actionsoft.apps.coe.pal.datamigration.web.DataMigrationWeb;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor; import com.actionsoft.apps.coe.pal.pal.repository.upfile.CoeFileProcessor;
import com.actionsoft.apps.listener.PluginListener; import com.actionsoft.apps.listener.PluginListener;
@ -24,7 +24,7 @@ public class Plugins implements PluginListener {
List<AWSPluginProfile> list = new ArrayList<AWSPluginProfile>(); List<AWSPluginProfile> list = new ArrayList<AWSPluginProfile>();
// 注册缓存 // 注册缓存
list.add(new CachePluginProfile(DataMigrationCache.class)); list.add(new CachePluginProfile(LogRealTimeCountCache.class));
list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false)); list.add(new DCPluginProfile("migration", CoeFileProcessor.class.getName(), "存放数据迁移文件", false, false));
list.add(new DCPluginProfile(ArisConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在arisXML数据迁移日志", false, false)); list.add(new DCPluginProfile(ArisConstant.REPOSITORY_NAME, CoeFileProcessor.class.getName(), "存在arisXML数据迁移日志", false, false));

View File

@ -9,11 +9,14 @@ 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.PALRepositoryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.apps.lifecycle.api.AppsAPIManager; import com.actionsoft.apps.lifecycle.api.AppsAPIManager;
import com.actionsoft.apps.resource.AppContext; import com.actionsoft.apps.resource.AppContext;
import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.i18n.I18nRes; import com.actionsoft.i18n.I18nRes;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import java.util.*; import java.util.*;
@ -183,11 +186,8 @@ public class ProcessUtil {
* @return * @return
*/ */
public static boolean isView(PALRepositoryModel model) { public static boolean isView(PALRepositoryModel model) {
if (model.isPublish() || model.isApproval() || model.isStop()) { return model.isPublish() || model.isApproval() || model.isStop();
return true; }
}
return false;
}
/** /**
* *
@ -197,10 +197,21 @@ public class ProcessUtil {
public static boolean isBlank(UserContext uc, PALRepositoryModel model) { public static boolean isBlank(UserContext uc, PALRepositoryModel model) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, model.getId()); String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(uc, model.getId());
JSONObject array = JSONObject.parseObject(define); JSONObject array = JSONObject.parseObject(define);
if (array.containsKey("elements") && array.getJSONObject("elements").size() == 0) { return array.containsKey("elements") && array.getJSONObject("elements").size() == 0;
return true; }
/**
* 获取模型文本路径
* @param id
* @return
*/
public static String getRepositoryPath(String id) {
JSONArray pathArr = CoeProcessLevelUtil.getRepositoryPath(id);
List<String> list = new ArrayList<>();
for (int i = 0; i < pathArr.size(); i++) {
list.add(pathArr.getJSONObject(i).getString("name"));
} }
return false; return StringUtils.join(list, "\\");
} }
} }