review flowable 的代码实现,测试通过

pull/2/head
YunaiV 2022-02-28 00:58:11 +08:00
parent b845d62e8b
commit 3201288036
19 changed files with 1396 additions and 39 deletions

1329
sql/bpm_flowable.sql Normal file

File diff suppressed because one or more lines are too long

View File

@ -16,16 +16,22 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- flowable 工作流相关 -->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-basic</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
</project>
</project>

View File

@ -32,6 +32,10 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>

View File

@ -8,7 +8,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* Api
* Activiti Api
*
* @author
*/

View File

@ -93,5 +93,4 @@ public class BpmModelController {
bpmModelService.updateModelState(reqVO.getId(), reqVO.getState());
return success(true);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;
@ -15,6 +16,7 @@ import java.util.Set;
public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript {
@Override
@DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
return calculateTaskCandidateUsers(task, 1);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;
@ -15,6 +16,7 @@ import java.util.Set;
public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript {
@Override
@DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
return calculateTaskCandidateUsers(task, 2);
}

View File

@ -21,18 +21,18 @@
<artifactId>yudao-module-bpm-base</artifactId>
<version>${revision}</version>
</dependency>
<!-- 工作流相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-flowable</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-actuator</artifactId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -7,6 +7,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* Flowable Api
*

View File

@ -55,5 +55,4 @@ public class BpmTaskAssignRuleController {
taskAssignRuleService.updateTaskAssignRule(reqVO);
return success(true);
}
}

View File

@ -1,24 +1,22 @@
package cn.iocoder.yudao.module.bpm.framework.flowable.config;
import cn.hutool.core.collection.ListUtil;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmActivityBehaviorFactory;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.BpmProcessInstanceEventListener;
import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* BPM Flowable
*
@ -28,26 +26,23 @@ import java.util.List;
public class BpmFlowableConfiguration {
/**
* Flowable engines
* @param listeners listener
* @param bpmActivityBehaviorFactory ActivityBehaviorFactory
* BPM ProcessEngineConfigurationConfigurer
*
* 1.
* 2. ActivityBehaviorFactory
*/
@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> addCustomerListenerConfigurer (ObjectProvider<FlowableEventListener> listeners,
BpmActivityBehaviorFactory bpmActivityBehaviorFactory) {
return engineConfiguration -> {
List<FlowableEventListener> eventListeners = new ArrayList<>();
Iterator<FlowableEventListener> iterator = listeners.iterator();
while (iterator.hasNext()) {
eventListeners.add(iterator.next());
}
engineConfiguration.setEventListeners(eventListeners);
engineConfiguration.setActivityBehaviorFactory(bpmActivityBehaviorFactory);
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> bpmProcessEngineConfigurationConfigurer(
ObjectProvider<FlowableEventListener> listeners,
BpmActivityBehaviorFactory bpmActivityBehaviorFactory) {
return configuration -> {
// 注册监听器,例如说 BpmActivitiEventListener
configuration.setEventListeners(ListUtil.toList(listeners.iterator()));
// 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义
configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory);
};
}
@Bean
public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService,
BpmUserGroupService userGroupService,

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.datapermission.core.dept.rule.DeptDataPermissionRule;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;
@ -17,7 +16,7 @@ import java.util.Set;
public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript {
@Override
@DataPermission(excludeRules = DeptDataPermissionRule.class)
@DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
return calculateTaskCandidateUsers(task, 1);
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.datapermission.core.dept.rule.DeptDataPermissionRule;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;
@ -18,8 +17,7 @@ public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScri
@Override
//不需要处理数据权限, 不然会有问题,查询不到数据
@DataPermission(excludeRules = DeptDataPermissionRule.class)
@DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
return calculateTaskCandidateUsers(task, 2);
}

View File

@ -0,0 +1,6 @@
/**
* bpm framework
*
* @author
*/
package cn.iocoder.yudao.module.bpm.framework;

View File

@ -281,5 +281,4 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
processDefinitionDOMap, formMap), definitionCount);
}
}

View File

@ -47,12 +47,17 @@
<artifactId>yudao-module-pay-impl</artifactId>
<version>${revision}</version>
</dependency>
<!-- 默认引入 bpm-activiti 实现,可以替换为 bpm-flowable 实现-->
<!-- 默认引入 yudao-module-bpm-impl-flowable 实现,可以替换为 yudao-module-bpm-impl-activiti 实现-->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-impl-activiti</artifactId>
<artifactId>yudao-module-bpm-impl-flowable</artifactId>
<version>${revision}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-bpm-impl-activiti</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- spring boot 配置所需依赖 -->
<dependency>

View File

@ -43,13 +43,15 @@ spring:
primary: master
datasource:
master:
name: ruoyi-vue-pro
# name: ruoyi-vue-pro
name: ruoyi-vue-pro-flowable
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 123456
slave: # 模拟从库,可根据自己需要修改
name: ruoyi-vue-pro
# name: ruoyi-vue-pro
name: ruoyi-vue-pro-flowable
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root

View File

@ -27,10 +27,21 @@ spring:
# 3. create_drop: 启动时自动创建表,关闭时自动删除表
# 4. drop_create: 启动时,删除旧表,再创建新表
database-schema-update: false # 设置为 false可通过 sql/activiti.sql 初始化
db-history-used: true # activiti7 默认不生成历史信息表,需手动设置开启
db-history-used: true # activiti7 默认 false 不生成历史信息表,需手动设置开启
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
# 工作流 Flowable 配置
flowable:
# 1. false: 默认值activiti启动时对比数据库表中保存的版本如果不匹配。将抛出异常
# 2. true: 启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表
# 3. create_drop: 启动时自动创建表,关闭时自动删除表
# 4. drop_create: 启动时,删除旧表,再创建新表
database-schema-update: false # 设置为 false可通过 https://github.com/flowable/flowable-sql 初始化
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
# MyBatis Plus 的配置项
mybatis-plus:
configuration: