【Activiti】从入门到放弃——项目实战之办理任务

前面,我们已经完成每个任务的动态表单实现,能看到任务详情,接下来就要根据它是否符合条件进行任务办理。

审批报备办理者动态指定

1.写一个类继承TaskListener

public class ManagerSettingListener implements TaskListener{

    @Autowired
    private IEmployeeService employeeService;
}

2.把这个类绑定对应的任务节点

3.在这个类中实现设置办理者的逻辑

public class ManagerSettingListener implements TaskListener {

	@Autowired
	private IEmployeeService employeeService;
	@Override
	public void notify(DelegateTask delegateTask) {
		//获取审批人员  获取营销人员---部门----部门经理
		String sellerNickName = delegateTask.getVariable("seller", String.class);
		System.out.println(sellerNickName);
		System.out.println(employeeService);
		
		//写死"超级管理员"-超级管理员就可以获取审批任务
		delegateTask.setAssignee("超级管理员");
	}

}

注意:要配置spring对listener的注解扫描:

<!-- listener的注解扫描 -->
	<context:component-scan base-package="cn.itsource.crm.listener"></context:component-scan>

流程办理完成状态修改

  1. 写一个类继承ExecutionListener
@Component
public class EndListener implements ExecutionListener {
    
    @Autowired
    private ICustomerService customerService;

}

2.绑定到结束节点

3.实现逻辑

扫描二维码关注公众号,回复: 4410790 查看本文章
@Component
public class EndListener implements ExecutionListener{

	@Autowired
	private ICustomerService customerService;
	@Override
	public void notify(DelegateExecution execution) throws Exception {
		//流程结束的时候修改status的状态值:
		//通过流程变量获取业务id
		Long businessObjId = execution.getVariable("businessObjId", Long.class);
		//查询业务对象
		Customer customer = customerService.get(businessObjId);
		//设置状态值
		customer.setStatus(2);
		//跟新数据库
		customerService.update(customer);
	}

}

 

 

 

 

猜你喜欢

转载自blog.csdn.net/qq_43097451/article/details/84777254
今日推荐