端到端功能 子流程节点一键展开与闭合 代码阶段性提交

This commit is contained in:
qinoy 2023-06-15 17:52:09 +08:00
parent 9bb5f1197e
commit 9a28bdf7c0
10 changed files with 207 additions and 11 deletions

View File

@ -155,4 +155,18 @@ public class SubProcessController {
return processWeb.shapeNodeClose(repositoryId, shapeId, endToEndProcessDefineStr);
}
/**
* 节点一键展开或者闭合
* @param uc
* @param action
* @param repositoryId
* @param define
* @return
*/
@Mapping("com.actionsoft.apps.coe.method.process.subprocess.shape_one_click")
public String shapeOneClick(UserContext uc, String action, String repositoryId, String define){
SubProcessWeb processWeb = new SubProcessWeb(uc);
return processWeb.shapeOneClick(action, repositoryId, define);
}
}

View File

@ -127,6 +127,10 @@ public class GraphNodeCloseHandle {
// 当前关闭的节点范围标识框的位置与大小
double[] scope = SubProcessNodeDefineUtil.calculateSubProcessNodeExpandScope(subProcessNodeDefineHandle);
// double[] scopeShapeBounding = new double[]{x, y, scope[2], scope[3]};
// boolean yIsMove = checkShapeYIsMove(elements, scopeShapeBounding);
for (String key : elements.keySet()) {
JSONObject ele = elements.getJSONObject(key);
if ("linker".equals(ele.getString("name"))) continue;
@ -181,6 +185,55 @@ public class GraphNodeCloseHandle {
}
}
/**
* 在节点闭合的时候 检查当前闭合的节点的下方节点是否需要上下移动
* @param elements
* @param scopeShapeBounding
* @return
*/
private boolean checkShapeYIsMove(JSONObject elements, double[] scopeShapeBounding){
// 当前闭合节点所对应的范围框
double scopeY = scopeShapeBounding[1];
double scopeH = scopeShapeBounding[3];
// 模型中已存在的范围框
boolean yIsMove = true;
boolean onlyScopeShape = true; // 在同一水平方向上是否就存在当前闭合的范围框
Map<String, ScopeShapeMonitor.MonitorInfo> scopeShapeMonitorMap = scopeShapeMonitor.getScopeShapeMonitorMap();
if (scopeShapeMonitorMap != null){
Set<String> scopeShapeKey = scopeShapeMonitor.getScopeShapeMonitorMap().keySet();
for (String key : scopeShapeKey) {
JSONObject scopeShape = elements.getJSONObject(key);
JSONObject props = scopeShape.getJSONObject("props");
double y = props.getDoubleValue("y");
double h = props.getDoubleValue("h");
if (y == scopeY){
onlyScopeShape = false;
}
if (y == scopeY && scopeH < h){ // 假设当前闭合的范围框为s1 依次找到与s1在水平方向同级 高度更高的范围框
scopeH = h;
}
}
}
if (onlyScopeShape){ // 如果仅有一个当前闭合的范围框 或者 同一水平方向上仅有一个范围框 那y轴上下方的节点肯定要向上移动的
return yIsMove;
}
for (String key : elements.keySet()) {
JSONObject shape = elements.getJSONObject(key);
if ("linker".equals(shape.getString("name"))) continue;
JSONObject shapeProps = shape.getJSONObject("props");
double y = shapeProps.getDoubleValue("y");
double bottomBound = scopeY + scopeH;
if (bottomBound < y && y - bottomBound == SubProcessConst.SHAPE_VERT_INTERVAL && !scopeShapeMonitor.checkShapeIsScopeInRange(key)){
yIsMove = false;
break;
}
}
return yIsMove;
}
/**
* 删除总图中节点展开前的连线

View File

@ -224,6 +224,8 @@ public class GraphNodeExpandHandle {
double scopeShapeW = scopeShapeProps.getDoubleValue("w");
double scopeShapeH = scopeShapeProps.getDoubleValue("h");
// boolean yIsMove = checkShapeYIsMove(elements, scopeLimitationShape);
for (String key : elements.keySet()) {
JSONObject ele = elements.getJSONObject(key);
if ("linker".equals(ele.getString("name"))) continue; // 连线先不处理
@ -272,6 +274,29 @@ public class GraphNodeExpandHandle {
}
}
/**
* 在节点扩展的时候 检查当前扩展的节点的下方节点是否需要上下移动
*/
private boolean checkShapeYIsMove(JSONObject elements, JSONObject scopeShape){
JSONObject props = scopeShape.getJSONObject("props");
double scopeY = props.getDoubleValue("y");
double scopeH = props.getDoubleValue("h");
boolean yIsMove = false;
for (String key : elements.keySet()) {
JSONObject shape = elements.getJSONObject(key);
if ("linker".equals(shape.getString("name"))) continue;
JSONObject shapeProps = shape.getJSONObject("props");
double y = shapeProps.getDoubleValue("y");
if (scopeY < y && y < scopeY + scopeH && !scopeShapeMonitor.checkShapeIsScopeInRange(key)){
yIsMove = true;
break;
}
}
return yIsMove;
}
/**
* 构建节点展开前 端到端总图的邻接矩阵
* 方便后续节点展开或者闭合进行重新连线

View File

@ -189,7 +189,7 @@ public class ScopeShapeMonitor {
}
class MonitorInfo {
public class MonitorInfo {
private String scopeShapeId; // 当前虚线范围框的图形ID
private boolean xMove; // 范围框发生左移或者右移

View File

@ -2,6 +2,9 @@ package com.actionsoft.apps.coe.method.process.subprocess.web;
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
import com.actionsoft.apps.coe.method.process.subprocess.graph.*;
import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractDefinitionHandle;
import com.actionsoft.apps.coe.method.process.subprocess.graph.util.DefinitionThreadUnSafe;
import com.actionsoft.apps.coe.method.process.subprocess.graph.util.SubProcessNodeDefineUtil;
import com.actionsoft.apps.coe.method.process.subprocess.mode.Node;
import com.actionsoft.apps.coe.method.process.subprocess.mode.vo.IndependentNodeVo;
import com.actionsoft.apps.coe.method.process.subprocess.mode.vo.SubProcessTagVo;
@ -344,4 +347,37 @@ public class SubProcessWeb extends ActionWeb {
}
}
public String shapeOneClick(String action, String repositoryId, String define){
// 1收集子流程节点
AbstractDefinitionHandle definitionHandle = new DefinitionThreadUnSafe(define);
JSONObject elements = definitionHandle.getElements();
if ("expand".equals(action)){ // 一键展开
Set<String> shapeKey = elements.keySet().stream().filter(key -> "subProcess".equals(elements.getJSONObject(key).getString("name"))).collect(Collectors.toSet());
Set<String> filterKey = new HashSet<>();
for (String key : shapeKey) {
try {
SubProcessNodeDefineUtil.readSubProcessNodeDefine(repositoryId, key);
filterKey.add(key);
} catch (AWSException e) {
continue;
}
}
for (String key : filterKey) {
GraphNodeExpandHandle expandHandle = new GraphNodeExpandHandle(repositoryId, key, define);
define = expandHandle.handleNodeExpand();
}
}else { // 一键闭合
Set<String> keySet = elements.keySet().stream().filter(key -> "scopeLimitation".equals(elements.getJSONObject(key).getString("name"))).collect(Collectors.toSet());
for (String key : keySet) {
GraphNodeCloseHandle closeHandle = new GraphNodeCloseHandle(repositoryId, key, define);
define = closeHandle.handleNodeClose();
}
}
ResponseObject ro = ResponseObject.newOkResponse("操作成功");
ro.setData(define);
return ro.toString();
}
}

View File

@ -37,4 +37,9 @@
<param name="shapeId"/>
<param name="endToEndProcessDefineStr"/>
</cmd-bean>
<cmd-bean name="com.actionsoft.apps.coe.method.process.subprocess.shape_one_click">
<param name="action"/>
<param name="repositoryId"/>
<param name="define"/>
</cmd-bean>
</aws-actions>

View File

@ -1161,6 +1161,13 @@
<div class="ico linkertype_normal"></div>创建连线
<div class="extend">L</div>
</li>
<li class="devider devi_selectall"></li>
<li ac="oneClickExpand">一键展开
<div class="extend"></div>
</li>
<li ac="oneClickClose">一键闭合
<div class="extend"></div>
</li>
<li class="devider devi_custom"></li>
<li ac="customdefine">自定义模板
<div class="extend"></div>

View File

@ -14,6 +14,15 @@ Designer.contextMenu.show = function(x, y) {
menu.children("li[ac=drawline]").show();
menu.children("li[ac=processAttribute]").show();
var clipLen = Designer.clipboard.elements.length;
if (methodId == 'process.subprocess') { // 当前建模为端到端
let iconShow = window.subProcess.oneClickExpandAndCloseIconShow();
if (iconShow.showExpandIcon){
menu.children("li[ac=oneClickExpand]").show();
}
if (iconShow.showCloseIcon){
menu.children("li[ac=oneClickClose]").show();
}
}
if (currentFocus == null) {
// 画布
if (clipLen > 0) {
@ -179,6 +188,12 @@ Designer.contextMenu.execAction = function(item) {
showLeadAndRearProcessDlg('lead');
} else if (action == 'addRearProcess') {// 关联至后置流程
showLeadAndRearProcessDlg('rear');
}else if (action == 'oneClickExpand'){ // 子流程节点一键展开
$.simpleAlert('一键展开了');
window.subProcess.oneClickOperate('expand');
}else if (action == 'oneClickClose'){ // 子流程节点一键闭合
$.simpleAlert('一键闭合了');
window.subProcess.oneClickOperate('close');
}
};

View File

@ -3,15 +3,14 @@ $(function(){
return;
}
// 1. 子流程展开 事件:获取当前子流程所代表的模型文件
(function (Model, ruuid, sid) {
const subProcess = new SubProcess(Model, ruuid, sid);
// (function (Model, ruuid, sid) {
// })(Model, ruuid, sid);
subProcess.init();
const subProcess = new SubProcess(Model, ruuid, sid);
window.subProcess = subProcess;
subProcess.init();
})(Model, ruuid, sid);
window.subProcess = subProcess;
});
class SubProcess {
@ -134,10 +133,6 @@ class SubProcess {
for (let key in elements) {
let shape = elements[key];
if (shape.name == 'linker') continue;
// if (shape.name == 'scopeLimitation') {
// $.simpleAlert("同一时间仅支持一个子流程节点展开", "warning");
// return;
// }
if (key == param.shapeId){
shapeText = shape.text;
}
@ -207,6 +202,52 @@ class SubProcess {
});
}
// 一键展开或闭合
oneClickOperate(action){
console.log('oneClickExpand',this);
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.method.process.subprocess.shape_one_click',
sid: this.sid,
action: action,
repositoryId: this.repositoryId,
define: JSON.stringify(this.Model.define)
},
ok: function (r){
definition.elements = r.data.elements;
definition.page = r.data.page;
Designer.open(definition); // 节点重新渲染
// 针对范围标识框渲染 节点关闭按钮
window.subProcess.shapeIconRender();
window.subProcess.linkerBoxPointerEvent();
// 提示用户文件已修改
window.subProcess.fileModifiedTip();
}
});
}
// 是否显示一键展开或者一键关闭
oneClickExpandAndCloseIconShow(){
let showExpandFlag = false;
let showCloseFlag = false;
let elements = this.Model.define.elements;
for (let key in elements) {
let shape = elements[key];
if (shape.name == 'linker') continue;
if (shape.name == 'subProcess'){
showExpandFlag = true;
}else if (shape.name == 'scopeLimitation'){
showCloseFlag = true;
}
if (showExpandFlag && showCloseFlag) break;
}
return {showExpandIcon: showExpandFlag, showCloseIcon: showCloseFlag};
}
// 文件修改提示
fileModifiedTip(){
if (isAutoSave == "0") {
$("#saving_tip").css("color", "rgb(255, 0, 0)");