燕鹏
vor 4 Jahren
9 geänderte Dateien mit 165 neuen und 33 gelöschten Zeilen
@ -0,0 +1,76 @@ |
|||
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; |
|||
} |
|||
} |
@ -0,0 +1,61 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|||
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/testm1604021504826" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1604021504826" name="" targetNamespace="http://www.activiti.org/testm1604021504826" typeLanguage="http://www.w3.org/2001/XMLSchema"> |
|||
<process id="testbpmn" isClosed="false" isExecutable="true" processType="None"> |
|||
<startEvent id="_2" name="StartEvent"/> |
|||
<userTask activiti:exclusive="true" id="_3" name="提交请假审批"/> |
|||
<userTask activiti:exclusive="true" id="_4" name="部门经理审核"/> |
|||
<endEvent id="_5" name="EndEvent"/> |
|||
<sequenceFlow id="_6" sourceRef="_2" targetRef="_3"/> |
|||
<sequenceFlow id="_7" sourceRef="_3" targetRef="_4"/> |
|||
<sequenceFlow id="_8" sourceRef="_4" targetRef="_5"/> |
|||
</process> |
|||
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram"> |
|||
<bpmndi:BPMNPlane bpmnElement="testbpmn"> |
|||
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2"> |
|||
<dc:Bounds height="32.0" width="32.0" x="355.0" y="60.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3"> |
|||
<dc:Bounds height="55.0" width="85.0" x="335.0" y="145.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4"> |
|||
<dc:Bounds height="55.0" width="85.0" x="340.0" y="260.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5"> |
|||
<dc:Bounds height="32.0" width="32.0" x="365.0" y="370.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNShape> |
|||
<bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_2" targetElement="_3"> |
|||
<di:waypoint x="371.0" y="92.0"/> |
|||
<di:waypoint x="371.0" y="145.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNEdge> |
|||
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_3" targetElement="_4"> |
|||
<di:waypoint x="380.0" y="200.0"/> |
|||
<di:waypoint x="380.0" y="260.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNEdge> |
|||
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_4" targetElement="_5"> |
|||
<di:waypoint x="381.0" y="315.0"/> |
|||
<di:waypoint x="381.0" y="370.0"/> |
|||
<bpmndi:BPMNLabel> |
|||
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> |
|||
</bpmndi:BPMNLabel> |
|||
</bpmndi:BPMNEdge> |
|||
</bpmndi:BPMNPlane> |
|||
</bpmndi:BPMNDiagram> |
|||
</definitions> |
Nachher Breite: | Höhe: | Größe: 4.1 KiB |
Laden…
In neuem Issue referenzieren