Browse Source

排他网关

master
燕鹏 4 years ago
parent
commit
80c0d220ca
  1. 13
      src/main/java/com/example/demo/controller/HolidayController.java
  2. 23
      src/main/java/com/example/demo/entity/Holiday.java
  3. 122
      src/main/resources/bpmn/holidayEx.bpmn

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

@ -1,5 +1,6 @@
package com.example.demo.controller;
import com.example.demo.entity.Holiday;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.activiti.engine.ProcessEngine;
@ -14,7 +15,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yanpeng
@ -35,7 +38,7 @@ public class HolidayController {
@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();
Deployment deploy = repositoryService.createDeployment().addClasspathResource("bpmn/holidayEx.bpmn").name("请假申请流程").key("holidayex").deploy();
System.out.println(deploy.getId());
System.out.println(deploy.getName());
System.out.println(deploy.getKey());
@ -45,7 +48,11 @@ public class HolidayController {
@GetMapping("start")
public void start() {
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday");
Holiday holiday = new Holiday();
holiday.setNum(7f);
Map<String,Object> map = new HashMap<>();
map.put("holiday",holiday);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holidayex",map);
System.out.println(processInstance.getProcessDefinitionId());
System.out.println(processInstance.getId());
}
@ -57,7 +64,7 @@ public class HolidayController {
@GetMapping("query")
public Boolean query() {
// TaskService taskService = processEngine.getTaskService();
List<Task> testbpmn = taskService.createTaskQuery().processDefinitionKey("holiday").list();
List<Task> testbpmn = taskService.createTaskQuery().processDefinitionKey("holidayex").list();
testbpmn.stream().forEach(x->{
System.out.println(x.getProcessDefinitionId());
System.out.println(x.getId());

23
src/main/java/com/example/demo/entity/Holiday.java

@ -0,0 +1,23 @@
package com.example.demo.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author yanpeng
* @version 1.0
* @desc TODO
* @company 北京中经网软件有限公司
* @date 2020/11/6 14:06
*/
@Data
public class Holiday implements Serializable {
private String username = "nelson";
private Date startTime = new Date();
private Date endTime;
private Float num;
private String reason = "有事请假";
private String type = "事假";
}

122
src/main/resources/bpmn/holidayEx.bpmn

@ -0,0 +1,122 @@
<?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="holidayex" 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="_7" name="HR存档"/>
<sequenceFlow id="_8" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_9" sourceRef="_3" targetRef="_5"/>
<endEvent id="_12" name="EndEvent"/>
<exclusiveGateway gatewayDirection="Unspecified" id="_4" name="ExclusiveGateway"/>
<userTask activiti:exclusive="true" id="_16" name="总监理审核"/>
<sequenceFlow id="_17" sourceRef="_5" targetRef="_4"/>
<sequenceFlow id="_18" sourceRef="_4" targetRef="_16">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num>5}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_19" sourceRef="_4" targetRef="_7">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${holiday.num>=1}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_20" sourceRef="_16" targetRef="_7"/>
<sequenceFlow id="_6" 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="holidayex">
<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="_7" id="Shape-_7">
<dc:Bounds height="55.0" width="85.0" x="520.0" y="335.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="730.0" y="315.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4" isMarkerVisible="false">
<dc:Bounds height="32.0" width="32.0" x="380.0" y="210.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_16" id="Shape-_16">
<dc:Bounds height="55.0" width="85.0" x="550.0" y="220.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_17" id="BPMNEdge__17" sourceElement="_5" targetElement="_4">
<di:waypoint x="310.0" y="207.5"/>
<di:waypoint x="380.0" y="226.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_19" id="BPMNEdge__19" sourceElement="_4" targetElement="_7">
<di:waypoint x="412.0" y="226.0"/>
<di:waypoint x="520.0" y="362.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_18" id="BPMNEdge__18" sourceElement="_4" targetElement="_16">
<di:waypoint x="412.0" y="226.0"/>
<di:waypoint x="550.0" y="247.5"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_7" targetElement="_12">
<di:waypoint x="605.0" y="362.5"/>
<di:waypoint x="730.0" y="331.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="_2" targetElement="_3">
<di:waypoint x="37.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="170.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="_20" id="BPMNEdge__20" sourceElement="_16" targetElement="_7">
<di:waypoint x="577.5" y="275.0"/>
<di:waypoint x="577.5" y="335.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>
Loading…
Cancel
Save