端到端功能
模型保存时接口子流程信息保存部分逻辑修改 画布中新拖拽图形依据位置以及连线关系增加部分属性扩展信息
This commit is contained in:
parent
8e933cc1ca
commit
c5739637df
Binary file not shown.
@ -6065,6 +6065,59 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
if (StringUtils.isNotEmpty(definition.getString("commonShapeConfig"))) {
|
||||
definition.remove("commonShapeConfig");
|
||||
}
|
||||
|
||||
// 针对端到端的模型文件 保存时 将已展开的范围框对应子流程模型 保存到总图的同级目录下
|
||||
if (repositoryModel.getMethodId().equals("process.subprocess")){
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
Set<String> scopeShapeIdSet = elements.keySet().stream().filter(key -> "scopeLimitation".equals(elements.getJSONObject(key).getString("name"))).collect(Collectors.toSet());
|
||||
if (scopeShapeIdSet.size() > 0){ // 说明有展开的节点
|
||||
for (String scopeShapeId : scopeShapeIdSet) {
|
||||
JSONObject scopeShape = elements.getJSONObject(scopeShapeId);
|
||||
// 当前范围框中已存在的内部元素
|
||||
JSONArray innerElements = scopeShape.getJSONArray("innerElements");
|
||||
// 存放范围框内部元素
|
||||
JSONArray inScopeShapeRangeEles = new JSONArray();
|
||||
// 获取当前范围框内的元素信息
|
||||
for (String key : elements.keySet()) {
|
||||
if (scopeShapeId.equals(key)) continue; // 范围框本身不算作其内部元素
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
if (shape.containsKey("scopeShapeId") && scopeShapeId.equals(shape.getString("scopeShapeId"))){
|
||||
inScopeShapeRangeEles.add(shape);
|
||||
if (!innerElements.contains(shape.getString("id"))){ // 说明当前图形不是生成的 是人为在画布新拖拽的 加入当前范围框的维护列表中
|
||||
innerElements.add(shape.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取当前范围框所对应的子流程文件信息
|
||||
if (inScopeShapeRangeEles.size() > 0){
|
||||
List<DesignerShapeRelationModel> relationModelList = DesignerShapeRelationCache.getListByAttrId(uuid, scopeShapeId, "child_process");
|
||||
DesignerShapeRelationModel relationModel = relationModelList.stream().findFirst().orElse(null);
|
||||
if (relationModel == null)
|
||||
throw new AWSException("未找到当前节点所标识的子流程文件信息");
|
||||
String relationFileId = relationModel.getRelationFileId();
|
||||
|
||||
String childProcessDefine = CoeDesignerAPIManager.getInstance().getChildProcessDefine(uuid, 0, relationFileId);
|
||||
if (UtilString.isEmpty(childProcessDefine)){ // 说明子流程信息是第一次保存
|
||||
// 直接去子流程源文件处 读取
|
||||
childProcessDefine = CoeDesignerAPIManager.getInstance().getDefinition(relationFileId, 0).getDefinition();
|
||||
}
|
||||
|
||||
JSONObject childProcessObj = JSONObject.parseObject(childProcessDefine);
|
||||
JSONObject newElements = new JSONObject();
|
||||
for (Object o : inScopeShapeRangeEles) {
|
||||
JSONObject ele = (JSONObject) o;
|
||||
newElements.put(ele.getString("id"), ele);
|
||||
}
|
||||
childProcessObj.put("elements", newElements);
|
||||
|
||||
// 保存展开的子流程信息到 总图的同级目录下
|
||||
BaseModel defineModel = CoeDesignerAPIManager.getInstance().getDefinition(uuid, 0);
|
||||
CoeDesignerAPIManager.getInstance().storeChildProcessDefine(defineModel, relationFileId, childProcessObj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
define = definition.toString();
|
||||
|
||||
// 修改流程图
|
||||
@ -6086,59 +6139,6 @@ public class CoeProcessLevelWeb extends ActionWeb {
|
||||
defineModel.setUpdateTime(now);
|
||||
defineModel.setDefinition(define);
|
||||
CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// 保存文件
|
||||
|
||||
// 针对端到端的模型文件 保存时 将已展开的范围框对应子流程模型 保存到总图的同级目录下
|
||||
JSONObject elements = definition.getJSONObject("elements");
|
||||
Set<String> scopeShapeIdSet = elements.keySet().stream().filter(key -> "scopeLimitation".equals(elements.getJSONObject(key).getString("name"))).collect(Collectors.toSet());
|
||||
if (scopeShapeIdSet.size() > 0){ // 说明有展开的节点
|
||||
for (String scopeShapeId : scopeShapeIdSet) {
|
||||
// 存放范围框内部元素
|
||||
JSONArray inScopeShapeRangeEles = new JSONArray();
|
||||
// 获取当前范围框内的元素信息
|
||||
JSONObject scopeShapeProps = elements.getJSONObject(scopeShapeId).getJSONObject("props");
|
||||
double scopeX = scopeShapeProps.getDoubleValue("x"), scopeY = scopeShapeProps.getDoubleValue("y"), scopeW = scopeShapeProps.getDoubleValue("w"), scopeH = scopeShapeProps.getDoubleValue("h");
|
||||
for (String key : elements.keySet()) {
|
||||
if (scopeShapeId.equals(key)) continue; // 范围框本身不算作其内部元素
|
||||
JSONObject shape = elements.getJSONObject(key);
|
||||
if ("linker".equals(shape.getString("name"))){ // 连线
|
||||
JSONObject from = shape.getJSONObject("from");
|
||||
JSONObject to = shape.getJSONObject("to");
|
||||
double fromX = from.getDoubleValue("x"), fromY = from.getDoubleValue("y"), toX = to.getDoubleValue("x"), toY = to.getDoubleValue("y");
|
||||
if ((scopeX < fromX && fromX < scopeX + scopeW && scopeY < fromY && fromY < scopeY + scopeH) || (scopeX < toX && toX < scopeX + scopeW && scopeY < toY && toY < scopeY + scopeH)){
|
||||
inScopeShapeRangeEles.add(shape);
|
||||
}
|
||||
}else {
|
||||
double x = shape.getJSONObject("props").getDoubleValue("x");
|
||||
double y = shape.getJSONObject("props").getDoubleValue("y");
|
||||
if (scopeX <= x && x < scopeX + scopeW && scopeY <= y && y < scopeY + scopeH){
|
||||
inScopeShapeRangeEles.add(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取当前范围框所对应的子流程文件信息
|
||||
if (inScopeShapeRangeEles.size() > 0){
|
||||
List<DesignerShapeRelationModel> relationModelList = DesignerShapeRelationCache.getListByAttrId(uuid, scopeShapeId, "child_process");
|
||||
DesignerShapeRelationModel relationModel = relationModelList.stream().findFirst().orElse(null);
|
||||
if (relationModel == null)
|
||||
throw new AWSException("未找到当前节点所标识的子流程文件信息");
|
||||
String relationFileId = relationModel.getRelationFileId();
|
||||
|
||||
BaseModel relationBaseModel = CoeDesignerAPIManager.getInstance().getDefinition(relationFileId, 0);
|
||||
|
||||
JSONObject childProcessObj = JSONObject.parseObject(relationBaseModel.getDefinition());
|
||||
JSONObject newElements = new JSONObject();
|
||||
for (Object o : inScopeShapeRangeEles) {
|
||||
JSONObject ele = (JSONObject) o;
|
||||
newElements.put(ele.getString("id"), ele);
|
||||
}
|
||||
childProcessObj.put("elements", newElements);
|
||||
|
||||
// 保存展开的子流程信息到 总图的同级目录下
|
||||
CoeDesignerAPIManager.getInstance().storeChildProcessDefine(defineModel, relationFileId, childProcessObj.toJSONString());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 关联/被关联图形的名称更新
|
||||
|
||||
@ -3883,6 +3883,24 @@ function saveRelevanceShapesTODB(shapesObj, shapeId, shapeName, fileName,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (methodId == "process.subprocess"){
|
||||
let ele = Model.getShapeById(shapeId);
|
||||
let relationFileId = list[0].relationFileId;
|
||||
let relationShapeText = list[0].relationShapeText;
|
||||
if (ele.extendAttr){
|
||||
ele.extendAttr.id = relationFileId;
|
||||
ele.extendAttr.name = relationShapeText;
|
||||
}else {
|
||||
let extendAttr = {
|
||||
id: relationFileId,
|
||||
name: relationShapeText
|
||||
}
|
||||
ele.extendAttr = extendAttr;
|
||||
}
|
||||
ele.text = relationShapeText;
|
||||
}
|
||||
|
||||
Model.update(shape);
|
||||
}
|
||||
});
|
||||
|
||||
@ -376,9 +376,13 @@ var Designer = {
|
||||
if (g.name == 'subProcess'){
|
||||
window.subProcess.shapeOpenIconRender(g);
|
||||
}
|
||||
// 判断当前图形的元素类型 ElementType.INNER_NODE ElementType.OUTER_NODE
|
||||
let elementType = window.subProcess.calculateShapeElementType(g);
|
||||
g.elementType = elementType;
|
||||
// 判断当前图形是否在某一个范围框中 如果在返回范围框图形的ID 同时设置元素类型 ElementType.INNER_NODE ElementType.OUTER_NODE
|
||||
g.elementType = "OUTER_NODE";
|
||||
let scopeShapeKey = window.subProcess.calculateShapeInWhichScope(g);
|
||||
if (scopeShapeKey) {
|
||||
g.elementType = "INNER_NODE";
|
||||
g.scopeShapeId = scopeShapeKey;
|
||||
}
|
||||
}
|
||||
Designer.events.push("created", g);
|
||||
Model.add(g);
|
||||
@ -2178,8 +2182,11 @@ var Designer = {
|
||||
let toObj = Model.getShapeById(to.id);
|
||||
if (fromObj.elementType == "OUTER_NODE" && toObj.elementType == "OUTER_NODE"){
|
||||
d.elementType = "OUTER_LINKER";
|
||||
window.subProcess.outerNodeExtendAttrHandle(d);
|
||||
}else if (fromObj.elementType == "INNER_NODE" && toObj.elementType == "INNER_NODE"){
|
||||
d.elementType = "INNER_LINKER";
|
||||
let scopeShapeKey = window.subProcess.calculateLinkerInWhichScope(d);
|
||||
d.scopeShapeId = scopeShapeKey;
|
||||
}else {
|
||||
d.elementType = "CROSS_LINKER";
|
||||
}
|
||||
|
||||
@ -341,9 +341,9 @@ class SubProcess {
|
||||
return false
|
||||
}
|
||||
|
||||
// 根据当前元素的坐标设置元素类型
|
||||
calculateShapeElementType(shape){
|
||||
let elementType = "OUTER_NODE"; // 默认指定外部节点
|
||||
// 判断图形在哪个范围框中 返回范围框的图形ID
|
||||
calculateShapeInWhichScope(shape){
|
||||
let scopeShapeKey = "";
|
||||
let props = shape.props;
|
||||
let elements = Model.define.elements;
|
||||
for (let key in elements) {
|
||||
@ -354,11 +354,67 @@ class SubProcess {
|
||||
let scopeW = ele.props.w;
|
||||
let scopeH = ele.props.h;
|
||||
if (scopeX < props.x && props.x < scopeX + scopeW && scopeY < props.y && props.y < scopeY + scopeH){
|
||||
elementType = "INNER_NODE";
|
||||
scopeShapeKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return elementType;
|
||||
return scopeShapeKey;
|
||||
}
|
||||
|
||||
// 判断当前连线在哪个范围框中
|
||||
calculateLinkerInWhichScope(linker){
|
||||
let scopeShapeKey = "";
|
||||
let fromObj = linker.from;
|
||||
let toObj = linker.to;
|
||||
let fromX = fromObj.x, fromY = fromObj.y;
|
||||
let toX = toObj.x, toY = toObj.y;
|
||||
let elements = Model.define.elements;
|
||||
for (let key in elements) {
|
||||
let ele = elements[key];
|
||||
if (ele.elementType == "SCOPE_NODE"){
|
||||
let scopeX = ele.props.x;
|
||||
let scopeY = ele.props.y;
|
||||
let scopeW = ele.props.w;
|
||||
let scopeH = ele.props.h;
|
||||
if (scopeX < fromX && fromX < scopeX + scopeW && scopeY < fromY && fromY < scopeY + scopeH
|
||||
&& scopeX < toX && toX < scopeX + scopeW && scopeY < toY && toY < scopeY + scopeH){
|
||||
scopeShapeKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scopeShapeKey;
|
||||
}
|
||||
|
||||
// 根据连线 处理from to 两个外部节点的extendAttr扩展属性
|
||||
outerNodeExtendAttrHandle(linker){
|
||||
let fromId = linker.from.id;
|
||||
let toId = linker.to.id;
|
||||
let fromShape = Model.getShapeById(fromId);
|
||||
let toShape = Model.getShapeById(toId);
|
||||
let extendAttr = {
|
||||
leadNodeArr: [],
|
||||
rearNodeArr: []
|
||||
}
|
||||
// 更新后置节点
|
||||
let rearNodeArr = [];
|
||||
if (fromShape.extendAttr){
|
||||
rearNodeArr = [...fromShape.extendAttr.rearNodeArr];
|
||||
}else {
|
||||
fromShape.extendAttr = extendAttr;
|
||||
}
|
||||
rearNodeArr.push(toId);
|
||||
fromShape.extendAttr.rearNodeArr = rearNodeArr;
|
||||
// 更新前置节点
|
||||
let leadNodeArr = [];
|
||||
if (toShape.extendAttr){
|
||||
leadNodeArr = [...toShape.extendAttr.leadNodeArr];
|
||||
}else {
|
||||
toShape.extendAttr = extendAttr;
|
||||
}
|
||||
leadNodeArr.push(fromId);
|
||||
toShape.extendAttr.leadNodeArr = leadNodeArr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user