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);
本文来自博客园,作者:星星之草%,转载请注明原文链接:https://www.cnblogs.com/zhaodefu/p/16358430.html