伊利项目 模型转换 epc转bpmn
This commit is contained in:
parent
715840e8a6
commit
ba49f71402
Binary file not shown.
@ -260,8 +260,12 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
Position epcLinkerToPoi = new Position(epcLinkerToObj.getDoubleValue("x"),epcLinkerToObj.getDoubleValue("y"));
|
||||
JSONObject epcLinkerProps = epcLinkerObj.getJSONObject("props");
|
||||
JSONArray epcLinkerPoints = epcLinkerObj.getJSONArray("points");
|
||||
// System.out.println("=======>>> " + epcLinkerObj.getString("text"));
|
||||
Position epcLinkerPoint1 = new Position(((JSONObject)epcLinkerPoints.get(0)).getDoubleValue("x"),((JSONObject)epcLinkerPoints.get(0)).getDoubleValue("y"));
|
||||
Position epcLinkerPoint2 = new Position(((JSONObject)epcLinkerPoints.get(1)).getDoubleValue("x"),((JSONObject)epcLinkerPoints.get(1)).getDoubleValue("y"));
|
||||
Position epcLinkerPoint2 = null;
|
||||
if (epcLinkerPoints.size() > 1){
|
||||
epcLinkerPoint2 = new Position(((JSONObject)epcLinkerPoints.get(1)).getDoubleValue("x"),((JSONObject)epcLinkerPoints.get(1)).getDoubleValue("y"));
|
||||
}
|
||||
|
||||
JSONObject bpmnLinkerObj = JSONObject.parseObject(LinkerDefConstant.linker);
|
||||
String bpmnLinkerDefId = UUIDGener.getObjectId();
|
||||
@ -288,6 +292,7 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
// || epcLinkerFromObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_DOWN)
|
||||
// && (epcLinkerToObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_UP
|
||||
// || epcLinkerToObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_DOWN)
|
||||
&& epcLinkerPoints.size() == 2
|
||||
&& epcLinkerPoint1.equals(epcLinkerPoint2)){ // 说明是连线原本是垂直方向的 转换后连线方向应为水平方向
|
||||
if (epcLinkerFromPoi.getY() < epcLinkerToPoi.getY()){ // 连线是自上而下的走向 转换后连线方向应为 自左向右
|
||||
// 处理from坐标
|
||||
@ -329,6 +334,7 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
// || epcLinkerFromObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_RIGHT)
|
||||
// && (epcLinkerToObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_LEFT
|
||||
// || epcLinkerToObj.getDoubleValue("angle") == LinkerDefConstant.ANGLE_RIGHT)
|
||||
&& epcLinkerPoints.size() == 2
|
||||
&& epcLinkerPoint1.equals(epcLinkerPoint2)){ // 说明连线原本是水平方向的 转换后连线方向应为垂直方向
|
||||
if (epcLinkerFromPoi.getX() < epcLinkerToPoi.getX()){ // 连线是自左而右的走向 转换后连线方向应为 自下而上
|
||||
// 处理from坐标
|
||||
@ -365,8 +371,7 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
points.add(point8);
|
||||
}
|
||||
}else { // 处理带明显折点的连线
|
||||
// System.out.println("==========================> "+epcLinkerObj.getString("text"));
|
||||
// 根据angle值 来判断转换后的连线是在图形的上方还是下方
|
||||
// 判断转换后的连线是在图形的上方还是下方
|
||||
if (epcLinkerFromObj.getDoubleValue("x") < epcLinkerPoint1.getX()
|
||||
&& epcLinkerFromObj.getDoubleValue("y") == epcLinkerPoint1.getY()){ // 从图形右侧侧出发 转换后 图形上侧出发
|
||||
bpmnLinkerFromObj.put("x",bpmnShapeFromProps.getDoubleValue("x") + (bpmnShapeFromProps.getDoubleValue("w") / 2));
|
||||
@ -377,13 +382,16 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
bpmnLinkerToObj.put("angle",LinkerDefConstant.ANGLE_DOWN);
|
||||
|
||||
JSONObject point9 = new JSONObject();
|
||||
JSONObject point10 = new JSONObject();
|
||||
point9.put("x",epcLinkerPoint1.getY());
|
||||
point9.put("y",epcPageWidth - epcLinkerPoint1.getX());
|
||||
points.add(point9);
|
||||
point10.put("x",epcLinkerPoint2.getY());
|
||||
point10.put("y",epcPageWidth - epcLinkerPoint2.getX());
|
||||
points.add(point10);
|
||||
if (epcLinkerPoints.size() > 1){
|
||||
JSONObject point10 = new JSONObject();
|
||||
point10.put("x",epcLinkerPoint2.getY());
|
||||
point10.put("y",epcPageWidth - epcLinkerPoint2.getX());
|
||||
points.add(point10);
|
||||
}
|
||||
// System.out.println("==========================> 11111 "+epcLinkerObj.getString("text"));
|
||||
}else if (epcLinkerFromObj.getDoubleValue("x") > epcLinkerPoint1.getX()
|
||||
&& epcLinkerFromObj.getDoubleValue("y") == epcLinkerPoint1.getY()){ // 从图形左侧出发 转换后 图形下侧出发
|
||||
bpmnLinkerFromObj.put("x",bpmnShapeFromProps.getDoubleValue("x") + (bpmnShapeFromProps.getDoubleValue("w") / 2));
|
||||
@ -397,10 +405,37 @@ public class EpcToBPMN implements ModelConvertStrategy {
|
||||
point11.put("x",epcLinkerPoint1.getY());
|
||||
point11.put("y",epcPageWidth - epcLinkerPoint1.getX());
|
||||
points.add(point11);
|
||||
JSONObject point12 = new JSONObject();
|
||||
point12.put("x",epcLinkerPoint2.getY());
|
||||
point12.put("y",epcPageWidth - epcLinkerPoint2.getX());
|
||||
points.add(point12);
|
||||
if (epcLinkerPoints.size() > 1){
|
||||
JSONObject point12 = new JSONObject();
|
||||
point12.put("x",epcLinkerPoint2.getY());
|
||||
point12.put("y",epcPageWidth - epcLinkerPoint2.getX());
|
||||
points.add(point12);
|
||||
}
|
||||
// System.out.println("==========================> 2222 "+epcLinkerObj.getString("text"));
|
||||
}else {
|
||||
// 垂直方向上
|
||||
// System.out.println("==========================> 333"+epcLinkerObj.getString("text"));
|
||||
Map<String, Position> anchorPoiMap = ConvertUtil.getConvertAnchorPoi(elements, bpmnElements, epcLinkerObj);
|
||||
if (anchorPoiMap.containsKey("from")){
|
||||
Position fromPoi = anchorPoiMap.get("from");
|
||||
bpmnLinkerFromObj.put("x",fromPoi.getX());
|
||||
bpmnLinkerFromObj.put("y",fromPoi.getY());
|
||||
}
|
||||
List<Position> positionList = new ArrayList<>();
|
||||
positionList.add(new Position(bpmnLinkerFromObj.getDoubleValue("x"),bpmnLinkerFromObj.getDoubleValue("y")));
|
||||
for (Object o : epcLinkerPoints) {
|
||||
JSONObject point = (JSONObject)o;
|
||||
Position tempPoi = new Position(point.getDoubleValue("y"),epcPageWidth - point.getDoubleValue("x"));
|
||||
positionList.add(tempPoi);
|
||||
}
|
||||
if (anchorPoiMap.containsKey("to")){
|
||||
Position toPoi = anchorPoiMap.get("to");
|
||||
bpmnLinkerToObj.put("x",toPoi.getX());
|
||||
bpmnLinkerToObj.put("y",toPoi.getY());
|
||||
}
|
||||
positionList.add(new Position(bpmnLinkerToObj.getDoubleValue("x"),bpmnLinkerToObj.getDoubleValue("y")));
|
||||
bpmnLinkerToObj.put("angle",ConvertUtil.getLinkerAngle(positionList,"to"));
|
||||
bpmnLinkerFromObj.put("angle",ConvertUtil.getLinkerAngle(positionList,"from"));
|
||||
}
|
||||
}
|
||||
JSONObject bpmnLinkerProps = new JSONObject();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.actionsoft.apps.coe.pal.modelconvert.util;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.ConvertType;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.LinkerDefConstant;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.model.Position;
|
||||
@ -205,4 +206,83 @@ public class ConvertUtil {
|
||||
return schemaShapeMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转换后的连线锚点位置【基于垂直方向转向水平向右方向的转换】
|
||||
* @param beforeConvertElement
|
||||
* @param afterConvertElement
|
||||
* @param beforeConvertLinker
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,Position> getConvertAnchorPoi(JSONObject beforeConvertElement,JSONObject afterConvertElement,JSONObject beforeConvertLinker){
|
||||
|
||||
Map<String,Position> resultMap = new HashMap<>(2);
|
||||
|
||||
JSONObject linkerFromObj = beforeConvertLinker.getJSONObject("from");
|
||||
JSONObject linkerToObj = beforeConvertLinker.getJSONObject("to");
|
||||
if (linkerFromObj.containsKey("id")){
|
||||
Position beforeConvertFromAnchorPoi = new Position(linkerFromObj.getDoubleValue("x"),linkerFromObj.getDoubleValue("y"));
|
||||
String beforeFromShapeId = linkerFromObj.getString("id");
|
||||
String afterFromShapeId = ConvertShapeIdMapping.getInstance().getTargetShapeId(ConvertType.EPC_BPMN,beforeFromShapeId);
|
||||
JSONObject beforeFromShapeObj = beforeConvertElement.getJSONObject(beforeFromShapeId);
|
||||
JSONObject beforeFromShapeProps = beforeFromShapeObj.getJSONObject("props");
|
||||
Position leftFromPoi = new Position(beforeFromShapeProps.getDoubleValue("x"),beforeFromShapeProps.getDoubleValue("y") + (beforeFromShapeProps.getDoubleValue("h") / 2));
|
||||
Position topFromPoi = new Position(beforeFromShapeProps.getDoubleValue("x") + (beforeFromShapeProps.getDoubleValue("w") / 2),beforeFromShapeProps.getDoubleValue("y"));
|
||||
Position rightFromPoi = new Position(beforeFromShapeProps.getDoubleValue("x") + beforeFromShapeProps.getDoubleValue("w"),beforeFromShapeProps.getDoubleValue("y") + (beforeFromShapeProps.getDoubleValue("h") / 2));
|
||||
Position bottomFromPoi = new Position(beforeFromShapeProps.getDoubleValue("x") + (beforeFromShapeProps.getDoubleValue("w") / 2),beforeFromShapeProps.getDoubleValue("y") + beforeFromShapeProps.getDoubleValue("h"));
|
||||
|
||||
JSONObject afterFromShapeObj = afterConvertElement.getJSONObject(afterFromShapeId);
|
||||
JSONObject afterFromShapeProps = afterFromShapeObj.getJSONObject("props");
|
||||
|
||||
if (beforeConvertFromAnchorPoi.equals(leftFromPoi)){ // 转换前从左侧出 转换后从下侧出
|
||||
Position afterBottomFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y") + afterFromShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("from",afterBottomFromPoi);
|
||||
}else if (beforeConvertFromAnchorPoi.equals(topFromPoi)){ // 转换前从上侧出 转换后从左侧出
|
||||
Position afterLeftFromPoi = new Position(afterFromShapeProps.getDoubleValue("x"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterLeftFromPoi);
|
||||
}else if (beforeConvertFromAnchorPoi.equals(rightFromPoi)){ // 转换前从右侧出 转换后从上侧出
|
||||
Position afterTopFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("from",afterTopFromPoi);
|
||||
}else if (beforeConvertFromAnchorPoi.equals(bottomFromPoi)){ // 转换前从下侧出 转换后从右侧出
|
||||
Position afterRightFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + afterFromShapeProps.getDoubleValue("w"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterRightFromPoi);
|
||||
}
|
||||
}else {
|
||||
Position noneShape = new Position(linkerFromObj.getDoubleValue("y"),beforeConvertElement.getJSONObject("page").getDoubleValue("width") - linkerFromObj.getDoubleValue("x"));
|
||||
resultMap.put("from",noneShape);
|
||||
}
|
||||
if (linkerToObj.containsKey("id")){
|
||||
Position beforeConvertToAnchorPoi = new Position(beforeConvertLinker.getJSONObject("to").getDoubleValue("x"),beforeConvertLinker.getJSONObject("to").getDoubleValue("y"));
|
||||
String beforeToShapeId = linkerToObj.getString("id");
|
||||
String afterToShapeId = ConvertShapeIdMapping.getInstance().getTargetShapeId(ConvertType.EPC_BPMN,beforeToShapeId);
|
||||
JSONObject beforeToShapeObj = beforeConvertElement.getJSONObject(beforeToShapeId);
|
||||
JSONObject beforeToShapeProps = beforeToShapeObj.getJSONObject("props");
|
||||
Position leftToPoi = new Position(beforeToShapeProps.getDoubleValue("x"),beforeToShapeProps.getDoubleValue("y") + (beforeToShapeProps.getDoubleValue("h") / 2));
|
||||
Position topToPoi = new Position(beforeToShapeProps.getDoubleValue("x") + (beforeToShapeProps.getDoubleValue("w") / 2),beforeToShapeProps.getDoubleValue("y"));
|
||||
Position rightToPoi = new Position(beforeToShapeProps.getDoubleValue("x") + beforeToShapeProps.getDoubleValue("w"),beforeToShapeProps.getDoubleValue("y") + (beforeToShapeProps.getDoubleValue("h") / 2));
|
||||
Position bottomToPoi = new Position(beforeToShapeProps.getDoubleValue("x") + (beforeToShapeProps.getDoubleValue("w") / 2),beforeToShapeProps.getDoubleValue("y") + beforeToShapeProps.getDoubleValue("h"));
|
||||
|
||||
JSONObject afterToShapeObj = afterConvertElement.getJSONObject(afterToShapeId);
|
||||
JSONObject afterToShapeProps = afterToShapeObj.getJSONObject("props");
|
||||
|
||||
if (beforeConvertToAnchorPoi.equals(leftToPoi)){ // 转换前从左侧进入 转换后从下侧进入
|
||||
Position afterBottomToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y") + afterToShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("to",afterBottomToPoi);
|
||||
}else if (beforeConvertToAnchorPoi.equals(topToPoi)){ // 转换前从上侧进入 转换后从左侧进入
|
||||
Position afterLeftToPoi = new Position(afterToShapeProps.getDoubleValue("x"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterLeftToPoi);
|
||||
}else if (beforeConvertToAnchorPoi.equals(rightToPoi)){ // 转换前从右侧进入 转换后从上侧进入
|
||||
Position afterTopToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("to",afterTopToPoi);
|
||||
}else if (beforeConvertToAnchorPoi.equals(bottomToPoi)){ // 转换前从下侧进入 转换后从右侧进入
|
||||
Position afterRightToPoi = new Position(afterToShapeProps.getDoubleValue("x") + afterToShapeProps.getDoubleValue("w"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterRightToPoi);
|
||||
}
|
||||
}else {
|
||||
Position noneShape = new Position(linkerToObj.getDoubleValue("y"),beforeConvertElement.getJSONObject("page").getDoubleValue("width") - linkerToObj.getDoubleValue("x"));
|
||||
resultMap.put("to",noneShape);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ var UI = {
|
||||
// debugger;
|
||||
if (methodId == "process.epc" && $("#bar_list_model_convert").length == 0){
|
||||
$("#bar_list_file").append("<li>模型转换<div class='extend ex_arrow'>►</div><ul id='bar_list_model_convert' class='menu list extend_menu menu_ico'></ul></li>");
|
||||
$("#bar_list_model_convert").append("<li ac='modelConvert' methodId='process.flowchart'>FlowChart</li>"+"<li ac='modelConvert' methodId='process.bpmn'>BPMN</li>");
|
||||
$("#bar_list_model_convert").append("<li ac='modelConvert' methodId='process.flowchart'>FlowChart</li>"+"<li ac='modelConvert' methodId='process.bpmn2'>BPMN</li>");
|
||||
$("#bar_list_model_convert > li").click(function () {
|
||||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||||
if (editable) {
|
||||
@ -705,10 +705,6 @@ var UI = {
|
||||
UI.gettingStart();
|
||||
} else if (action == "modelConvert"){
|
||||
var targetMethod = item.attr("methodId");
|
||||
if (targetMethod == 'process.bpmn'){
|
||||
$.simpleAlert('暂不支持转换BPMN', 'warning');
|
||||
return;
|
||||
}
|
||||
$.simpleAlert('转换后同名校验中', 'loading');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
@ -577,7 +577,7 @@ var UI = {
|
||||
// debugger;
|
||||
if (methodId == "process.epc" && $("#bar_list_model_convert").length == 0){
|
||||
$("#bar_list_file").append("<li>模型转换<div class='extend ex_arrow'>►</div><ul id='bar_list_model_convert' class='menu list extend_menu menu_ico'></ul></li>");
|
||||
$("#bar_list_model_convert").append("<li ac='modelConvert' methodId='process.flowchart'>FlowChart</li>"+"<li ac='modelConvert' methodId='process.bpmn'>BPMN</li>");
|
||||
$("#bar_list_model_convert").append("<li ac='modelConvert' methodId='process.flowchart'>FlowChart</li>"+"<li ac='modelConvert' methodId='process.bpmn2'>BPMN</li>");
|
||||
$("#bar_list_model_convert > li").click(function () {
|
||||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||||
if (editable) {
|
||||
@ -765,10 +765,6 @@ var UI = {
|
||||
UI.gettingStart();
|
||||
} else if (action == "modelConvert"){
|
||||
var targetMethod = item.attr("methodId");
|
||||
if (targetMethod == 'process.bpmn'){
|
||||
$.simpleAlert('暂不支持转换BPMN', 'warning');
|
||||
return;
|
||||
}
|
||||
$.simpleAlert('转换后同名校验中', 'loading');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user