review flowable 的代码实现,测试通过
parent
b845d62e8b
commit
3201288036
File diff suppressed because one or more lines are too long
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 流程实例 Api 实现类
|
||||
* Activiti 流程实例 Api 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
|
|
@ -93,5 +93,4 @@ public class BpmModelController {
|
|||
bpmModelService.updateModelState(reqVO.getId(), reqVO.getState());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* Flowable 流程实例 Api 实现类
|
||||
*
|
||||
|
|
|
@ -55,5 +55,4 @@ public class BpmTaskAssignRuleController {
|
|||
taskAssignRuleService.updateTaskAssignRule(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* 属于 bpm 模块的 framework 封装
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
package cn.iocoder.yudao.module.bpm.framework;
|
|
@ -281,5 +281,4 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||
processDefinitionDOMap, formMap), definitionCount);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue