当前位置: 首页 > news >正文

【Flowable】Springboot使用Flowable(一)

一、项目依赖

<dependency><groupId>org.flowable</groupId><artifactId>flowable-engine</artifactId><version>6.3.0</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.21</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.21</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.7.21</version></dependency>

二、新建Test类

public class Test01 {/*** 获取流程引擎对象*/@Testpublic void testProcessEngine() {// 获取 ProcessEngineConfiguration 对象ProcessEngineConfiguration configuration = new StandaloneProcessEngineConfiguration();//配置相关的数据库连接信息configuration.setJdbcDriver("com.mysql.cj.jdbc.Driver");configuration.setJdbcUsername("xxx");configuration.setJdbcPassword("xxx");configuration.setJdbcUrl("jdbc:mysql://xxx/flowable?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");//如果数据库中的表结构不存在就新建configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);//构建流程引擎对象ProcessEngine processEngine = configuration.buildProcessEngine();System.out.println("processEngine = " + processEngine);}ProcessEngineConfiguration configuration = null;@Beforepublic void before() {// 获取 ProcessEngineConfiguration 对象configuration = new StandaloneProcessEngineConfiguration();//配置相关的数据库连接信息configuration.setJdbcDriver("com.mysql.cj.jdbc.Driver");configuration.setJdbcUsername("xxxx");configuration.setJdbcPassword("xxxx");configuration.setJdbcUrl("jdbc:mysql://xxxxx/flowable?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");//如果数据库中的表结构不存在就新建configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);}/*** 部署流程*/@Testpublic void testDeploy() {//1.获取ProcessEngine 对象ProcessEngine processEngine = configuration.buildProcessEngine();//2.获取RepositoryServiceRepositoryService repositoryService = processEngine.getRepositoryService();//3.完成流程部署操作Deployment deploy = repositoryService.createDeployment().addClasspathResource("test.bpmn20.xml") //关联要部署的流程名称.name("请假流程").deploy(); //部署流程System.out.println("id: " + deploy.getId());System.out.println("name: " + deploy.getName());System.out.println("key: " + deploy.getKey());}/*** 查询部署流程的定义信息*/@Testpublic void testDeployQuery() {ProcessEngine processEngine = configuration.buildProcessEngine();RepositoryService repositoryService = processEngine.getRepositoryService();//创建流程查询对象ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();ProcessDefinition processDefinition = processDefinitionQuery.deploymentId("15001").singleResult();//部署的流程图ID,常用来做版本控制System.out.println("processDefinition.getDeploymentId() = " + processDefinition.getDeploymentId());//流程名称System.out.println("processDefinition.getName() = " + processDefinition.getName());//流程描述System.out.println("processDefinition.getDescription() = " + processDefinition.getDescription());//流程图idSystem.out.println("processDefinition.getId() = " + processDefinition.getId());//流程唯一标识System.out.println("processDefinition.getKey() = " + processDefinition.getKey());}/*** 删除部署的流程*/@Testpublic void testDeleteDeploy() {ProcessEngine processEngine = configuration.buildProcessEngine();RepositoryService repositoryService = processEngine.getRepositoryService();//删除部署ID为1的,如果部署的流程启动了 则没法删除
//        repositoryService.deleteDeployment("1");// 第二个参数是级联删除,如果流程启动了也可以进行删除,相关的任务也会被删除repositoryService.deleteDeployment("7501", true);}/*** 启动流程*/@Testpublic void testStartProcess() {//id :2501ProcessEngine processEngine = configuration.buildProcessEngine();//通过runtimeService 启动流程实例RuntimeService runtimeService = processEngine.getRuntimeService();//构建流程变量Map<String, Object> variable = new HashMap<>();variable.put("employee", "张三");variable.put("nrOfHolidays", 3);variable.put("description", "感冒了");//启动流程实例ProcessInstance holidayRequest = runtimeService.startProcessInstanceByKey("test", variable);//流程实例IDSystem.out.println("holidayRequest.getProcessInstanceId() = " + holidayRequest.getProcessInstanceId());System.out.println("holidayRequest.getProcessDefinitionId() = " + holidayRequest.getProcessDefinitionId());System.out.println("holidayRequest.getActivityId() = " + holidayRequest.getActivityId());}/*** 查询代办*/@Testpublic void testQueryTask() {ProcessEngine processEngine = configuration.buildProcessEngine();TaskService taskService = processEngine.getTaskService();TaskQuery taskQuery = taskService.createTaskQuery();List<Task> list = taskQuery.processDefinitionKey("holidayRequest")
//                .taskAssignee("zhangsan").taskDefinitionId("test:1:15004").list();for (Task task : list) {System.out.println("task.getProcessDefinitionId() = " + task.getProcessDefinitionId());System.out.println("task.getName() = " + task.getName());System.out.println("task.getAssignee() = " + task.getAssignee());System.out.println("task.getDescription() = " + task.getDescription());System.out.println("task.getId() = " + task.getId());}}/*** 处理完成当前任务*/@Testpublic void testCompleteTask() {ProcessEngine processEngine = configuration.buildProcessEngine();TaskService taskService = processEngine.getTaskService();Task task = taskService.createTaskQuery().processDefinitionKey("test").taskAssignee("zhangsan").singleResult();//创建流程变量HashMap<String, Object> variables = new HashMap<>();variables.put("approved", false);//完成任务taskService.complete(task.getId(), variables);}/*** 获取流程历史信息*/@Testpublic void testHistory(){ProcessEngine processEngine = configuration.buildProcessEngine();HistoryService historyService = processEngine.getHistoryService();List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery().processInstanceId("17501").finished().orderByHistoricActivityInstanceEndTime().asc().list();for (HistoricActivityInstance historicActivityInstance : list) {System.out.println("historicActivityInstance.getActivityId() = " + historicActivityInstance.getActivityId());System.out.println("historicActivityInstance.getActivityName() = " + historicActivityInstance.getActivityName());System.out.println("historicActivityInstance.getTaskId() = " + historicActivityInstance.getTaskId());System.out.println("historicActivityInstance.getAssignee() = " + historicActivityInstance.getAssignee());System.out.println("historicActivityInstance.getDeleteReason() = " + historicActivityInstance.getDeleteReason());System.out.println("处理时间:historicActivityInstance.getDurationInMillis() = " + historicActivityInstance.getDurationInMillis());System.out.println("------------------");}}
}

三、flowable流程图

