activiti工作流

activiti工作流基础教程,activiti工作流视频教程,activiti工作流 pdf电子书下载,activiti工作流免费视频教程,activiti工作流视频教程下载

Activiti入门程序-查询正在执行人员的个人任务与完成任务

2016-03-25| 发布: | 浏览: 4911 |保存PDF

TaskService 是activiti的任务服务类。可以从这个类中获取任务的信息
//与正在执行的任务管理相关的Service
TaskService service = processEngine.getTaskService();
//创建任务查询对象
TaskQuery query = service.createTaskQuery();
//指定个人任务查询,指定办理人
query.taskAssignee("张三");

完整示例
/**查询当前人的个人任务*/
@Test
public void queryAssigneeTaskTest(){
    //与正在执行的任务管理相关的Service
    TaskService service = processEngine.getTaskService();
    //创建任务查询对象
    TaskQuery query = service.createTaskQuery();
    //指定个人任务查询,指定办理人
    query.taskAssignee("张三");
    List<Task> list = query.list();
    if(list!=null && list.size()>0){
        for(Task task:list){
            System.out.println("任务ID:"+task.getId());
            System.out.println("任务名称:"+task.getName());
            System.out.println("任务的创建时间:"+task.getCreateTime());
            System.out.println("任务的办理人:"+task.getAssignee());
            System.out.println("流程实例ID:"+task.getProcessInstanceId());
            System.out.println("执行对象ID:"+task.getExecutionId());
            System.out.println("流程定义ID:"+task.getProcessDefinitionId());
        }
    }
}
任务ID:2504
任务名称:提交申请
任务的创建时间:Thu Mar 24 20:43:07 CST 2016
任务的办理人:张三
流程实例ID:2501
执行对象ID:2501
流程定义ID:hello:1:4


调用TaskService的complete方法完成任务

/**完成个人任务*/
@Test
public void completeTaskTest(){
    //任务ID
    String taskId = "2504";
    processEngine.getTaskService()
                .complete(taskId);
    System.out.println("完成任务:任务ID:"+taskId);
}
执行流程
1、张三执行完成
查看 HistoricActivityInstanceQuery
activitiId:startevent1,name:Start,type:startEvent,pid:2501,assignee:null,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 20:43:07 CST 2016,duration:16
activitiId:usertask1,name:提交申请,type:userTask,pid:2501,assignee:张三,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 22:55:53 CST 2016,duration:7966470
activitiId:usertask2,name:审批【部门经理】,type:userTask,pid:2501,assignee:李四,startTime:Thu Mar 24 22:55:53 CST 2016,endTime:null,duration:null


2、李四执行完成

查看 HistoricActivityInstanceQuery
activitiId:startevent1,name:Start,type:startEvent,pid:2501,assignee:null,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 20:43:07 CST 2016,duration:16
activitiId:usertask1,name:提交申请,type:userTask,pid:2501,assignee:张三,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 22:55:53 CST 2016,duration:7966470
activitiId:usertask2,name:审批【部门经理】,type:userTask,pid:2501,assignee:李四,startTime:Thu Mar 24 22:55:53 CST 2016,endTime:Thu Mar 24 22:59:51 CST 2016,duration:238220
activitiId:usertask3,name:审批【总经理】,type:userTask,pid:2501,assignee:王五,startTime:Thu Mar 24 22:59:51 CST 2016,endTime:null,duration:null


3、王五执行完成

查看 HistoricActivityInstanceQuery
activitiId:endevent1,name:End,type:endEvent,pid:2501,assignee:null,startTime:Thu Mar 24 23:01:36 CST 2016,endTime:Thu Mar 24 23:01:36 CST 2016,duration:0
activitiId:startevent1,name:Start,type:startEvent,pid:2501,assignee:null,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 20:43:07 CST 2016,duration:16
activitiId:usertask1,name:提交申请,type:userTask,pid:2501,assignee:张三,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 22:55:53 CST 2016,duration:7966470
activitiId:usertask2,name:审批【部门经理】,type:userTask,pid:2501,assignee:李四,startTime:Thu Mar 24 22:55:53 CST 2016,endTime:Thu Mar 24 22:59:51 CST 2016,duration:238220
activitiId:usertask3,name:审批【总经理】,type:userTask,pid:2501,assignee:王五,startTime:Thu Mar 24 22:59:51 CST 2016,endTime:Thu Mar 24 23:01:36 CST 2016,duration:105181


查看HistoricProcessInstanceQuery

pid:2501,pdid:hello:1:4,startTime:Thu Mar 24 20:43:07 CST 2016,endTime:Thu Mar 24 23:01:36 CST 2016,duration:8309223,vars:{}


到此整个流程就结束了


示例程序参考于网络


系列教程

大家都在看

热门访问