Je kunt niet meer dan 25 onderwerpen selecteren
Onderwerpen moeten beginnen met een letter of nummer, kunnen streepjes bevatten ('-') en kunnen maximaal 35 tekens lang zijn.
77 regels
2.6 KiB
77 regels
2.6 KiB
4 jaren geleden
|
package com.example.demo.controller;
|
||
|
|
||
|
import io.swagger.annotations.Api;
|
||
|
import io.swagger.annotations.ApiOperation;
|
||
|
import org.activiti.engine.ProcessEngine;
|
||
|
import org.activiti.engine.RepositoryService;
|
||
|
import org.activiti.engine.RuntimeService;
|
||
|
import org.activiti.engine.TaskService;
|
||
|
import org.activiti.engine.repository.Deployment;
|
||
|
import org.activiti.engine.runtime.ProcessInstance;
|
||
|
import org.activiti.engine.task.Task;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* @author yanpeng
|
||
|
* @version 1.0
|
||
|
* @desc TODO
|
||
|
* @company 北京中经网软件有限公司
|
||
|
* @date 2020/10/27 14:34
|
||
|
*/
|
||
|
@RestController
|
||
|
@RequestMapping("workflow")
|
||
|
@Api(tags = "工作流接口")
|
||
|
public class WorkFlowController {
|
||
|
|
||
|
@Autowired
|
||
|
private ProcessEngine processEngine;
|
||
|
|
||
|
@ApiOperation(value = "发布工作流")
|
||
|
@GetMapping("deploy")
|
||
|
public void deploy() {
|
||
|
RepositoryService repositoryService = processEngine.getRepositoryService();
|
||
|
Deployment deploy = repositoryService.createDeployment().addClasspathResource("bpmn/testbpmn.bpmn").addClasspathResource("bpmn/testbpmn.png").name("请假申请流程").key("testbpmn").deploy();
|
||
|
System.out.println(deploy.getId());
|
||
|
System.out.println(deploy.getName());
|
||
|
System.out.println(deploy.getKey());
|
||
|
}
|
||
|
|
||
|
@ApiOperation(value = "启动工作流")
|
||
|
@GetMapping("start")
|
||
|
public void start() {
|
||
|
RuntimeService runtimeService = processEngine.getRuntimeService();
|
||
|
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testbpmn");
|
||
|
System.out.println(processInstance.getProcessDefinitionId());
|
||
|
System.out.println(processInstance.getId());
|
||
|
}
|
||
|
|
||
|
|
||
|
@ApiOperation(value = "查询任务")
|
||
|
@GetMapping("query")
|
||
|
public Boolean query() {
|
||
|
TaskService taskService = processEngine.getTaskService();
|
||
|
List<Task> testbpmn = taskService.createTaskQuery().processDefinitionKey("testbpmn").list();
|
||
|
testbpmn.stream().forEach(x->{
|
||
|
System.out.println(x.getProcessDefinitionId());
|
||
|
System.out.println(x.getId());
|
||
|
System.out.println(x.getName());
|
||
|
System.out.println(x.getAssignee());
|
||
|
});
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
@ApiOperation(value = "完成任务")
|
||
|
@GetMapping("ok")
|
||
|
public Boolean ok(String taskid) {
|
||
|
TaskService taskService = processEngine.getTaskService();
|
||
|
taskService.complete(taskid);
|
||
|
return true;
|
||
|
}
|
||
|
}
|