  • 新建一个xml文件命名为:holiday-request.bpmn20.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"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:flowable="http://flowable.org/bpmn"typeLanguage="http://www.w3.org/2001/XMLSchema"expressionLanguage="http://www.w3.org/1999/XPath"targetNamespace="http://www.flowable.org/processdef"><!--id:流程主键 name:流程名称 --><process id="holidayRequest" name="qingjia" isExecutable="true"><!--startEvent:开始事件--><startEvent id="startEvent"/><!--sequenceFlow顺序流  sourceRef:源  targetRef:目标ID--><sequenceFlow sourceRef="startEvent" targetRef="approveTask"/><!--userTask:用户任务--><userTask id="approveTask" name="tongyi or reject" flowable:assignee="zhangsan"/><sequenceFlow sourceRef="approveTask" targetRef="decision"/><!--exclusiveGateway:排他网关--><exclusiveGateway id="decision"/><sequenceFlow sourceRef="decision" targetRef="externalSystemCall"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${approved}]]></conditionExpression></sequenceFlow><sequenceFlow sourceRef="decision" targetRef="sendRejectionMail"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${!approved}]]></conditionExpression></sequenceFlow><serviceTask id="externalSystemCall" name="Enter holidays in external system"flowable:class="org.flowable.CallExternalSystemDelegate"/><sequenceFlow sourceRef="externalSystemCall" targetRef="holidayApprovedTask"/><userTask id="holidayApprovedTask" name="Holiday approved"/><sequenceFlow sourceRef="holidayApprovedTask" targetRef="approveEnd"/><serviceTask id="sendRejectionMail" name="Send out rejection email"flowable:class="org.flowable.SendRejectionMail"/><sequenceFlow sourceRef="sendRejectionMail" targetRef="rejectEnd"/><endEvent id="approveEnd"/><endEvent id="rejectEnd"/></process></definitions>

以上简单介绍springboot整合flowable,后续会继续深入研究,欢迎各位小伙伴指点不足。

相关文章:

【Flowable】Springboot使用Flowable(一)

一、项目依赖 <dependency><groupId>org.flowable</groupId><artifactId>flowable-engine</artifactId><version>6.3.0</version></dependency><dependency><groupId>mysql</groupId><artifactId>my…...

戳泡泡小游戏

欢迎来到程序小院 戳泡泡 玩法&#xff1a; 鼠标点击上升的起泡泡&#xff0c;点击暴躁记录分数&#xff0c;不要让泡泡越过屏幕&#xff0c;共有三次复活生命&#xff0c;会有随机星星出现&#xff0c;点击即可暴躁全屏哦^^。开始游戏https://www.ormcc.com/play/gameStart/1…...

Redis缓存

1. Redis缓存相关问题 1.1 缓存穿透 缓存穿透是指查询一个数据库一定不存在的数据。 我们以前正常的使用Redis缓存的流程大致是&#xff1a; 1、数据查询首先进行缓存查询 2、如果数据存在则直接返回缓存数据 3、如果数据不存在&#xff0c;就对数据库进行查询&#xff0…...

mysql 插入更新数据

insert into insert into 语句进行插入时&#xff0c;如果插入的字段包含 主键或者唯一索引字段&#xff0c;那么&#xff0c; 1&#xff09;主键或唯一索引 已存在&#xff0c;则插入失败 1062 - Duplicate entry 1 for key PRIMARY 2&#xff09;只有主键或者唯一索 引不存…...

系统架构设计高级技能 · 软件产品线

现在的一切都是为将来的梦想编织翅膀&#xff0c;让梦想在现实中展翅高飞。 Now everything is for the future of dream weaving wings, let the dream fly in reality. 点击进入系列文章目录 系统架构设计高级技能 软件产品线 一、产品线概述二、产品线的过程模型2.1 双生命…...

C语言学习系列-->字符函数和字符串函数

文章目录 一、字符函数1、字符分类函数2、字符转换函数 二、字符串函数1、strlen概述模拟实现 2、strcpy概述模拟实现 3、strcat概述模拟实现 3、strcmp概述模拟实现 4、有限制的字符串函数strncpystrncatstrncmp 4、strstr概述模拟实现 一、字符函数 1、字符分类函数 包含头…...

尖端AR技术如何在美国革新外科手术实践?

AR智能眼镜已成为一种革新性的工具&#xff0c;在外科领域具有无穷的优势和无限的机遇。Vuzix与众多医疗创新企业建立了长期合作关系&#xff0c;如Pixee Medical、Medacta、Ohana One、Rods & Cones、Proximie等。这些公司一致认为Vuzix智能眼镜可有效提升手术实践&#x…...

【木板】Python实现-附ChatGPT解析

1.题目 木板 时间限制:1s 空间限制:256MB 限定语言:不限题目描述: 小明有n块木板,第i (1<=i<=n) 块木板的长度为ai.小明买了一块长度为m的木料,这块木料可以切割成任意块,拼接到已有的木板上用来加长木板。 小明想让最短的木板尽量长。 请问小明加长木板后,最短木板…...

第一章:绪论

1.1 系统架构概述 架构是体现在组件中的一个系统的基本组织、它们彼此的关系与环境的关系以及指导它的设计和发展的原则。 系统是组织起来完成某一特定功能火一组功能的组件集。系统这个术语包括了单独的应用程序、传统意义上的系统、子系统、系统之系统、产品线、整个企业及…...

C++面试知识点总结

知识点总结 <<符号表示该语句将把这个字符串发送给cout&#xff1b;该符号指出了信息流动的路径&#xff1b;cout的对象属性包括一个插入运算符&#xff08;<<&#xff09;&#xff0c;它可以将其右侧的信息插入到流中&#xff0c;endl:重起一行。在输出流中插入en…...

从智能手机到智能机器人:小米品牌的高端化之路

原创 | 文 BFT机器人 前言 在前阵子落幕的2023世界机器人大会“合作之夜”上&#xff0c;北京经济技术开发区管委会完成了与世界机器人合作组织、小米机器人等16个重点项目签约&#xff0c;推动机器人创新链和产业链融合&#xff0c;其中小米的投资额达到20亿&#xff01; 据了…...

深度学习推荐系统(八)AFM模型及其在Criteo数据集上的应用

深度学习推荐系统(八)AFM模型及其在Criteo数据集上的应用 1 AFM模型原理及其实现 沿着特征工程自动化的思路&#xff0c;深度学习模型从 PNN ⼀路⾛来&#xff0c;经过了Wide&#xff06;Deep、Deep&#xff06;Cross、FNN、DeepFM、NFM等模型&#xff0c;进⾏了大量的、基于不…...

【Spring】aop的底层原理

&#x1f384;欢迎来到边境矢梦的csdn博文&#x1f384; &#x1f384;本文主要梳理 Spring 中的切面编程aop的底层原理和重点注意的地方 &#x1f384; &#x1f308;我是边境矢梦&#xff0c;一个正在为秋招和算法竞赛做准备的学生&#x1f308; &#x1f386;喜欢的朋友可以…...

微信小程序开发---基本组件的使用

目录 一、scroll-view &#xff08;1&#xff09;作用 &#xff08;2&#xff09;用法 二、swiper和swiper-item &#xff08;1&#xff09;作用 &#xff08;2&#xff09;用法 三、text &#xff08;1&#xff09;作用 &#xff08;2&#xff09;使用 四、rich-tex…...

SpringBoot国际化配置组件支持本地配置和数据库配置

文章目录 0. 前言i18n-spring-boot-starter1. 使用方式0.引入依赖1.配置项2.初始化国际化配置表3.如何使用 2. 核心源码实现一个拦截器I18nInterceptorI18nMessageResource 加载国际化配置 3.源码地址 0. 前言 写个了原生的SpringBoot国际化配置组件支持本地配置和数据库配置 背…...

Shell编程之sort

sort 命令将文件的每一行作为比较对象&#xff0c;通过将不同行进行相互比较&#xff0c;从而得到最终结果。从首字符开始&#xff0c;依次按ASCII码值进行比较&#xff0c;最后将结果按升序输出。 基本语法 sort (选项)(参数) 常用选项 常用选项 -n根据字符串的数字比较-r…...

windows docker 容器启动报错:Ports are not available

docker 启动容器报错&#xff1a; (HTTP code 500) server error - Ports are not available: listen tcp 0.0.0.0:6379: bind: An attempt was made to access a socket in a way forbidden by its access permissions. 问题排查 检查端口是否被其它程序占用&#xff1a;nets…...

300. 最长递增子序列

题目描述 给你一个整数数组 nums &#xff0c;找到其中最长严格递增子序列的长度。 子序列 是由数组派生而来的序列&#xff0c;删除&#xff08;或不删除&#xff09;数组中的元素而不改变其余元素的顺序。例如&#xff0c;[3,6,2,7] 是数组 [0,3,1,6,2,2,7] 的子序列。 示…...

DNS(域名解析系统)

含义 当我们在上网要访问莫个服务器的时候&#xff0c;就需要知道服务器的IP地址&#xff0c;但IP地址是一串数字&#xff0c;虽然这串数字用点分十进制已经清晰不少了&#xff0c;但还是不利于人们记忆和传播&#xff0c;于是人们使用单词来代替IP地址&#xff08;例如baidu&a…...

解决jsp/html界面跳转servlet出现404错误的方法

解决jsp/html界面跳转servlet出现404错误的方法 最近在学习黑马项目过程中遇到的问题 问题一&#xff1a; 检查页面的跳转路径和名称拼写是否正确 问题二&#xff1a; tomcat发布项目时所使用的路径名称与项目不同 在idea右上角点击如图圈住的按钮 在deployment中更改出现…...

盘古信息PCB行业解决方案:以全域场景重构,激活智造新未来

一、破局&#xff1a;PCB行业的时代之问 在数字经济蓬勃发展的浪潮中&#xff0c;PCB&#xff08;印制电路板&#xff09;作为 “电子产品之母”&#xff0c;其重要性愈发凸显。随着 5G、人工智能等新兴技术的加速渗透&#xff0c;PCB行业面临着前所未有的挑战与机遇。产品迭代…...

Cesium1.95中高性能加载1500个点

一、基本方式&#xff1a; 图标使用.png比.svg性能要好 <template><div id"cesiumContainer"></div><div class"toolbar"><button id"resetButton">重新生成点</button><span id"countDisplay&qu…...

【SpringBoot】100、SpringBoot中使用自定义注解+AOP实现参数自动解密

在实际项目中,用户注册、登录、修改密码等操作,都涉及到参数传输安全问题。所以我们需要在前端对账户、密码等敏感信息加密传输,在后端接收到数据后能自动解密。 1、引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId...

【SQL学习笔记1】增删改查+多表连接全解析(内附SQL免费在线练习工具)

可以使用Sqliteviz这个网站免费编写sql语句&#xff0c;它能够让用户直接在浏览器内练习SQL的语法&#xff0c;不需要安装任何软件。 链接如下&#xff1a; sqliteviz 注意&#xff1a; 在转写SQL语法时&#xff0c;关键字之间有一个特定的顺序&#xff0c;这个顺序会影响到…...

2021-03-15 iview一些问题

1.iview 在使用tree组件时&#xff0c;发现没有set类的方法&#xff0c;只有get&#xff0c;那么要改变tree值&#xff0c;只能遍历treeData&#xff0c;递归修改treeData的checked&#xff0c;发现无法更改&#xff0c;原因在于check模式下&#xff0c;子元素的勾选状态跟父节…...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

Matlab | matlab常用命令总结

常用命令 一、 基础操作与环境二、 矩阵与数组操作(核心)三、 绘图与可视化四、 编程与控制流五、 符号计算 (Symbolic Math Toolbox)六、 文件与数据 I/O七、 常用函数类别重要提示这是一份 MATLAB 常用命令和功能的总结,涵盖了基础操作、矩阵运算、绘图、编程和文件处理等…...

【C语言练习】080. 使用C语言实现简单的数据库操作

080. 使用C语言实现简单的数据库操作 080. 使用C语言实现简单的数据库操作使用原生APIODBC接口第三方库ORM框架文件模拟1. 安装SQLite2. 示例代码:使用SQLite创建数据库、表和插入数据3. 编译和运行4. 示例运行输出:5. 注意事项6. 总结080. 使用C语言实现简单的数据库操作 在…...

C++ 求圆面积的程序(Program to find area of a circle)

给定半径r&#xff0c;求圆的面积。圆的面积应精确到小数点后5位。 例子&#xff1a; 输入&#xff1a;r 5 输出&#xff1a;78.53982 解释&#xff1a;由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982&#xff0c;因为我们只保留小数点后 5 位数字。 输…...

【HarmonyOS 5 开发速记】如何获取用户信息(头像/昵称/手机号)

1.获取 authorizationCode&#xff1a; 2.利用 authorizationCode 获取 accessToken&#xff1a;文档中心 3.获取手机&#xff1a;文档中心 4.获取昵称头像&#xff1a;文档中心 首先创建 request 若要获取手机号&#xff0c;scope必填 phone&#xff0c;permissions 必填 …...