Activiti7工作流引擎:实战篇(一) 准备工作

2023-11-21 09:59

本文主要是介绍Activiti7工作流引擎:实战篇(一) 准备工作,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

知识传送门 》》》》》》》》》》》》》》》》》》》

本来我是想买块肉的,但是现在我只能买块豆腐。

请添加图片描述

1. pom.xml

引入最新版本 activiti-spring-boot-starter依赖和spring-boot-starter-security。

<dependency><groupId>org.activiti</groupId><artifactId>activiti-spring-boot-starter</artifactId><version>7.1.0.M6</version>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId><version>2.2.0.RELEASE</version>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.2.0</version>
</dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope>
</dependency>
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope>
</dependency>

2. application.yml

spring:datasource:url: jdbc:mysql://localhost:3306/activiti?useUnicode=true&characterEncoding=utf8&serverTimezone=GMTusername: rootpassword: root123driver-class-name: com.mysql.cj.jdbc.Driveractiviti:#1.flase: 默认值。activiti在启动时,会对比数据库表中保存的版本,如果没有表或者版本不匹配,将抛出异常#2.true: activiti会对数据库中所有表进行更新操作。如果表不存在,则自动创建#3.create_drop: 在activiti启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)#4.drop-create: 在activiti启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎)database-schema-update: true#检测历史表是否存在 activiti7默认没有开启数据库历史记录 启动数据库历史记录db-history-used: true#记录历史等级 可配置的历史级别有none, activity, audit, fullhistory-level: full#校验流程文件,默认校验resources下的processes文件夹里的流程文件check-process-definitions: false

3. database

