Ver a proveniência

请假流程定义

master
燕鹏 há 4 anos
ascendente
cometimento
2238f38918
  1. 78
      src/main/java/com/example/demo/controller/HolidayController.java
  2. 4
      src/main/java/com/example/demo/controller/WorkFlowController.java
  3. 2
      src/main/resources/application.yml
  4. 107
      src/main/resources/bpmn/holiday.bpmn
  5. BIN
      src/main/resources/bpmn/holiday.png
  6. 107
      src/main/resources/bpmn/holiday.xml

78
src/main/java/com/example/demo/controller/HolidayController.java

@ -0,0 +1,78 @@
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("holiday")
@Api(tags = "请假工作流接口")
public class HolidayController {
@Autowired
private ProcessEngine processEngine;
@ApiOperation(value = "发布工作流")
@GetMapping("deploy")
public void deploy() {
RepositoryService repositoryService = processEngine.getRepositoryService();
Deployment deploy = repositoryService.createDeployment().addClasspathResource("bpmn/holiday.bpmn").addClasspathResource("bpmn/holiday.png").name("请假申请流程").key("holiday").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("holiday");
System.out.println(processInstance.getProcessDefinitionId());
System.out.println(processInstance.getId());
}
@Autowired
private TaskService taskService;
@ApiOperation(value = "查询任务")
@GetMapping("query")
public Boolean query() {
// TaskService taskService = processEngine.getTaskService();
List<Task> testbpmn = taskService.createTaskQuery().processDefinitionKey("holiday").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;
}
}

4
src/main/java/com/example/demo/controller/WorkFlowController.java

@ -50,11 +50,13 @@ public class WorkFlowController {
System.out.println(processInstance.getId());
}
@Autowired
private TaskService taskService;
@ApiOperation(value = "查询任务")
@GetMapping("query")
public Boolean query() {
TaskService taskService = processEngine.getTaskService();
// TaskService taskService = processEngine.getTaskService();
List<Task> testbpmn = taskService.createTaskQuery().processDefinitionKey("testbpmn").list();
testbpmn.stream().forEach(x->{
System.out.println(x.getProcessDefinitionId());

2
src/main/resources/application.yml

@ -21,4 +21,4 @@ spring:
minimum-idle: 3
maximum-pool-size: 10
max-lifetime: 1800000
connection-test-query: SELECT 1
connection-test-query: SELECT 1

107
src/main/resources/bpmn/holiday.bpmn

@ -0,0 +1,107 @@
<?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/testm1604633800390" 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="m1604633800390" name="" targetNamespace="http://www.activiti.org/testm1604633800390" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="holiday" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="StartEvent"/>
<userTask activiti:exclusive="true" id="_3" name="填写请假单"/>
<userTask activiti:exclusive="true" id="_5" name="部门经理审核"/>
<userTask activiti:exclusive="true" id="_6" name="总经理审核"/>
<userTask activiti:exclusive="true" id="_7" name="HR存档"/>
<sequenceFlow id="_8" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_9" sourceRef="_3" targetRef="_5"/>
<sequenceFlow id="_4" sourceRef="_5" targetRef="_6">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num>=3}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_10" sourceRef="_5" targetRef="_7">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num<3}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_11" sourceRef="_6" targetRef="_7"/>
<endEvent id="_12" name="EndEvent"/>
<sequenceFlow id="_13" sourceRef="_7" targetRef="_12"/>
</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="holiday">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="5.0" y="195.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="85.0" y="180.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="55.0" width="85.0" x="225.0" y="180.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<dc:Bounds height="55.0" width="85.0" x="405.0" y="175.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
<dc:Bounds height="55.0" width="85.0" x="415.0" y="345.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_12" id="Shape-_12">
<dc:Bounds height="32.0" width="32.0" x="440.0" y="450.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_7" targetElement="_12">
<di:waypoint x="456.0" y="415.0"/>
<di:waypoint x="456.0" y="450.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="_5" targetElement="_6">
<di:waypoint x="325.0" y="207.5"/>
<di:waypoint x="405.0" y="202.5"/>
<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="_2" targetElement="_3">
<di:waypoint x="52.0" y="211.0"/>
<di:waypoint x="85.0" y="207.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_3" targetElement="_5">
<di:waypoint x="185.0" y="207.5"/>
<di:waypoint x="225.0" y="207.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_6" targetElement="_7">
<di:waypoint x="452.5" y="245.0"/>
<di:waypoint x="452.5" y="345.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_5" targetElement="_7">
<di:waypoint x="325.0" y="207.5"/>
<di:waypoint x="415.0" y="372.5"/>
<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>

BIN
src/main/resources/bpmn/holiday.png

Ficheiro binário não mostrado.

Depois

Largura:  |  Altura:  |  Tamanho: 5.5 KiB

107
src/main/resources/bpmn/holiday.xml

@ -0,0 +1,107 @@
<?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/testm1604633800390" 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="m1604633800390" name="" targetNamespace="http://www.activiti.org/testm1604633800390" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="holiday" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="StartEvent"/>
<userTask activiti:exclusive="true" id="_3" name="填写请假单"/>
<userTask activiti:exclusive="true" id="_5" name="部门经理审核"/>
<userTask activiti:exclusive="true" id="_6" name="总经理审核"/>
<userTask activiti:exclusive="true" id="_7" name="HR存档"/>
<sequenceFlow id="_8" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_9" sourceRef="_3" targetRef="_5"/>
<sequenceFlow id="_4" sourceRef="_5" targetRef="_6">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num>=3}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_10" sourceRef="_5" targetRef="_7">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num<3}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_11" sourceRef="_6" targetRef="_7"/>
<endEvent id="_12" name="EndEvent"/>
<sequenceFlow id="_13" sourceRef="_7" targetRef="_12"/>
</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="holiday">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="5.0" y="195.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="85.0" y="180.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="55.0" width="85.0" x="225.0" y="180.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<dc:Bounds height="55.0" width="85.0" x="405.0" y="175.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7">
<dc:Bounds height="55.0" width="85.0" x="415.0" y="345.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_12" id="Shape-_12">
<dc:Bounds height="32.0" width="32.0" x="440.0" y="450.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_7" targetElement="_12">
<di:waypoint x="456.0" y="415.0"/>
<di:waypoint x="456.0" y="450.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="_5" targetElement="_6">
<di:waypoint x="325.0" y="207.5"/>
<di:waypoint x="405.0" y="202.5"/>
<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="_2" targetElement="_3">
<di:waypoint x="52.0" y="211.0"/>
<di:waypoint x="85.0" y="207.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_3" targetElement="_5">
<di:waypoint x="185.0" y="207.5"/>
<di:waypoint x="225.0" y="207.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_6" targetElement="_7">
<di:waypoint x="452.5" y="245.0"/>
<di:waypoint x="452.5" y="345.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_5" targetElement="_7">
<di:waypoint x="325.0" y="207.5"/>
<di:waypoint x="415.0" y="372.5"/>
<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>
Carregando…
Cancelar
Guardar