fix(部署流程): 修改部署流程方法,增加保存用户节点的表单信息

This commit is contained in:
konbai
2022-08-01 21:16:04 +08:00
parent 4adb99729b
commit 1ff440c235
6 changed files with 123 additions and 35 deletions

View File

@@ -1,12 +1,11 @@
package com.ruoyi.flowable.utils;
import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.StartEvent;
import org.flowable.bpmn.model.*;
import org.flowable.common.engine.impl.util.io.StringStreamSource;
import java.util.ArrayList;
import java.util.Collection;
/**
@@ -45,9 +44,54 @@ public class ModelUtils {
*/
public static StartEvent getStartEvent(BpmnModel model) {
Process process = model.getMainProcess();
Collection<FlowElement> elements = process.getFlowElements();
return (StartEvent) elements.stream()
.filter(flowElement -> flowElement instanceof StartEvent)
.findFirst().orElse(null);
Collection<FlowElement> flowElements = process.getFlowElements();
return getStartEvent(flowElements);
}
/**
* 获取开始节点
*
* @param flowElements 流程元素集合
* @return 开始节点未找到开始节点返回null
*/
public static StartEvent getStartEvent(Collection<FlowElement> flowElements) {
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof StartEvent) {
return (StartEvent) flowElement;
}
}
return null;
}
/**
* 获取所有用户任务节点
*
* @param model bpmnModel对象
* @return 用户任务节点列表
*/
public static Collection<UserTask> getAllUserTaskEvent(BpmnModel model) {
Process process = model.getMainProcess();
Collection<FlowElement> flowElements = process.getFlowElements();
return getAllUserTaskEvent(flowElements, null);
}
/**
* 获取所有用户任务节点
* @param flowElements 流程元素集合
* @param allElements 所有流程元素集合
* @return 用户任务节点列表
*/
public static Collection<UserTask> getAllUserTaskEvent(Collection<FlowElement> flowElements, Collection<UserTask> allElements) {
allElements = allElements == null ? new ArrayList<>() : allElements;
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof UserTask) {
allElements.add((UserTask) flowElement);
}
if (flowElement instanceof SubProcess) {
// 继续深入子流程,进一步获取子流程
allElements = getAllUserTaskEvent(((SubProcess) flowElement).getFlowElements(), allElements);
}
}
return allElements;
}
}