修复流程干预场景下设置审批人的bug

Signed-off-by: orange-form <3510245832@qq.com>
This commit is contained in:
orange-form
2024-07-12 15:28:00 +00:00
committed by Gitee
parent d06ca09375
commit f9a4567d3d

View File

@@ -4,6 +4,7 @@ import com.orangeforms.common.core.util.ApplicationContextHolder;
import com.orangeforms.common.flow.constant.FlowConstant; import com.orangeforms.common.flow.constant.FlowConstant;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService; import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.TaskListener; import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask; import org.flowable.task.service.delegate.DelegateTask;
@@ -13,19 +14,21 @@ import java.util.Map;
* 流程任务通用监听器。 * 流程任务通用监听器。
* *
* @author Jerry * @author Jerry
* @date 2024-07-02 * @date 2024-04-15
*/ */
@Slf4j @Slf4j
public class FlowUserTaskListener implements TaskListener { public class FlowUserTaskListener implements TaskListener {
private final transient RuntimeService runtimeService = private final transient RuntimeService runtimeService =
ApplicationContextHolder.getBean(RuntimeService.class); ApplicationContextHolder.getBean(RuntimeService.class);
private final transient TaskService taskService =
ApplicationContextHolder.getBean(TaskService.class);
@Override @Override
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
Map<String, Object> variables = delegateTask.getVariables(); Map<String, Object> variables = delegateTask.getVariables();
if (variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR) != null) { if (variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR) != null) {
delegateTask.setAssignee(variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR).toString()); taskService.setAssignee(delegateTask.getId(), variables.get(FlowConstant.DELEGATE_ASSIGNEE_VAR).toString());
runtimeService.removeVariableLocal(delegateTask.getExecutionId(), FlowConstant.DELEGATE_ASSIGNEE_VAR); runtimeService.removeVariableLocal(delegateTask.getExecutionId(), FlowConstant.DELEGATE_ASSIGNEE_VAR);
} }
} }