Aris流程迁移IT系统属性问题处理

This commit is contained in:
446052889@qq.com 2022-06-28 19:27:08 +08:00
parent 1e3ab9da10
commit dae3b29c4e
7 changed files with 126 additions and 1513213 deletions

View File

@ -88,7 +88,7 @@ public class ModelMappingAPIManager {
objDefMappingMap.put("OT_POS-ST_POS",o10);
}
if (PALMethodCache.getPALMethodModelById("itsystem.normal") != null) {
// 岗位
// IT系统
ObjDefMappingModel o11 = new ObjDefMappingModel("OT_APPL_SYS_TYPE","ST_APPL_SYS_TYPE","appSystem","itsystem.normal",null,"shape");
objDefMappingMap.put("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE",o11);
}

View File

@ -8,10 +8,8 @@ import java.util.List;
*/
public class CxnOccModel {
private String id;// CxnOcc.ID
private String id;// ObjOcc.ID
private String toId;// ToObjOcc.IdRef
private String objDefId;// 连线起始端形状定义ID
private String toObjDefId;// 连线终点形状定义ID
private List<PositionModel> positionList;// 连线起始端+折点
public String getId() {
@ -30,22 +28,6 @@ public class CxnOccModel {
this.toId = toId;
}
public String getObjDefId() {
return objDefId;
}
public void setObjDefId(String objDefId) {
this.objDefId = objDefId;
}
public String getToObjDefId() {
return toObjDefId;
}
public void setToObjDefId(String toObjDefId) {
this.toObjDefId = toObjDefId;
}
public List<PositionModel> getPositionList() {
return positionList;
}

View File

@ -7,10 +7,7 @@ import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.Element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 对Aris文件进行解析清洗
@ -29,6 +26,8 @@ public class ArisXmlHandleWeb {
public Map<String, List<CxnOccModel>> cxnOccMap = new HashMap<>();// 所有模型中所有连线map记录
public Map<String, Set<String>> objDefLinkerMap = new HashMap<>();// 记录所有定义形状的连线map记录
// 连线 todo
@ -42,7 +41,34 @@ public class ArisXmlHandleWeb {
getNodes(root, groupPath);
// 整合Model路径
calculateModelPath();
test();
// 计算定义形状之间的连线
calculateObjDefLinker();
// test();
}
/**
* 计算定义形状与定义形状之间的所有连线
*/
private void calculateObjDefLinker() {
// 获取所有定义形状
for (Map.Entry<String, ObjDefModel> entry: objDefMap.entrySet()) {
if (!objDefLinkerMap.containsKey(entry.getKey())) {
objDefLinkerMap.put(entry.getKey(), new HashSet<>());
}
}
// 定义形状连线设置
for (Map.Entry<String, List<CxnOccModel>> entry : cxnOccMap.entrySet()) {
String fromOccId = entry.getKey();
ObjOccModel fromObjOccModel = objOccMap.get(fromOccId);
List<CxnOccModel> list = entry.getValue();
if (list != null) {
for (CxnOccModel c: list) {
String toObjOccId = c.getToId();
ObjOccModel toObjOccModel = objOccMap.get(toObjOccId);
objDefLinkerMap.get(fromObjOccModel.getDefId()).add(toObjOccModel.getDefId());
}
}
}
}
private void calculateModelPath() {
@ -266,28 +292,38 @@ public class ArisXmlHandleWeb {
if (list != null) {
System.out.println("模型内形状信息:");
for (ObjOccModel objOccModel : list) {
// System.out.println("模型内的形状信息:" + objDefMap.get(objOccModel.getDefId()).getName());
System.out.println("模型内的形状信息:" + objDefMap.get(objOccModel.getDefId()).getName());
System.out.println("该形状定义信息的下一个连线定义形状:");
Set<String> set = objDefLinkerMap.get(objOccModel.getDefId());
if (set.size() == 0) {
System.out.println("");
} else {
for (String defId : set) {
System.out.println(objDefMap.get(defId).getName());
}
}
System.out.println("-------------");
// System.out.print(objDefMap.get(objOccModel.getDefId()).getName() + " ");
// System.out.println(objDefMap.get(objOccModel.getDefId()).getAttrData());
// System.out.println(objOccModel);
// System.out.println("该形状定义信息");
// System.out.println(objDefMap.get(objOccModel.getDefId()));
}
System.out.println();
// 获取模型内所有连线
for (ObjOccModel occ: list) {
if (cxnOccMap.containsKey(occ.getId())) {
List<CxnOccModel> cxnOccModels = cxnOccMap.get(occ.getId());
for (CxnOccModel cxn: cxnOccModels) {
ObjOccModel idObj = objOccMap.get(cxn.getId());
ObjOccModel toIdObj = objOccMap.get(cxn.getToId());
System.out.println(
objDefMap.get(idObj.getDefId()).getName() + " 的下一个形状是 " + objDefMap.get(toIdObj.getDefId()).getName()
);
}
}
}
// System.out.println();
// // 获取模型内所有连线
// for (ObjOccModel occ: list) {
// if (cxnOccMap.containsKey(occ.getId())) {
// List<CxnOccModel> cxnOccModels = cxnOccMap.get(occ.getId());
// for (CxnOccModel cxn: cxnOccModels) {
// ObjOccModel idObj = objOccMap.get(cxn.getId());
// ObjOccModel toIdObj = objOccMap.get(cxn.getToId());
// System.out.println(
// objDefMap.get(idObj.getDefId()).getName() + " 的下一个形状是 " + objDefMap.get(toIdObj.getDefId()).getName()
// );
//
// }
// }
// }
}else {
System.out.println("当前流程【"+modelModel.getName()+"】下没有图形 流程的ARIS路径为 "+modelModel.getModelPath());
}

View File

@ -13,9 +13,9 @@ import com.actionsoft.apps.coe.pal.datamigration.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.datamigration.util.WordUtil;
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.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryAttributeCache;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
@ -178,8 +178,8 @@ public class DataMigrationWeb extends ActionWeb {
// String fileName = "xmlexport.xml";
// 读取xml文件
Document d = XMLUtil.readXML(file.getPath(), true);
// String toFilePath = "/Users/actionsoft/Documents/workspace/IDEA/yili/apps/com.actionsoft.apps.coe.pal.datamigration/testFile/targetFile/";
// XMLUtil.writeXml(d, toFilePath + fileName);
// String toFilePath = "/Users/sunlh/Documents/ideaData/actionsoft/aws6.4.1.1008.yili2/apps/com.actionsoft.apps.coe.pal.datamigration/testFile/targetFile/";
// XMLUtil.writeXml(d, toFilePath + fileName);
// 解析xml文件
if (d == null) {
return ResponseObject.newErrResponse().toString();
@ -200,8 +200,27 @@ public class DataMigrationWeb extends ActionWeb {
Map<String, List<CxnOccModel>> cxnOccMap = handleWeb.cxnOccMap;// 形状连线记录
Map<String, Set<String>> objDefLinkerMap = handleWeb.objDefLinkerMap;// 记录所有定义形状的连线map记录
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);
}
}
// 存储匹配到与未匹配到的模型信息
List<ModelModel> matchModels = new ArrayList<>();
List<ModelModel> unMatchModels = new ArrayList<>();
@ -278,7 +297,6 @@ public class DataMigrationWeb extends ActionWeb {
// 创建形状和连线
JSONObject newElements = createShapeElement(wsId, currentModelNoShape, idRelationMap, roleShapeIdRelationMap, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap);
System.out.println("111");
if (newElements == null) continue;
// 处理输入输出活动属性
@ -288,7 +306,7 @@ public class DataMigrationWeb extends ActionWeb {
this.handleProcessAttrRoleRelation(wsId, palModel.getId(), roleShapeIdRelationMap, newElements, arisModel, modelObjOccMap, objDefMap);
// 处理流程关联属性IT系统
this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap);
this.handleProcessAttrItSystemRelation(wsId, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap, objDefLinkerMap, itShapeMap);
this.handleProcessAttrLeadOrRearProcess(wsId, currentModelNoShape, idRelationMap, palModel.getId(), newElements, arisModel, modelObjOccMap, objDefMap);
@ -437,9 +455,10 @@ public class DataMigrationWeb extends ActionWeb {
/**
* 校验一些必备的建模属性
*
* @param wsId
* @param mappingKey
* @param shapeMethodId
* @param shapeMethodName
* @param methodId
* @param categoryName
* @param methodName
* @param methodCode
@ -927,7 +946,6 @@ public class DataMigrationWeb extends ActionWeb {
/**
* 处理流程关联属性IT系统
*
* @param wsId
* @param idRelationMap
* @param repositoryModelId
@ -935,125 +953,55 @@ public class DataMigrationWeb extends ActionWeb {
* @param arisModel
* @param modelObjOccMap
* @param objDefMap
* @param objDefLinkerMap
* @param itShapeMap
*/
private void handleProcessAttrItSystemRelation(String wsId, Map<String, String> idRelationMap, String repositoryModelId, JSONObject elements, ModelModel arisModel,
Map<String, List<ObjOccModel>> modelObjOccMap,
Map<String, ObjDefModel> objDefMap) {
Map<String, ObjDefModel> objDefMap, Map<String, Set<String>> objDefLinkerMap, Map<String, JSONObject> itShapeMap) {
// 获取ARIS图形定义与PAL图形定义关系
Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_APPL_SYS_TYPE-ST_APPL_SYS_TYPE");
// 获取当前ARIS模型下所有的图形信息
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId());
// 存放待删除图形的KEY
List<String> removeKey = new ArrayList<>();
// 流程关联属性结果集
Map<String, Set<String>> shapeRelationItMap = new HashMap<>();// 记录PAL形状关联的IT系统文本
for (ObjOccModel objOccModel: objOccModels) {
String objDefId = objOccModel.getDefId();
System.out.println(objDefMap.get(objDefId).getName());
// 获取定义形状通过连线进行连接的所有定义形状
Set<String> toObjDefIds = objDefLinkerMap.get(objDefId);
if (toObjDefIds == null || toObjDefIds.size() == 0) {
continue;
}
// 取出所有IT系统
Set<String> shapeRelationItObjDefNames = new HashSet<>();// 记录当前形状的IT系统s
for (String toObjDefId: toObjDefIds) {
ObjDefModel objDefModel = objDefMap.get(toObjDefId);
if (objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum()) && objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum())) {
// 是IT系统
shapeRelationItObjDefNames.add(objDefModel.getName());
}
}
if (shapeRelationItObjDefNames.size() > 0) {
shapeRelationItMap.put(idRelationMap.get(objOccModel.getId()), shapeRelationItObjDefNames);
}
}
List<DesignerShapeRelationModel> relationList = new ArrayList<>();
for (ObjOccModel objOccModel : objOccModels) {
ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
// 根据ARIS图形定义信息判断当前模型下的所有形状里是否有系统形状
if (objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum()) && objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum())) {
// 如果有输入输出形状 取出关联的PAL模型ID
String shapeId = idRelationMap.get(objOccModel.getId());
JSONObject itSystemObj = elements.getJSONObject(shapeId);
// 根据当前关联的系统图内容与已经导入进的系统图的内容去匹配 如果没有匹配上 暂时不处理暂定
// 需求变动--暂作文本处理
// String itSysShapeRelationId = "";
// String itSysRepositoryRelationId = "";
// List<PALRepositoryModel> repositoryModels = PALRepositoryQueryAPIManager.getInstance().getPalRepositoryModelsByWsIdAndMethodId(wsId, "itsystem.normal");
// for (PALRepositoryModel model : repositoryModels){
// BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(model.getId(), 0);
// if (baseModel == null) {
// continue;
// }
// String define = baseModel.getDefinition();
// JSONObject definition = JSONObject.parseObject(define);
// JSONObject ele = definition.getJSONObject("elements");
// for (String key : ele.keySet()) {
// JSONObject shapeObj = elements.getJSONObject(key);
// if (shapeObj.getString("text").equals(itSystemObj.getString("text"))) {
// itSysShapeRelationId = key;
// itSysRepositoryRelationId = model.getId();
// break;
// }
// }
// if (UtilString.isNotEmpty(itSysShapeRelationId)) {
// break;
// }
// }
for (String key : elements.keySet()) {
JSONObject shapeObj = elements.getJSONObject(key);
if ("linker".equals(shapeObj.getString("name"))) {
List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance()
.getValidAttributeModels(wsId, "process.epc", "process", "process.epc");
attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_INFO_SYSTEM.equals(item.getKey())).collect(Collectors.toList());
PALMethodAttributeModel attributeModel = attributeModels.get(0);
String relationedShapeId = "";
if (shapeObj.getJSONObject("from").getString("id").equals(shapeId)) {
relationedShapeId = shapeObj.getJSONObject("to").getString("id");
} else if (shapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
relationedShapeId = shapeObj.getJSONObject("from").getString("id");
}
if (UtilString.isEmpty(relationedShapeId)) {
continue;
}
// 将转化后的信息放到相应位置
// DesignerShapeRelationModel relationModel = new DesignerShapeRelationModel();
// relationModel.setFileId(repositoryModelId);
// relationModel.setAttrId(attributeModel.getKey());
// relationModel.setId(UUIDGener.getUUID());
// relationModel.setShapeId(relationedShapeId);
// relationModel.setShapeText(elements.getJSONObject(relationedShapeId).getString("text"));
// relationModel.setRelationFileId(itSysRepositoryRelationId);
// relationModel.setRelationShapeId(itSysShapeRelationId);
// relationModel.setRelationShapeText(itSystemObj.getString("text"));
// relationList.add(relationModel);
JSONArray dataAttributes = elements.getJSONObject(relationedShapeId).getJSONArray("dataAttributes");
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
JSONObject tempRelationObj = new JSONObject();
tempRelationObj.put("value", itSystemObj.getString("text"));
tempRelationObj.put("key", attributeModel.getKey());
tempRelationObj.put("isRequired", attributeModel.getIsRequired());
tempRelationObj.put("ref", attributeModel.getRef());
tempRelationObj.put("readonly", attributeModel.getReadonly());
tempRelationObj.put("scope", attributeModel.getScope());
tempRelationObj.put("name", attributeModel.getTitle());
tempRelationObj.put("id", attributeModel.getKey());
tempRelationObj.put("type", attributeModel.getType());
tempRelationObj.put("groupPath", attributeModel.getGroupPath());
tempRelationObj.put("desc", attributeModel.getDesc());
for (Object attribute : dataAttributes) {
JSONObject obj = (JSONObject) attribute;
if (obj.containsKey("attributesJsonArray")) {
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
JSONArray tempJSONArr = attributesJsonArray.stream()
.filter(item -> ((JSONObject) item).getString("key").equals(attributeModel.getKey()))
.collect(Collectors.toCollection(JSONArray::new));
if (tempJSONArr.size() > 0) {
for (Object o : attributesJsonArray) {
if (attributeModel.getKey().equals(((JSONObject) o).getString("key"))) {
String tempValue = new StringBuffer(((JSONObject) o).getString("value"))
.append(",").append(itSystemObj.getString("text")).toString();
((JSONObject) o).put("value", tempValue);
}
}
} else {
tempRelationObj.put("value", new JSONArray());
tempRelationObj.getJSONArray("value").add(tempRelationObj);
attributesJsonArray.add(tempRelationObj);
}
break;
} else {
tempRelationObj.put("value", new JSONArray());
tempRelationObj.getJSONArray("value").add(tempRelationObj);
obj.put("attributesJsonArray", new JSONArray());
obj.getJSONArray("attributesJsonArray").add(tempRelationObj);
break;
}
}
}
removeKey.add(key);
removeKey.add(shapeId);
}
for (Map.Entry<String, Set<String>> entry: shapeRelationItMap.entrySet()) {
String shapeId = entry.getKey();
Set<String> itShapeNames = entry.getValue();
for (String itShapeName: itShapeNames) {
if (itShapeMap.containsKey(itShapeName)) {
DesignerShapeRelationModel m = new DesignerShapeRelationModel();
m.setId(UUIDGener.getUUID());
m.setFileId(repositoryModelId);
m.setShapeId(shapeId);
m.setShapeText(elements.getJSONObject(shapeId).getString("text"));
m.setRelationFileId(itShapeMap.get(itShapeName).getString("plId"));
m.setRelationShapeId(itShapeMap.get(itShapeName).getString("shapeId"));
m.setRelationShapeText(itShapeMap.get(itShapeName).getString("shapeName"));
m.setAttrId(Constant.METHOD_INFO_SYSTEM);
relationList.add(m);
}
}
}
@ -1063,7 +1011,6 @@ public class DataMigrationWeb extends ActionWeb {
relationList.stream().forEach(item -> printMsg("流程【" + arisModel.getName() + "】中的活动节点【" + item.getShapeText() + "】关联当前流程下IT系统【" + item.getRelationShapeText() + ""));
relationDao.barchInsert(relationList);
}
removeKey.stream().forEach(key -> elements.remove(key));
}
/**
@ -1637,7 +1584,7 @@ public class DataMigrationWeb extends ActionWeb {
if (propertyModel.getPropertyValue().equals(modelPath)) {
// printMsg("ARIS路径 "+propertyModel.getPropertyValue());
repositoryModel = new PALRepository().getInstance(propertyModel.getPlId());
if (arisModel.getName().equals(repositoryModel.getName())) {
if (arisModel.getName().trim().equals(repositoryModel.getName())) {
printMsg("匹配到的MODEL PATH " + modelPath + "\\" + arisModel.getName());
flag = true;
break;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long