如何在Activiti工作流程中获取先前的任务名称

编程入门 行业动态 更新时间:2024-10-12 01:28:31
本文介绍了如何在Activiti工作流程中获取先前的任务名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

实际上,我想在当前任务中使用先前的任务名称,因此如何在Activiti中获得当前任务中的先前任务名称。

Actually i want to use the previous task name in current task so how to get the previous task name in current task in activiti. If any one knows could you help me?

例如:TASK1 ==> TASK2 ==> TASK3

eg:TASK1==>TASK2==>TASK3

我想在task2中使用task1名称,在task1中使用task2名称。

i want to use the task1 name in task2 and task2 name in task1.

推荐答案

您可以从当前的流程实例中获取它:

You can get it from your current Process Instance:

@Service public class SomeWorkflowService { @Autowired HistoryService historyService; @Autowired TaskService taskService; public Map<String, Object> currentTaskService(String currentTaskId) { Map<String, Object> taskMap = new HashMap<>(); Task currentTask = taskService.createTaskQuery().taskId(currentTaskId).singleResult(); HistoricTaskInstance previousTask = findPreviousTask(currentTask.getProcessInstanceId()); taskMap.put("Current task name: ", currentTask.getName()); taskMap.put("Previous task name: ", previousTask.getName()); return taskMap; } // Order tasks by end date and get the latest public HistoricTaskInstance findPreviousTask(String processInstanceId) { return historyService.createHistoricTaskInstanceQuery(). processInstanceId(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list().get(0); } }

可能存在这种问题简单算法。例如,我在应用程序中有多个子流程,或者可能有并行执行的任务,那么我在使用更复杂的算法来查找先前的任务。

There maybe some issues with this kind of simple algorithm. For example, I have multiple subprocesses in application, or there may be parallely executed tasks, then I'm using more complex algorithm to find previous task.

更多推荐

如何在Activiti工作流程中获取先前的任务名称

本文发布于:2023-11-28 12:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642341.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:先前   工作流程   名称   如何在   Activiti

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!