每一年都奔走在自己热爱里

没有人是一座孤岛,总有谁爱着你

activiti6工作流的简单步骤

1、获取默认流程引擎
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

2、根据流程引擎获取相关的service
RuntimeService runtimeService = processEngine.getRuntimeService();
IdentityService identityService = processEngine.getIdentityService();
TaskService taskService = processEngine.getTaskService();

3、设置用户发起人【流程发起前设置发起人,记录在流程历史中】
identityService.setAuthenticatedUserId(authenticatedUserId);

4、使用流程定义Key和业务key启动流程,key对应bpmn文件中的id,businessKey对应业务ID
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey);
5、根据流程实例ID查找任务
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
6、设置任务受理人
taskService.setAssignee(task.getId(), authenticatedUserId);
7、添加批注信息
taskService.addComment(task.getId(), null, "发起流程");//comment为批注内容
8、完成任务
taskService.complete(task.getId(),variables);

posted @ 2022-06-09 10:38  星星之草%  阅读(683)  评论(2编辑  收藏  举报