-- 用户表,用于登录和Spring Security集成, 密码: 123456
CREATE TABLE `tb_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`age` int(40) DEFAULT NULL,`username` varchar(100) DEFAULT NULL,`password` varchar(100) DEFAULT NULL,`email` varchar(100) DEFAULT NULL,`gender` int(40) DEFAULT NULL,`role` varchar(100) DEFAULT NULL,`rolegroup` varchar(100) DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;INSERT INTO `tb_user` VALUES (1, 20, 'jack', '$2a$10$9FIX76XUZgIyiOTjy5iswe9fJrWuaxAwTLsJb0QFJAcu5OqTb/TJS', '123@123.com', 1, 'ADMIN', 'activiti_user');
INSERT INTO `tb_user` VALUES (2, 25, 'rose', '$2a$10$9FIX76XUZgIyiOTjy5iswe9fJrWuaxAwTLsJb0QFJAcu5OqTb/TJS', '234@234.com', 2, 'ADMIN', 'activiti_user');
INSERT INTO `tb_user` VALUES (3, 22, 'tom', '$2a$10$9FIX76XUZgIyiOTjy5iswe9fJrWuaxAwTLsJb0QFJAcu5OqTb/TJS', '345@35.com', 1, 'ADMIN', 'activiti_user');
INSERT INTO `tb_user` VALUES (4, 30, 'jerry', '$2a$10$9FIX76XUZgIyiOTjy5iswe9fJrWuaxAwTLsJb0QFJAcu5OqTb/TJS', '456@456.com', 2, 'ADMIN', 'activiti_user');-- 出差表:保存业务相关数据
CREATE TABLE `tb_evection` (`id` int(10) NOT NULL AUTO_INCREMENT,`evectionName` varchar(100) DEFAULT NULL,`num` double DEFAULT NULL,`destination` varchar(100) DEFAULT NULL,`begindate` date DEFAULT NULL,`enddate` date DEFAULT NULL,`reson` varchar(100) DEFAULT NULL,`state` int(4) DEFAULT NULL,`userid` int(20) DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

4. entity

需要实现SpringSecurity中的UserDetails接口。

@Data
public class User implements Serializable, UserDetails {private Long id;private String username;private String password;private String email;private Integer gender;private Integer age;private String role;@Overridepublic Collection<? extends GrantedAuthority> getAuthorities() {return null;}@Overridepublic String getPassword() {return password;}@Overridepublic String getUsername() {return username;}@Overridepublic boolean isAccountNonExpired() {return false;}@Overridepublic boolean isAccountNonLocked() {return false;}@Overridepublic boolean isCredentialsNonExpired() {return false;}@Overridepublic boolean isEnabled() {return false;}
}
/*** 出差申请*/
@Data
public class Evection implements Serializable {private Long id;private Long userid;/** 出差申请单名称 */private String evectionName;/** 出差天数 */private Double num;/** 预计开始时间 */private Date beginDate;/** 预计结束时间 */private Date endDate;/** 目的地 */private String destination;/** 出差事由 */private String reson;/** 0-初始录入,1-开始审批,2-审批完成 */private int state;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {private Integer status;private String message;
}

5. bpmn

在这里插入图片描述
evection.bpmn

<?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="m1585999805036" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema"><process id="evection" isClosed="false" isExecutable="true" name="出差申请" processType="None"><startEvent id="_2" name="StartEvent"/><userTask activiti:assignee="${assignee0}" activiti:exclusive="true" id="_3" name="创建出差申请"><extensionElements><activiti:taskListener class="com.itheima.listener.MyTaskListener" event="assignment"/></extensionElements></userTask><userTask activiti:assignee="${assignee1}" activiti:exclusive="true" id="_4" name="部门经理审核"><extensionElements><activiti:taskListener class="com.itheima.listener.MyTaskListener" event="assignment"/></extensionElements></userTask><userTask activiti:assignee="${assignee2}" activiti:exclusive="true" id="_5" name="总经理审批"><extensionElements><activiti:taskListener class="com.itheima.listener.MyTaskListener" event="assignment"/></extensionElements></userTask><userTask activiti:assignee="${assignee3}" activiti:exclusive="true" id="_6" name="财务审批"><extensionElements><activiti:taskListener class="com.itheima.listener.MyTaskListener" event="assignment"/></extensionElements></userTask><endEvent id="_7" name="EndEvent"><extensionElements><activiti:executionListener class="com.itheima.listener.MyExecutionListener" event="end"/></extensionElements></endEvent><sequenceFlow id="_8" sourceRef="_2" targetRef="_3"/><sequenceFlow id="_9" sourceRef="_3" targetRef="_4"/><sequenceFlow id="_10" sourceRef="_4" targetRef="_6"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${evection.num<3}]]></conditionExpression></sequenceFlow><sequenceFlow id="_11" sourceRef="_4" targetRef="_5"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${evection.num>=3}]]></conditionExpression></sequenceFlow><sequenceFlow id="_12" sourceRef="_5" targetRef="_6"/><sequenceFlow id="_13" sourceRef="_6" targetRef="_7"/></process><bpmndi:BPMNDiagram documentation="background=#FFFFFF;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="evection"><bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2"><omgdc:Bounds height="32.0" width="32.0" x="5.0" y="160.0"/><bpmndi:BPMNLabel><omgdc: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="100.0" y="150.0"/><bpmndi:BPMNLabel><omgdc: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="265.0" y="150.0"/><bpmndi:BPMNLabel><omgdc: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="55.0" width="85.0" x="480.0" y="115.0"/><bpmndi:BPMNLabel><omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6"><omgdc:Bounds height="55.0" width="85.0" x="485.0" y="260.0"/><bpmndi:BPMNLabel><omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="_7" id="Shape-_7"><omgdc:Bounds height="32.0" width="32.0" x="655.0" y="265.0"/><bpmndi:BPMNLabel><omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="_13" id="BPMNEdge__13" sourceElement="_6" targetElement="_7"><omgdi:waypoint x="570.0" y="287.5"/><omgdi:waypoint x="655.0" y="281.0"/><bpmndi:BPMNLabel><omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_12" id="BPMNEdge__12" sourceElement="_5" targetElement="_6"><omgdi:waypoint x="525.0" y="170.0"/><omgdi:waypoint x="525.0" y="260.0"/><bpmndi:BPMNLabel><omgdc: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="_2" targetElement="_3"><omgdi:waypoint x="37.0" y="176.0"/><omgdi:waypoint x="100.0" y="177.5"/><bpmndi:BPMNLabel><omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_3" targetElement="_4"><omgdi:waypoint x="185.0" y="177.5"/><omgdi:waypoint x="265.0" y="177.5"/><bpmndi:BPMNLabel><omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_4" targetElement="_5"><omgdi:waypoint x="350.0" y="177.5"/><omgdi:waypoint x="480.0" y="142.5"/><bpmndi:BPMNLabel><omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_4" targetElement="_6"><omgdi:waypoint x="350.0" y="177.5"/><omgdi:waypoint x="485.0" y="287.5"/><bpmndi:BPMNLabel><omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge></bpmndi:BPMNPlane></bpmndi:BPMNDiagram>
</definitions>

6. main

配置Mapper扫描包。

@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class SpringbootActivitiApplication {public static void main(String[] args) {SpringApplication.run(SpringbootActivitiApplication.class, args);}
}

知识传送门 》》》》》》》》》》》》》》》》》》》

这篇关于Activiti7工作流引擎:实战篇(一) 准备工作的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/401594

相关文章

kotlin中的模块化结构组件及工作原理

《kotlin中的模块化结构组件及工作原理》本文介绍了Kotlin中模块化结构组件,包括ViewModel、LiveData、Room和Navigation的工作原理和基础使用,本文通过实例代码给大家... 目录ViewModel 工作原理LiveData 工作原理Room 工作原理Navigation 工

MySQL常见的存储引擎和区别说明

《MySQL常见的存储引擎和区别说明》MySQL支持多种存储引擎,如InnoDB、MyISAM、MEMORY、Archive、CSV和Blackhole,每种引擎有其特点和适用场景,选择存储引擎时需根... 目录mysql常见的存储引擎和区别说明1. InnoDB2. MyISAM3. MEMORY4. A

MySQL InnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据

《MySQLInnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据》mysql的ibdata文件被误删、被恶意修改,没有从库和备份数据的情况下的数据恢复,不能保证数据库所有表数据... 参考:mysql Innodb表空间卸载、迁移、装载的使用方法注意!此方法只适用于innodb_fi

SSID究竟是什么? WiFi网络名称及工作方式解析

《SSID究竟是什么?WiFi网络名称及工作方式解析》SID可以看作是无线网络的名称,类似于有线网络中的网络名称或者路由器的名称,在无线网络中,设备通过SSID来识别和连接到特定的无线网络... 当提到 Wi-Fi 网络时,就避不开「SSID」这个术语。简单来说,SSID 就是 Wi-Fi 网络的名称。比如

Python基于火山引擎豆包大模型搭建QQ机器人详细教程(2024年最新)

《Python基于火山引擎豆包大模型搭建QQ机器人详细教程(2024年最新)》:本文主要介绍Python基于火山引擎豆包大模型搭建QQ机器人详细的相关资料,包括开通模型、配置APIKEY鉴权和SD... 目录豆包大模型概述开通模型付费安装 SDK 环境配置 API KEY 鉴权Ark 模型接口Prompt

工作常用指令与快捷键

Git提交代码 git fetch  git add .  git commit -m “desc”  git pull  git push Git查看当前分支 git symbolic-ref --short -q HEAD Git创建新的分支并切换 git checkout -b XXXXXXXXXXXXXX git push origin XXXXXXXXXXXXXX

速了解MySQL 数据库不同存储引擎

快速了解MySQL 数据库不同存储引擎 MySQL 提供了多种存储引擎,每种存储引擎都有其特定的特性和适用场景。了解这些存储引擎的特性,有助于在设计数据库时做出合理的选择。以下是 MySQL 中几种常用存储引擎的详细介绍。 1. InnoDB 特点: 事务支持:InnoDB 是一个支持 ACID(原子性、一致性、隔离性、持久性)事务的存储引擎。行级锁:使用行级锁来提高并发性,减少锁竞争

嵌入式方向的毕业生,找工作很迷茫

一个应届硕士生的问题: 虽然我明白想成为技术大牛需要日积月累的磨练,但我总感觉自己学习方法或者哪些方面有问题,时间一天天过去,自己也每天不停学习,但总感觉自己没有想象中那样进步,总感觉找不到一个很清晰的学习规划……眼看 9 月份就要参加秋招了,我想毕业了去大城市磨练几年,涨涨见识,拓开眼界多学点东西。但是感觉自己的实力还是很不够,内心慌得不行,总怕浪费了这人生唯一的校招机会,当然我也明白,毕业

husky 工具配置代码检查工作流:提交代码至仓库前做代码检查

提示:这篇博客以我前两篇博客作为先修知识,请大家先去看看我前两篇博客 博客指路:前端 ESlint 代码规范及修复代码规范错误-CSDN博客前端 Vue3 项目开发—— ESLint & prettier 配置代码风格-CSDN博客 husky 工具配置代码检查工作流的作用 在工作中,我们经常需要将写好的代码提交至代码仓库 但是由于程序员疏忽而将不规范的代码提交至仓库,显然是不合理的 所

未来工作趋势:零工小程序在共享经济中的作用

经济在不断发展的同时,科技也在飞速发展。零工经济作为一种新兴的工作模式,正在全球范围内迅速崛起。特别是在中国,随着数字经济的蓬勃发展和共享经济模式的深入推广,零工小程序在促进就业、提升资源利用效率方面显示出了巨大的潜力和价值。 一、零工经济的定义及现状 零工经济是指通过临时性、自由职业或项目制的工作形式,利用互联网平台快速匹配供需双方的新型经济模式。这种模式打破了传统全职工作的界限,为劳动