Flowable实现流程退回
时间: 2024-05-10 09:08:57 浏览: 209
Flowable提供了多种方式实现流程退回,以下是其中两种常见的方式:
1. 使用历史数据回退
在流程中使用历史数据回退的方式,即在流程实例中获取历史流程实例信息,然后将历史流程实例信息重新作为新的流程实例启动。这种方式的实现需要满足以下条件:
- 流程实例需要使用历史数据回退,即需要记录历史数据。
- 需要保存历史数据的流程实例需要使用自定义的处理逻辑。
2. 使用多实例节点实现退回
在流程中使用多实例节点实现退回的方式,即使用多实例节点将当前任务和历史任务都加入到一个任务集合中,并且将集合中的任务按照特定的排序规则排序,然后在任务集合中进行退回操作。这种方式的实现需要满足以下条件:
- 需要使用多实例节点。
- 需要使用自定义的排序规则。
- 需要使用自定义的退回操作。
以上是两种常见的流程退回实现方式,具体实现需要根据业务需求进行选择。
相关问题
flowable如何实现退回
Flowable中实现退回可以采用以下两种方式:
1. 使用历史记录回退:通过查询当前任务之前的所有历史记录,找到最后一个处理人并把任务指派给他,实现任务退回。代码示例如下:
```
List<HistoricTaskInstance> historicTaskList = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(processInstanceId)
.finished()
.orderByHistoricTaskInstanceEndTime()
.desc()
.list();
if (historicTaskList != null && historicTaskList.size() > 0) {
// 找到最后一个处理人
String assignee = historicTaskList.get(0).getAssignee();
// 退回任务
taskService.setAssignee(taskId, assignee);
}
```
2. 使用环节回退:在流程定义文件中配置回退环节,通过回退环节将任务退回到指定的环节进行处理。在BPMN文件中可以使用“Boundary Event”来配置回退环节。代码示例如下:
```
<userTask id="task1" name="Task1" >
<extensionElements>
<flowable:executionListener event="start" class="org.flowable.engine.delegate.ExecutionListener">
<flowable:field name="delegateExpression">
<flowable:string><![CDATA[#{task1Listener}]]></flowable:string>
</flowable:field>
</flowable:executionListener>
<flowable:taskListener event="complete" class="org.flowable.engine.delegate.TaskListener">
<flowable:field name="delegateExpression">
<flowable:string><![CDATA[#{task1CompleteListener}]]></flowable:string>
</flowable:field>
</flowable:taskListener>
</extensionElements>
</userTask>
<boundaryEvent id="boundary" attachedToRef="task1" cancelActivity="true">
<extensionElements>
<flowable:executionListener event="start" class="org.flowable.engine.delegate.ExecutionListener">
<flowable:field name="delegateExpression">
<flowable:string><![CDATA[#{boundaryEventListener}]]></flowable:string>
</flowable:field>
</flowable:executionListener>
</extensionElements>
</boundaryEvent>
<userTask id="task2" name="Task2" >
<extensionElements>
<flowable:executionListener event="start" class="org.flowable.engine.delegate.ExecutionListener">
<flowable:field name="delegateExpression">
<flowable:string><![CDATA[#{task2Listener}]]></flowable:string>
</flowable:field>
</flowable:executionListener>
<flowable:taskListener event="complete" class="org.flowable.engine.delegate.TaskListener">
<flowable:field name="delegateExpression">
<flowable:string><![CDATA[#{task2CompleteListener}]]></flowable:string>
</flowable:field>
</flowable:taskListener>
</extensionElements>
</userTask>
```
在上述BPMN文件中,当任务1完成后,如果需要将任务退回到任务1之前,需要触发边界事件“boundary”来实现。当边界事件触发后,任务将回退到任务1并重新分配给之前的处理人。
Flowable如何实现退回
Flowable中实现任务退回可以通过以下几种方式:
1. 使用流程变量:可以在任务完成时添加一个退回标识流程变量,然后在网关处使用条件判断,根据条件退回到指定任务。
2. 使用回退任务:Flowable提供了一个回退任务的功能,可以通过创建一个新的回退任务,将当前任务退回到指定任务节点。使用此方法需要注意回退任务的流程变量与历史流程实例的处理。
3. 使用Java API:Flowable API提供了很多操作流程的方法,可以通过Java代码编写实现任务的退回。可以通过查询历史任务实例,将历史任务实例重新激活,然后将当前任务完成,并将当前任务所在节点设置为历史任务实例所在节点,从而实现任务的退回。
总之,Flowable提供了很多实现任务退回的方式,可以根据实际需求选择合适的方式进行实现。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)