package com.itheima.activiti;import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;/*** 处理当前用户的任务* 背后操作的表:* act_hi_actinstact_hi_identitylinkact_hi_taskinstact_ru_identitylinkact_ru_task 永远都有且仅有一条记录*/
public class ActivitiCompleteTask {
//查询当前用户wangwu的任务并处理掉public static void main(String[] args) {
//1.得到ProcessEngine对象ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();//2.得到TaskService对象TaskService taskService = processEngine.getTaskService();//3.查询当前用户的任务Task task = taskService.createTaskQuery().processDefinitionKey("holiday").taskAssignee("wangwu").singleResult();//4.处理任务,结合当前用户任务列表的查询操作的话,任务ID:task.getId()taskService.complete(task.getId());//5.输出任务的idSystem.out.println(task.getId());}//lishi完成自己的任务/*public static void main(String[] args) {//1.得到ProcessEngine对象ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();//2.得到TaskService对象TaskService taskService = processEngine.getTaskService();//3.处理任务,结合当前用户任务列表的查询操作的话,任务ID:5002taskService.complete("5002");}*///zhangsan完成自己的任务/*public static void main(String[] args) {//1.得到ProcessEngine对象ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();//2.得到TaskService对象TaskService taskService = processEngine.getTaskService();//3.处理任务,结合当前用户任务列表的查询操作的话,任务ID:2505taskService.complete("2505");}*/
}
张三的这个任务处理之前截图如下:
代码执行之后: