模型转换应用

This commit is contained in:
qinoy 2022-09-26 14:25:54 +08:00
parent e486a02b05
commit f9404552a3
12 changed files with 398 additions and 4 deletions

View File

@ -19,6 +19,7 @@ public class TransferModelConvert implements ASLP {
"name:'repositoryId',required:true,allowEmpty:false,desc:'被转换的模型ID'",
"name:'sourceMethod',required:true,allowEmpty:false,desc:'被转换类型'",
"name:'targetMethod',required:true,allowEmpty:false,desc:'目标转换类型'",
"name:'duplicateName',required:true,allowEmpty:false,desc:'如果重名是否生成副本'",
"name:'sid',required:true,allowEmpty:false,desc:'会话ID'"
})
public ResponseObject call(Map<String, Object> map) {
@ -38,6 +39,10 @@ public class TransferModelConvert implements ASLP {
if (UtilString.isEmpty(targetMethod)){
return ResponseObject.newErrResponse("目标转换类型不能为空");
}
String duplicateName = (String) map.get("duplicateName");
if (UtilString.isEmpty(duplicateName)){
return ResponseObject.newErrResponse("参数[duplicateName]不能为空");
}
String sid = (String) map.get("sid");
if (UtilString.isEmpty(sid)){
return ResponseObject.newErrResponse("会话ID不能为空");

View File

@ -0,0 +1,9 @@
package com.actionsoft.apps.coe.pal.modelconvert.constant;
public class ShapeConstant {
// 判定图形的初始宽
public static final double DECISION_NODE_WIDTH = 90;
// 判定图形的初始高
public static final double DECISION_NODE_HEIGHT = 46;
}

View File

@ -0,0 +1,88 @@
package com.actionsoft.apps.coe.pal.modelconvert.model;
public class DecisionNode {
private String id;
private String logicNodeId;
private String shapeName;
private Position position; // 中心点
private double x;
private double y;
private double w;
private double h;
public DecisionNode(String id, String logicNodeId, String shapeName, Position position, double x, double y, double w, double h) {
this.id = id;
this.logicNodeId = logicNodeId;
this.shapeName = shapeName;
this.position = position;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLogicNodeId() {
return logicNodeId;
}
public void setLogicNodeId(String logicNodeId) {
this.logicNodeId = logicNodeId;
}
public String getShapeName() {
return shapeName;
}
public void setShapeName(String shapeName) {
this.shapeName = shapeName;
}
public Position getPosition() {
return position;
}
public void setPosition(Position position) {
this.position = position;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getW() {
return w;
}
public void setW(double w) {
this.w = w;
}
public double getH() {
return h;
}
public void setH(double h) {
this.h = h;
}
}

View File

@ -0,0 +1,38 @@
package com.actionsoft.apps.coe.pal.modelconvert.model;
public class LogicNode {
private String id; // 标识ID
private String shapeName; // and or xor
private Position position; // 节点中心坐标
public LogicNode(String id, String shapeName, Position position) {
this.id = id;
this.shapeName = shapeName;
this.position = position;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getShapeName() {
return shapeName;
}
public void setShapeName(String shapeName) {
this.shapeName = shapeName;
}
public Position getPosition() {
return position;
}
public void setPosition(Position position) {
this.position = position;
}
}

View File

@ -2,9 +2,8 @@ package com.actionsoft.apps.coe.pal.modelconvert.strategy.impl;
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.model.EventNode;
import com.actionsoft.apps.coe.pal.modelconvert.model.LinkerAdapter;
import com.actionsoft.apps.coe.pal.modelconvert.model.Position;
import com.actionsoft.apps.coe.pal.modelconvert.constant.ShapeConstant;
import com.actionsoft.apps.coe.pal.modelconvert.model.*;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.ModelConvertStrategy;
import com.actionsoft.apps.coe.pal.modelconvert.util.ConvertUtil;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
@ -38,6 +37,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");
PALRepository repository = CoeProcessLevelDaoFacotory.createCoeProcessLevel();
PALRepositoryModelImpl epcRepositoryModel = (PALRepositoryModelImpl)repository.getInstance(repositoryId);
@ -52,7 +52,11 @@ public class EpcToFlowChart implements ModelConvertStrategy {
String methodCategory = targetMethod.substring(0,targetMethod.indexOf("."));
int orderIndex = repository.getChildrenMaxOrderIndexByPidAndWsId(parentId, wsId) + 1;
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
PALRepositoryModelImpl repositoryModel = CoeProcessLevelUtil.createPALRepositoryModel(newRepositoryId, plRid, wsId, epcRepositoryModel.getName(), "", orderIndex, parentId,
String repositoryName = epcRepositoryModel.getName();
if (duplicateName) {
repositoryName += "副本";
}
PALRepositoryModelImpl repositoryModel = CoeProcessLevelUtil.createPALRepositoryModel(newRepositoryId, plRid, wsId, repositoryName, "", orderIndex, parentId,
methodCategory, true, 1, newRepositoryId, false, targetMethod, "0", epcRepositoryModel.getLevel(), null, null,
uc.getUID(), uc.getUID(), nowTime, null, null, null, null, null, null, null, null, null,epcRepositoryModel.getSecurityLevel());
repository.insert(repositoryModel);
@ -92,7 +96,11 @@ public class EpcToFlowChart implements ModelConvertStrategy {
JSONObject defineJsonObj = JSONObject.parseObject(definition);
JSONObject page = defineJsonObj.getJSONObject("page");
JSONObject elements = defineJsonObj.getJSONObject("elements");
// 存储事件节点
Map<String, EventNode> eventNodeMap = new HashMap<>();
// 存储逻辑与 异或节点
Map<String, LogicNode> logicNodeMap = new HashMap<>();
Map<String, DecisionNode> decisionNodeMap = new HashMap<>();
Map<String,Map<String,List<LinkerAdapter>>> linkerAdapterMap = new HashMap<>();
Set<String> toBeDeletes = new HashSet<>();
// 保存图形y坐标的最大值
@ -108,12 +116,41 @@ public class EpcToFlowChart implements ModelConvertStrategy {
EventNode eventNode = new EventNode(key,props.getDoubleValue("x"),props.getDoubleValue("y"),props.getDoubleValue("w"),props.getDoubleValue("h"));
eventNodeMap.put(key,eventNode);
}
if ("and".equals(shapeName) || "or".equals(shapeName) || "xor".equals(shapeName)){
double x = props.getDoubleValue("x");
double y = props.getDoubleValue("y");
double w = props.getDoubleValue("w");
double h = props.getDoubleValue("h");
Position position = new Position(x + (w / 2), y + (h / 2));
// LogicNode logicNode = new LogicNode(key, shapeName, position);
// logicNodeMap.put(key,logicNode);
// 用判定图源代替与 异或
String _id = UUIDGener.getObjectId();
double _x = position.getX() - (ShapeConstant.DECISION_NODE_WIDTH / 2);
double _y = position.getY() - (ShapeConstant.DECISION_NODE_HEIGHT / 2);
DecisionNode decisionNode = new DecisionNode(_id,key, shapeName,position, _x, _y, ShapeConstant.DECISION_NODE_WIDTH, ShapeConstant.DECISION_NODE_HEIGHT);
decisionNodeMap.put(key,decisionNode);
JSONObject decision = ShapeUtil.getProcessShapeDefinition("process.flowchart", "判定");
decision.put("id",_id);
JSONObject decisionProps = decision.getJSONObject("props");
decisionProps.put("x",_x);
decisionProps.put("y",_y);
decisionProps.put("w",ShapeConstant.DECISION_NODE_WIDTH);
decisionProps.put("h",ShapeConstant.DECISION_NODE_HEIGHT);
decision.put("props",decisionProps);
String text = "and".equals(shapeName) ? "" : "or".equals(shapeName) ? "" : "异或";
decision.put("text",text);
elements.put(_id,decision);
// 记录待删除的逻辑图形的key值
toBeDeletes.add(key);
}
if (!"linker".equals(shapeName)) {
element.put("category",targetMethodId);
double y = props.getDoubleValue("y");
if (y > maxShapeY[0]) maxShapeY[0] = y;
}
});
// 处理事件节点
eventNodeMap.keySet().stream().forEach(key -> {
EventNode eventNode = eventNodeMap.get(key);
elements.keySet().stream()
@ -181,6 +218,54 @@ 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
linkerAdapterMap.keySet().stream().forEach(key -> {
EventNode eventNode = eventNodeMap.get(key);

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
if(window.navigator.userAgent.indexOf('MSIE') > -1 || window.navigator.userAgent.indexOf('Trident') > -1){
window.location.replace("../not_support_vue.htm");
}
</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="../apps/com.actionsoft.apps.coe.pal.modelconvert/main/favicon.ico" />
<title></title>
<link type='text/css' rel='stylesheet' href='../commons/css/font/iconfont.css'/>
<!--
其它的js或css引用方式示例<%= htmlWebpackPlugin.options.awsjsandcsspath%>
<link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.options.awsjsandcsspath%>apps/_bpm.platform/css/model/console.m.dw.design.css"/>
-->
<script>
const settingParam = <#settingParam>;
const axiosBaseUrl = "./";
const production = true;
const devUserInfo = {};
</script>
<script type="module" crossorigin src="../apps/com.actionsoft.apps.coe.pal.modelconvert/main/js/entry-index-a5f3846f.js"></script>
<link rel="stylesheet" href="../apps/com.actionsoft.apps.coe.pal.modelconvert/main/assets/asset-style-a4265554.css">
</head>
<body style="margin:0;">
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1 @@
import{_,d as v,r as w,f as E,h as f,a as d,c as y,b as o,t as B,e as u,w as r,F as A,o as N,g as P,p as T,i as g,j as M}from"./entry-index-a5f3846f.js";const k=v({name:"history",setup(){const{proxy:e}=P(),a=[{id:"",wsId:"",number:1,convertType:"EPC\u8F6CFlowChart",operator:"liuqun",operatorName:"\u5218\u7FA4",operationTime:"2022-09-10 00:00:00",convertCount:15,processNames:"1.0\u6218\u7565\u89C4\u5212\u6D41\u7A0B\u30012.0\u51B7\u996E\u4E8B\u4E1A\u6D41\u7A0B\u30013.0\u6D4B\u8BD5\u6D4B\u8BD5\u6D41\u7A0B"},{id:"",wsId:"",number:2,convertType:"EPC\u8F6CBPMN",operator:"gaoyang",operatorName:"\u9AD8\u626C",operationTime:"2022-09-10 00:00:00",convertCount:15,processNames:"1.0\u6218\u7565\u89C4\u5212\u6D41\u7A0B\u30012.0\u51B7\u996E\u4E8B\u4E1A\u6D41\u7A0B\u30013.0\u6D4B\u8BD5\u6D4B\u8BD5\u6D41\u7A0B"}],C=[{text:"EPC\u8F6CFlowChart",sourceMethod:"EPC",targetMethod:"FlowChart",value:"EPC\u8F6CFlowChart"},{text:"EPC\u8F6CBPMN",sourceMethod:"EPC",targetMethod:"BPMN",value:"EPC\u8F6CBPMN"},{text:"FlowChart\u8F6CBPMN",sourceMethod:"FlowChart",targetMethod:"BPMN",value:"FlowChart\u8F6CBPMN"}],F=w(""),p=w([]),m=E({visible:!1,title:"\u6D41\u7A0B\u6E05\u5355",direction:"rtl",headerRowStyle:{paddingTop:"10px"},processList:[{number:1,processName:"1.0\u6218\u7565\u89C4\u5212\u6D41\u7A0B(v1.0)",processId:""},{number:2,processName:"2.0\u4EA7\u54C1\u6280\u672F\u4E0E\u7814\u53D1(v1.0)",processId:""}]}),n=()=>{p.value=[]},s=(t,i)=>{console.log("\u67E5\u770B\u6D41\u7A0B\u6E05\u5355"),m.visible=!0},l=(t,i,b)=>{const D=b.property;return i[D]===t},h=()=>{e.$router.push("/")};return f(()=>{n()}),{tableData:a,searchText:F,historyList:p,loadHistoryFn:n,openProcessListFn:s,convertTypeFilters:C,filterHandlerFn:l,backToHomeFn:h,drawer:m}}}),c=e=>(T("data-v-344d8a88"),e=e(),g(),e),$={class:"header-container"},I=c(()=>o("span",null,[o("i",{class:"awsui-iconfont"},"\uE6FA")],-1)),V=c(()=>o("span",null,"\u8FD4\u56DE",-1)),H=[I,V],L={class:"search-container"},S=c(()=>o("i",{class:"awsui-iconfont"},"\uE6E9",-1)),R={class:"main-container"},U=["onClick"],j={class:"drawer-body-container"},q={class:"drawer-body-header"},x=c(()=>o("span",null,[o("i",{class:"awsui-iconfont",style:{color:"#0d84ff"}},"\uE635"),M(" \u603B\u8BA1: ")],-1)),z={class:"drawer-body-main"},G=["onClick"];function J(e,a,C,F,p,m){const n=d("el-input"),s=d("el-table-column"),l=d("el-table"),h=d("el-drawer");return N(),y(A,null,[o("div",$,[o("div",{class:"back-to-home",onClick:a[0]||(a[0]=(...t)=>e.backToHomeFn&&e.backToHomeFn(...t))},H),o("div",L,[o("span",null," \u5171\u6709"+B(e.tableData.length)+"\u6761\u8BB0\u5F55 ",1),o("span",null,[u(n,{modelValue:e.searchText,"onUpdate:modelValue":a[1]||(a[1]=t=>e.searchText=t),placeholder:"\u8BF7\u8F93\u5165\u6D41\u7A0B\u540D\u79F0\u8FDB\u884C\u641C\u7D22"},{prefix:r(()=>[S]),_:1},8,["modelValue"])])])]),o("div",R,[u(l,{ref:"tableRef",data:e.tableData,style:{width:"100%",padding:"0 20px"}},{default:r(()=>[u(s,{prop:"number",label:"\u5E8F\u53F7","min-width":"180"}),u(s,{prop:"convertType",label:"\u7C7B\u578B","min-width":"180","column-key":"convertType",filters:e.convertTypeFilters,"filter-method":e.filterHandlerFn},null,8,["filters","filter-method"]),u(s,{prop:"operatorName",label:"\u64CD\u4F5C\u4EBA","min-width":"180"}),u(s,{prop:"operationTime",label:"\u64CD\u4F5C\u65F6\u95F4","min-width":"180"}),u(s,{prop:"convertCount",label:"\u8F6C\u6362\u6570\u91CF","min-width":"180"}),u(s,{prop:"processNames",label:"\u8F6C\u6362\u6D41\u7A0B","min-width":"400"}),u(s,{label:"\u64CD\u4F5C","min-width":"180"},{default:r(t=>[o("span",{style:{color:"rgb(80,168,246)",cursor:"pointer"},onClick:i=>e.openProcessListFn(t.$index,t.row)},"\u67E5\u770B\u6D41\u7A0B\u6E05\u5355",8,U)]),_:1})]),_:1},8,["data"]),u(h,{"custom-class":"history-detail-drawer",modelValue:e.drawer.visible,"onUpdate:modelValue":a[2]||(a[2]=t=>e.drawer.visible=t),title:e.drawer.title,direction:e.drawer.direction,"close-on-click-modal":!1,"close-on-press-escape":!1,size:"45%"},{default:r(()=>[o("div",j,[o("div",q,[x,o("span",null,B(e.drawer.processList.length)+"\u652F\u6D41\u7A0B ",1)]),o("div",z,[u(l,{data:e.drawer.processList,style:{width:"100%"},"header-row-style":e.drawer.headerRowStyle},{default:r(()=>[u(s,{prop:"number",label:"\u5E8F\u53F7","min-width":"180"}),u(s,{prop:"processName",label:"\u6D41\u7A0B\u540D\u79F0","min-width":"180"}),u(s,{label:"\u64CD\u4F5C"},{default:r(t=>[o("span",{style:{color:"rgb(80,168,246)",cursor:"pointer"},onClick:i=>e.openProcessListFn(t.$index,t.row)},"\u6253\u5F00\u6587\u4EF6",8,G)]),_:1})]),_:1},8,["data","header-row-style"])])])]),_:1},8,["modelValue","title","direction"])])],64)}var O=_(k,[["render",J],["__scopeId","data-v-344d8a88"]]);export{O as default};