gpt4 book ai didi

java - 使用 Activiti 工作流程跳过或完成用户任务

转载 作者:行者123 更新时间:2023-12-02 12:07:48 28 4
gpt4 key购买 nike

有没有办法用 Java 完成或跳过 activiti 用户任务?我实现了一个 TaskListener 来执行此操作,但是当我调用此代码时:

delegateTask.getExecution().getEngineServices().getTaskService().complete( task.getId() );

我得到这个异常:

Caused by: org.activiti.engine.ActivitiException: UserTask should not be signalled before complete
at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.signal(UserTaskActivityBehavior.java:146)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:407)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:201)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:50)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)[415:org.activiti.engine:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)[415:org.activiti.engine:5.17.0]
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:179)
at Proxy7b61ad98_bd2d_436d_94dd_1e7381cca64e.complete(Unknown Source)

最佳答案

您无法在任务监听器中完成任务,因为上下文仍在实例化中。如果您想跳过某项任务,您应该使用网关来执行此操作。

另一种仅在 xml 级别受支持(未在建模器中公开)的替代方案是使用以下博客中记录的跳过表达式语法,效果非常好:

https://blog.canang.com.my/2016/09/30/whats-activiti-skiptask-about/

关于java - 使用 Activiti 工作流程跳过或完成用户任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46770684/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com