燕鹏 4 anni fa
parent
commit
2f26f1e988
  1. 4
      build.gradle
  2. 4
      src/main/java/com/example/demo/DemoApplication.java
  3. 7
      src/main/java/com/example/demo/controller/AdminController.java
  4. 76
      src/main/java/com/example/demo/controller/WorkFlowController.java
  5. 1
      src/main/java/com/example/demo/entity/Admin.java
  6. 7
      src/main/resources/application.yml
  7. 61
      src/main/resources/bpmn/testbpmn.bpmn
  8. BIN
      src/main/resources/bpmn/testbpmn.png
  9. 38
      src/main/resources/bpmn/testbpmn.xml

4
build.gradle

@ -20,8 +20,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.aiprose:jpa-common-utils:2.3.4'
implementation 'org.activiti:activiti-spring-boot-starter:7.1.0.M4'
implementation 'org.activiti:activiti-image-generator:7.1.0.M4'
implementation 'org.activiti:activiti-spring-boot-starter:7.1.0.M3.1'
implementation 'org.activiti:activiti-image-generator:7.1.0.M3.1'
runtimeOnly 'mysql:mysql-connector-java'

4
src/main/java/com/example/demo/DemoApplication.java

@ -1,10 +1,6 @@
package com.example.demo;
import lombok.extern.slf4j.Slf4j;
import org.activiti.api.runtime.shared.query.Page;
import org.activiti.api.runtime.shared.query.Pageable;
import org.activiti.api.task.model.Task;
import org.activiti.api.task.model.builders.TaskPayloadBuilder;
import org.activiti.api.task.runtime.TaskRuntime;
import org.activiti.api.task.runtime.events.TaskAssignedEvent;
import org.activiti.api.task.runtime.events.TaskCompletedEvent;

7
src/main/java/com/example/demo/controller/AdminController.java

@ -2,9 +2,6 @@ package com.example.demo.controller;
import com.example.demo.entity.Admin;
import com.example.demo.service.AdminService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -29,13 +26,9 @@ public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
private ProcessEngine processEngine;
@GetMapping("list")
public Flux<List<Admin>> list(){
List<Admin> list = adminService.findList(null);
HistoryService historyService = processEngine.getHistoryService();
return Flux.just(list);
}

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

@ -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;
}
}

1
src/main/java/com/example/demo/entity/Admin.java

@ -13,6 +13,7 @@ import javax.persistence.Table;
* @company 北京中经网软件有限公司
* @date 2020/10/27 13:54
*/
@Data
@Entity
@Table(name="t_admin")

7
src/main/resources/application.yml

@ -16,4 +16,9 @@ spring:
username: root
password: trgis
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.98.109.5:3309/actibpmn?characterEncoding=utf8&useSSL=false
url: jdbc:mysql://47.98.109.5:3309/actibpmn?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
hikari:
minimum-idle: 3
maximum-pool-size: 10
max-lifetime: 1800000
connection-test-query: SELECT 1

61
src/main/resources/bpmn/testbpmn.bpmn

@ -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>

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

File binario non mostrato.

Dopo

Larghezza:  |  Altezza:  |  Dimensione: 4.1 KiB

38
src/main/resources/bpmn/test.bpmn → src/main/resources/bpmn/testbpmn.xml

@ -1,8 +1,8 @@
<?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:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" 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="m1603943189125" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<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="myProcess_1" isClosed="false" isExecutable="true" processType="None">
<startEvent id="_2" name="StartEvent"/>
<userTask activiti:exclusive="true" id="_3" name="填写请��"/>
<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"/>
@ -12,48 +12,48 @@
<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="myProcess_1">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="275.0" y="65.0"/>
<dc:Bounds height="32.0" width="32.0" x="355.0" y="60.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
<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">
<omgdc:Bounds height="55.0" width="85.0" x="250.0" y="135.0"/>
<dc:Bounds height="55.0" width="85.0" x="335.0" y="145.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
<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">
<omgdc:Bounds height="55.0" width="85.0" x="250.0" y="235.0"/>
<dc:Bounds height="55.0" width="85.0" x="340.0" y="260.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
<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">
<omgdc:Bounds height="32.0" width="32.0" x="275.0" y="340.0"/>
<dc:Bounds height="32.0" width="32.0" x="365.0" y="370.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
<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">
<omgdi:waypoint x="291.0" y="97.0"/>
<omgdi:waypoint x="291.0" y="135.0"/>
<di:waypoint x="371.0" y="92.0"/>
<di:waypoint x="371.0" y="145.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
<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">
<omgdi:waypoint x="292.5" y="190.0"/>
<omgdi:waypoint x="292.5" y="235.0"/>
<di:waypoint x="380.0" y="200.0"/>
<di:waypoint x="380.0" y="260.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
<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">
<omgdi:waypoint x="291.0" y="290.0"/>
<omgdi:waypoint x="291.0" y="340.0"/>
<di:waypoint x="381.0" y="315.0"/>
<di:waypoint x="381.0" y="370.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
Caricamento…
Annulla
Salva