任务委派

/*** 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill*/@Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn")public void testTaskDelegate() throws Exception {Map<String, Object> variables = new HashMap<String, Object>();String userId = "bill";variables.put("userId", userId);ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables);Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult();assertNotNull(task);assertNull(task.getOwner());System.out.println(task.getOwner());System.out.println(task.getAssignee());// 委派任务给其他人String delegatedUserId = "henryyan";taskService.delegateTask(task.getId(), delegatedUserId);// 查看数据状态task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult();assertEquals(task.getOwner(), userId);assertEquals(task.getAssignee(), delegatedUserId);System.out.println(task.getOwner());System.out.println(task.getAssignee());// 被委派人处理完成任务taskService.resolveTask(task.getId());// 任务回归到委派人task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult();assertEquals(task.getOwner(), userId);assertEquals(task.getAssignee(), userId);System.out.println(task.getOwner());System.out.println(task.getAssignee());// 委派人完成任务taskService.complete(task.getId());long count = historyService.createHistoricProcessInstanceQuery().finished().count();assertEquals(1, count);


本文链接:https://my.lmcjl.com/post/10858.html

展开阅读全文

4 评论

留下您的评论.