From 2238f38918075221be0f3ebddc3ce7000def6373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E9=B9=8F?= Date: Fri, 6 Nov 2020 11:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E5=81=87=E6=B5=81=E7=A8=8B=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/HolidayController.java | 78 +++++++++++++ .../demo/controller/WorkFlowController.java | 4 +- src/main/resources/application.yml | 2 +- src/main/resources/bpmn/holiday.bpmn | 107 ++++++++++++++++++ src/main/resources/bpmn/holiday.png | Bin 0 -> 5618 bytes src/main/resources/bpmn/holiday.xml | 107 ++++++++++++++++++ 6 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/example/demo/controller/HolidayController.java create mode 100644 src/main/resources/bpmn/holiday.bpmn create mode 100644 src/main/resources/bpmn/holiday.png create mode 100644 src/main/resources/bpmn/holiday.xml diff --git a/src/main/java/com/example/demo/controller/HolidayController.java b/src/main/java/com/example/demo/controller/HolidayController.java new file mode 100644 index 0000000..886f49a --- /dev/null +++ b/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 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; + } +} diff --git a/src/main/java/com/example/demo/controller/WorkFlowController.java b/src/main/java/com/example/demo/controller/WorkFlowController.java index 2551f53..725b111 100644 --- a/src/main/java/com/example/demo/controller/WorkFlowController.java +++ b/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 testbpmn = taskService.createTaskQuery().processDefinitionKey("testbpmn").list(); testbpmn.stream().forEach(x->{ System.out.println(x.getProcessDefinitionId()); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7f877c4..34a02d5 100644 --- a/src/main/resources/application.yml +++ b/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 \ No newline at end of file diff --git a/src/main/resources/bpmn/holiday.bpmn b/src/main/resources/bpmn/holiday.bpmn new file mode 100644 index 0000000..6edbac0 --- /dev/null +++ b/src/main/resources/bpmn/holiday.bpmn @@ -0,0 +1,107 @@ + + + + + + + + + + + + + =3}]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/bpmn/holiday.png b/src/main/resources/bpmn/holiday.png new file mode 100644 index 0000000000000000000000000000000000000000..e68b4c74aaf6104caefc268d8f1456954792c48d GIT binary patch literal 5618 zcmdUzc{r49-^V4pY}vAJAr(_{8^YL=3Kc13$xe1A+{TP%5XnuY5|a?OC0n74ku6EG zjR_FclUmL!S4xauG#$Go{(ByS9FeV?-NN9AObA`aGB=N)iz+&P* zyKVgjS@tQ$BnAEQUKjLmDXtkl|4~oMqU^SFlY2hnpy^-dvn2b<$HwXk58YM<-L^^f z0nIs#wc=x=1LX`Xt{AWn`Q$U%?V&1RcF zA*$-#G0jBSH^sooZ(bg&){n2;=$U@#-0=7}O|$0)L?Psx!);zfMgu!BXPJ~>MYD|(g@mUBl9NEEdV;w7}7_HoR?naJr+3|(>m4}WL8)0>uTLY zFQz>Zk$s;x+Nigk#SmKNxr+bFUD8s$hDlLF<1{0nh-I|$*oO5 zo&zTvlMYi`mk}ozxrn%VCVA2+OYg$$P4lg-&ecm`h*^#zkbXbREwryLIjR|{%pB^4 zzLC>GT76i9mN`QlXHM;N#wx*ttC4&gH5~D3^Y;1L8m4L5v*BPl{>?{-HMbCWJ*1&?SjLjfAN(!m?9>yUUsUkt z6Y_Mr;+;JUG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(f9rz0SUdSBE9+<(n_XzSrG?yS+8Bb814By78Egz^8ChIuC33Hchv}@o}-Z9_aSQf#O#~pDo>kEnek_0&y;ri%RhLI4F7XFDkF@7aU`*xcf{#2M}!W- zRa|3gZ2Qw*9J7ZasdH8Qxz{C;!&(wzr*9VX^+_bSU)(oO=J0s%BEsYeQaGNMd_W;~ z1x=C1qK)1Ld7=8HY!e&hD#$lOgjrN&jK5S$)8vlQ6%6y;IDH>xj_;^#j|g!Twlf?f zJWn$(S9GNj()A+wu_0jqw<~xBi8kYx=aQ%Z0Y03?(QoRhmz}FuA&vq(IM`ycp1B1?TTs>(iMj*yw-iazJf95D1M_4KqM}>p9EDHBrV?#kgXPzUz*sM{8}z!H0n(jY zH$y_Pe0T+37nw+dKrUSU(c@bc{UxK20XbG-8*aiI%uc+I^G|`!7Y378F)i_aO;;sC oK3W6BjEP?gvj1^bx}~7u_uamF_SOs5SuUHkrL9G!*;UMc0az=basU7T literal 0 HcmV?d00001 diff --git a/src/main/resources/bpmn/holiday.xml b/src/main/resources/bpmn/holiday.xml new file mode 100644 index 0000000..6edbac0 --- /dev/null +++ b/src/main/resources/bpmn/holiday.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + =3}]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +