Camunda 整合SpringBoot基本Api
代码实现:需要接口
@Autowired private RuntimeService runtimeService; @Autowired private RepositoryService repositoryService; @Autowired private TaskService taskService;
发布流程:
@GetMapping("/deploy") public Object deploy() { Deployment obj = repositoryService.createDeployment().name("first-test") .addClasspathResource("process.bpmn") .deploy(); return obj.getId() + ":" + obj.getName(); }
启动流程:
@Test public void startFlow(){ ProcessInstance instance = runtimeService.startProcessInstanceById("7fb602df-03a0-11ef-8636-ac74b1571bba"); System.out.println(instance.getProcessInstanceId()); System.out.println(instance.getProcessDefinitionId()); }
查询任务:
@Test void queryTask(){ List<Task> list = taskService.createTaskQuery().taskAssignee("demo").list(); list.forEach(x ->{ System.out.println(x.getAssignee()); System.out.println(x.getCaseDefinitionId()); System.out.println(x.getProcessInstanceId()); }); }
完成任务
@Test void completedTask(){ Task task = taskService.createTaskQuery().processInstanceId("5fdc7d8d-03a4-11ef-be66-ac74b1571bba").singleResult(); if(Objects.nonNull(task)){ taskService.complete(task.getId()); System.out.println("审批完成..........."); } }