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

相关文章

工作常用指令与快捷键

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 工具配置代码检查工作流的作用 在工作中,我们经常需要将写好的代码提交至代码仓库 但是由于程序员疏忽而将不规范的代码提交至仓库,显然是不合理的 所

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

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

Smarty模板引擎工作机制(一)

深入浅出Smarty模板引擎工作机制,我们将对比使用smarty模板引擎和没使用smarty模板引擎的两种开发方式的区别,并动手开发一个自己的模板引擎,以便加深对smarty模板引擎工作机制的理解。 在没有使用Smarty模板引擎的情况下,我们都是将PHP程序和网页模板合在一起编辑的,好比下面的源代码: <?php$title="深处浅出之Smarty模板引擎工作机制";$content=

Detectorn2预训练模型复现:数据准备、训练命令、日志分析与输出目录

Detectorn2预训练模型复现:数据准备、训练命令、日志分析与输出目录 在深度学习项目中,目标检测是一项重要的任务。本文将详细介绍如何使用Detectron2进行目标检测模型的复现训练,涵盖训练数据准备、训练命令、训练日志分析、训练指标以及训练输出目录的各个文件及其作用。特别地,我们将演示在训练过程中出现中断后,如何使用 resume 功能继续训练,并将我们复现的模型与Model Zoo中的

3.比 HTTP 更安全的 HTTPS(工作原理理解、非对称加密理解、证书理解)

所谓的协议 协议只是一种规则,你不按规则来就无法和目标方进行你的工作 协议说白了只是人定的规则,任何人都可以定协议 我们不需要太了解细节,这些制定和完善协议的人去做的,我们只需要知道协议的一个大概 HTTPS 协议 1、概述 HTTPS(Hypertext Transfer Protocol Secure)是一种安全的超文本传输协议,主要用于在客户端和服务器之间安全地传输数据

第十章 【后端】环境准备(10.4)——Vagrant

10.4 Vagrant Vagrant 官网 Vagrant 镜像仓库 下载 安装 直接 install。 设置环境变量 Vagrant 默认将镜像保存在用户文件夹的 .vagrant.d 目录下,若用户文件夹在C盘,下载的镜像文件会大量占用C盘空间。设置环境变量 VAGRANT_HOME 后,Vagrant 会将镜像保存到环境变量指定的文件夹下。

以太网交换机工作原理学习笔记

在网络中传输数据时需要遵循一些标准,以太网协议定义了数据帧在以太网上的传输标准,了解以太网协议是充分理解数据链路层通信的基础。以太网交换机是实现数据链路层通信的主要设备,了解以太网交换机的工作原理也是十分必要的。 1、以太网协议介绍 1.1以太网协议 以太网是当今现有局域网(Local Area Network, LAN)采用的最通用的通信协议标准,该标准定义了在局域网中采用的电缆类型和信号