购物商城网站设计方案,网站建设完成后期维护,php网站验证码错误,惠州网站建设 惠州邦一、工作流介绍
1、概念 通过计算机对业务流程的自动化管理。工作流是建立在业务流程的基础上#xff0c;一个软件的系统核心根本上还是系统的业务流程#xff0c;工作流只是协助进行业务流程管理。
解决的是#xff1a;在多个参与者之间按照某种预定义的规则自动进行传递…一、工作流介绍
1、概念 通过计算机对业务流程的自动化管理。工作流是建立在业务流程的基础上一个软件的系统核心根本上还是系统的业务流程工作流只是协助进行业务流程管理。
解决的是在多个参与者之间按照某种预定义的规则自动进行传递文档、信息或任务的过程从而实现某个预期的业务目标
2、工作流系统 概念具有工作流功能的系统 比如OA、ERP系统可能涉及工作流都可以叫工作流系统
3、具体应用 关键业务流程订单、报价处理、合同审核、客户电话处理、供应链管理等 行政管理类出差申请、加班申请、请假申请、用车申请、各种办公用品申请、购买申请、日报周报等凡是原来手工流转处理的行政表单。 人事管理类员工培训安排、绩效考评、职位变动处理、员工档案信息管理等。 财务相关类付款请求、应收款处理、日常报销处理、出差报销、预算和计划申请等。 客户服务类客户信息管理、客户投诉、请求处理、售后服务管理等。 特殊服务类SO系列对应流程、质量管理对应流程、产品数据信息管理、贸易公司报关处理、物流公司货物跟踪处理等各种通过表单逐步手工流转完成的任务均可应用工作流软件自动规范地实施。 4、实现方式对比 原始方式就是采用状态值来跟踪流程的变化通过这个值去决定不同用户是否展示耦合度高 新的工作流引擎可以灵活调整实现简单
二、Flowable概述
具体参考官网https://tkjohn.github.io/flowable-userguide/#_introduction
1、介绍 Flowable是一个使用Java编写的轻量级业务流程引擎。Flowable流程引擎可用于部署BPMN 2.0流程定义用于定义流程的行业XML标准 创建这些流程定义的流程实例进行查询访问运行中或历史的流程实例与相关数据等等。
2、BPM 业务流程管理一种规范化的构造端到端的业务流程提高组织业务效率。
3、BPMN 业务流程模型和符号由BPMI 开发的一套标准的业务流程建模符号使用BPMN提供的符号可以创建业务流程。
一般就是用来画我们需要的流程图。 常用符号 网关 **互斥网关Exclusive Gateway**又称排他网关他有且仅有一个有效出口可以理解为if…else if… else if…else就和我们平时写代码的一样。 **并行网关Parallel Gateway**他的所有出口都会被执行可以理解为开多线程同时执行多个任务。 **包容性网关Inclusive Gateway**只要满足条件的出口都会执行可以理解为 if(…) do, if (…) do, if (…) do所有的条件判断都是同级别的。 任务 人工任务User Task 它是使用的最多的一种任务类型他自带有一些人工任务的变量例如签收人Assignee签收人就代表该任务交由谁处理我们也可以通过某个特定或一系列特定的签收人来查找待办任务。利用上面的行为解释便是当到达User Task节点的时候节点设置Assignee变量或等待设置Assignee变量当任务被完成的时候我们使用Trigger来要求流程引擎退出该任务继续流转。 服务任务Service Task 该任务会在到达的时候执行一段自动的逻辑并自动流转。从“到达自动执行一段逻辑”这里我们就可以发现服务任务的想象空间就可以非常大我们可以执行一段计算执行发送邮件执行RPC调用而使用最广泛的则为HTTP调用因为HTTP是使用最广泛的协议之一它可以解决大部分第三方调用问题在我们的使用中HTTP服务任务也被我们单独剥离出来作为一个特殊任务节点。 接受任务Receive Task 该任务的名字让人费解但它又是最简单的一种任务当该任务到达的时候它不做任何逻辑而是被动地等待Trigger它的适用场景往往是一些不明确的阻塞比如一个复杂的计算需要等待很多条件这些条件是需要人为来判断是否可以执行而不是直接执行这个时候工作人员如果判断可以继续了那么就Trigger一下使其流转。 结构 调用活动Call Activity 调用活动可以理解为函数调用它会引用另外一个流程使之作为子流程运行调用活动跟函数调用的功能一样使流程模块化增加复用的可能性。 一个流程必须包含一个事件如开始事件和至少一个结束事件。其中网关的作用是流程流转逻辑的控制。任务则分很多类型他们各司其职所有节点均由连线联系起来。 4、为什么选择Flowable 修复了activiti6很多的bug可以实现零成本从activiti迁移到flowable。flowable目前已经支持加签、动态增加实例中的节点、支持cmmn、dmn规范。这些都是activiti6目前版本没有的。
flowable已经支持所有的历史数据使用mongdb存储activiti没有。 flowable支持事务子流程activiti没有。 flowable支持多实例加签、减签activiti没有。 flowable支持httpTask等新的类型节点activiti没有。 flowable支持在流程中动态添加任务节点activiti没有。 flowable支持历史任务数据通过消息中间件发送activiti没有。 flowable支持java11,activiti没有。 flowable支持动态脚本,activiti没有。 flowable支持条件表达式中自定义juel函数activiti没有。 flowable支持cmmn规范activiti没有。 flowable修复了dmn规范设计器activit用的dmn设计器还是旧的框架bug太多。 flowable屏蔽了pvmactiviti6也屏蔽了pvm因为6版本官方提供了加签功能发现pvm设计的过于臃肿索性直接移除这样加签实现起来更简洁、事实确实如此如果需要获取节点、连线等信息可以使用bpmnmodel替代。 flowable与activiti提供了新的事务监听器。activiti5版本只有事件监听器、任务监听器、执行监听器。 flowable对activiti的代码大量的进行了重构。 activiti以及flowable支持的数据库有h2、hsql、mysql、oracle、postgres、mssql、db2。其他数据库不支持的。使用国产数据库的可能有点失望了需要修改源码了。 flowable支持jms、rabbitmq、mongodb方式处理历史数据activiti没有。
5、Flowable基础表结构
工作流程的相关操作都是操作存储在对应的表结构中为了能更好的弄清楚Flowable的实现原理和细节我们有必要先弄清楚Flowable的相关表结构及其作用。在Flowable中的表结构在初始化的时候会创建五类表结构具体如下
ACT_RE RE’表示 repository。 这个前缀的表包含了流程定义和流程静态资源 图片规则等等。 ACT_RURU’表示 runtime。 这些运行时的表包含流程实例任务变量异步任务等运行中的数据。 Flowable只在流程实例执行过程中保存这些数据 在流程结束时就会删除这些记录。 这样运行时表可以一直很小速度很快。 ACT_HIHI’表示 history。 这些表包含历史数据比如历史流程实例 变量任务等等。 ACT_GE GE 表示 general。 通用数据 用于不同场景下 ACT_ID: ’ID’表示identity组织机构。这些表包含标识的信息如用户用户组等等。 Flowable在项目启动的时候会自动创建表以下是主要几张表介绍
ACT_RU_TASK每次启动的流程都会在这张表中表示代办项流程结束会删除该流程数据 ACT_RU_EXECUTION流程执行过程表会存该流程正在执行的过程数据流程结束会删除该流程数据 ACT_RU_VARIABLE流程变量表流程中传的参数都会在该表存储流程结束会删除该流程数据 ACT_HI_PROCINST历史运行流程当流程处理完了 在ACT_RU_* 表中就不会有数据, 可以在该表中查询历史 ACT_HI_TASKINST历史运行的task信息, ACT_RE_PROCDEF流程模板记录同一个key多次发布version_字段会递增 ACT_RE_DEPLOYMENT部署的流程模板可以启动流程使用的
三、创建项目
创建一个maven项目引入springboot、mysql、flowable
pom.xml
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.test/groupIdartifactIdflowable-test/artifactIdversion1.0-SNAPSHOT/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.3.0.RELEASE/versionrelativePath//parentdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--mysql--dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.38/version/dependency!--flowable--dependencygroupIdorg.flowable/groupIdartifactIdflowable-spring-boot-starter/artifactIdversion6.4.1/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-api/artifactIdversion1.7.22/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-log4j12/artifactIdversion1.7.25/version/dependency/dependencies
/projectapplication.yml
注意mysql数据库驱动版本差异
com.mysql.jdbc.Driver
这是 旧版 MySQL JDBC 驱动的类名。 该驱动属于 mysql-connector-java 5.x 或更早版本。 它是 MySQL 5.x 系列及之前的 JDBC 驱动程序的标准类名。 从 MySQL 5.1 到 MySQL 5.7 版本使用的是这个驱动。
com.mysql.cj.jdbc.Driver
这是 新版 MySQL JDBC 驱动的类名。 该驱动是 MySQL 8.x 及之后版本的标准 JDBC 驱动程序。 com.mysql.cj.jdbc.Driver 是从 mysql-connector-java 8.x 开始引入的。 com.mysql.cj 代表 “Connector/J” 的缩写cj 指代的是 Connector/J 新的模块命名空间。
spring:datasource:username: rootpassword: 123456url: jdbc:mysql://localhost:3306/flowable-test?allowMultiQueriestrueuseUnicodetruecharacterEncodingUTF-8driver-class-name: com.mysql.jdbc.Driver
flowable:# 业务流程设计的表自动创建database-schema-update: true# 异步执行耗时操作提升性能async-executor-activate: falseFlowableApplication.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication
public class FlowableApplication {public static void main(String[] args) {SpringApplication.run(FlowableApplication.class, args);}
}运行并启动项目会在数据库自动生成工作流所使用的表 四、画流程图
这里使用 IDEA 插件Flowable BPMN visualizer如下图 装好插件之后在 resources 目录下新建 processes 目录这个目录下的流程文件将来会被自动部署
新建一个ask_for_leave.bpmn20.xml文件.bpmn20.xml是固定文件后缀不需要填写
文件创建出来之后右键单击选择 View BPMN(Flowable) Diagram就打开了此文件的可视化页面了然后就可以来绘制自己的流程图 然后在可视化页面空白处右键点击就可以添加不同的符号来绘制流程图 绘制完成 我们来看下这个流程对应的 XML 文件一些流程细节会在 XML 文件中体现出来如下
?xml version1.0 encodingUTF-8?
definitions xmlnshttp://www.omg.org/spec/BPMN/20100524/MODEL xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:xsdhttp://www.w3.org/2001/XMLSchema xmlns:flowablehttp://flowable.org/bpmn xmlns:bpmndihttp://www.omg.org/spec/BPMN/20100524/DI xmlns:omgdchttp://www.omg.org/spec/DD/20100524/DC xmlns:omgdihttp://www.omg.org/spec/DD/20100524/DI typeLanguagehttp://www.w3.org/2001/XMLSchema expressionLanguagehttp://www.w3.org/1999/XPath targetNamespacehttp://www.flowable.org/processdefprocess idask_for_leave nameask_for_leave isExecutabletruestartEvent idstartLeave/userTask idleaveTask name请假 flowable:assignee#{leaveUser}/sequenceFlow idflowStart sourceRefstartLeave targetRefleaveTask/userTask idzuZhangTask name组长审核 flowable:assignee#{zuZhangUser}/sequenceFlow idmodeFlow sourceRefleaveTask targetRefzuZhangTask/exclusiveGateway idzuZhangJudgeGateway/sequenceFlow idzuZhang_go_judge sourceRefzuZhangTask targetRefzuZhangJudgeGateway/userTask idmanagerTask name经理审核 flowable:assignee#{managerUser}/sequenceFlow idzuZhangPass sourceRefzuZhangJudgeGateway targetRefmanagerTask name组长审核通过conditionExpression xsi:typetFormalExpression${var:equals(zuZhangCheckResult,通过)}/conditionExpression/sequenceFlowendEvent idendLeave/exclusiveGateway idmanagerJudgeGateway/sequenceFlow idmanager_go_judge sourceRefmanagerTask targetRefmanagerJudgeGateway/sequenceFlow idmanagerPass sourceRefmanagerJudgeGateway targetRefendLeave name经理审核通过conditionExpression xsi:typetFormalExpression${var:equals(managerCheckResult,通过)}/conditionExpression/sequenceFlowserviceTask idsendFailMessage flowable:exclusivetrue name发送失败提示 isForCompensationtrue flowable:classcom.test.service.LeaveFailService/sequenceFlow idzuZhangRefuse sourceRefzuZhangJudgeGateway targetRefsendFailMessage name组长审核拒绝conditionExpression xsi:typetFormalExpression${var:equals(zuZhangCheckResult,拒绝)}/conditionExpression/sequenceFlowendEvent idfailEndLeave/sequenceFlow idgo_fail_end sourceRefsendFailMessage targetReffailEndLeave/sequenceFlow idmanagerRefuse sourceRefmanagerJudgeGateway targetRefsendFailMessage name经理审核拒绝conditionExpression xsi:typetFormalExpression${var:equals(managerCheckResult,拒绝)}/conditionExpression/sequenceFlow/processbpmndi:BPMNDiagram idBPMNDiagram_ask_for_leavebpmndi:BPMNPlane bpmnElementask_for_leave idBPMNPlane_ask_for_leavebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-92e89192-ae6e-4c06-84ea-e3deb6d92402 bpmnElementstartLeaveomgdc:Bounds x-454.35 y-60.0 width30.0 height30.0//bpmdi:BPMNShapebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-9ab478cf-067b-4984-a12e-0b14d28d6bb5 bpmnElementleaveTaskomgdc:Bounds x-381.4296 y-85.0 width100.0 height80.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-5e4ce6f7-76af-4972-91a1-ce776b2ca0c7 bpmnElementflowStartomgdi:waypoint x-424.35 y-45.0/omgdi:waypoint x-381.4296 y-45.0//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-46866177-80d1-4db8-abd7-f0426459804a bpmnElementzuZhangTaskomgdc:Bounds x-234.44722 y-85.0 width100.0 height80.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-c65d7d95-b9f8-44e1-89a3-0bf2a9e95738 bpmnElementmodeFlowomgdi:waypoint x-281.4296 y-45.0/omgdi:waypoint x-234.44722 y-45.0//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-53989386-6942-4e52-8f37-9076c52057a6 bpmnElementzuZhangJudgeGatewayomgdc:Bounds x-78.09332 y-65.0 width40.0 height40.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-4b34e417-f0c0-40ef-8bb6-7690e136d67f bpmnElementzuZhang_go_judgeomgdi:waypoint x-134.44722 y-45.0/omgdi:waypoint x-78.09332 y-45.0//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-86d89ed3-dcb1-451c-b96c-ba3ef43baeba bpmnElementmanagerTaskomgdc:Bounds x26.607117 y-85.0 width100.0 height80.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-c2ec3e89-62ab-4e90-af28-0cf551530ca0 bpmnElementzuZhangPassomgdi:waypoint x-38.093323 y-45.0/omgdi:waypoint x26.607117 y-45.0//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-dd6c6e8f-e05d-4e50-9852-672656a76494 bpmnElementendLeaveomgdc:Bounds x284.48773 y-59.999996 width30.0 height30.0//bpmdi:BPMNShapebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-fa4fc0dc-9773-4944-9fde-d2741dc9386b bpmnElementmanagerJudgeGatewayomgdc:Bounds x164.3713 y-65.0 width40.0 height40.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-4d924eb1-02a1-43d3-b884-d7a3e5918359 bpmnElementmanager_go_judgeomgdi:waypoint x126.60712 y-45.0/omgdi:waypoint x164.3713 y-45.0//bpmdi:BPMNEdgebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-9918da8c-b7e5-4ec1-866b-dbfae2c6ea05 bpmnElementmanagerPassomgdi:waypoint x204.3713 y-45.0/omgdi:waypoint x284.48773 y-44.999996//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-ccc89da3-1cf3-414b-8c39-3a90c8a42326 bpmnElementsendFailMessageomgdc:Bounds x-108.09332 y41.54 width100.0 height80.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-98a4db5f-6ff9-48d0-a358-9470a03c8f1c bpmnElementzuZhangRefuseomgdi:waypoint x-58.093323 y-25.0/omgdi:waypoint x-58.093323 y41.54//bpmdi:BPMNEdgebpmdi:BPMNShape xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idshape-48b0f47e-8768-4275-b013-575039f2cd20 bpmnElementfailEndLeaveomgdc:Bounds x-199.44724 y66.54 width30.0 height30.0//bpmdi:BPMNShapebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-08d8631a-3c62-486f-9a65-6f1d1a63c317 bpmnElementgo_fail_endomgdi:waypoint x-108.09332 y81.54/omgdi:waypoint x-169.44724 y81.54//bpmdi:BPMNEdgebpmdi:BPMNEdge xmlns:bpmdihttp://www.omg.org/spec/BPMN/20100524/DI idedge-136a3062-a9f0-4c34-a275-0d6b51fc55d3 bpmnElementmanagerRefuseomgdi:waypoint x184.3713 y-25.0/omgdi:waypoint x184.3713 y81.54/omgdi:waypoint x-8.093322 y81.53999//bpmdi:BPMNEdge/bpmndi:BPMNPlane/bpmndi:BPMNDiagram
/definitions五、流程接口代码
AskForLeaveController.java
package com.test.controller;import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.*;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;RestController
public class AskForLeaveController {AutowiredRuntimeService runtimeService;AutowiredRepositoryService repositoryService;AutowiredTaskService taskService;AutowiredProcessEngine processEngine;/*** 查看流程进度图* param resp* param processId 流程id* throws Exception*/GetMapping(/viewFlowChart)public void viewFlowChart(HttpServletResponse resp, String processId) throws Exception {ProcessInstance pi runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();if (pi null) {return;}ListExecution executions runtimeService.createExecutionQuery().processInstanceId(processId).list();ListString activityIds new ArrayList();ListString flows new ArrayList();for (Execution exe : executions) {ListString ids runtimeService.getActiveActivityIds(exe.getId());activityIds.addAll(ids);}// 生成流程图BpmnModel bpmnModel repositoryService.getBpmnModel(pi.getProcessDefinitionId());ProcessEngineConfiguration engconf processEngine.getProcessEngineConfiguration();ProcessDiagramGenerator diagramGenerator engconf.getProcessDiagramGenerator();InputStream in diagramGenerator.generateDiagram(bpmnModel, png, activityIds, flows, engconf.getActivityFontName(), engconf.getLabelFontName(), engconf.getAnnotationFontName(), engconf.getClassLoader(), 1.0, false);OutputStream out null;byte[] buf new byte[1024];int legth 0;try {out resp.getOutputStream();while ((legth in.read(buf)) ! -1) {out.write(buf, 0, legth);}} finally {if (in ! null) {in.close();}if (out ! null) {out.close();}}}/*** 开启一个请假流程*/GetMapping(/askForLeave)public String askForLeave() {MapString, Object map new HashMap();map.put(leaveUser, 张三);map.put(name, ego);map.put(reason, 出去玩);map.put(days, 10);ProcessInstance instance runtimeService.startProcessInstanceByKey(ask_for_leave, map);return 开启请假流程 processId instance.getId();}/*** 员工请假提交给组长审核*/GetMapping(/submitToZuZhang)public String submitToZuZhang() {// 员工查找到自己的任务然后提交给组长审批ListTask list taskService.createTaskQuery().taskAssignee(张三).orderByTaskId().desc().list();String info null;for (Task task: list) {info 任务 ID task.getId() 任务申请人 task.getAssignee() 任务是否挂起 task.isSuspended();//提交给组长的时候需要指定组长的idMapString, Object map new HashMap();map.put(zuZhangUser, 李四);taskService.complete(task.getId(), map);}return info;}/*** 组长审核请假*/GetMapping(/zuZhangApprove)public String zuZhangApprove() {ListTask list taskService.createTaskQuery().taskAssignee(李四).orderByTaskId().desc().list();String info null;for (Task task: list) {if (组长审核.equals(task.getName())) {info 任务 ID task.getId() 组长审核人 task.getAssignee() 任务是否挂起 task.isSuspended();// 提交给经理的时候需要指定经理的idMapString, Object map new HashMap();map.put(managerUser, 王五);map.put(zuZhangCheckResult, 通过);map.put(zuZhangUser, 李四);try {taskService.complete(task.getId(), map);} catch (Exception e) {e.printStackTrace();info 组长审核失败 task.getId() task.getAssignee();}}}return info;}/*** 经理审核通过*/GetMapping(/managerApprove)public String managerApprove() {ListTask list taskService.createTaskQuery().taskAssignee(王五).orderByTaskId().desc().list();String info null;for (Task task: list) {info 经理 task.getAssignee() 审核通过 task.getId() 任务;MapString, Object map new HashMap();map.put(managerCheckResult, 通过);taskService.complete(task.getId(), map);}return info;}/*** 经理审核拒绝*/GetMapping(/managerRefuse)public String managerRefuse() {ListTask list taskService.createTaskQuery().taskAssignee(王五).orderByTaskId().desc().list();String info null;for (Task task: list) {info 经理 task.getAssignee() 审核拒绝 task.getId() 任务;MapString, Object map new HashMap();map.put(managerCheckResult, 拒绝);taskService.complete(task.getId(), map);}return info;}
}LeaveFailService.java
对应流程图中的
package com.test.service;import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;Component
public class LeaveFailService implements JavaDelegate {Overridepublic void execute(DelegateExecution delegateExecution) {System.out.println(审批不通过 delegateExecution.getCurrentActivityId());}
}FlowableConfig.java防止流程图出现中文乱码的配置类
package com.test.config;import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.context.annotation.Configuration;Configuration
public class FlowableConfig implements EngineConfigurationConfigurerSpringProcessEngineConfiguration {Overridepublic void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) {springProcessEngineConfiguration.setActivityFontName(宋体);springProcessEngineConfiguration.setLabelFontName(宋体);springProcessEngineConfiguration.setAnnotationFontName(宋体);}
}五、测试一下流程接口
1、开启一个请假流程http://localhost:8080/askForLeave 查看流程进度图参数是开启的流程的processId
http://localhost:8080/viewFlowChartprocessIdef67cd51-af01-11ef-8fdb-005056c00001
可以看到请假这个userTask用红色的框框起来了说明当前流程走到了这一步 2、员工请假提交给组长审核http://localhost:8080/submitToZuZhang 查看流程进度图 3、组长审核请假http://localhost:8080/zuZhangApprove 查看流程进度 4、经理审核拒绝http://localhost:8080/managerRefuse 调用LeaveFailService控制台打印 流程结束 5、重新开启一个流程重复1-4试一试“经理审核通过”