activiti5转activiti7获取各流程节点
⽹上都是5或者6版本的获取流程图节点,连线列表的信息。
我想知道⽤activiti7版本的怎么获取流程图各节点信息,
因为我想查出连线和节点信息去设置⼀些⾃定义的信息。
``` // 查询当前的流程实例
ProcessInstance processInstance = ateProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); BpmnModel bpmnModel = ProcessDefinitionId());
//获取当前流程的流程定义processDefinitionEntity,然后根据流程定义获得所有的节点
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ateProcessDefinitionQuery()
.ProcessDefinitionId()).singleResult();
最主要的是 Activities() 再activiti7版本没有这个get⽅法了。就不知道怎么⽤了。求教各位⼤神,帮我研究下。有效建议:
/**
createprocessa* 获取流程节点
*
* @param definitionId 流程定义ID
* @param processId 流程ID(可能为⼦流程),也就是流程定义Key
* @return
*/
protected List<FlowElement> getProcessDefinitionNodes(String definitionId, String processId) {
BpmnModel bpmnModel = BpmnModel(definitionId);
List<Process> processes = wArrayList();
if (StrUtil.isNotEmpty(processId)) {
processes.ProcessById(processId));
} else {
processes = Processes();
}
List<FlowElement> flowElements = wArrayList();
processes.forEach(process -> flowElements.FlowElements()));
return flowElements;
}
@GetMapping(value = "process/def/nodes/userTask")
public AppResult getUserTaskNodes(
@RequestParam(value = "id") String definitionId,
@RequestParam(value = "processId", required = false) String processId) {
List<FlowElement> flowElements = getProcessDefinitionNodes(definitionId, processId);
List<UserTask> userTasks = wArrayList();
flowElements.forEach(
node -> {
if (node instanceof UserTask) {
userTasks.add((UserTask) node);
}
});
return buildSuccess(userTasks);
}
// 返回数据格式(节点)
{
"code": 200,
"message": "操作成功",
"data": [
{
"id": "Activity_14xmp0o",
"xmlRowNumber": 7,
"xmlColumnNumber": 5,
"name": "⼀级审批",
"asynchronous": false,
"notExclusive": false,
"incomingFlows": [
{
"id": "Flow_1s2ypsj",
"xmlRowNumber": 20,
"xmlColumnNumber": 5,
"sourceRef": "StartEvent_1",
"targetRef": "Activity_14xmp0o",
"waypoints": [
238,
470,
350,
470
]
}
],
"outgoingFlows": [
{
"id": "Flow_1xbbtsl",
"xmlRowNumber": 21,
"xmlColumnNumber": 5,
"sourceRef": "Activity_14xmp0o",
"targetRef": "Gateway_0astncq",
"waypoints": [
450,
470,
555,
470
]
}
],
"forCompensation": false,
"formKey": "one-level",
"candidateGroups": [
"one-approval"
],
"extended": false,
"exclusive": true
},
{
"id": "Activity_19kus41",
"xmlRowNumber": 11,
"xmlColumnNumber": 5,
"name": "⼆级审批",
"asynchronous": false,
"notExclusive": false,
"incomingFlows": [
{
"id": "Flow_101i5h2",
"xmlRowNumber": 34,
"xmlColumnNumber": 5,
"name": "通过",
"conditionExpression": "${gateway==true}",
"sourceRef": "Gateway_0astncq",
"targetRef": "Activity_19kus41",
"waypoints": [
580,
445,
580,
340,
670,
340
]
}
]
,
"outgoingFlows": [
{
"id": "Flow_0zdqnmv",
"xmlRowNumber": 42,
"xmlColumnNumber": 5,
"sourceRef": "Activity_19kus41",
"targetRef": "Gateway_0jvvxgy",
"waypoints": [
770,
340,
875,
340
]
}
],
"forCompensation": false,
"formKey": "two-level",
"candidateGroups": [
"two-approval"
],
"extended": false,
"exclusive": true
}
]
}
原⽂链接:
Activiti7获取当前任务节点出⼝连线(动态⽣成处理节点)
Activiti7 中 PVM,ActivitiImpl,PvmTransition ,ExecutionImpl, TransitionImpl 替代⽅法。
PVM classes
All classes from the ine.impl.pvm package (and subpackages) have been removed. Th
is is because the PVM (Process Virtual Machine) model has been removed and replaced by a simpler and more ligh This means that usages of ActivitiImpl, ProcessDefinitionImpl, ExecutionImpl, TransitionImpl are invalid.
Generally, most of the usage of these classes in version 5 came down to getting information that was contained in the process definition. In version 6, all the process definition information can be found through the BpmnM The quickest way to get the BpmnModel for a process definition is to use the ine.impl.util.ProcessDefinitionUtil class:
// The whole model
// Only the specific process definition
⼤致是说:官⽅为了轻量化,所以就把原来的PVM 流程引擎给优化了、
删了后推荐我们获取bpmnModel或者process来获取模型的参数。
BpmnModel获取⽅式可以使⽤官⽅推荐的,我这边交互刚好只有taskId,就⽤这个做个demo;
// 获取当前任务
Task task = ateTaskQuery().taskId(taskId).singleResult();
//获取当前模型
BpmnModel bpmnModel = ProcessDefinitionId());
// 获取当前节点
FlowElement flowElement = TaskDefinitionKey()); // 这⾥不转也有⽅法拿到,我这是为了后⼈阅读⽅便
UserTask userTask = (UserTask)flowElement;
//获取节点出⼝线段
List<SequenceFlow> outgoingFlows = OutgoingFlows();
// 我这边暂时是解析expression 获取条件和约定的值返回到前端构造button
原⽂链接:
Activiti7中没有getOutgoingTransitions等⽅法
activiti 当前活动id
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论