Activiti使用监听发布无法查询到历史

问题

在监听器中,根据业务赋值给任务对应办理人
delegateTask.setAssignee(“xxx”);

但是在对该任务负责人进行查询历史任务的时候缺查询不到已经执行了的数据

而对应的ACT_HI_TASKINST也没有对应负责人的数据
在这里插入图片描述

解决代码示例

package cn.inther.oa.activiti.controller;

import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author Kevin
 * @date 2023/5/14 11:08
 * @description 自定义任务监听器类
 **/
@Component
public class MyTaskListener implements TaskListener, ApplicationContextAware {

  private static TaskService taskService;

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    taskService = applicationContext.getBean(TaskService.class);
  }

  /**
   * Create:任务创建后触发
   * Assignment:任务分配后触发
   * Delete:任务完成后触发
   * ALL:所有事件发生都触发
   * @param delegateTask
   */
  @Override
  public void notify(DelegateTask delegateTask) {
    if (delegateTask.getName().equals("经理审批")){
      // 指定任务负责人
      // 这样使用会查不到任务历史
//      delegateTask.setAssignee("kevin1");
      // 需要如下使用
      taskService.setAssignee(delegateTask.getId(),"kevin1");
    }

    if (delegateTask.getName().equals("人事审批")){
      // 指定任务负责人
      // 需要如下使用
      taskService.setAssignee(delegateTask.getId(),"kevin2");
    }

  }

}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值