1.使用eclipse的activiti插件畫流程圖eclipse
在resource文件夾下新建一個工做流diagramspa
右鍵——new——other...——選擇activiti diagram.net
畫一個簡單的工做流程圖插件
在Event選出一個開始節點startEvent和一個結束節點endEventcode
在中間過程用task裏面的userTask對象
如:blog
2.部署流程定義(至關於在頁面選擇bpmn文件上傳部署)ip
- ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
-
- @Test
- public void deploymentProcessDefinition(){
- Deployment deployment = processEngine.getRepositoryService()
- .createDeployment()
- .name("helloworld入門程序")
- .addClasspathResource("diagrams/helloworld.bpmn")
- .addClasspathResource("diagrams/helloworld.png")
- .deploy();
- System.out.println("部署ID:"+deployment.getId());
- System.out.println("部署名稱:"+deployment.getName());
- }
3.啓動流程實例(至關於新建一個流程)
- ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
-
-
- @Test
- public void startProcessInstance(){
-
- String processDefinitionKey = "helloworld";
- ProcessInstance pi = processEngine.getRuntimeService()
- .startProcessInstanceByKey(processDefinitionKey);
- System.out.println("流程實例ID:"+pi.getId());
- System.out.println("流程定義ID:"+pi.getProcessDefinitionId());
- }
4.查詢當前人的我的任務(至關於查詢代辦列表)
- ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
-
- @Test
- public void findMyPersonalTask(){
- String assignee = "王五";
- List<Task> list = processEngine.getTaskService()
- .createTaskQuery()
- .taskAssignee(assignee)
- .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());
- System.out.println("########################################################");
- }
- }
- }
5.完成個人任務(至關於提交流程,流程進入下一環節)
- ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
-
-
- @Test
- public void completeMyPersonalTask(){
-
- String taskId = "302";
- processEngine.getTaskService()
- .complete(taskId);
- System.out.println("完成任務:任務ID:"+taskId);
- }