模型转换功能阶段提交
This commit is contained in:
parent
c3859b2745
commit
94219d7cbd
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
package com.actionsoft.apps.coe.pal.modelconvert.cache;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConvertShapeNameMapping {
|
||||
|
||||
private ConvertShapeNameMapping(){}
|
||||
private static ConvertShapeNameMapping shapeNameMapping = new ConvertShapeNameMapping();
|
||||
private static Map<String, String> map = new HashMap<>();
|
||||
|
||||
static {
|
||||
map.put("and","decision"); // 与 -> 判定
|
||||
map.put("or","decision"); // 或 -> 判定
|
||||
map.put("xor","decision"); // 异或 -> 判定
|
||||
map.put("procedure","procedure"); // 流程接口
|
||||
map.put("method_approval_node","method_approval_node"); // 线上审批
|
||||
map.put("method_service_node","method_service_node"); // 线下审批
|
||||
map.put("method_approval_node3","method_approval_node3"); // 系统任务
|
||||
map.put("method_service_node4","method_service_node4"); // 人工任务
|
||||
}
|
||||
|
||||
public static ConvertShapeNameMapping getInstance(){
|
||||
return shapeNameMapping;
|
||||
}
|
||||
|
||||
public String getShapeName(String key){
|
||||
if (map.containsKey(key)){
|
||||
return map.get(key);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,19 @@
|
||||
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.model.RelationAttributeModel;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
|
||||
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.PALRepositoryPropertyModel;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -18,6 +26,22 @@ public class AwsOrgTypeAttrHandle implements DataAttributeStrategy {
|
||||
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
|
||||
String targetRepositoryId = (String) param.get("targetRepositoryId");
|
||||
String attrId = (String) param.get("attrId");
|
||||
// 1.处理 _prop表
|
||||
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
|
||||
List<PALRepositoryPropertyModel> propertyModels = propertyDao.getPropertysByPlid(sourceRepositoryId, attrId);
|
||||
List<PALRepositoryPropertyModel> batchList = new ArrayList<>();
|
||||
for (PALRepositoryPropertyModel propertyModel : propertyModels) {
|
||||
PALRepositoryPropertyModel model = new PALRepositoryPropertyModel();
|
||||
model.setId(UUIDGener.getUUID());
|
||||
model.setPlId(targetRepositoryId);
|
||||
model.setPropertyId(propertyModel.getPropertyId());
|
||||
model.setPropertyName(propertyModel.getPropertyName());
|
||||
model.setPropertyValue(propertyModel.getPropertyValue());
|
||||
model.setOrderIndex(0);
|
||||
batchList.add(model);
|
||||
}
|
||||
propertyDao.batchInsert(batchList);
|
||||
// 2.处理 _shape_rlat表
|
||||
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
|
||||
List<DesignerShapeRelationModel> sourceRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
|
||||
// 关联类型的文件属性 关联表中 shapeId shapeText 字段是空值
|
||||
@ -48,6 +72,81 @@ public class AwsOrgTypeAttrHandle implements DataAttributeStrategy {
|
||||
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
|
||||
String targetRepositoryId = (String) param.get("targetRepositoryId");
|
||||
String attrId = (String) param.get("attrId");
|
||||
String beforeShapeName = (String) param.get("beforeShapeName");
|
||||
// 1. definition 做处理
|
||||
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(sourceRepositoryId, 0);
|
||||
String definition = baseModel.getDefinition();
|
||||
JSONObject defineJsonObj = JSONObject.parseObject(definition);
|
||||
JSONObject sourceElements = defineJsonObj.getJSONObject("elements");
|
||||
sourceElements.keySet().stream()
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("linker"))
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("event")) // 事件的属性直接跳过了 因为转换后 事件图形变成连线了
|
||||
.filter(key -> sourceElements.getJSONObject(key).getString("name").equals(beforeShapeName))
|
||||
.forEach(key -> {
|
||||
// 当前被转换的节点图形
|
||||
JSONObject sourceShape = sourceElements.getJSONObject(key);
|
||||
if (sourceShape.containsKey("dataAttributes") && sourceShape.getJSONArray("dataAttributes") != null){
|
||||
JSONArray dataAttributes = sourceShape.getJSONArray("dataAttributes");
|
||||
if (dataAttributes.size() > 0){
|
||||
for (int i = 0; i < dataAttributes.size(); i++) {
|
||||
JSONObject item = dataAttributes.getJSONObject(i);
|
||||
if (item.containsKey("attributesJsonArray")){
|
||||
JSONArray attributesJsonArray = item.getJSONArray("attributesJsonArray");
|
||||
for (int j = 0; j < attributesJsonArray.size(); j++) {
|
||||
JSONObject object = attributesJsonArray.getJSONObject(j);
|
||||
if (object == null) continue;
|
||||
if (object.getString("id").equals(attrId) && "awsorg".equals(object.getString("type"))){
|
||||
// 将当前的属性存入到转换后的文件中
|
||||
String targetDefinition = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0).getDefinition();
|
||||
JSONObject targetDefineJsonObj = JSONObject.parseObject(targetDefinition);
|
||||
JSONObject targetElements = targetDefineJsonObj.getJSONObject("elements");
|
||||
JSONObject targetShape = targetElements.getJSONObject(ConvertShapeIdMapping.getInstance().getTargetShapeId(key));
|
||||
if (targetShape.containsKey("dataAttributes") && targetShape.getJSONArray("dataAttributes") != null){
|
||||
JSONArray targetDataAttributes = targetShape.getJSONArray("dataAttributes");
|
||||
for (int k = 0; k < targetDataAttributes.size(); k++) {
|
||||
JSONObject targetItem = targetDataAttributes.getJSONObject(k);
|
||||
if (targetItem.containsKey("attributesJsonArray")){
|
||||
JSONArray targetItemJSONArray = targetItem.getJSONArray("attributesJsonArray");
|
||||
for (int l = 0; l < targetItemJSONArray.size(); l++) {
|
||||
JSONObject targetObj = targetItemJSONArray.getJSONObject(l);
|
||||
if (targetObj == null) continue;
|
||||
if (targetObj.getString("id").equals(attrId) && "awsorg".equals(targetObj.getString("type"))) targetItemJSONArray.remove(l);
|
||||
}
|
||||
JSONObject tempObj = new JSONObject();
|
||||
tempObj.put("isRequired",object.getBooleanValue("isRequired"));
|
||||
tempObj.put("ref",object.getString("ref"));
|
||||
tempObj.put("readonly",object.getBooleanValue("readonly"));
|
||||
tempObj.put("scope",object.getString("scope"));
|
||||
tempObj.put("name",object.getString("name"));
|
||||
tempObj.put("icon",object.getString("icon"));
|
||||
tempObj.put("id",object.getString("id"));
|
||||
tempObj.put("type",object.getString("type"));
|
||||
tempObj.put("value",object.getJSONArray("value"));
|
||||
tempObj.put("groupPath",object.getString("groupPath"));
|
||||
tempObj.put("key",object.getString("key"));
|
||||
targetItemJSONArray.add(tempObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetElements.put(ConvertShapeIdMapping.getInstance().getTargetShapeId(key),targetShape);
|
||||
targetDefineJsonObj.put("elements",targetElements);
|
||||
BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0);
|
||||
if (model == null) {
|
||||
model = CoeDesignerUtil.createModel(targetRepositoryId, 0);
|
||||
}
|
||||
model.setDefinition(JSONObject.toJSONString(targetDefineJsonObj));
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(model);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 2. _shape_rlat 表做处理
|
||||
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
|
||||
List<DesignerShapeRelationModel> shapeRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
|
||||
|
||||
@ -1,11 +1,19 @@
|
||||
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.model.RelationAttributeModel;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
|
||||
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.PALRepositoryPropertyModel;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -18,6 +26,27 @@ public class RelationTypeAttrHandle implements DataAttributeStrategy {
|
||||
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
|
||||
String targetRepositoryId = (String) param.get("targetRepositoryId");
|
||||
String attrId = (String) param.get("attrId");
|
||||
// 1.处理 _prop表
|
||||
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
|
||||
List<PALRepositoryPropertyModel> propertyModels = propertyDao.getPropertysByPlid(sourceRepositoryId, attrId);
|
||||
List<PALRepositoryPropertyModel> batchList = new ArrayList<>();
|
||||
for (PALRepositoryPropertyModel propertyModel : propertyModels) {
|
||||
PALRepositoryPropertyModel model = new PALRepositoryPropertyModel();
|
||||
model.setId(UUIDGener.getUUID());
|
||||
model.setPlId(targetRepositoryId);
|
||||
model.setPropertyId(propertyModel.getPropertyId());
|
||||
model.setPropertyName(propertyModel.getPropertyName());
|
||||
JSONObject relationObj = JSONObject.parseObject(propertyModel.getPropertyValue());
|
||||
RelationAttributeModel relationAttributeModel = new RelationAttributeModel(targetRepositoryId, relationObj.getString("shapeId"),
|
||||
relationObj.getString("shapeText"), relationObj.getString("attrId"), relationObj.getString("relationFileId"),
|
||||
relationObj.getString("relationShapeId"), relationObj.getString("relationShapeText"),
|
||||
relationObj.getString("groupPath"));
|
||||
model.setPropertyValue(relationAttributeModel.toJSONObject().toJSONString());
|
||||
model.setOrderIndex(0);
|
||||
batchList.add(model);
|
||||
}
|
||||
propertyDao.batchInsert(batchList);
|
||||
// 2.处理 _shape_rlat表
|
||||
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
|
||||
List<DesignerShapeRelationModel> sourceRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
|
||||
// 关联类型的文件属性 关联表中 shapeId shapeText 字段是空值
|
||||
@ -48,8 +77,81 @@ public class RelationTypeAttrHandle implements DataAttributeStrategy {
|
||||
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
|
||||
String targetRepositoryId = (String) param.get("targetRepositoryId");
|
||||
String attrId = (String) param.get("attrId");
|
||||
String beforeShapeName = (String) param.get("beforeShapeName");
|
||||
// 1. definition 做处理
|
||||
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(sourceRepositoryId, 0);
|
||||
String definition = baseModel.getDefinition();
|
||||
JSONObject defineJsonObj = JSONObject.parseObject(definition);
|
||||
JSONObject sourceElements = defineJsonObj.getJSONObject("elements");
|
||||
sourceElements.keySet().stream()
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("linker"))
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("event")) // 事件的属性直接跳过了 因为转换后 事件图形变成连线了
|
||||
.filter(key -> sourceElements.getJSONObject(key).getString("name").equals(beforeShapeName))
|
||||
.forEach(key -> {
|
||||
// 当前被转换的节点图形
|
||||
JSONObject sourceShape = sourceElements.getJSONObject(key);
|
||||
if (sourceShape.containsKey("dataAttributes") && sourceShape.getJSONArray("dataAttributes") != null){
|
||||
JSONArray dataAttributes = sourceShape.getJSONArray("dataAttributes");
|
||||
if (dataAttributes.size() > 0){
|
||||
for (int i = 0; i < dataAttributes.size(); i++) {
|
||||
JSONObject item = dataAttributes.getJSONObject(i);
|
||||
if (item.containsKey("attributesJsonArray")){
|
||||
JSONArray attributesJsonArray = item.getJSONArray("attributesJsonArray");
|
||||
for (int j = 0; j < attributesJsonArray.size(); j++) {
|
||||
JSONObject object = attributesJsonArray.getJSONObject(j);
|
||||
if (object == null) continue;
|
||||
if (object.getString("id").equals(attrId) && "relation".equals(object.getString("type"))){
|
||||
// 将当前的属性存入到转换后的文件中
|
||||
String targetDefinition = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0).getDefinition();
|
||||
JSONObject targetDefineJsonObj = JSONObject.parseObject(targetDefinition);
|
||||
JSONObject targetElements = targetDefineJsonObj.getJSONObject("elements");
|
||||
JSONObject targetShape = targetElements.getJSONObject(ConvertShapeIdMapping.getInstance().getTargetShapeId(key));
|
||||
if (targetShape.containsKey("dataAttributes") && targetShape.getJSONArray("dataAttributes") != null){
|
||||
JSONArray targetDataAttributes = targetShape.getJSONArray("dataAttributes");
|
||||
for (int k = 0; k < targetDataAttributes.size(); k++) {
|
||||
JSONObject targetItem = targetDataAttributes.getJSONObject(k);
|
||||
if (targetItem.containsKey("attributesJsonArray")){
|
||||
JSONArray targetItemJSONArray = targetItem.getJSONArray("attributesJsonArray");
|
||||
for (int l = 0; l < targetItemJSONArray.size(); l++) {
|
||||
JSONObject targetObj = targetItemJSONArray.getJSONObject(l);
|
||||
if (targetObj == null) continue;
|
||||
if (targetObj.getString("id").equals(attrId) && "relation".equals(targetObj.getString("type"))) targetItemJSONArray.remove(l);
|
||||
}
|
||||
JSONObject tempObj = new JSONObject();
|
||||
tempObj.put("isRequired",object.getBooleanValue("isRequired"));
|
||||
tempObj.put("ref",object.getString("ref"));
|
||||
tempObj.put("readonly",object.getBooleanValue("readonly"));
|
||||
tempObj.put("scope",object.getString("scope"));
|
||||
tempObj.put("name",object.getString("name"));
|
||||
tempObj.put("icon",object.getString("icon"));
|
||||
tempObj.put("id",object.getString("id"));
|
||||
tempObj.put("type",object.getString("type"));
|
||||
tempObj.put("value",object.getString("value"));
|
||||
tempObj.put("groupPath",object.getString("groupPath"));
|
||||
tempObj.put("key",object.getString("key"));
|
||||
targetItemJSONArray.add(tempObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetElements.put(ConvertShapeIdMapping.getInstance().getTargetShapeId(key),targetShape);
|
||||
targetDefineJsonObj.put("elements",targetElements);
|
||||
BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0);
|
||||
if (model == null) {
|
||||
model = CoeDesignerUtil.createModel(targetRepositoryId, 0);
|
||||
}
|
||||
model.setDefinition(JSONObject.toJSONString(targetDefineJsonObj));
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(model);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 2. _shape_rlat 表做处理
|
||||
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
|
||||
List<DesignerShapeRelationModel> shapeRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
|
||||
|
||||
@ -47,7 +47,9 @@ public class TextTypeAttrHandle implements DataAttributeStrategy {
|
||||
// 直接处理 definition
|
||||
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
|
||||
String targetRepositoryId = (String) param.get("targetRepositoryId");
|
||||
String sourcePropertyId = (String) param.get("sourcePropertyId");
|
||||
String attrId = (String) param.get("attrId");
|
||||
String beforeShapeName = (String) param.get("beforeShapeName");
|
||||
String afterShapeName = (String) param.get("afterShapeName");
|
||||
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(sourceRepositoryId, 0);
|
||||
String definition = baseModel.getDefinition();
|
||||
JSONObject defineJsonObj = JSONObject.parseObject(definition);
|
||||
@ -55,6 +57,7 @@ public class TextTypeAttrHandle implements DataAttributeStrategy {
|
||||
sourceElements.keySet().stream()
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("linker"))
|
||||
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("event")) // 事件的属性直接跳过了 因为转换后 事件图形变成连线了
|
||||
.filter(key -> sourceElements.getJSONObject(key).getString("name").equals(beforeShapeName))
|
||||
.forEach(key -> {
|
||||
// 当前被转换的节点图形
|
||||
JSONObject sourceShape = sourceElements.getJSONObject(key);
|
||||
@ -68,7 +71,7 @@ public class TextTypeAttrHandle implements DataAttributeStrategy {
|
||||
for (int j = 0; j < attributesJsonArray.size(); j++) {
|
||||
JSONObject object = attributesJsonArray.getJSONObject(j);
|
||||
if (object == null) continue;
|
||||
if (object.getString("id").equals(sourcePropertyId)){
|
||||
if (object.getString("id").equals(attrId)){
|
||||
// 将当前的属性存入到转换后的文件中
|
||||
String targetDefinition = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0).getDefinition();
|
||||
JSONObject targetDefineJsonObj = JSONObject.parseObject(targetDefinition);
|
||||
@ -83,7 +86,7 @@ public class TextTypeAttrHandle implements DataAttributeStrategy {
|
||||
for (int l = 0; l < targetItemJSONArray.size(); l++) {
|
||||
JSONObject targetObj = targetItemJSONArray.getJSONObject(l);
|
||||
if (targetObj == null) continue;
|
||||
if (targetObj.getString("id").equals(sourcePropertyId)) targetItemJSONArray.remove(l);
|
||||
if (targetObj.getString("id").equals(attrId)) targetItemJSONArray.remove(l);
|
||||
}
|
||||
JSONObject tempObj = new JSONObject();
|
||||
tempObj.put("isRequired",object.getBooleanValue("isRequired"));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.actionsoft.apps.coe.pal.modelconvert.strategy.impl;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeNameMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.RepositoryModelCache;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.LinkerDefConstant;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.ShapeConstant;
|
||||
@ -20,6 +21,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelI
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
@ -41,7 +43,7 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
String repositoryId = (String) param.get("repositoryId");
|
||||
String sourceMethod = (String)param.get("sourceMethod");
|
||||
String targetMethod = (String)param.get("targetMethod");
|
||||
boolean duplicateName = (boolean)param.get("duplicateName");
|
||||
boolean duplicateName = Boolean.parseBoolean((String) param.get("duplicateName"));
|
||||
PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
|
||||
PALRepositoryModelImpl epcRepositoryModel = (PALRepositoryModelImpl)repository.getInstance(repositoryId);
|
||||
|
||||
@ -115,6 +117,7 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
Map<String, DecisionNode> decisionNodeMap = new HashMap<>();
|
||||
Map<String,Map<String,List<LinkerAdapter>>> linkerAdapterMap = new HashMap<>();
|
||||
Set<String> toBeDeletes = new HashSet<>();
|
||||
Map<String,JSONObject> decisionMap = new HashMap<>();
|
||||
// 保存图形y坐标的最大值
|
||||
double[] maxShapeY = {0.0};
|
||||
elements.keySet().stream().forEach(key -> {
|
||||
@ -152,7 +155,7 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
decision.put("props",decisionProps);
|
||||
String text = "and".equals(shapeName) ? "与" : "or".equals(shapeName) ? "或" : "异或";
|
||||
decision.put("text",text);
|
||||
elements.put(_id,decision);
|
||||
decisionMap.put(_id,decision);
|
||||
// 记录待删除的逻辑图形的key值
|
||||
toBeDeletes.add(key);
|
||||
|
||||
@ -170,6 +173,11 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
}
|
||||
}
|
||||
});
|
||||
// epc的逻辑节点 替换为 flowchart的判定节点
|
||||
decisionMap.keySet().stream().forEach(key -> {
|
||||
JSONObject decision = decisionMap.get(key);
|
||||
elements.put(key,decision);
|
||||
});
|
||||
// 处理事件节点
|
||||
eventNodeMap.keySet().stream().forEach(key -> {
|
||||
EventNode eventNode = eventNodeMap.get(key);
|
||||
@ -238,55 +246,8 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
// 记录下待删除图形的key
|
||||
toBeDeletes.add(key);
|
||||
});
|
||||
// 处理与 或 异或 节点的连线
|
||||
decisionNodeMap.keySet().stream().forEach(key -> {
|
||||
DecisionNode decisionNode = decisionNodeMap.get(key);
|
||||
elements.keySet().stream()
|
||||
.filter(k -> "linker".equals(elements.getJSONObject(k).getString("name")))
|
||||
.forEach(k -> {
|
||||
JSONObject linkerObj = elements.getJSONObject(k);
|
||||
JSONObject fromObj = linkerObj.getJSONObject("from");
|
||||
JSONObject toObj = linkerObj.getJSONObject("to");
|
||||
if (decisionNode.getLogicNodeId().equals(fromObj.getString("id"))){
|
||||
double x = fromObj.getDoubleValue("x");
|
||||
double y = fromObj.getDoubleValue("y");
|
||||
if (x == decisionNode.getPosition().getX()) {
|
||||
if (y < decisionNode.getPosition().getY()){
|
||||
fromObj.put("y",decisionNode.getPosition().getY() - (decisionNode.getH() / 2));
|
||||
}else if (y > decisionNode.getPosition().getY()){
|
||||
fromObj.put("y",decisionNode.getPosition().getY() + (decisionNode.getH() / 2));
|
||||
}
|
||||
fromObj.put("id",decisionNode.getId());
|
||||
}else if (y == decisionNode.getPosition().getY()){
|
||||
if (x < decisionNode.getPosition().getX()){
|
||||
fromObj.put("x",decisionNode.getPosition().getX() - (decisionNode.getW() / 2));
|
||||
}else if (x > decisionNode.getPosition().getX()){
|
||||
fromObj.put("x",decisionNode.getPosition().getX() + (decisionNode.getW() / 2));
|
||||
}
|
||||
fromObj.put("id",decisionNode.getId());
|
||||
}
|
||||
}else if (decisionNode.getLogicNodeId().equals(toObj.getString("id"))){
|
||||
double x = toObj.getDoubleValue("x");
|
||||
double y = toObj.getDoubleValue("y");
|
||||
if (x == decisionNode.getPosition().getX()){
|
||||
if (y < decisionNode.getPosition().getY()){
|
||||
toObj.put("y",decisionNode.getPosition().getY() - (decisionNode.getH() / 2));
|
||||
}else if (y > decisionNode.getPosition().getY()){
|
||||
toObj.put("y",decisionNode.getPosition().getY() + (decisionNode.getH() / 2));
|
||||
}
|
||||
toObj.put("id",decisionNode.getId());
|
||||
}else if (y == decisionNode.getPosition().getY()){
|
||||
if (x < decisionNode.getPosition().getX()){
|
||||
toObj.put("x",decisionNode.getPosition().getX() - (decisionNode.getW() / 2));
|
||||
}else if (x > decisionNode.getPosition().getX()){
|
||||
toObj.put("x",decisionNode.getPosition().getX() + (decisionNode.getW() / 2));
|
||||
}
|
||||
toObj.put("id",decisionNode.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// 3.2 根据封装的LinkerAdapter生成新的linker
|
||||
|
||||
// 3.2 根据封装的LinkerAdapter生成新的linker 生成事件线
|
||||
linkerAdapterMap.keySet().stream().forEach(key -> {
|
||||
EventNode eventNode = eventNodeMap.get(key);
|
||||
Position centerShapePosi = eventNode.getCenterShapePosi();
|
||||
@ -383,7 +344,56 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
}
|
||||
}
|
||||
});
|
||||
// 3.3 增加开始与结束节点
|
||||
|
||||
// 3.3 处理与 或 异或 节点的连线
|
||||
decisionNodeMap.keySet().stream().forEach(key -> {
|
||||
DecisionNode decisionNode = decisionNodeMap.get(key);
|
||||
elements.keySet().stream()
|
||||
.filter(k -> "linker".equals(elements.getJSONObject(k).getString("name")))
|
||||
.forEach(k -> {
|
||||
JSONObject linkerObj = elements.getJSONObject(k);
|
||||
JSONObject fromObj = linkerObj.getJSONObject("from");
|
||||
JSONObject toObj = linkerObj.getJSONObject("to");
|
||||
if (decisionNode.getLogicNodeId().equals(fromObj.getString("id"))){
|
||||
double x = fromObj.getDoubleValue("x");
|
||||
double y = fromObj.getDoubleValue("y");
|
||||
if (x == decisionNode.getPosition().getX()) {
|
||||
if (y < decisionNode.getPosition().getY()){
|
||||
fromObj.put("y",decisionNode.getPosition().getY() - (decisionNode.getH() / 2));
|
||||
}else if (y > decisionNode.getPosition().getY()){
|
||||
fromObj.put("y",decisionNode.getPosition().getY() + (decisionNode.getH() / 2));
|
||||
}
|
||||
fromObj.put("id",decisionNode.getId());
|
||||
}else if (y == decisionNode.getPosition().getY()){
|
||||
if (x < decisionNode.getPosition().getX()){
|
||||
fromObj.put("x",decisionNode.getPosition().getX() - (decisionNode.getW() / 2));
|
||||
}else if (x > decisionNode.getPosition().getX()){
|
||||
fromObj.put("x",decisionNode.getPosition().getX() + (decisionNode.getW() / 2));
|
||||
}
|
||||
fromObj.put("id",decisionNode.getId());
|
||||
}
|
||||
}else if (decisionNode.getLogicNodeId().equals(toObj.getString("id"))){
|
||||
double x = toObj.getDoubleValue("x");
|
||||
double y = toObj.getDoubleValue("y");
|
||||
if (x == decisionNode.getPosition().getX()){
|
||||
if (y < decisionNode.getPosition().getY()){
|
||||
toObj.put("y",decisionNode.getPosition().getY() - (decisionNode.getH() / 2));
|
||||
}else if (y > decisionNode.getPosition().getY()){
|
||||
toObj.put("y",decisionNode.getPosition().getY() + (decisionNode.getH() / 2));
|
||||
}
|
||||
toObj.put("id",decisionNode.getId());
|
||||
}else if (y == decisionNode.getPosition().getY()){
|
||||
if (x < decisionNode.getPosition().getX()){
|
||||
toObj.put("x",decisionNode.getPosition().getX() - (decisionNode.getW() / 2));
|
||||
}else if (x > decisionNode.getPosition().getX()){
|
||||
toObj.put("x",decisionNode.getPosition().getX() + (decisionNode.getW() / 2));
|
||||
}
|
||||
toObj.put("id",decisionNode.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// 3.4 增加开始与结束节点
|
||||
JSONObject startNode = ShapeUtil.getProcessShapeDefinition("process.flowchart", "开始/结束");
|
||||
String startNodeId = UUIDGener.getObjectId();
|
||||
startNode.put("id",startNodeId);
|
||||
@ -428,8 +438,8 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
private void handleDataAttribute(String sourceRepositoryId,String targetRepositoryId,String wsId,String sourceMethod,String targetMethod){
|
||||
// 文件属性配置
|
||||
PALRepositoryAttributeDao fileAttrDao = new PALRepositoryAttributeDao();
|
||||
List<PALRepositoryAttributeModel> sourceFileAttrList = fileAttrDao.getFileAttribute(wsId, sourceMethod);
|
||||
List<PALRepositoryAttributeModel> targetFileAttrList = fileAttrDao.getFileAttribute(wsId, targetMethod);
|
||||
List<PALRepositoryAttributeModel> sourceFileAttrList = fileAttrDao.getFileAttrConfigList(wsId, sourceMethod);
|
||||
List<PALRepositoryAttributeModel> targetFileAttrList = fileAttrDao.getFileAttrConfigList(wsId, targetMethod);
|
||||
|
||||
sourceFileAttrList.stream().forEach(sourceFileAttr -> {
|
||||
boolean targetFileAttrIsExist = targetFileAttrList.stream()
|
||||
@ -447,22 +457,28 @@ public class EpcToFlowChart implements ModelConvertStrategy {
|
||||
});
|
||||
// 图形属性配置
|
||||
PALRepositoryShapeAttributeDao shapeAttrDao = new PALRepositoryShapeAttributeDao();
|
||||
List<PALRepositoryShapeAttributeModel> sourceShapeAttrList = shapeAttrDao.getShapeAttribute(wsId, sourceMethod);
|
||||
List<PALRepositoryShapeAttributeModel> targetShapeAttrList = shapeAttrDao.getShapeAttribute(wsId, targetMethod);
|
||||
sourceShapeAttrList.stream().forEach(sourceShapeAttr -> {
|
||||
boolean targetShapeAttrIsExist = targetShapeAttrList.stream()
|
||||
.anyMatch(targetFileAttr -> sourceShapeAttr.getAttrId().equals(targetFileAttr.getAttrId())
|
||||
&& sourceShapeAttr.getShapeName().equals(targetFileAttr.getShapeName()));
|
||||
if (targetShapeAttrIsExist){ // 如果转换后的文件的图形建模属性中也有该属性配置 则将被转换的属性值导入过来
|
||||
// 图形属性值的处理
|
||||
DataAttributeStrategy attributeStrategy = DataAttributeContext.getInstance().dataAttributeStrategy(sourceShapeAttr.getType());
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("sourceRepositoryId",sourceRepositoryId);
|
||||
param.put("targetRepositoryId",targetRepositoryId);
|
||||
param.put("attrId",sourceShapeAttr.getAttrId());
|
||||
attributeStrategy.shapeAttrHandle(param);
|
||||
}
|
||||
});
|
||||
List<PALRepositoryShapeAttributeModel> sourceShapeAttrList = shapeAttrDao.getShapeAttrConfigList(wsId, sourceMethod,"");
|
||||
List<PALRepositoryShapeAttributeModel> targetShapeAttrList = shapeAttrDao.getShapeAttrConfigList(wsId, targetMethod,"");
|
||||
sourceShapeAttrList.stream()
|
||||
.filter(shapeAttr -> !"event".equals(shapeAttr.getShapeName())) // 事件图形 直接跳过
|
||||
.filter(sourceShapeAttr -> UtilString.isNotEmpty(ConvertShapeNameMapping.getInstance().getShapeName(sourceShapeAttr.getShapeName()))) // 表中可能会存在一些历史脏数据
|
||||
.forEach(sourceShapeAttr -> {
|
||||
boolean targetShapeAttrIsExist = targetShapeAttrList.stream()
|
||||
.anyMatch(targetFileAttr -> sourceShapeAttr.getAttrId().equals(targetFileAttr.getAttrId())
|
||||
&& sourceShapeAttr.getType().equals(targetFileAttr.getType())
|
||||
&& ConvertShapeNameMapping.getInstance().getShapeName(sourceShapeAttr.getShapeName()).equals(targetFileAttr.getShapeName()));
|
||||
if (targetShapeAttrIsExist){ // 如果转换后的文件的图形建模属性中也有该属性配置 则将被转换的属性值导入过来
|
||||
// 图形属性值的处理
|
||||
DataAttributeStrategy attributeStrategy = DataAttributeContext.getInstance().dataAttributeStrategy(sourceShapeAttr.getType());
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("sourceRepositoryId",sourceRepositoryId);
|
||||
param.put("targetRepositoryId",targetRepositoryId);
|
||||
param.put("beforeShapeName",sourceShapeAttr.getShapeName());
|
||||
param.put("afterShapeName",ConvertShapeNameMapping.getInstance().getShapeName(sourceShapeAttr.getShapeName()));
|
||||
param.put("attrId",sourceShapeAttr.getAttrId());
|
||||
attributeStrategy.shapeAttrHandle(param);
|
||||
}
|
||||
});
|
||||
// 形状显示规则
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -9,13 +9,13 @@ import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
public class ModelConvertController {
|
||||
|
||||
@Mapping("com.actionsoft.apps.coe.pal.handle_epc_to_flowchart")
|
||||
public String handleEpcToFlowChart(UserContext uc,String repositoryId,String sourceMethod,String targetMethod,boolean duplicateName){
|
||||
public String handleEpcToFlowChart(UserContext uc,String repositoryId,String sourceMethod,String targetMethod,String duplicateName){
|
||||
ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc);
|
||||
return modelConvertWeb.handleEpcToFlowChart(repositoryId,sourceMethod,targetMethod,duplicateName);
|
||||
}
|
||||
|
||||
@Mapping("com.actionsoft.apps.coe.pal.handle_epc_to_flowchart_batch")
|
||||
public String handleEpcToFlowChartBatch(UserContext uc,String repositoryIds,String sourceMethod,String targetMethod,boolean duplicateName){
|
||||
public String handleEpcToFlowChartBatch(UserContext uc,String repositoryIds,String sourceMethod,String targetMethod,String duplicateName){
|
||||
ModelConvertWeb modelConvertWeb = new ModelConvertWeb(uc);
|
||||
return modelConvertWeb.handleEpcToFlowChartBatch(repositoryIds,sourceMethod,targetMethod,duplicateName);
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class ModelConvertWeb extends ActionWeb {
|
||||
}
|
||||
|
||||
// 单个文件处理模型EPC转FlowChart
|
||||
public String handleEpcToFlowChart(String repositoryId,String sourceMethod,String targetMethod,boolean duplicateName){
|
||||
public String handleEpcToFlowChart(String repositoryId,String sourceMethod,String targetMethod,String duplicateName){
|
||||
Map<String,Object> params = new HashMap<String, Object>();
|
||||
params.put("sid",uc.getSessionId());
|
||||
params.put("repositoryId",repositoryId);
|
||||
@ -39,7 +39,7 @@ public class ModelConvertWeb extends ActionWeb {
|
||||
}
|
||||
|
||||
// 批量处理模型EPC转FlowChart
|
||||
public String handleEpcToFlowChartBatch(String repositoryIds,String sourceMethod,String targetMethod,boolean duplicateName){
|
||||
public String handleEpcToFlowChartBatch(String repositoryIds,String sourceMethod,String targetMethod,String duplicateName){
|
||||
JSONArray array = JSONArray.parseArray(repositoryIds);
|
||||
List<String> repositoryIdList = array.stream().map(id -> (String) id).collect(Collectors.toList());
|
||||
Map<String,Object> params = new HashMap<String, Object>();
|
||||
|
||||
@ -328,6 +328,21 @@ public class PALRepositoryAttributeDao extends DaoObject<PALRepositoryAttributeM
|
||||
return DBSql.query(sql, params, rowMapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定资产库下有效的文件属性配置信息
|
||||
* @param wsId
|
||||
* @param methodId
|
||||
* @return
|
||||
*/
|
||||
public List<PALRepositoryAttributeModel> getFileAttrConfigList(String wsId,String methodId){
|
||||
String sql = "SELECT * FROM " + entityName() + " WHERE " + PALRepositoryAttributeModel.FIELD_WSID + "=:wsId AND " + PALRepositoryAttributeModel.FIELD_METHODID + "=:methodId AND " + PALRepositoryAttributeModel.FIELD_IS_DELETE + "=:isDelete";
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("wsId",wsId);
|
||||
params.put("methodId",methodId);
|
||||
params.put("isDelete",0);
|
||||
return DBSql.query(sql, params, rowMapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改属性的名称和排序
|
||||
*
|
||||
|
||||
@ -188,6 +188,26 @@ public class PALRepositoryShapeAttributeDao extends DaoObject<PALRepositoryShape
|
||||
return DBSql.query(sql, params, rowMapper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定资产库下的图形属性配置信息
|
||||
* @param wsId
|
||||
* @param methodId
|
||||
* @param shapeName 可选 图形标识
|
||||
* @return
|
||||
*/
|
||||
public List<PALRepositoryShapeAttributeModel> getShapeAttrConfigList(String wsId,String methodId,String shapeName){
|
||||
String sql = "SELECT * FROM " + entityName() + " WHERE " + PALRepositoryShapeAttributeModel.FIELD_WSID + "=:wsId AND " + PALRepositoryShapeAttributeModel.FIELD_METHODID + "=:methodId";
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("wsId", wsId);
|
||||
params.put("methodId", methodId);
|
||||
if (UtilString.isNotEmpty(shapeName)){
|
||||
sql += " AND " + PALRepositoryShapeAttributeModel.FIELD_SHAPE_NAME + "=:shapeName";
|
||||
params.put("shapeName",shapeName);
|
||||
}
|
||||
return DBSql.query(sql, params, rowMapper());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定资产库的数据属性列表
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user