Merge remote-tracking branch 'origin/apps_dev' into apps_dev

This commit is contained in:
wangpf 2023-06-01 16:22:45 +08:00
commit 1436ab758c
6 changed files with 47 additions and 19 deletions

View File

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

View File

@ -146,7 +146,7 @@ public class GraphNodeExpandHandle {
* @throws Exception * @throws Exception
* @return 节点展开后的模型存储信息 * @return 节点展开后的模型存储信息
*/ */
public String handleNodeExpand(String direction) throws Exception{ public String handleNodeExpand() throws Exception{
// Thread t1 = new Thread(() -> { // Thread t1 = new Thread(() -> {
// // 1总图节点以及连线处理 // // 1总图节点以及连线处理
@ -164,7 +164,7 @@ public class GraphNodeExpandHandle {
// t2.join(); // t2.join();
// 1总图节点以及连线处理 // 1总图节点以及连线处理
handleEndToEndGraphNodeAndLinker(direction); handleEndToEndGraphNodeAndLinker();
// 2子流程节点内部元素处理 // 2子流程节点内部元素处理
handleRelationModelNodePosition(); handleRelationModelNodePosition();
@ -187,7 +187,7 @@ public class GraphNodeExpandHandle {
* 6删除旧有连线关系 * 6删除旧有连线关系
* 7构建新的连线关系 * 7构建新的连线关系
*/ */
private void handleEndToEndGraphNodeAndLinker(String direction){ private void handleEndToEndGraphNodeAndLinker(){
// 1删除当前要展开的节点 // 1删除当前要展开的节点
removeEndToEndGraphElements(shapeId); removeEndToEndGraphElements(shapeId);
@ -200,18 +200,30 @@ public class GraphNodeExpandHandle {
// 4构建邻接矩阵 // 4构建邻接矩阵
NodeExpandAdjMatrix expandAdjMatrix = buildEndToEndGraphAdjMatrix(); NodeExpandAdjMatrix expandAdjMatrix = buildEndToEndGraphAdjMatrix();
expandAdjMatrix.buildAdjMatrix(); expandAdjMatrix.buildAdjMatrix();
// expandAdjMatrix.printAdjMatrix();
// 5删除节点展开前的连线 // 5删除节点展开前的连线
removeEndToEndGraphOldLinker(); removeEndToEndGraphOldLinker();
// 6获取所有节点坐标 // 6获取所有节点坐标
JSONObject elements = endToEndProcessDefine.getJSONObject("elements"); JSONObject elements = endToEndProcessDefine.getJSONObject("elements");
double[][] vertexPosition = expandAdjMatrix.getVertexPosition(elements); double[][] vertexPosition = expandAdjMatrix.getVertexPosition(elements);
// 7构建新的连线 // 7构建新的连线
JSONObject processProperties = endToEndProcessDefine.getJSONObject("processProperties");
String direction = processProperties.getString("direction");
NodeExpandLinkerRender linkerRender = new NodeExpandLinkerRender(vertexPosition, expandAdjMatrix, scopeLimitationShape); NodeExpandLinkerRender linkerRender = new NodeExpandLinkerRender(vertexPosition, expandAdjMatrix, scopeLimitationShape);
JSONArray linkers = linkerRender.toAssembleLinker(direction, shapeId); JSONArray linkers = linkerRender.toAssembleLinker(direction, shapeId);
for (Object o : linkers) { for (Object o : linkers) {
JSONObject linker = (JSONObject) o; JSONObject linker = (JSONObject) o;
addEndToEndGraphElements(linker); addEndToEndGraphElements(linker);
} }
// 8更新画布的大小
// 确定画布的宽度与高度
double w = Arrays.stream(vertexPosition).mapToDouble(position -> position[0]).max().orElse(0.0);
double h = Arrays.stream(vertexPosition).mapToDouble(position -> position[1]).max().orElse(0.0);
JSONObject page = endToEndProcessDefine.getJSONObject("page");
page.put("width", w + 300);
page.put("height", h + 300);
} }
/** /**
@ -544,7 +556,7 @@ class NodeExpandLinkerRender{
private double[][] calculationLinkerPointInVertLayOut(double[] fromPoi, double[] toPoi, boolean currentExpandNodeIsStart, boolean currentExpandNodeIsEnd) { private double[][] calculationLinkerPointInVertLayOut(double[] fromPoi, double[] toPoi, boolean currentExpandNodeIsStart, boolean currentExpandNodeIsEnd) {
double fromX = fromPoi[0],fromY = fromPoi[1],toX = toPoi[0],toY = toPoi[1]; double fromX = fromPoi[0],fromY = fromPoi[1],toX = toPoi[0],toY = toPoi[1];
double scopeShapeW = scopeLimitationShape.getDoubleValue("w"), scopeShapeH = scopeLimitationShape.getDoubleValue("h"); double scopeShapeW = scopeLimitationShape.getJSONObject("props").getDoubleValue("w"), scopeShapeH = scopeLimitationShape.getJSONObject("props").getDoubleValue("h");
if (fromY == toY){ // 水平 分析可知 水平方向上不会出现 从左到右直连的情况 只有 右边节点右侧锚点出 向上走 左折 连到左侧节点上方锚点 if (fromY == toY){ // 水平 分析可知 水平方向上不会出现 从左到右直连的情况 只有 右边节点右侧锚点出 向上走 左折 连到左侧节点上方锚点
double[] startPoi = new double[]{fromX + (currentExpandNodeIsStart ? scopeShapeW : SubProcessConst.SUB_PROCESS_SHAPE_W), fromY + (currentExpandNodeIsStart ? scopeShapeH : SubProcessConst.SUB_PROCESS_SHAPE_H) / 2}; double[] startPoi = new double[]{fromX + (currentExpandNodeIsStart ? scopeShapeW : SubProcessConst.SUB_PROCESS_SHAPE_W), fromY + (currentExpandNodeIsStart ? scopeShapeH : SubProcessConst.SUB_PROCESS_SHAPE_H) / 2};
double[] turnPoi1 = new double[]{fromX + (currentExpandNodeIsStart ? scopeShapeW : SubProcessConst.SUB_PROCESS_SHAPE_W) + SubProcessConst.SHAPE_HORIZ_INTERVAL / 2, fromY + (currentExpandNodeIsStart ? scopeShapeH : SubProcessConst.SUB_PROCESS_SHAPE_H) / 2}; double[] turnPoi1 = new double[]{fromX + (currentExpandNodeIsStart ? scopeShapeW : SubProcessConst.SUB_PROCESS_SHAPE_W) + SubProcessConst.SHAPE_HORIZ_INTERVAL / 2, fromY + (currentExpandNodeIsStart ? scopeShapeH : SubProcessConst.SUB_PROCESS_SHAPE_H) / 2};
@ -612,7 +624,7 @@ class NodeExpandLinkerRender{
private double[][] calculationLinkerPointInHorizLayOut(double[] fromPoi, double[] toPoi, boolean currentExpandNodeIsStart, boolean currentExpandNodeIsEnd) { private double[][] calculationLinkerPointInHorizLayOut(double[] fromPoi, double[] toPoi, boolean currentExpandNodeIsStart, boolean currentExpandNodeIsEnd) {
double fromX = fromPoi[0],fromY = fromPoi[1],toX = toPoi[0],toY = toPoi[1]; double fromX = fromPoi[0],fromY = fromPoi[1],toX = toPoi[0],toY = toPoi[1];
double scopeShapeW = scopeLimitationShape.getDoubleValue("w"), scopeShapeH = scopeLimitationShape.getDoubleValue("h"); double scopeShapeW = scopeLimitationShape.getJSONObject("props").getDoubleValue("w"), scopeShapeH = scopeLimitationShape.getJSONObject("props").getDoubleValue("h");
if (fromY == toY) { // 水平 方向上 存在从左向右直连的情况 但不存在从右向左直连的情况 水平方向上 从左向右 应是 右出 向上 左折 向下 if (fromY == toY) { // 水平 方向上 存在从左向右直连的情况 但不存在从右向左直连的情况 水平方向上 从左向右 应是 右出 向上 左折 向下
return fromX < toX return fromX < toX
? new double[][] ? new double[][]

View File

@ -150,4 +150,15 @@ public class GraphRender {
CoeDesignerAPIManager.getInstance().storeDefinition(this.baseModel); CoeDesignerAPIManager.getInstance().storeDefinition(this.baseModel);
} }
} }
/**
* 布局方向添加到流程属性中
* 方便后续节点展开时用到
* @param direction
*/
public void addDirectionToProcessProperties(String direction){
JSONObject defineJsonObj = JSONObject.parseObject(this.baseModel.getDefinition());
JSONObject processProperties = defineJsonObj.getJSONObject("processProperties");
processProperties.put("direction", direction);
}
} }

View File

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

View File

@ -6,6 +6,7 @@ $(function(){
(function (Model, ruuid, sid) { (function (Model, ruuid, sid) {
const subProcess = new SubProcess(Model, ruuid, sid); const subProcess = new SubProcess(Model, ruuid, sid);
subProcess.shapeIconRender(); subProcess.shapeIconRender();
window.subProcess = subProcess;
// 连线框 鼠标指针样式设置 防止因为连线z-index层级较高 会导致节点展开图标点击不到 // 连线框 鼠标指针样式设置 防止因为连线z-index层级较高 会导致节点展开图标点击不到
$('.shape_box.linker_box').css({ $('.shape_box.linker_box').css({
@ -29,14 +30,16 @@ class SubProcess {
for (let shapeId in elements) { for (let shapeId in elements) {
let shape = elements[shapeId]; let shape = elements[shapeId];
if (shape.name == 'linker') continue; // 当前元素为连线的话 直接略过 if (shape.name == 'linker') continue; // 当前元素为连线的话 直接略过
if (shape.name == 'subProcess') { // 当前元素为子流程节点 渲染展开图标 并绑定展开事件 if (shape.name == 'scopeLimitation' || shape.name == 'subProcess'){ // 只有子流程或者范围选择框才有对应的图标渲染
let expandIcon = "<span id='icon_"+shapeId+"' class='iconfont icon-zhankaishousuo' style='position: absolute;cursor: pointer;'></span>"; if (shape.name == 'subProcess') { // 当前元素为子流程节点 渲染展开图标 并绑定展开事件
$('#'+shapeId).append(expandIcon); let expandIcon = "<span id='icon_"+shapeId+"' class='iconfont icon-zhankaishousuo' style='position: absolute;cursor: pointer;'></span>";
$('#icon_'+shapeId).on('click', '', {shapeId: shapeId, Model: this.Model, repositoryId: this.repositoryId, sid: this.sid}, this.shapeExpand); $('#'+shapeId).append(expandIcon);
}else { // 当前元素为虚线范围限制框的话 渲染关闭图标 并绑定关闭事件 $('#icon_'+shapeId).on('click', '', {shapeId: shapeId, Model: this.Model, repositoryId: this.repositoryId, sid: this.sid}, this.shapeExpand);
let closeIcon = "<span id='icon_"+shapeId+"' class='iconfont icon-quanpingshouqi' style='position: absolute;cursor: pointer;'></span>"; }else { // 当前元素为虚线范围限制框的话 渲染关闭图标 并绑定关闭事件
$('#'+shapeId).append(closeIcon); let closeIcon = "<span id='icon_"+shapeId+"' class='iconfont icon-quanpingshouqi' style='position: absolute;cursor: pointer;'></span>";
$('#icon_'+shapeId).on('click', '', {shapeId: shapeId, Model: this.Model, repositoryId: this.repositoryId, sid: this.sid}, this.shapeClose); $('#'+shapeId).append(closeIcon);
$('#icon_'+shapeId).on('click', '', {shapeId: shapeId, Model: this.Model, repositoryId: this.repositoryId, sid: this.sid}, this.shapeClose);
}
} }
} }
} }
@ -66,9 +69,11 @@ class SubProcess {
shapeId: param.shapeId shapeId: param.shapeId
}, },
ok: function(r){ ok: function(r){
console.log(JSON.stringify(r.data)); // console.log(JSON.stringify(r.data));
definition = JSON.stringify(r.data); definition = JSON.stringify(r.data);
Designer.open(definition); Designer.open(definition); // 节点重新渲染
// 针对范围标识框渲染 节点关闭按钮
window.subProcess.shapeIconRender();
}, },
err: function(r){ err: function(r){
$.simpleAlert(r.msg); $.simpleAlert(r.msg);