端到端功能 代码阶段性提交

This commit is contained in:
qinoy 2023-06-09 16:06:39 +08:00
parent bb07770c4e
commit a91dd7482b
13 changed files with 245 additions and 166 deletions

View File

@ -137,9 +137,9 @@ public class SubProcessController {
* @return define
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.shape_expand")
public String shapeExpand(UserContext uc, String repositoryId, String shapeId){
public String shapeExpand(UserContext uc, String repositoryId, String shapeId, String endToEndProcessDefineStr){
SubProcessWeb processWeb = new SubProcessWeb(uc);
return processWeb.shapeNodeExpand(repositoryId, shapeId);
return processWeb.shapeNodeExpand(repositoryId, shapeId, endToEndProcessDefineStr);
}
/**

View File

@ -1,5 +1,6 @@
package com.actionsoft.apps.coe.method.process.subprocess.graph;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractAdjMatrix;
import com.actionsoft.apps.coe.method.process.subprocess.mode.Node;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.bpms.util.ConsolePrinter;
@ -13,9 +14,8 @@ import java.util.Map;
* @author oYang
* @create 2023-05-11 17:10
*/
public class GraphAdjMatrix {
public class GraphAdjMatrix extends AbstractAdjMatrix {
private int[][] adjMatrix; // 邻接矩阵
private List<Node> vertexList; // 存储节点
/**
@ -23,45 +23,10 @@ public class GraphAdjMatrix {
* @param nodeList
*/
public GraphAdjMatrix(List<Node> nodeList) {
adjMatrix = new int[nodeList.size()][nodeList.size()];
super(nodeList.size());
vertexList = nodeList;
}
/**
* 添加一条从顶点 u 到顶点 v 的有向边
*/
public void addEdge(int u, int v) {
adjMatrix[u][v] = 1; // 设置邻接矩阵中相应的位置为 1
}
/**
* 获取从顶点 u 出发可以到达的所有顶点
*/
public List<Integer> getNeighbors(int u) {
List<Integer> neighbors = new ArrayList<>();
for (int i = 0; i < vertexList.size(); i++) {
if (adjMatrix[u][i] == 1) {
neighbors.add(i);
}
}
return neighbors;
}
/**
* 判断从顶点 u 是否可以到达顶点 v
*/
public boolean hasEdge(int u, int v) {
return adjMatrix[u][v] == 1;
}
/**
* 获取邻接矩阵
* @return
*/
public int[][] getAdjMatrix(){
return adjMatrix;
}
/**
* 构建邻接矩阵
*/
@ -90,7 +55,7 @@ public class GraphAdjMatrix {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < vertexList.size(); i++) {
for (int j = 0; j < vertexList.size(); j++) {
sb.append(adjMatrix[i][j]).append(" ");
sb.append(getAdjMatrix()[i][j]).append(" ");
}
sb.append("\n");
}

View File

@ -48,7 +48,7 @@ public class GraphLinkerRender {
double[][] turnPoi = "horizontal".equals(direction)
? calculationLinkerPointInHorizLayOut(fromPoi, toPoi)
: calculationLinkerPointInVertLayOut(fromPoi, toPoi);
double[] angleArr = calculationLinkerAngle(fromPoi, toPoi, turnPoi[1], turnPoi[turnPoi.length - 2]);
double[] angleArr = calculationLinkerAngle(turnPoi[0], turnPoi[turnPoi.length - 1], turnPoi[1], turnPoi[turnPoi.length - 2]);
// 构建连线
JSONObject linkerObj = JSONObject.parseObject(LinkerDefConstant.linker);
linkerObj.put("id", UUIDGener.getObjectId());

View File

@ -2,6 +2,7 @@ package com.actionsoft.apps.coe.method.process.subprocess.graph;
import com.actionsoft.apps.coe.method.process.subprocess.constant.LinkerDefConstant;
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractAdjMatrix;
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
@ -252,53 +253,17 @@ public class GraphNodeCloseHandle {
/**
* 节点展开的邻接矩阵
*/
class NodeCloseAdjMatrix{
class NodeCloseAdjMatrix extends AbstractAdjMatrix {
private int[][] adjMatrix;
private List<String> nodeIds;
private List<JSONObject> linkerList;
public NodeCloseAdjMatrix(List<String> nodeIds, List<JSONObject> linkerList) {
this.adjMatrix = new int[nodeIds.size()][nodeIds.size()];
super(nodeIds.size());
this.nodeIds = nodeIds;
this.linkerList = linkerList;
}
/**
* 添加一条从顶点 u 到顶点 v 的有向边
*/
public void addEdge(int u, int v) {
adjMatrix[u][v] = 1; // 设置邻接矩阵中相应的位置为 1
}
/**
* 获取从顶点 u 出发可以到达的所有顶点
*/
public List<Integer> getNeighbors(int u) {
List<Integer> neighbors = new ArrayList<>();
for (int i = 0; i < nodeIds.size(); i++) {
if (adjMatrix[u][i] == 1) {
neighbors.add(i);
}
}
return neighbors;
}
/**
* 判断从顶点 u 是否可以到达顶点 v
*/
public boolean hasEdge(int u, int v) {
return adjMatrix[u][v] == 1;
}
/**
* 获取邻接矩阵
* @return
*/
public int[][] getAdjMatrix(){
return adjMatrix;
}
public List<String> getNodeIds() {
return nodeIds;
}
@ -320,18 +285,6 @@ class NodeCloseAdjMatrix{
}
}
// 输出邻接矩阵
public void printAdjMatrix() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < nodeIds.size(); i++) {
for (int j = 0; j < nodeIds.size(); j++) {
sb.append(adjMatrix[i][j]).append(" ");
}
sb.append("\n");
}
System.out.println(sb.toString());
}
/**
* 获取总图中节点展开前的所有节点坐标
* @param elements
@ -394,7 +347,7 @@ class NodeCloseLinkerRender{
double[][] turnPoi = "horizontal".equals(direction)
? calculationLinkerPointInHorizLayOut(fromPoi, toPoi, currentExpandNodeIsStart, currentExpandNodeIsEnd)
: calculationLinkerPointInVertLayOut(fromPoi, toPoi, currentExpandNodeIsStart, currentExpandNodeIsEnd);
double[] angleArr = calculationLinkerAngle(fromPoi, toPoi, turnPoi[1], turnPoi[turnPoi.length - 2]);
double[] angleArr = calculationLinkerAngle(turnPoi[0], turnPoi[turnPoi.length - 1], turnPoi[1], turnPoi[turnPoi.length - 2]);
// 构建连线
JSONObject linkerObj = JSONObject.parseObject(LinkerDefConstant.linker);
linkerObj.put("id", UUIDGener.getObjectId());

View File

@ -2,6 +2,7 @@ package com.actionsoft.apps.coe.method.process.subprocess.graph;
import com.actionsoft.apps.coe.method.process.subprocess.constant.LinkerDefConstant;
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractAdjMatrix;
import com.actionsoft.apps.coe.method.process.subprocess.mode.Node;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
@ -36,7 +37,7 @@ public class GraphNodeExpandHandle {
private final ReentrantLock lock = new ReentrantLock();
public GraphNodeExpandHandle(String repositoryId, String shapeId) throws AWSException{
public GraphNodeExpandHandle(String repositoryId, String shapeId, String endToEndProcessDefineStr) throws AWSException{
this.repositoryId = repositoryId;
this.shapeId = shapeId;
@ -44,9 +45,9 @@ public class GraphNodeExpandHandle {
try {
readChildProcessDefine();
readCurrentProcessDefine();
readCurrentProcessDefine(endToEndProcessDefineStr);
toAssembleScopeLimitationShape();
} catch (AWSException e) {
} catch (Exception e) {
throw new AWSException(e);
}
}
@ -76,11 +77,10 @@ public class GraphNodeExpandHandle {
* 读取当前总图的存储信息
* @throws AWSException
*/
private void readCurrentProcessDefine() throws AWSException{
BaseModel baseModel = apiManager.getDefinition(repositoryId, 0);
if (baseModel == null)
throw new AWSException("未找到当前总图存储的模型信息");
endToEndProcessDefine = JSONObject.parseObject(baseModel.getDefinition());
private void readCurrentProcessDefine(String endToEndProcessDefineStr) throws AWSException{
if (UtilString.isEmpty(endToEndProcessDefineStr))
throw new AWSException("参数异常,模型存储信息未传");
endToEndProcessDefine = JSONObject.parseObject(endToEndProcessDefineStr);
}
/**
@ -136,7 +136,7 @@ public class GraphNodeExpandHandle {
scopeShapeProps.put("y", y);
scopeShapeProps.put("w", scopeShapeW);
scopeShapeProps.put("h", scopeShapeH);
scopeShapeProps.put("zindex", 1);
scopeShapeProps.put("zindex", 0);
scopeLimitationShape.put("dataAttributes", currentExpandShape.getJSONArray("dataAttributes"));
@ -149,7 +149,7 @@ public class GraphNodeExpandHandle {
* @throws Exception
* @return 节点展开后的模型存储信息
*/
public String handleNodeExpand() throws Exception{
public String handleNodeExpand() throws AWSException{
// Thread t1 = new Thread(() -> {
// // 1总图节点以及连线处理
@ -393,53 +393,17 @@ public class GraphNodeExpandHandle {
/**
* 节点展开的邻接矩阵
*/
class NodeExpandAdjMatrix{
class NodeExpandAdjMatrix extends AbstractAdjMatrix {
private int[][] adjMatrix;
private List<String> nodeIds;
private List<JSONObject> linkerList;
public NodeExpandAdjMatrix(List<String> nodeIds, List<JSONObject> linkerList) {
this.adjMatrix = new int[nodeIds.size()][nodeIds.size()];
super(nodeIds.size());
this.nodeIds = nodeIds;
this.linkerList = linkerList;
}
/**
* 添加一条从顶点 u 到顶点 v 的有向边
*/
public void addEdge(int u, int v) {
adjMatrix[u][v] = 1; // 设置邻接矩阵中相应的位置为 1
}
/**
* 获取从顶点 u 出发可以到达的所有顶点
*/
public List<Integer> getNeighbors(int u) {
List<Integer> neighbors = new ArrayList<>();
for (int i = 0; i < nodeIds.size(); i++) {
if (adjMatrix[u][i] == 1) {
neighbors.add(i);
}
}
return neighbors;
}
/**
* 判断从顶点 u 是否可以到达顶点 v
*/
public boolean hasEdge(int u, int v) {
return adjMatrix[u][v] == 1;
}
/**
* 获取邻接矩阵
* @return
*/
public int[][] getAdjMatrix(){
return adjMatrix;
}
public List<String> getNodeIds() {
return nodeIds;
}
@ -461,18 +425,6 @@ class NodeExpandAdjMatrix{
}
}
// 输出邻接矩阵
public void printAdjMatrix() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < nodeIds.size(); i++) {
for (int j = 0; j < nodeIds.size(); j++) {
sb.append(adjMatrix[i][j]).append(" ");
}
sb.append("\n");
}
System.out.println(sb.toString());
}
/**
* 获取总图中节点展开前的所有节点坐标
* @param elements
@ -535,7 +487,7 @@ class NodeExpandLinkerRender{
double[][] turnPoi = "horizontal".equals(direction)
? calculationLinkerPointInHorizLayOut(fromPoi, toPoi, currentExpandNodeIsStart, currentExpandNodeIsEnd)
: calculationLinkerPointInVertLayOut(fromPoi, toPoi, currentExpandNodeIsStart, currentExpandNodeIsEnd);
double[] angleArr = calculationLinkerAngle(fromPoi, toPoi, turnPoi[1], turnPoi[turnPoi.length - 2]);
double[] angleArr = calculationLinkerAngle(turnPoi[0], turnPoi[turnPoi.length - 1], turnPoi[1], turnPoi[turnPoi.length - 2]);
// 构建连线
JSONObject linkerObj = JSONObject.parseObject(LinkerDefConstant.linker);
linkerObj.put("id", UUIDGener.getObjectId());

View File

@ -0,0 +1,61 @@
package com.actionsoft.apps.coe.method.process.subprocess.graph.component;
import java.util.ArrayList;
import java.util.List;
/**
* @author oYang
* @Description 邻接矩阵的基础类
* @createTime 2023年06月09日 10:19:00
*/
public abstract class AbstractAdjMatrix {
private int[][] adjMatrix; // 邻接矩阵存储
private int n; // 矩阵大小
public AbstractAdjMatrix(int n) {
this.adjMatrix = new int[n][n];
this.n = n;
}
/**
* 构建邻接矩阵
*/
public abstract void buildAdjMatrix();
/**
* 添加一条从顶点 u 到顶点 v 的有向边
*/
public void addEdge(int u, int v) {
adjMatrix[u][v] = 1; // 设置邻接矩阵中相应的位置为 1
}
/**
* 获取从顶点 u 出发可以到达的所有顶点
*/
public List<Integer> getNeighbors(int u) {
List<Integer> neighbors = new ArrayList<>();
for (int i = 0; i < n; i++) {
if (adjMatrix[u][i] == 1) {
neighbors.add(i);
}
}
return neighbors;
}
/**
* 判断从顶点 u 是否可以到达顶点 v
*/
public boolean hasEdge(int u, int v) {
return adjMatrix[u][v] == 1;
}
/**
* 获取邻接矩阵
* @return
*/
public int[][] getAdjMatrix(){
return adjMatrix;
}
}

View File

@ -0,0 +1,47 @@
package com.actionsoft.apps.coe.method.process.subprocess.graph.component;
import com.alibaba.fastjson.JSONObject;
/**
* @author oYang
* @Description TODO
* @createTime 2023年06月09日 11:21:00
*/
public abstract class AbstractDefinitionHandle {
private final String definition;
public AbstractDefinitionHandle(String definition) {
this.definition = definition;
}
protected JSONObject getDefine(){
JSONObject define = JSONObject.parseObject(definition);
return define;
}
/**
* 获取 elements 属性
* @return
*/
protected abstract JSONObject getElements();
/**
* 获取 processProperties 属性
* @return
*/
protected abstract JSONObject getProcessProperties();
/**
* 删除 elements 属性中元素
* @param key
*/
protected abstract void removeShape(String key);
/**
* 添加元素到 elements
* @param key
* @param ele
*/
protected abstract void addEle(String key, JSONObject ele);
}

View File

@ -0,0 +1,56 @@
package com.actionsoft.apps.coe.method.process.subprocess.graph.util;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractDefinitionHandle;
import com.alibaba.fastjson.JSONObject;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author oYang
* @Description 操作 definition 工具类 线程安全
* @createTime 2023年06月09日 11:06:00
*/
public class DefinitionThreadSafe extends AbstractDefinitionHandle {
private final ReentrantLock lock = new ReentrantLock();
public DefinitionThreadSafe(String definition) {
super(definition);
}
public JSONObject getElements(){
lock.lock();
try {
return getDefine().getJSONObject("elements");
}finally {
lock.unlock();
}
}
public JSONObject getProcessProperties(){
lock.lock();
try{
return getDefine().getJSONObject("processProperties");
}finally {
lock.unlock();
}
}
public void removeShape(String key){
lock.lock();
try{
getElements().remove(key);
}finally {
lock.unlock();
}
}
public void addEle(String key, JSONObject ele){
lock.lock();
try {
getElements().put(key, ele);
}finally {
lock.unlock();
}
}
}

View File

@ -0,0 +1,36 @@
package com.actionsoft.apps.coe.method.process.subprocess.graph.util;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractDefinitionHandle;
import com.alibaba.fastjson.JSONObject;
/**
* @author oYang
* @Description TODO
* @createTime 2023年06月09日 11:29:00
*/
public class DefinitionThreadUnSafe extends AbstractDefinitionHandle {
public DefinitionThreadUnSafe(String definition) {
super(definition);
}
@Override
protected JSONObject getElements() {
return getDefine().getJSONObject("elements");
}
@Override
protected JSONObject getProcessProperties() {
return getDefine().getJSONObject("processProperties");
}
@Override
protected void removeShape(String key) {
getElements().remove(key);
}
@Override
protected void addEle(String key, JSONObject ele) {
getElements().put(key, ele);
}
}

View File

@ -312,14 +312,14 @@ public class SubProcessWeb extends ActionWeb {
* @param shapeId 待展开的子流程节点ID
* @param direction 布局方向
*/
public String shapeNodeExpand(String repositoryId, String shapeId){
public String shapeNodeExpand(String repositoryId, String shapeId, String endToEndProcessDefineStr){
try {
GraphNodeExpandHandle nodeExpandHandle = new GraphNodeExpandHandle(repositoryId, shapeId);
GraphNodeExpandHandle nodeExpandHandle = new GraphNodeExpandHandle(repositoryId, shapeId, endToEndProcessDefineStr);
String define = nodeExpandHandle.handleNodeExpand();
ResponseObject ro = ResponseObject.newOkResponse("节点展开成功");
ro.setData(define);
return ro.toString();
} catch (Exception e) {
} catch (AWSException e) {
return ResponseObject.newErrResponse(e.getMessage()).toString();
}
}

View File

@ -30,6 +30,7 @@
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.shape_expand">
<param name="repositoryId"/>
<param name="shapeId"/>
<param name="endToEndProcessDefineStr"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.shape_close">
<param name="repositoryId"/>

View File

@ -10,11 +10,6 @@ $(function(){
window.subProcess = subProcess;
// 连线框 鼠标指针样式设置 防止因为连线z-index层级较高 会导致节点展开图标点击不到
$('.shape_box.linker_box').css({
'pointer-events': 'none'
});
})(Model, ruuid, sid);
});
@ -33,6 +28,14 @@ class SubProcess {
init(){
this.shapeIconRender();
this.handleScopeShapeEvent();
this.linkerBoxPointerEvent();
}
linkerBoxPointerEvent(){
// 连线框 鼠标指针样式设置 防止因为连线z-index层级较高 会导致节点展开图标点击不到
$('.shape_box.linker_box').css({
'pointer-events': 'none'
});
}
// 图形图标渲染 并绑定节点展开或者关闭事件
@ -147,14 +150,17 @@ class SubProcess {
cmd: 'com.actionsoft.apps.coe.method.process.subprocess.shape_expand',
sid: param.sid,
repositoryId: param.repositoryId,
shapeId: param.shapeId
shapeId: param.shapeId,
endToEndProcessDefineStr: JSON.stringify(param.Model.define)
},
ok: function(r){
// console.log(JSON.stringify(r.data));
definition = JSON.stringify(r.data);
definition.elements = r.data.elements;
definition.page = r.data.page;
Designer.open(definition); // 节点重新渲染
// 针对范围标识框渲染 节点关闭按钮
window.subProcess.shapeIconRender();
window.subProcess.linkerBoxPointerEvent();
window.subProcess.scopeShapeRenderTitle(param.shapeId, shapeText);
// 提示用户文件已修改
window.subProcess.fileModifiedTip();
@ -183,14 +189,16 @@ class SubProcess {
sid: param.sid,
repositoryId: param.repositoryId,
shapeId: param.shapeId,
endToEndProcessDefineStr: definition
endToEndProcessDefineStr: JSON.stringify(param.Model.define)
},
ok: function (r) {
definition = JSON.stringify(r.data);
definition.elements = r.data.elements;
definition.page = r.data.page;
Designer.open(definition); // 节点重新渲染
// 针对范围标识框渲染 节点关闭按钮
window.subProcess.shapeIconRender();
window.subProcess.linkerBoxPointerEvent();
// 提示用户文件已修改
window.subProcess.fileModifiedTip();
},