From 80c0d220cae6c45687dd764f3f6f2c92fce4fd65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E9=B9=8F?= Date: Fri, 6 Nov 2020 17:54:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E4=BB=96=E7=BD=91=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/HolidayController.java | 13 +- .../java/com/example/demo/entity/Holiday.java | 23 ++++ src/main/resources/bpmn/holidayEx.bpmn | 122 ++++++++++++++++++ 3 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/example/demo/entity/Holiday.java create mode 100644 src/main/resources/bpmn/holidayEx.bpmn diff --git a/src/main/java/com/example/demo/controller/HolidayController.java b/src/main/java/com/example/demo/controller/HolidayController.java index 886f49a..d9e5fb7 100644 --- a/src/main/java/com/example/demo/controller/HolidayController.java +++ b/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 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 testbpmn = taskService.createTaskQuery().processDefinitionKey("holiday").list(); + List testbpmn = taskService.createTaskQuery().processDefinitionKey("holidayex").list(); testbpmn.stream().forEach(x->{ System.out.println(x.getProcessDefinitionId()); System.out.println(x.getId()); diff --git a/src/main/java/com/example/demo/entity/Holiday.java b/src/main/java/com/example/demo/entity/Holiday.java new file mode 100644 index 0000000..ff19080 --- /dev/null +++ b/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 = "事假"; +} diff --git a/src/main/resources/bpmn/holidayEx.bpmn b/src/main/resources/bpmn/holidayEx.bpmn new file mode 100644 index 0000000..e118291 --- /dev/null +++ b/src/main/resources/bpmn/holidayEx.bpmn @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + 5}]]> + + + + + =1}]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +