# warm-flow工作流
**Repository Path**: xldc/warm-flow
## Basic Information
- **Project Name**: warm-flow工作流
- **Description**: 🎉国产自研工作流,使用极其简单的,但又五脏俱全,并且只有6张表,一个小时就可以看完整个设计。
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: https://warm_4.gitee.io/warm-flow-doc/#/
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 744
- **Created**: 2024-03-27
- **Last Updated**: 2024-03-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 介绍
🎉国产自研工作流,使用极其简单的,但又五脏俱全,并且只有6张表,一个小时就可以看完整个设计。
1. 支持简单的流程流转,比如跳转、回退、审批
2. 支持角色、部门和用户等权限配置
3. 官方提供简单流程封装demo项目,很实用
4. 支持多租户
5. 支持代办任务和已办任务,通过权限标识过滤数据
6. 支持互斥网关,并行网关(会签、或签)
7. 可退回任意节点
8. 支持条件表达式,可扩展
9. 同时支持spring和solon
10. 兼容java8和java17,理论11也可以
11. 支持不同orm框架和数据库扩展
12. 支持增加监听器,参数传递
> **希望一键三连,你的⭐️ Star ⭐️是我持续开发的动力,项目也活的更长**
> **可二开、商用,但请注明出处,保留代码注释中的作者名**
> **联系方式:qq群:778470567**,微信:warm-houhou
>
> **[gitee地址](https://gitee.com/warm_4/warm-flow.git )** |**[github地址](https://github.com/minliuhua/warm-flow.git)**
## 使用文档
[使用文档](https://warm_4.gitee.io/warm-flow-doc/#/)
**demo项目**:
springboot:[RuoYi-Vue-Warm-Flow](https://gitee.com/min290/hh-vue) |[演示地址](http://www.hhzai.top:81)
solon:[warm-sun](https://gitee.com/min290/warm-sun.git) |[演示地址](http://www.warm-sun.vip)
## 快速开始
在开始之前,我们假定您已经:
* 熟悉 Java 环境配置及其开发
* 熟悉 关系型 数据库,比如 MySQL
* 熟悉 Spring Boot或者Solon 及相关框架
* 熟悉 Java 构建工具,比如 Maven
### 导入sql,按需求执行增量脚本
> **如果第一次导入,请先创建数据库,并导入:https://gitee.com/warm_4/warm-flow/blob/master/sql/warm-flow.sql**
> **如果需要增量更细,请按需导入:https://gitee.com/warm_4/warm-flow/blob/master/sql/warm-flow_xxx.sql**
### maven依赖
**springboot项目**
```maven
io.github.minliuhua
warm-flow-mybatis-sb-starter
最新版本
```
**solon项目**
```maven
io.github.minliuhua
warm-flow-mybatis-solon-plugin
最新版本
```
### 支持数据库类型
* [x] mysql
* [ ] oracle
* [ ] sqlserver
* [ ] ......
### 支持orm框架类型
* [x] mybatis及其增强组件
* [ ] jpa
* [ ] easy-query
* [ ] wood
* [ ] sqltoy
* [ ] beetlsql
* [ ] ......
> **有想扩展其他orm框架和数据库的可加qq群联系群主**
### 代码示例
https://gitee.com/min290/hh-vue/blob/master/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/FlowTest.java
#### 部署流程
```java
public void deployFlow() throws Exception {
String path = "/Users/minliuhua/Desktop/mdata/file/IdeaProjects/min/hh-vue/hh-admin/src/main/resources/leaveFlow-serial.xml";
System.out.println("已部署流程的id:" + defService.importXml(new FileInputStream(path)).getId());
}
```
#### 发布流程
```java
public void publish() throws Exception {
defService.publish(1212437969554771968L);
}
```
#### 开启流程
```java
public void startFlow() {
System.out.println("已开启的流程实例id:" + insService.start("1", getUser()).getId());
}
```
#### 流程流转
```java
public void skipFlow() throws Exception {
// 通过实例id流转
Instance instance = insService.skipByInsId(1219286332141080576L, getUser().skipType(SkipType.PASS.getKey())
.permissionFlag(Arrays.asList("role:1", "role:2")));
System.out.println("流转后流程实例:" + instance.toString());
// // 通过任务id流转
// Instance instance = insService.skip(1219286332145274880L, getUser().skipType(SkipType.PASS.getKey())
// .permissionFlag(Arrays.asList("role:1", "role:2")));
// System.out.println("流转后流程实例:" + instance.toString());
}
public void skipAnyNode() throws Exception {
// 跳转到指定节点
Instance instance = insService.skip(1219286332145274880L, getUser().skipType(SkipType.PASS.getKey())
.permissionFlag(Arrays.asList("role:1", "role:2")).nodeCode("4"));
System.out.println("流转后流程实例:" + instance.toString());
}
```
#### 参数传递
```java
// 流程变量
Map variable = new HashMap<>();
variable.put("testLeave", testLeave);
flowParams.variable(variable);
Instance instance = insService.skip(taskId, flowParams);
```
#### 监听器
实现Listener接口,然后在设计器中配置好监听器
```java
public class FinishListener implements Listener {
@Resource
private TestLeaveMapper testLeaveMapper;
private static final Logger log = LoggerFactory.getLogger(StartListener.class);
@Override
public void notify(ListenerVariable variable) {
log.info("完成监听器:{}", variable);
Instance instance = variable.getInstance();
Map testLeaveMap = variable.getVariable();
TestLeave testLeave = (TestLeave) testLeaveMap.get("testLeave");
/** 如果{@link com.ruoyi.system.service.impl.TestLeaveServiceImpl}中更新了,这里就不用更新了*/
// testLeave.setNodeCode(instance.getNodeCode());
// testLeave.setNodeName(instance.getNodeName());
// testLeave.setFlowStatus(instance.getFlowStatus());
// testLeave.setUpdateTime(DateUtils.getNowDate());
// testLeaveMapper.updateTestLeave(testLeave);
log.info("完成监听器结束;{}", "任务完成");
}
}
```
## 你可以请作者喝杯咖啡表示鼓励

### 特别感谢JetBrains对开源项目支持