diff --git a/pom.xml b/pom.xml
index 5f3320a22..e5986837e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
yudao-framework
-
+ yudao-module-bpm
yudao-module-system
yudao-module-infra
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/TenantProperties.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/TenantProperties.java
index a23ccd341..7cb813ca9 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/TenantProperties.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/TenantProperties.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.tenant.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import java.util.Collections;
import java.util.Set;
/**
@@ -29,13 +30,13 @@ public class TenantProperties {
*
* 默认情况下,每个请求需要带上 tenant-id 的请求头。但是,部分请求是无需带上的,例如说短信回调、支付回调等 Open API!
*/
- private Set ignoreUrls;
+ private Set ignoreUrls = Collections.emptySet();
/**
* 需要忽略多租户的表
*
* 即默认所有表都开启多租户的功能,所以记得添加对应的 tenant_id 字段哟
*/
- private Set ignoreTables;
+ private Set ignoreTables = Collections.emptySet();
}
diff --git a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java
index 3621d9d99..b41f678d6 100644
--- a/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java
+++ b/yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/util/FlowableUtils.java
@@ -59,4 +59,15 @@ public class FlowableUtils {
BpmnXMLConverter converter = new BpmnXMLConverter();
return converter.convertToXML(model);
}
+
+ // ========== Execution 相关的工具方法 ==========
+
+ public static String formatCollectionVariable(String activityId) {
+ return activityId + "_assignees";
+ }
+
+ public static String formatCollectionElementVariable(String activityId) {
+ return activityId + "_assignee";
+ }
+
}
diff --git a/yudao-gateway/src/main/resources/application.yaml b/yudao-gateway/src/main/resources/application.yaml
index 6d4439553..29d9576a6 100644
--- a/yudao-gateway/src/main/resources/application.yaml
+++ b/yudao-gateway/src/main/resources/application.yaml
@@ -23,3 +23,7 @@ spring:
uri: grayLb://infra-server
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
- Path=/app-api/infra/**
+ - id: bpm-admin-api # 路由的编号
+ uri: grayLb://bpm-server
+ predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
+ - Path=/admin-api/bpm/**
diff --git a/yudao-module-bpm/pom.xml b/yudao-module-bpm/pom.xml
new file mode 100644
index 000000000..432b97ae4
--- /dev/null
+++ b/yudao-module-bpm/pom.xml
@@ -0,0 +1,27 @@
+
+
+
+ cn.iocoder.cloud
+ yudao
+ ${revision}
+
+ 4.0.0
+
+ yudao-module-bpm-api
+ yudao-module-bpm-biz
+
+ yudao-module-bpm
+ pom
+
+ ${project.artifactId}
+
+ bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。
+ 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等
+ bpm 解释:https://baike.baidu.com/item/BPM/1933
+
+ 工作流基于 Flowable 6 实现,分成流程定义、流程表单、流程实例、流程任务等功能模块。
+
+
+
diff --git a/yudao-module-bpm/yudao-module-bpm-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-api/pom.xml
new file mode 100644
index 000000000..ba89fc7f6
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ cn.iocoder.cloud
+ yudao-module-bpm
+ ${revision}
+
+ 4.0.0
+ yudao-module-bpm-api
+ jar
+
+ ${project.artifactId}
+
+ bpm 模块 API,暴露给其它模块调用
+
+
+
+
+ cn.iocoder.cloud
+ yudao-common
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+ true
+
+
+
+
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java
new file mode 100644
index 000000000..37a92219f
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * bpm API 包,定义暴露给其它模块的 API
+ */
+package cn.iocoder.yudao.module.bpm.api;
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java
new file mode 100644
index 000000000..e94a2c84f
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.bpm.api.task;
+
+import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
+
+import javax.validation.Valid;
+
+/**
+ * 流程实例 Api 接口
+ *
+ * @author 芋道源码
+ */
+public interface BpmProcessInstanceApi {
+
+ /**
+ * 创建流程实例(提供给内部)
+ *
+ * @param userId 用户编号
+ * @param reqDTO 创建信息
+ * @return 实例的编号
+ */
+ String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java
new file mode 100644
index 000000000..5d7edbe80
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.bpm.api.task.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.Map;
+
+/**
+ * 流程实例的创建 Request DTO
+ *
+ * @author 芋道源码
+ */
+@Data
+public class BpmProcessInstanceCreateReqDTO {
+
+ /**
+ * 流程定义的标识
+ */
+ @NotEmpty(message = "流程定义的标识不能为空")
+ private String processDefinitionKey;
+ /**
+ * 变量实例
+ */
+ private Map variables;
+
+ /**
+ * 业务的唯一标识
+ *
+ * 例如说,请假申请的编号。通过它,可以查询到对应的实例
+ */
+ @NotEmpty(message = "业务的唯一标识")
+ private String businessKey;
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java
new file mode 100644
index 000000000..7abb3e1db
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java
@@ -0,0 +1,13 @@
+package cn.iocoder.yudao.module.bpm.enums;
+
+/**
+ * BPM 字典类型的枚举类
+ *
+ * @author 芋道源码
+ */
+public interface DictTypeConstants {
+
+ String TASK_ASSIGN_RULE_TYPE = "bpm_task_assign_rule_type"; // 任务分配规则类型
+ String TASK_ASSIGN_SCRIPT = "bpm_task_assign_script"; // 任务分配自定义脚本
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
new file mode 100644
index 000000000..9451f6d49
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
@@ -0,0 +1,64 @@
+package cn.iocoder.yudao.module.bpm.enums;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+
+/**
+ * 工作流 错误码枚举类
+ *
+ * 工作流系统,使用 1-009-000-000 段
+ */
+public interface ErrorCodeConstants {
+
+ // ========== 通用流程处理 模块 1-009-000-000 ==========
+ ErrorCode HIGHLIGHT_IMG_ERROR = new ErrorCode(1009000002, "获取高亮流程图异常");
+
+ // ========== OA 流程模块 1-009-001-000 ==========
+ ErrorCode OA_LEAVE_NOT_EXISTS = new ErrorCode(1009001001, "请假申请不存在");
+ ErrorCode OA_PM_POST_NOT_EXISTS = new ErrorCode(1009001002, "项目经理岗位未设置");
+ ErrorCode OA_DEPART_PM_POST_NOT_EXISTS = new ErrorCode(1009001009, "部门的项目经理不存在");
+ ErrorCode OA_BM_POST_NOT_EXISTS = new ErrorCode(1009001004, "部门经理岗位未设置");
+ ErrorCode OA_DEPART_BM_POST_NOT_EXISTS = new ErrorCode(1009001005, "部门的部门经理不存在");
+ ErrorCode OA_HR_POST_NOT_EXISTS = new ErrorCode(1009001006, "HR岗位未设置");
+ ErrorCode OA_DAY_LEAVE_ERROR = new ErrorCode(1009001007, "请假天数必须>=1");
+
+ // ========== 流程模型 1-009-002-000 ==========
+ ErrorCode MODEL_KEY_EXISTS = new ErrorCode(1009002000, "已经存在流程标识为【{}】的流程");
+ ErrorCode MODEL_NOT_EXISTS = new ErrorCode(1009002001, "流程模型不存在");
+ ErrorCode MODEL_KEY_VALID = new ErrorCode(1009002002, "流程标识格式不正确,需要以字母或下划线开头,后接任意字母、数字、中划线、下划线、句点!");
+ ErrorCode MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG = new ErrorCode(1009002003, "部署流程失败,原因:流程表单未配置,请点击【修改流程】按钮进行配置");
+ ErrorCode MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG = new ErrorCode(1009002004, "部署流程失败," +
+ "原因:用户任务({})未配置分配规则,请点击【修改流程】按钮进行配置");
+ ErrorCode MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS = new ErrorCode(1009003005, "流程定义部署失败,原因:信息未发生变化");
+
+ // ========== 流程定义 1-009-003-000 ==========
+ ErrorCode PROCESS_DEFINITION_KEY_NOT_MATCH = new ErrorCode(1009003000, "流程定义的标识期望是({}),当前是({}),请修改 BPMN 流程图");
+ ErrorCode PROCESS_DEFINITION_NAME_NOT_MATCH = new ErrorCode(1009003001, "流程定义的名字期望是({}),当前是({}),请修改 BPMN 流程图");
+ ErrorCode PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1009003002, "流程定义不存在");
+ ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1009003003, "流程定义处于挂起状态");
+ ErrorCode PROCESS_DEFINITION_BPMN_MODEL_NOT_EXISTS = new ErrorCode(1009003004, "流程定义的模型不存在");
+
+ // ========== 流程实例 1-009-004-000 ==========
+ ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1009004000, "流程实例不存在");
+ ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004001, "流程取消失败,流程不处于运行中");
+ ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1009004002, "流程取消失败,该流程不是你发起的");
+
+ // ========== 流程任务 1-009-005-000 ==========
+ ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009005000, "审批任务失败,原因:该任务不处于未审批");
+ ErrorCode TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1009005001, "审批任务失败,原因:该任务的审批人不是你");
+
+ // ========== 流程任务分配规则 1-009-006-000 ==========
+ ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1009006000, "流程({}) 的任务({}) 已经存在分配规则");
+ ErrorCode TASK_ASSIGN_RULE_NOT_EXISTS = new ErrorCode(1009006001, "流程任务分配规则不存在");
+ ErrorCode TASK_UPDATE_FAIL_NOT_MODEL = new ErrorCode(1009006002, "只有流程模型的任务分配规则,才允许被修改");
+ ErrorCode TASK_CREATE_FAIL_NO_CANDIDATE_USER = new ErrorCode(1009006003, "操作失败,原因:找不到任务的审批人!");
+ ErrorCode TASK_ASSIGN_SCRIPT_NOT_EXISTS = new ErrorCode(1009006004, "操作失败,原因:任务分配脚本({}) 不存在");
+
+ // ========== 动态表单模块 1-009-010-000 ==========
+ ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
+ ErrorCode FORM_FIELD_REPEAT = new ErrorCode(1009010001, "表单项({}) 和 ({}) 使用了相同的字段名({})");
+
+ // ========== 用户组模块 1-009-011-000 ==========
+ ErrorCode USER_GROUP_NOT_EXISTS = new ErrorCode(1009011000, "用户组不存在");
+ ErrorCode USER_GROUP_IS_DISABLE = new ErrorCode(1009011001, "名字为【{}】的用户组已被禁用");
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java
new file mode 100644
index 000000000..c21d6f999
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.enums.definition;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * BPM 模型的表单类型的枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmModelFormTypeEnum {
+
+ NORMAL(10, "流程表单"), // 对应 BpmFormDO
+ CUSTOM(20, "业务表单") // 业务自己定义的表单,自己进行数据的存储
+ ;
+
+ private final Integer type;
+ private final String desc;
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java
new file mode 100644
index 000000000..b7ccc7ae8
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.bpm.enums.definition;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * BPM 任务分配规则的类型枚举
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmTaskAssignRuleTypeEnum {
+
+ ROLE(10, "角色"),
+ DEPT_MEMBER(20, "部门的成员"), // 包括负责人
+ DEPT_LEADER(21, "部门的负责人"),
+ POST(22, "岗位"),
+ USER(30, "用户"),
+ USER_GROUP(40, "用户组"),
+ SCRIPT(50, "自定义脚本"), // 例如说,发起人所在部门的领导、发起人所在部门的领导的领导
+ ;
+
+ /**
+ * 类型
+ */
+ private final Integer type;
+ /**
+ * 描述
+ */
+ private final String desc;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java
new file mode 100644
index 000000000..7fc0e3b8b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.bpm.enums.definition;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * BPM 任务规则的脚本枚举
+ * 目前暂时通过 TODO 芋艿:硬编码,未来可以考虑 Groovy 动态脚本的方式
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmTaskRuleScriptEnum {
+
+ START_USER(10L, "流程发起人"),
+
+ LEADER_X1(20L, "流程发起人的一级领导"),
+ LEADER_X2(21L, "流程发起人的二级领导");
+
+ /**
+ * 脚本编号
+ */
+ private final Long id;
+ /**
+ * 脚本描述
+ */
+ private final String desc;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java
new file mode 100644
index 000000000..79001fccd
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.enums.message;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Bpm 消息的枚举
+ *
+ * @author 芋道源码
+ */
+@AllArgsConstructor
+@Getter
+public enum BpmMessageEnum {
+
+ PROCESS_INSTANCE_APPROVE("bpm_process_instance_approve"), // 流程任务被审批通过时,发送给申请人
+ PROCESS_INSTANCE_REJECT("bpm_process_instance_reject"), // 流程任务被审批不通过时,发送给申请人
+ TASK_ASSIGNED("bpm_task_assigned"); // 任务被分配时,发送给审批人
+
+ /**
+ * 短信模板的标识
+ *
+ * 关联 SmsTemplateDO 的 code 属性
+ */
+ private final String smsTemplateCode;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java
new file mode 100644
index 000000000..4f99d0a3d
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java
@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.bpm.enums.task;
+
+import cn.hutool.core.util.StrUtil;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 流程实例的删除原因
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmProcessInstanceDeleteReasonEnum {
+
+ REJECT_TASK("不通过任务,原因:{}"), // 修改文案时,需要注意 isRejectReason 方法
+ CANCEL_TASK("主动取消任务,原因:{}"),
+
+ // ========== 流程任务的独有原因 ==========
+ MULTI_TASK_END("系统自动取消,原因:多任务审批已经满足条件,无需审批该任务"), // 多实例满足 condition 而结束时,其它任务实例任务会被取消,对应的删除原因是 MI_END
+
+ ;
+
+ private final String reason;
+
+ /**
+ * 格式化理由
+ *
+ * @param args 参数
+ * @return 理由
+ */
+ public String format(Object... args) {
+ return StrUtil.format(reason, args);
+ }
+
+ // ========== 逻辑 ==========
+
+ public static boolean isRejectReason(String reason) {
+ return StrUtil.startWith(reason, "不通过任务,原因:");
+ }
+
+ /**
+ * 将 Flowable 的删除原因,翻译成对应的中文原因
+ *
+ * @param reason 原始原因
+ * @return 原因
+ */
+ public static String translateReason(String reason) {
+ if (StrUtil.isEmpty(reason)) {
+ return reason;
+ }
+ switch (reason) {
+ case "MI_END": return MULTI_TASK_END.getReason();
+ default: return reason;
+ }
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java
new file mode 100644
index 000000000..3b57554cf
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java
@@ -0,0 +1,48 @@
+package cn.iocoder.yudao.module.bpm.enums.task;
+
+import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 流程实例的结果
+ *
+ * @author jason
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmProcessInstanceResultEnum {
+
+ PROCESS(1, "处理中"),
+ APPROVE(2, "通过"),
+ REJECT(3, "不通过"),
+ CANCEL(4, "已取消"),
+
+ // ========== 流程任务独有的状态 ==========
+
+ BACK(5, "退回/驳回");
+
+ /**
+ * 结果
+ *
+ * 如果新增时,注意 {@link #isEndResult(Integer)} 是否需要变更
+ */
+ private final Integer result;
+ /**
+ * 描述
+ */
+ private final String desc;
+
+ /**
+ * 判断该结果是否已经处于 End 最终结果
+ *
+ * 主要用于一些结果更新的逻辑,如果已经是最终结果,就不再进行更新
+ *
+ * @param result 结果
+ * @return 是否
+ */
+ public static boolean isEndResult(Integer result) {
+ return ObjectUtils.equalsAny(result, APPROVE.getResult(), REJECT.getResult(), CANCEL.getResult(), BACK.getResult());
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java
new file mode 100644
index 000000000..70a31dd34
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.bpm.enums.task;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 流程实例的状态
+ *
+ * @author 芋道源码
+ */
+@Getter
+@AllArgsConstructor
+public enum BpmProcessInstanceStatusEnum {
+
+ RUNNING(1, "进行中"),
+ FINISH(2, "已完成");
+
+ /**
+ * 状态
+ */
+ private final Integer status;
+ /**
+ * 描述
+ */
+ private final String desc;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/pom.xml b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml
new file mode 100644
index 000000000..b168de28e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/pom.xml
@@ -0,0 +1,125 @@
+
+
+
+ cn.iocoder.cloud
+ yudao-module-bpm
+ ${revision}
+
+ 4.0.0
+ yudao-module-bpm-biz
+
+ ${project.artifactId}
+
+ bpm-base 模块,实现公用的工作流的逻辑,提供给 bpm-activiti 和 bpm-flowable 复用
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+ cn.iocoder.cloud
+ yudao-module-bpm-api
+ ${revision}
+
+
+ cn.iocoder.cloud
+ yudao-module-system-api
+ ${revision}
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-biz-operatelog
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-biz-data-permission
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-biz-tenant
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-biz-error-code
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-security
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-mybatis
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-redis
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-rpc
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-job
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-mq
+
+
+
+
+
+
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-test
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-monitor
+
+
+
+
+ cn.iocoder.cloud
+ yudao-spring-boot-starter-flowable
+
+
+
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java
new file mode 100644
index 000000000..d86a045a2
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/BpmServerApplication.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.bpm;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 项目的启动类
+ *
+ * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ * 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ *
+ * @author 芋道源码
+ */
+@SpringBootApplication
+public class BpmServerApplication {
+
+ public static void main(String[] args) {
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+
+ SpringApplication.run(BpmServerApplication.class, args);
+
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ // 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java
new file mode 100644
index 000000000..2137e2203
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * bpm API 实现类,定义暴露给其它模块的 API
+ */
+package cn.iocoder.yudao.module.bpm.api;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java
new file mode 100644
index 000000000..596c9981a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java
@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.bpm.api.task;
+
+import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+/**
+ * Flowable 流程实例 Api 实现类
+ *
+ * @author 芋道源码
+ * @author jason
+ */
+@Service
+@Validated
+public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi {
+
+ @Resource
+ private BpmProcessInstanceService processInstanceService;
+
+ @Override
+ public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO reqDTO) {
+ return processInstanceService.createProcessInstance(userId, reqDTO);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java
new file mode 100644
index 000000000..217067f31
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java
@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.*;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmFormConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 动态表单")
+@RestController
+@RequestMapping("/bpm/form")
+@Validated
+public class BpmFormController {
+
+ @Resource
+ private BpmFormService formService;
+
+ @PostMapping("/create")
+ @ApiOperation("创建动态表单")
+ @PreAuthorize("@ss.hasPermission('bpm:form:create')")
+ public CommonResult createForm(@Valid @RequestBody BpmFormCreateReqVO createReqVO) {
+ return success(formService.createForm(createReqVO));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation("更新动态表单")
+ @PreAuthorize("@ss.hasPermission('bpm:form:update')")
+ public CommonResult updateForm(@Valid @RequestBody BpmFormUpdateReqVO updateReqVO) {
+ formService.updateForm(updateReqVO);
+ return success(true);
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("删除动态表单")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('bpm:form:delete')")
+ public CommonResult deleteForm(@RequestParam("id") Long id) {
+ formService.deleteForm(id);
+ return success(true);
+ }
+
+ @GetMapping("/get")
+ @ApiOperation("获得动态表单")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('bpm:form:query')")
+ public CommonResult getForm(@RequestParam("id") Long id) {
+ BpmFormDO form = formService.getForm(id);
+ return success(BpmFormConvert.INSTANCE.convert(form));
+ }
+
+ @GetMapping("/list-all-simple")
+ @ApiOperation(value = "获得动态表单的精简列表", notes = "用于表单下拉框")
+ public CommonResult> getSimpleForms() {
+ List list = formService.getFormList();
+ return success(BpmFormConvert.INSTANCE.convertList2(list));
+ }
+
+ @GetMapping("/page")
+ @ApiOperation("获得动态表单分页")
+ @PreAuthorize("@ss.hasPermission('bpm:form:query')")
+ public CommonResult> getFormPage(@Valid BpmFormPageReqVO pageVO) {
+ PageResult pageResult = formService.getFormPage(pageVO);
+ return success(BpmFormConvert.INSTANCE.convertPage(pageResult));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
new file mode 100644
index 000000000..3dd0a0a4d
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
@@ -0,0 +1,97 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.io.IoUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import java.io.IOException;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 流程模型")
+@RestController
+@RequestMapping("/bpm/model")
+@Validated
+public class BpmModelController {
+
+ @Resource
+ private BpmModelService modelService;
+
+ @GetMapping("/page")
+ @ApiOperation(value = "获得模型分页")
+ public CommonResult> getModelPage(BpmModelPageReqVO pageVO) {
+ return success(modelService.getModelPage(pageVO));
+ }
+
+ @GetMapping("/get")
+ @ApiOperation("获得模型")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:model:query')")
+ public CommonResult getModel(@RequestParam("id") String id) {
+ BpmModelRespVO model = modelService.getModel(id);
+ return success(model);
+ }
+
+ @PostMapping("/create")
+ @ApiOperation(value = "新建模型")
+ @PreAuthorize("@ss.hasPermission('bpm:model:create')")
+ public CommonResult createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) {
+ return success(modelService.createModel(createRetVO, null));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation(value = "修改模型")
+ @PreAuthorize("@ss.hasPermission('bpm:model:update')")
+ public CommonResult updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) {
+ modelService.updateModel(modelVO);
+ return success(true);
+ }
+
+ @PostMapping("/import")
+ @ApiOperation(value = "导入模型")
+ @PreAuthorize("@ss.hasPermission('bpm:model:import')")
+ public CommonResult importModel(@Valid BpmModeImportReqVO importReqVO) throws IOException {
+ BpmModelCreateReqVO createReqVO = BpmModelConvert.INSTANCE.convert(importReqVO);
+ // 读取文件
+ String bpmnXml = IoUtils.readUtf8(importReqVO.getBpmnFile().getInputStream(), false);
+ return success(modelService.createModel(createReqVO, bpmnXml));
+ }
+
+ @PostMapping("/deploy")
+ @ApiOperation(value = "部署模型")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:model:deploy')")
+ public CommonResult deployModel(@RequestParam("id") String id) {
+ modelService.deployModel(id);
+ return success(true);
+ }
+
+ @PutMapping("/update-state")
+ @ApiOperation(value = "修改模型的状态", notes = "实际更新的部署的流程定义的状态")
+ @PreAuthorize("@ss.hasPermission('bpm:model:update')")
+ public CommonResult updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) {
+ modelService.updateModelState(reqVO.getId(), reqVO.getState());
+ return success(true);
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("删除模型")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:model:delete')")
+ public CommonResult deleteModel(@RequestParam("id") String id) {
+ modelService.deleteModel(id);
+ return success(true);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java
new file mode 100644
index 000000000..ebcaad05b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java
@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 流程定义")
+@RestController
+@RequestMapping("/bpm/process-definition")
+@Validated
+public class BpmProcessDefinitionController {
+
+ @Resource
+ private BpmProcessDefinitionService bpmDefinitionService;
+
+ @GetMapping("/page")
+ @ApiOperation(value = "获得流程定义分页")
+ @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')")
+ public CommonResult> getProcessDefinitionPage(
+ BpmProcessDefinitionPageReqVO pageReqVO) {
+ return success(bpmDefinitionService.getProcessDefinitionPage(pageReqVO));
+ }
+
+ @GetMapping ("/list")
+ @ApiOperation(value = "获得流程定义列表")
+ @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')")
+ public CommonResult> getProcessDefinitionList(
+ BpmProcessDefinitionListReqVO listReqVO) {
+ return success(bpmDefinitionService.getProcessDefinitionList(listReqVO));
+ }
+
+ @GetMapping ("/get-bpmn-xml")
+ @ApiOperation(value = "获得流程定义的 BPMN XML")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:process-definition:query')")
+ public CommonResult getProcessDefinitionBpmnXML(@RequestParam("id") String id) {
+ String bpmnXML = bpmDefinitionService.getProcessDefinitionBpmnXML(id);
+ return success(bpmnXML);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java
new file mode 100644
index 000000000..3e946707a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java
@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 任务分配规则")
+@RestController
+@RequestMapping("/bpm/task-assign-rule")
+@Validated
+public class BpmTaskAssignRuleController {
+
+ @Resource
+ private BpmTaskAssignRuleService taskAssignRuleService;
+
+ @GetMapping("/list")
+ @ApiOperation(value = "获得任务分配规则列表")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "modelId", value = "模型编号", example = "1024", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "processDefinitionId", value = "流程定义的编号", example = "2048", dataTypeClass = String.class)
+ })
+ @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:query')")
+ public CommonResult> getTaskAssignRuleList(
+ @RequestParam(value = "modelId", required = false) String modelId,
+ @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId) {
+ return success(taskAssignRuleService.getTaskAssignRuleList(modelId, processDefinitionId));
+ }
+
+ @PostMapping("/create")
+ @ApiOperation(value = "创建任务分配规则")
+ @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:create')")
+ public CommonResult createTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleCreateReqVO reqVO) {
+ return success(taskAssignRuleService.createTaskAssignRule(reqVO));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation(value = "更新任务分配规则")
+ @PreAuthorize("@ss.hasPermission('bpm:task-assign-rule:update')")
+ public CommonResult updateTaskAssignRule(@Valid @RequestBody BpmTaskAssignRuleUpdateReqVO reqVO) {
+ taskAssignRuleService.updateTaskAssignRule(reqVO);
+ return success(true);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java
new file mode 100644
index 000000000..4267f0902
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java
@@ -0,0 +1,85 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmUserGroupConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 用户组")
+@RestController
+@RequestMapping("/bpm/user-group")
+@Validated
+public class BpmUserGroupController {
+
+ @Resource
+ private BpmUserGroupService userGroupService;
+
+ @PostMapping("/create")
+ @ApiOperation("创建用户组")
+ @PreAuthorize("@ss.hasPermission('bpm:user-group:create')")
+ public CommonResult createUserGroup(@Valid @RequestBody BpmUserGroupCreateReqVO createReqVO) {
+ return success(userGroupService.createUserGroup(createReqVO));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation("更新用户组")
+ @PreAuthorize("@ss.hasPermission('bpm:user-group:update')")
+ public CommonResult updateUserGroup(@Valid @RequestBody BpmUserGroupUpdateReqVO updateReqVO) {
+ userGroupService.updateUserGroup(updateReqVO);
+ return success(true);
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("删除用户组")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('bpm:user-group:delete')")
+ public CommonResult deleteUserGroup(@RequestParam("id") Long id) {
+ userGroupService.deleteUserGroup(id);
+ return success(true);
+ }
+
+ @GetMapping("/get")
+ @ApiOperation("获得用户组")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('bpm:user-group:query')")
+ public CommonResult getUserGroup(@RequestParam("id") Long id) {
+ BpmUserGroupDO userGroup = userGroupService.getUserGroup(id);
+ return success(BpmUserGroupConvert.INSTANCE.convert(userGroup));
+ }
+
+ @GetMapping("/page")
+ @ApiOperation("获得用户组分页")
+ @PreAuthorize("@ss.hasPermission('bpm:user-group:query')")
+ public CommonResult> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) {
+ PageResult pageResult = userGroupService.getUserGroupPage(pageVO);
+ return success(BpmUserGroupConvert.INSTANCE.convertPage(pageResult));
+ }
+
+ @GetMapping("/list-all-simple")
+ @ApiOperation(value = "获取用户组精简信息列表", notes = "只包含被开启的用户组,主要用于前端的下拉选项")
+ public CommonResult> getSimpleUserGroups() {
+ // 获用户门列表,只要开启状态的
+ List list = userGroupService.getUserGroupListByStatus(CommonStatusEnum.ENABLE.getStatus());
+ // 排序后,返回给前端
+ return success(BpmUserGroupConvert.INSTANCE.convertList2(list));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java
new file mode 100644
index 000000000..11fee5c00
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+/**
+* 动态表单 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class BpmFormBaseVO {
+
+ @ApiModelProperty(value = "表单名称", required = true, example = "芋道")
+ @NotNull(message = "表单名称不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "表单状态", required = true, notes = "参见 CommonStatusEnum 枚举", example = "1")
+ @NotNull(message = "表单状态不能为空")
+ private Integer status;
+
+ @ApiModelProperty(value = "备注", example = "我是备注")
+ private String remark;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java
new file mode 100644
index 000000000..d9a628125
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import lombok.*;
+import io.swagger.annotations.*;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@ApiModel("管理后台 - 动态表单创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmFormCreateReqVO extends BpmFormBaseVO {
+
+ @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串")
+ @NotNull(message = "表单的配置不能为空")
+ private String conf;
+
+ @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组")
+ @NotNull(message = "表单项的数组不能为空")
+ private List fields;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java
new file mode 100644
index 000000000..a8097c437
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 动态表单分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmFormPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "表单名称", example = "芋道")
+ private String name;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java
new file mode 100644
index 000000000..76cf62046
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+import java.util.List;
+
+@ApiModel("管理后台 - 动态表单 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmFormRespVO extends BpmFormBaseVO {
+
+ @ApiModelProperty(value = "表单编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串")
+ @NotNull(message = "表单的配置不能为空")
+ private String conf;
+
+ @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组")
+ @NotNull(message = "表单项的数组不能为空")
+ private List fields;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java
new file mode 100644
index 000000000..3a6b3c093
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java
@@ -0,0 +1,17 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel("管理后台 - 流程表单精简 Response VO")
+@Data
+public class BpmFormSimpleRespVO {
+
+ @ApiModelProperty(value = "表单编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "表单名称", required = true, example = "芋道")
+ private String name;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java
new file mode 100644
index 000000000..55b997679
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+import java.util.List;
+
+@ApiModel("管理后台 - 动态表单更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmFormUpdateReqVO extends BpmFormBaseVO {
+
+ @ApiModelProperty(value = "表单编号", required = true, example = "1024")
+ @NotNull(message = "表单编号不能为空")
+ private Long id;
+
+ @ApiModelProperty(value = "表单的配置", required = true, notes = "JSON 字符串")
+ @NotNull(message = "表单的配置不能为空")
+ private String conf;
+
+ @ApiModelProperty(value = "表单项的数组", required = true, notes = "JSON 字符串的数组")
+ @NotNull(message = "表单项的数组不能为空")
+ private List fields;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java
new file mode 100644
index 000000000..e0dfe568e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java
@@ -0,0 +1,31 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+/**
+* 用户组 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class BpmUserGroupBaseVO {
+
+ @ApiModelProperty(value = "组名", required = true, example = "芋道")
+ @NotNull(message = "组名不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "描述", required = true, example = "芋道源码")
+ @NotNull(message = "描述不能为空")
+ private String description;
+
+ @ApiModelProperty(value = "成员编号数组", required = true, example = "1,2,3")
+ @NotNull(message = "成员编号数组不能为空")
+ private Set memberUserIds;
+
+ @ApiModelProperty(value = "状态", required = true, example = "1")
+ @NotNull(message = "状态不能为空")
+ private Integer status;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java
new file mode 100644
index 000000000..48b44d38b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java
@@ -0,0 +1,12 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import lombok.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 用户组创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmUserGroupCreateReqVO extends BpmUserGroupBaseVO {
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java
new file mode 100644
index 000000000..2bbe95192
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.util.date.DateUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 用户组分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmUserGroupPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "组名", example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "状态", example = "1")
+ private Integer status;
+
+ @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @ApiModelProperty(value = "创建时间")
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java
new file mode 100644
index 000000000..55018d502
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 用户组 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmUserGroupRespVO extends BpmUserGroupBaseVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java
new file mode 100644
index 000000000..0b47f447e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@ApiModel("管理后台 - 用户组精简信息 Response VO")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmUserGroupSimpleRespVO {
+
+ @ApiModelProperty(value = "用户组编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "用户组名字", required = true, example = "芋道")
+ private String name;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java
new file mode 100644
index 000000000..14aa25c5b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java
@@ -0,0 +1,17 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+@ApiModel("管理后台 - 用户组更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmUserGroupUpdateReqVO extends BpmUserGroupBaseVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ @NotNull(message = "编号不能为空")
+ private Long id;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java
new file mode 100644
index 000000000..7240ba15c
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.constraints.NotNull;
+
+@ApiModel(value = "管理后台 - 流程模型的导入 Request VO", description = "相比流程模型的新建来说,只是多了一个 bpmnFile 文件")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmModeImportReqVO extends BpmModelCreateReqVO {
+
+ @ApiModelProperty(value = "BPMN 文件", required = true)
+ @NotNull(message = "BPMN 文件不能为空")
+ private MultipartFile bpmnFile;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java
new file mode 100644
index 000000000..542a177e4
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java
@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+/**
+* 流程模型 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class BpmModelBaseVO {
+
+ @ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
+ @NotEmpty(message = "流程标识不能为空")
+ private String key;
+
+ @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
+ @NotEmpty(message = "流程名称不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "流程描述", example = "我是描述")
+ private String description;
+
+ @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
+ @NotEmpty(message = "流程分类不能为空")
+ private String category;
+
+ @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
+ private Integer formType;
+ @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private Long formId;
+ @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomCreatePath;
+ @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomViewPath;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java
new file mode 100644
index 000000000..c85ef3ae4
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.NotEmpty;
+
+@ApiModel("管理后台 - 流程模型的创建 Request VO")
+@Data
+public class BpmModelCreateReqVO {
+
+ @ApiModelProperty(value = "流程标识", required = true, example = "process_yudao")
+ @NotEmpty(message = "流程标识不能为空")
+ private String key;
+
+ @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
+ @NotEmpty(message = "流程名称不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "流程描述", example = "我是描述")
+ private String description;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java
new file mode 100644
index 000000000..7442b5ab0
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java
@@ -0,0 +1,49 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程模型的分页的每一项 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmModelPageItemRespVO extends BpmModelBaseVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "表单名字", example = "请假表单")
+ private String formName;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+ /**
+ * 最新部署的流程定义
+ */
+ private ProcessDefinition processDefinition;
+
+ @ApiModel("流程定义")
+ @Data
+ public static class ProcessDefinition {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "版本", required = true, example = "1")
+ private Integer version;
+
+ @ApiModelProperty(value = "部署时间", required = true)
+ private Date deploymentTime;
+
+ @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
+ private Integer suspensionState;
+
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java
new file mode 100644
index 000000000..945da139c
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+
+@ApiModel("管理后台 - 流程模型分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmModelPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "标识", example = "process1641042089407", notes = "精准匹配")
+ private String key;
+
+ @ApiModelProperty(value = "名字", example = "芋道", notes = "模糊匹配")
+ private String name;
+
+ @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
+ private String category;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java
new file mode 100644
index 000000000..bce0f9100
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程模型的创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmModelRespVO extends BpmModelBaseVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "BPMN XML", required = true)
+ private String bpmnXml;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java
new file mode 100644
index 000000000..972aa31bb
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+@ApiModel("管理后台 - 流程模型的更新 Request VO")
+@Data
+public class BpmModelUpdateReqVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ @NotEmpty(message = "编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "流程名称", example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "流程描述", example = "我是描述")
+ private String description;
+
+ @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
+ private String category;
+
+ @ApiModelProperty(value = "BPMN XML", required = true)
+ private String bpmnXml;
+
+ @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
+ private Integer formType;
+ @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private Long formId;
+ @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomCreatePath;
+ @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomViewPath;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java
new file mode 100644
index 000000000..9cfcebbdc
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@ApiModel("管理后台 - 流程模型更新状态 Request VO")
+@Data
+public class BpmModelUpdateStateReqVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ @NotNull(message = "编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SuspensionState 枚举")
+ @NotNull(message = "状态不能为空")
+ private Integer state;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java
new file mode 100644
index 000000000..5e45b8bde
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 流程定义列表 Request VO")
+@Data
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+public class BpmProcessDefinitionListReqVO extends PageParam {
+
+ @ApiModelProperty(value = "中断状态", example = "1", notes = "参见 SuspensionState 枚举")
+ private Integer suspensionState;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java
new file mode 100644
index 000000000..75990f08a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程定义的分页的每一项 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmProcessDefinitionPageItemRespVO extends BpmProcessDefinitionRespVO {
+
+ @ApiModelProperty(value = "表单名字", example = "请假表单")
+ private String formName;
+
+ @ApiModelProperty(value = "部署时间", required = true)
+ private Date deploymentTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java
new file mode 100644
index 000000000..a9657e9a2
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 流程定义分页 Request VO")
+@Data
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+public class BpmProcessDefinitionPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "标识", example = "process1641042089407", notes = "精准匹配")
+ private String key;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java
new file mode 100644
index 000000000..6f8fd4e5b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java
@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@ApiModel("管理后台 - 流程定义 Response VO")
+@Data
+public class BpmProcessDefinitionRespVO {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "版本", required = true, example = "1")
+ private Integer version;
+
+ @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
+ @NotEmpty(message = "流程名称不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "流程描述", example = "我是描述")
+ private String description;
+
+ @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
+ @NotEmpty(message = "流程分类不能为空")
+ private String category;
+
+ @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
+ private Integer formType;
+ @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private Long formId;
+ @ApiModelProperty(value = "表单的配置", required = true,
+ notes = "JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formConf;
+ @ApiModelProperty(value = "表单项的数组", required = true,
+ notes = "JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private List formFields;
+ @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomCreatePath;
+ @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomViewPath;
+
+ @ApiModelProperty(value = "中断状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
+ private Integer suspensionState;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java
new file mode 100644
index 000000000..bcb9fc0f0
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.Set;
+
+/**
+ * 流程任务分配规则 Base VO,提供给添加、修改、详细的子 VO 使用
+ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+ */
+@Data
+public class BpmTaskAssignRuleBaseVO {
+
+ @ApiModelProperty(value = "规则类型", required = true, example = "bpm_task_assign_rule_type")
+ @NotNull(message = "规则类型不能为空")
+ private Integer type;
+
+ @ApiModelProperty(value = "规则值数组", required = true, example = "1,2,3")
+ @NotNull(message = "规则值数组不能为空")
+ private Set options;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java
new file mode 100644
index 000000000..cbbc108c0
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.NotEmpty;
+
+@ApiModel("管理后台 - 流程任务分配规则的创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO {
+
+ @ApiModelProperty(value = "流程模型的编号", required = true, example = "1024")
+ @NotEmpty(message = "流程模型的编号不能为空")
+ private String modelId;
+
+ @ApiModelProperty(value = "流程任务定义的编号", required = true, example = "2048")
+ @NotEmpty(message = "流程任务定义的编号不能为空")
+ private String taskDefinitionKey;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java
new file mode 100644
index 000000000..c0786e52b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 流程任务分配规则的 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskAssignRuleRespVO extends BpmTaskAssignRuleBaseVO {
+
+ @ApiModelProperty(value = "任务分配规则的编号", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "流程模型的编号", required = true, example = "2048")
+ private String modelId;
+
+ @ApiModelProperty(value = "流程定义的编号", required = true, example = "4096")
+ private String processDefinitionId;
+
+ @ApiModelProperty(value = "流程任务定义的编号", required = true, example = "2048")
+ private String taskDefinitionKey;
+ @ApiModelProperty(value = "流程任务定义的名字", required = true, example = "关注芋道")
+ private String taskDefinitionName;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java
new file mode 100644
index 000000000..8f1c12701
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.NotNull;
+
+@ApiModel("管理后台 - 流程任务分配规则的更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskAssignRuleUpdateReqVO extends BpmTaskAssignRuleBaseVO {
+
+ @ApiModelProperty(value = "任务分配规则的编号", required = true, example = "1024")
+ @NotNull(message = "任务分配规则的编号不能为空")
+ private Long id;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http
new file mode 100644
index 000000000..96bbf964d
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http
@@ -0,0 +1,12 @@
+### 请求 /bpm/oa/leave/create 接口 => 成功
+POST {{baseUrl}}/bpm/oa/leave/create
+Content-Type: application/json
+tenant-id: 1
+Authorization: Bearer {{token}}
+
+{
+ "startTime": "2022-03-01",
+ "endTime": "2022-03-05",
+ "type": 1,
+ "reason": "我要请假啦啦啦!"
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java
new file mode 100644
index 000000000..dd66580d3
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java
@@ -0,0 +1,63 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.oa;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO;
+import cn.iocoder.yudao.module.bpm.convert.oa.BpmOALeaveConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
+
+/**
+ * OA 请假申请 Controller,用于演示自己存储数据,接入工作流的例子
+ *
+ * @author jason
+ * @author 芋道源码
+ */
+@Api(tags = "管理后台 - OA 请假申请")
+@RestController
+@RequestMapping("/bpm/oa/leave")
+@Validated
+public class BpmOALeaveController {
+
+ @Resource
+ private BpmOALeaveService leaveService;
+
+ @PostMapping("/create")
+ @PreAuthorize("@ss.hasPermission('bpm:oa-leave:create')")
+ @ApiOperation("创建请求申请")
+ public CommonResult createLeave(@Valid @RequestBody BpmOALeaveCreateReqVO createReqVO) {
+ return success(leaveService.createLeave(getLoginUserId(), createReqVO));
+ }
+
+ @GetMapping("/get")
+ @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')")
+ @ApiOperation("获得请假申请")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ public CommonResult getLeave(@RequestParam("id") Long id) {
+ BpmOALeaveDO leave = leaveService.getLeave(id);
+ return success(BpmOALeaveConvert.INSTANCE.convert(leave));
+ }
+
+ @GetMapping("/page")
+ @PreAuthorize("@ss.hasPermission('bpm:oa-leave:query')")
+ @ApiOperation("获得请假申请分页")
+ public CommonResult> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) {
+ PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO);
+ return success(BpmOALeaveConvert.INSTANCE.convertPage(pageResult));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java
new file mode 100644
index 000000000..7028708b1
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * OA 示例,用于演示外部业务接入 BPM 工作流的示例
+ * 一般的接入方式,只需要调用 接口,后续 Admin 用户在管理后台的【待办事务】进行审批
+ */
+package cn.iocoder.yudao.module.bpm.controller.admin.oa;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java
new file mode 100644
index 000000000..cbc568a11
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+* 请假申请 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class BpmOALeaveBaseVO {
+
+ @ApiModelProperty(value = "请假的开始时间", required = true)
+ @NotNull(message = "开始时间不能为空")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date startTime;
+ @ApiModelProperty(value = "请假的结束时间", required = true)
+ @NotNull(message = "结束时间不能为空")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date endTime;
+
+ @ApiModelProperty(value = "请假类型", required = true, example = "1", notes = "参见 bpm_oa_type 枚举")
+ private Integer type;
+
+ @ApiModelProperty(value = "原因", required = true, example = "阅读芋道源码")
+ private String reason;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java
new file mode 100644
index 000000000..2ebab63e9
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.AssertTrue;
+
+@ApiModel("管理后台 - 请假申请创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO {
+
+ @AssertTrue(message = "结束时间,需要在开始时间之后")
+ public boolean isEndTimeValid() {
+ return !getEndTime().before(getStartTime());
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java
new file mode 100644
index 000000000..2e49efaa1
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 请假申请分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmOALeavePageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "状态", example = "1", notes = "参见 bpm_process_instance_result 枚举")
+ private Integer result;
+
+ @ApiModelProperty(value = "请假类型", example = "1", notes = "参见 bpm_oa_type")
+ private Integer type;
+
+ @ApiModelProperty(value = "原因", example = "阅读芋道源码", notes = "模糊匹配")
+ private String reason;
+
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @ApiModelProperty(value = "申请时间")
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java
new file mode 100644
index 000000000..908c48e06
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java
@@ -0,0 +1,32 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 请假申请 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmOALeaveRespVO extends BpmOALeaveBaseVO {
+
+ @ApiModelProperty(value = "请假表单主键", required = true, example = "1024")
+ private Long id;
+
+ @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 bpm_process_instance_result 枚举")
+ private Integer result;
+
+ @ApiModelProperty(value = "申请时间", required = true)
+ @NotNull(message = "申请时间不能为空")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date createTime;
+
+ @ApiModelProperty(value = "流程id")
+ private String processInstanceId;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java
new file mode 100644
index 000000000..24d89cd36
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java
@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO;
+import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 流程活动实例")
+@RestController
+@RequestMapping("/bpm/activity")
+@Validated
+public class BpmActivityController {
+
+ @Resource
+ private BpmActivityService activityService;
+
+ @GetMapping("/list")
+ @ApiOperation(value = "生成指定流程实例的高亮流程图",
+ notes = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成")
+ @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:task:query')")
+ public CommonResult> getActivityList(
+ @RequestParam("processInstanceId") String processInstanceId) {
+ return success(activityService.getActivityListByProcessInstanceId(processInstanceId));
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
new file mode 100644
index 000000000..31abf7de1
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java
@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
+
+@Api(tags = "管理后台 - 流程实例") // 流程实例,通过流程定义创建的一次“申请”
+@RestController
+@RequestMapping("/bpm/process-instance")
+@Validated
+public class BpmProcessInstanceController {
+
+ @Resource
+ private BpmProcessInstanceService processInstanceService;
+
+ @GetMapping("/my-page")
+ @ApiOperation(value = "获得我的实例分页列表", notes = "在【我的流程】菜单中,进行调用")
+ @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
+ public CommonResult> getMyProcessInstancePage(
+ @Valid BpmProcessInstanceMyPageReqVO pageReqVO) {
+ return success(processInstanceService.getMyProcessInstancePage(getLoginUserId(), pageReqVO));
+ }
+
+ @PostMapping("/create")
+ @ApiOperation("新建流程实例")
+ @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
+ public CommonResult createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateReqVO createReqVO) {
+ return success(processInstanceService.createProcessInstance(getLoginUserId(), createReqVO));
+ }
+
+ @GetMapping("/get")
+ @ApiOperation(value = "获得指定流程实例", notes = "在【流程详细】界面中,进行调用")
+ @ApiImplicitParam(name = "id", value = "流程实例的编号", required = true, dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
+ public CommonResult getProcessInstance(@RequestParam("id") String id) {
+ return success(processInstanceService.getProcessInstanceVO(id));
+ }
+
+ @DeleteMapping("/cancel")
+ @ApiOperation(value = "取消流程实例", notes = "撤回发起的流程")
+ @PreAuthorize("@ss.hasPermission('bpm:process-instance:cancel')")
+ public CommonResult cancelProcessInstance(@Valid @RequestBody BpmProcessInstanceCancelReqVO cancelReqVO) {
+ processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO);
+ return success(true);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
new file mode 100644
index 000000000..eaa991f55
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
@@ -0,0 +1,78 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
+import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
+
+@Api(tags = "管理后台 - 流程任务实例")
+@RestController
+@RequestMapping("/bpm/task")
+@Validated
+public class BpmTaskController {
+
+ @Resource
+ private BpmTaskService taskService;
+
+ @GetMapping("todo-page")
+ @ApiOperation("获取 Todo 待办任务分页")
+ @PreAuthorize("@ss.hasPermission('bpm:task:query')")
+ public CommonResult> getTodoTaskPage(@Valid BpmTaskTodoPageReqVO pageVO) {
+ return success(taskService.getTodoTaskPage(getLoginUserId(), pageVO));
+ }
+
+ @GetMapping("done-page")
+ @ApiOperation("获取 Done 已办任务分页")
+ @PreAuthorize("@ss.hasPermission('bpm:task:query')")
+ public CommonResult> getDoneTaskPage(@Valid BpmTaskDonePageReqVO pageVO) {
+ return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO));
+ }
+
+ @GetMapping("/list-by-process-instance-id")
+ @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的")
+ @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class)
+ @PreAuthorize("@ss.hasPermission('bpm:task:query')")
+ public CommonResult> getTaskListByProcessInstanceId(
+ @RequestParam("processInstanceId") String processInstanceId) {
+ return success(taskService.getTaskListByProcessInstanceId(processInstanceId));
+ }
+
+ @PutMapping("/approve")
+ @ApiOperation("通过任务")
+ @PreAuthorize("@ss.hasPermission('bpm:task:update')")
+ public CommonResult approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
+ taskService.approveTask(getLoginUserId(), reqVO);
+ return success(true);
+ }
+
+ @PutMapping("/reject")
+ @ApiOperation("不通过任务")
+ @PreAuthorize("@ss.hasPermission('bpm:task:update')")
+ public CommonResult rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) {
+ taskService.rejectTask(getLoginUserId(), reqVO);
+ return success(true);
+ }
+
+ @PutMapping("/update-assignee")
+ @ApiOperation(value = "更新任务的负责人", notes = "用于【流程详情】的【转派】按钮")
+ @PreAuthorize("@ss.hasPermission('bpm:task:update')")
+ public CommonResult updateTaskAssignee(@Valid @RequestBody BpmTaskUpdateAssigneeReqVO reqVO) {
+ taskService.updateTaskAssignee(getLoginUserId(), reqVO);
+ return success(true);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java
new file mode 100644
index 000000000..ef9d11ac1
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程活动的 Response VO")
+@Data
+public class BpmActivityRespVO {
+
+ @ApiModelProperty(value = "流程活动的标识", required = true, example = "1024")
+ private String key;
+ @ApiModelProperty(value = "流程活动的类型", required = true, example = "StartEvent")
+ private String type;
+
+ @ApiModelProperty(value = "流程活动的开始时间", required = true)
+ private Date startTime;
+ @ApiModelProperty(value = "流程活动的结束时间", required = true)
+ private Date endTime;
+
+ @ApiModelProperty(value = "关联的流程任务的编号", example = "2048", notes = "关联的流程任务,只有 UserTask 等类型才有")
+ private String taskId;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java
new file mode 100644
index 000000000..928f187e7
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.Map;
+
+@ApiModel("管理后台 - 流程实例的取消 Request VO")
+@Data
+public class BpmProcessInstanceCancelReqVO {
+
+ @ApiModelProperty(value = "流程实例的编号", required = true, example = "1024")
+ @NotEmpty(message = "流程实例的编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "取消原因", required = true, example = "不请假了!")
+ @NotEmpty(message = "取消原因不能为空")
+ private String reason;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java
new file mode 100644
index 000000000..2085253d3
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.Map;
+
+@ApiModel("管理后台 - 流程实例的创建 Request VO")
+@Data
+public class BpmProcessInstanceCreateReqVO {
+
+ @ApiModelProperty(value = "流程定义的编号", required = true, example = "1024")
+ @NotEmpty(message = "流程定义编号不能为空")
+ private String processDefinitionId;
+
+ @ApiModelProperty(value = "变量实例")
+ private Map variables;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java
new file mode 100644
index 000000000..db297e268
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 流程实例的分页 Item Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmProcessInstanceMyPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "流程名称", example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "流程定义的编号", example = "2048")
+ private String processDefinitionId;
+
+ @ApiModelProperty(value = "流程实例的状态", notes = "参见 bpm_process_instance_status", example = "1")
+ private Integer status;
+
+ @ApiModelProperty(value = "流程实例的结果", notes = "参见 bpm_process_instance_result", example = "2")
+ private Integer result;
+
+ @ApiModelProperty(value = "流程分类", notes = "参见 bpm_model_category 数据字典", example = "1")
+ private String category;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java
new file mode 100644
index 000000000..5b5d5797a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java
@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@ApiModel("管理后台 - 流程实例的分页 Item Response VO")
+@Data
+public class BpmProcessInstancePageItemRespVO {
+
+ @ApiModelProperty(value = "流程实例的编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "流程定义的编号", required = true, example = "2048")
+ private String processDefinitionId;
+
+ @ApiModelProperty(value = "流程分类", required = true, notes = "参见 bpm_model_category 数据字典", example = "1")
+ private String category;
+
+ @ApiModelProperty(value = "流程实例的状态", required = true, notes = "参见 bpm_process_instance_status", example = "1")
+ private Integer status;
+
+ @ApiModelProperty(value = "流程实例的结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
+ private Integer result;
+
+ @ApiModelProperty(value = "提交时间", required = true)
+ private Date createTime;
+
+ @ApiModelProperty(value = "结束时间", required = true)
+ private Date endTime;
+
+ /**
+ * 当前任务
+ */
+ private List tasks;
+
+ @ApiModel("流程任务")
+ @Data
+ public static class Task {
+
+ @ApiModelProperty(value = "流程任务的编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "任务名称", required = true, example = "芋道")
+ private String name;
+
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java
new file mode 100644
index 000000000..a1547b175
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java
@@ -0,0 +1,97 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@ApiModel("管理后台 - 流程实例的 Response VO")
+@Data
+public class BpmProcessInstanceRespVO {
+
+ @ApiModelProperty(value = "流程实例的编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "流程名称", required = true, example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "流程分类", required = true, notes = "参见 bpm_model_category 数据字典", example = "1")
+ private String category;
+
+ @ApiModelProperty(value = "流程实例的状态", required = true, notes = "参见 bpm_process_instance_status", example = "1")
+ private Integer status;
+
+ @ApiModelProperty(value = "流程实例的结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
+ private Integer result;
+
+ @ApiModelProperty(value = "提交时间", required = true)
+ private Date createTime;
+
+ @ApiModelProperty(value = "结束时间", required = true)
+ private Date endTime;
+
+ @ApiModelProperty(value = "提交的表单值", required = true)
+ private Map formVariables;
+
+ @ApiModelProperty(value = "业务的唯一标识", example = "1", notes = "例如说,请假申请的编号")
+ private String businessKey;
+
+ /**
+ * 发起流程的用户
+ */
+ private User startUser;
+
+ /**
+ * 流程定义
+ */
+ private ProcessDefinition processDefinition;
+
+ @ApiModel("用户信息")
+ @Data
+ public static class User {
+
+ @ApiModelProperty(value = "用户编号", required = true, example = "1")
+ private Long id;
+ @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
+ private String nickname;
+
+ @ApiModelProperty(value = "部门编号", required = true, example = "1")
+ private Long deptId;
+ @ApiModelProperty(value = "部门名称", required = true, example = "研发部")
+ private String deptName;
+
+ }
+
+ @ApiModel("流程定义信息")
+ @Data
+ public static class ProcessDefinition {
+
+ @ApiModelProperty(value = "编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
+ private Integer formType;
+ @ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private Long formId;
+ @ApiModelProperty(value = "表单的配置", required = true,
+ notes = "JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formConf;
+ @ApiModelProperty(value = "表单项的数组", required = true,
+ notes = "JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private List formFields;
+ @ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomCreatePath;
+ @ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
+ notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
+ private String formCustomViewPath;
+
+ @ApiModelProperty(value = "BPMN XML", required = true)
+ private String bpmnXml;
+
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java
new file mode 100644
index 000000000..1b6a69066
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+@ApiModel("管理后台 - 通过流程任务的 Request VO")
+@Data
+public class BpmTaskApproveReqVO {
+
+ @ApiModelProperty(value = "任务编号", required = true, example = "1024")
+ @NotEmpty(message = "任务编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "审批意见", required = true, example = "不错不错!")
+ @NotEmpty(message = "审批意见不能为空")
+ private String reason;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java
new file mode 100644
index 000000000..c5e2c23ae
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程任务的 Done 已完成的分页项 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskDonePageItemRespVO extends BpmTaskTodoPageItemRespVO {
+
+ @ApiModelProperty(value = "结束时间", required = true)
+ private Date endTime;
+ @ApiModelProperty(value = "持续时间", required = true, example = "1000")
+ private Long durationInMillis;
+
+ @ApiModelProperty(value = "任务结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
+ private Integer result;
+ @ApiModelProperty(value = "审批建议", required = true, example = "不请假了!")
+ private String reason;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java
new file mode 100644
index 000000000..99145b434
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java
@@ -0,0 +1,32 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 流程任务的 Done 已办的分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskDonePageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "流程任务名", example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "开始的创建收间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date beginCreateTime;
+
+ @ApiModelProperty(value = "结束的创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date endCreateTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java
new file mode 100644
index 000000000..596a82f77
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+
+@ApiModel("管理后台 - 不通过流程任务的 Request VO")
+@Data
+public class BpmTaskRejectReqVO {
+
+ @ApiModelProperty(value = "任务编号", required = true, example = "1024")
+ @NotEmpty(message = "任务编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "审批意见", required = true, example = "不错不错!")
+ @NotEmpty(message = "审批意见不能为空")
+ private String reason;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java
new file mode 100644
index 000000000..1f7d2c7fa
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java
@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+@ApiModel("管理后台 - 流程任务的 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO {
+
+ @ApiModelProperty(value = "任务定义的标识", required = true, example = "user-001")
+ private String definitionKey;
+
+ /**
+ * 审核的用户信息
+ */
+ private User assigneeUser;
+
+ @ApiModel("用户信息")
+ @Data
+ public static class User {
+
+ @ApiModelProperty(value = "用户编号", required = true, example = "1")
+ private Long id;
+ @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
+ private String nickname;
+
+ @ApiModelProperty(value = "部门编号", required = true, example = "1")
+ private Long deptId;
+ @ApiModelProperty(value = "部门名称", required = true, example = "研发部")
+ private String deptName;
+
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java
new file mode 100644
index 000000000..e25e3aa49
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java
@@ -0,0 +1,54 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@ApiModel("管理后台 - 流程任务的 Running 进行中的分页项 Response VO")
+@Data
+public class BpmTaskTodoPageItemRespVO {
+
+ @ApiModelProperty(value = "任务编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "任务名字", required = true, example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "接收时间", required = true)
+ private Date claimTime;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+ @ApiModelProperty(value = "激活状态", required = true, example = "1", notes = "参见 SuspensionState 枚举")
+ private Integer suspensionState;
+
+ /**
+ * 所属流程实例
+ */
+ private ProcessInstance processInstance;
+
+ @Data
+ @ApiModel("流程实例")
+ public static class ProcessInstance {
+
+ @ApiModelProperty(value = "流程实例编号", required = true, example = "1024")
+ private String id;
+
+ @ApiModelProperty(value = "流程实例名称", required = true, example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "发起人的用户编号", required = true, example = "1024")
+ private Long startUserId;
+
+ @ApiModelProperty(value = "发起人的用户昵称", required = true, example = "芋艿")
+ private String startUserNickname;
+
+ @ApiModelProperty(value = "流程定义的编号", required = true, example = "2048")
+ private String processDefinitionId;
+
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java
new file mode 100644
index 000000000..9f248e198
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java
@@ -0,0 +1,32 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 流程任务的 TODO 待办的分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskTodoPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "流程任务名", example = "芋道")
+ private String name;
+
+ @ApiModelProperty(value = "开始的创建收间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date beginCreateTime;
+
+ @ApiModelProperty(value = "结束的创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date endCreateTime;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java
new file mode 100644
index 000000000..0dd0ffed4
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import net.bytebuddy.implementation.bind.annotation.Empty;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@ApiModel("管理后台 - 流程任务的更新负责人的 Request VO")
+@Data
+public class BpmTaskUpdateAssigneeReqVO {
+
+ @ApiModelProperty(value = "任务编号", required = true, example = "1024")
+ @NotEmpty(message = "任务编号不能为空")
+ private String id;
+
+ @ApiModelProperty(value = "新审批人的用户编号", required = true, example = "2048")
+ @NotNull(message = "新审批人的用户编号不能为空")
+ private Long assigneeUserId;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java
new file mode 100644
index 000000000..e8d285e35
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 占位
+ */
+package cn.iocoder.yudao.module.bpm.controller.app;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java
new file mode 100644
index 000000000..d1930bd6a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 提供 RESTful API 给前端:
+ * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目
+ * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分
+ */
+package cn.iocoder.yudao.module.bpm.controller;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java
new file mode 100644
index 000000000..6ba757417
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.bpm.convert.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormSimpleRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+ * 动态表单 Convert
+ *
+ * @author 芋艿
+ */
+@Mapper
+public interface BpmFormConvert {
+
+ BpmFormConvert INSTANCE = Mappers.getMapper(BpmFormConvert.class);
+
+ BpmFormDO convert(BpmFormCreateReqVO bean);
+
+ BpmFormDO convert(BpmFormUpdateReqVO bean);
+
+ BpmFormRespVO convert(BpmFormDO bean);
+
+ List convertList2(List list);
+
+ PageResult convertPage(PageResult page);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java
new file mode 100644
index 000000000..4d1b2a003
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java
@@ -0,0 +1,140 @@
+package cn.iocoder.yudao.module.bpm.convert.definition;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
+import org.flowable.common.engine.impl.db.SuspensionState;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.Model;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.mapstruct.Mapper;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 流程模型 Convert
+ *
+ * @author yunlongn
+ */
+@Mapper
+public interface BpmModelConvert {
+
+ BpmModelConvert INSTANCE = Mappers.getMapper(BpmModelConvert.class);
+
+ default List convertList(List list, Map formMap,
+ Map deploymentMap,
+ Map processDefinitionMap) {
+ return CollectionUtils.convertList(list, model -> {
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
+ BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
+ Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null;
+ ProcessDefinition processDefinition = model.getDeploymentId() != null ? processDefinitionMap.get(model.getDeploymentId()) : null;
+ return convert(model, form, deployment, processDefinition);
+ });
+ }
+
+ default BpmModelPageItemRespVO convert(Model model, BpmFormDO form, Deployment deployment, ProcessDefinition processDefinition) {
+ BpmModelPageItemRespVO modelRespVO = new BpmModelPageItemRespVO();
+ modelRespVO.setId(model.getId());
+ modelRespVO.setCreateTime(model.getCreateTime());
+ // 通用 copy
+ copyTo(model, modelRespVO);
+ // Form
+ if (form != null) {
+ modelRespVO.setFormId(form.getId());
+ modelRespVO.setFormName(form.getName());
+ }
+ // ProcessDefinition
+ modelRespVO.setProcessDefinition(this.convert(processDefinition));
+ if (modelRespVO.getProcessDefinition() != null) {
+ modelRespVO.getProcessDefinition().setSuspensionState(processDefinition.isSuspended() ?
+ SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
+ modelRespVO.getProcessDefinition().setDeploymentTime(deployment.getDeploymentTime());
+ }
+ return modelRespVO;
+ }
+
+ default BpmModelRespVO convert(Model model) {
+ BpmModelRespVO modelRespVO = new BpmModelRespVO();
+ modelRespVO.setId(model.getId());
+ modelRespVO.setCreateTime(model.getCreateTime());
+ // 通用 copy
+ copyTo(model, modelRespVO);
+ return modelRespVO;
+ }
+
+ default void copyTo(Model model, BpmModelBaseVO to) {
+ to.setName(model.getName());
+ to.setKey(model.getKey());
+ to.setCategory(model.getCategory());
+ // metaInfo
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
+ copyTo(metaInfo, to);
+ }
+
+ BpmModelCreateReqVO convert(BpmModeImportReqVO bean);
+
+ default BpmProcessDefinitionCreateReqDTO convert2(Model model, BpmFormDO form) {
+ BpmProcessDefinitionCreateReqDTO createReqDTO = new BpmProcessDefinitionCreateReqDTO();
+ createReqDTO.setModelId(model.getId());
+ createReqDTO.setName(model.getName());
+ createReqDTO.setKey(model.getKey());
+ createReqDTO.setCategory(model.getCategory());
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
+ // metaInfo
+ copyTo(metaInfo, createReqDTO);
+ // form
+ if (form != null) {
+ createReqDTO.setFormConf(form.getConf());
+ createReqDTO.setFormFields(form.getFields());
+ }
+ return createReqDTO;
+ }
+
+ void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmProcessDefinitionCreateReqDTO to);
+
+ void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to);
+
+ BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean);
+
+ default void copy(Model model, BpmModelCreateReqVO bean) {
+ model.setName(bean.getName());
+ model.setKey(bean.getKey());
+ model.setMetaInfo(buildMetaInfoStr(null, bean.getDescription(), null, null,
+ null, null));
+ }
+
+ default void copy(Model model, BpmModelUpdateReqVO bean) {
+ model.setName(bean.getName());
+ model.setCategory(bean.getCategory());
+ model.setMetaInfo(buildMetaInfoStr(JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class),
+ bean.getDescription(), bean.getFormType(), bean.getFormId(),
+ bean.getFormCustomCreatePath(), bean.getFormCustomViewPath()));
+ }
+
+ default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo, String description, Integer formType,
+ Long formId, String formCustomCreatePath, String formCustomViewPath) {
+ if (metaInfo == null) {
+ metaInfo = new BpmModelMetaInfoRespDTO();
+ }
+ // 只有非空,才进行设置,避免更新时的覆盖
+ if (StrUtil.isNotEmpty(description)) {
+ metaInfo.setDescription(description);
+ }
+ if (Objects.nonNull(formType)) {
+ metaInfo.setFormType(formType);
+ metaInfo.setFormId(formId);
+ metaInfo.setFormCustomCreatePath(formCustomCreatePath);
+ metaInfo.setFormCustomViewPath(formCustomViewPath);
+ }
+ return JsonUtils.toJsonString(metaInfo);
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java
new file mode 100644
index 000000000..8f5bfcd26
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java
@@ -0,0 +1,82 @@
+package cn.iocoder.yudao.module.bpm.convert.definition;
+
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
+import org.flowable.common.engine.impl.db.SuspensionState;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.Named;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Bpm 流程定义的 Convert
+ *
+ * @author yunlong.li
+ */
+@Mapper
+public interface BpmProcessDefinitionConvert {
+
+ BpmProcessDefinitionConvert INSTANCE = Mappers.getMapper(BpmProcessDefinitionConvert.class);
+
+ BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean);
+
+ BpmProcessDefinitionExtDO convert2(BpmProcessDefinitionCreateReqDTO bean);
+
+ default List convertList(List list, Map deploymentMap,
+ Map processDefinitionDOMap, Map formMap) {
+ return CollectionUtils.convertList(list, definition -> {
+ Deployment deployment = definition.getDeploymentId() != null ? deploymentMap.get(definition.getDeploymentId()) : null;
+ BpmProcessDefinitionExtDO definitionDO = processDefinitionDOMap.get(definition.getId());
+ BpmFormDO form = definitionDO != null ? formMap.get(definitionDO.getFormId()) : null;
+ return convert(definition, deployment, definitionDO, form);
+ });
+ }
+
+ default List convertList3(List list,
+ Map processDefinitionDOMap) {
+ return CollectionUtils.convertList(list, processDefinition -> {
+ BpmProcessDefinitionRespVO respVO = convert3(processDefinition);
+ BpmProcessDefinitionExtDO processDefinitionExtDO = processDefinitionDOMap.get(processDefinition.getId());
+ // 复制通用属性
+ copyTo(processDefinitionExtDO, respVO);
+ return respVO;
+ });
+ }
+
+ @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")
+ BpmProcessDefinitionRespVO convert3(ProcessDefinition bean);
+
+ @Named("convertSuspendedToSuspensionState")
+ default Integer convertSuspendedToSuspensionState(boolean suspended) {
+ return suspended ? SuspensionState.SUSPENDED.getStateCode() :
+ SuspensionState.ACTIVE.getStateCode();
+ }
+
+ default BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean, Deployment deployment,
+ BpmProcessDefinitionExtDO processDefinitionExtDO, BpmFormDO form) {
+ BpmProcessDefinitionPageItemRespVO respVO = convert(bean);
+ respVO.setSuspensionState(bean.isSuspended() ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode());
+ if (deployment != null) {
+ respVO.setDeploymentTime(deployment.getDeploymentTime());
+ }
+ if (form != null) {
+ respVO.setFormName(form.getName());
+ }
+ // 复制通用属性
+ copyTo(processDefinitionExtDO, respVO);
+ return respVO;
+ }
+
+ @Mapping(source = "from.id", target = "to.id", ignore = true)
+ void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessDefinitionRespVO to);
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java
new file mode 100644
index 000000000..c616e90b0
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.bpm.convert.definition;
+
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
+import org.flowable.bpmn.model.UserTask;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface BpmTaskAssignRuleConvert {
+ BpmTaskAssignRuleConvert INSTANCE = Mappers.getMapper(BpmTaskAssignRuleConvert.class);
+
+ default List convertList(List tasks, List rules) {
+ Map ruleMap = CollectionUtils.convertMap(rules, BpmTaskAssignRuleDO::getTaskDefinitionKey);
+ // 以 UserTask 为主维度,原因是:流程图编辑后,一些规则实际就没用了。
+ return CollectionUtils.convertList(tasks, task -> {
+ BpmTaskAssignRuleRespVO respVO = convert(ruleMap.get(task.getId()));
+ if (respVO == null) {
+ respVO = new BpmTaskAssignRuleRespVO();
+ respVO.setTaskDefinitionKey(task.getId());
+ }
+ respVO.setTaskDefinitionName(task.getName());
+ return respVO;
+ });
+ }
+
+ BpmTaskAssignRuleRespVO convert(BpmTaskAssignRuleDO bean);
+
+ BpmTaskAssignRuleDO convert(BpmTaskAssignRuleCreateReqVO bean);
+
+ BpmTaskAssignRuleDO convert(BpmTaskAssignRuleUpdateReqVO bean);
+
+ List convertList2(List list);
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java
new file mode 100644
index 000000000..bbf00ba52
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java
@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.module.bpm.convert.definition;
+
+import java.util.*;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import org.mapstruct.Mapper;
+import org.mapstruct.Named;
+import org.mapstruct.factory.Mappers;
+
+/**
+ * 用户组 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmUserGroupConvert {
+
+ BpmUserGroupConvert INSTANCE = Mappers.getMapper(BpmUserGroupConvert.class);
+
+ BpmUserGroupDO convert(BpmUserGroupCreateReqVO bean);
+
+ BpmUserGroupDO convert(BpmUserGroupUpdateReqVO bean);
+
+ BpmUserGroupRespVO convert(BpmUserGroupDO bean);
+
+ List convertList(List list);
+
+ PageResult convertPage(PageResult page);
+
+ @Named("convertList2")
+ List convertList2(List list);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java
new file mode 100644
index 000000000..92683f4c9
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java
@@ -0,0 +1,16 @@
+package cn.iocoder.yudao.module.bpm.convert.message;
+
+import cn.iocoder.yudao.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.Map;
+
+@Mapper
+public interface BpmMessageConvert {
+
+ BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class);
+
+ SmsSendSingleToUserReqDTO convert(Long userId, String templateCode, Map templateParams);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java
new file mode 100644
index 000000000..f87531bfc
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.bpm.convert.oa;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveRespVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+ * 请假申请 Convert
+ *
+ * @author 芋艿
+ */
+@Mapper
+public interface BpmOALeaveConvert {
+
+ BpmOALeaveConvert INSTANCE = Mappers.getMapper(BpmOALeaveConvert.class);
+
+ BpmOALeaveDO convert(BpmOALeaveCreateReqVO bean);
+
+ BpmOALeaveRespVO convert(BpmOALeaveDO bean);
+
+ List convertList(List list);
+
+ PageResult convertPage(PageResult page);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java
new file mode 100644
index 000000000..6db6ebc46
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 提供 POJO 类的实体转换
+ *
+ * 目前使用 MapStruct 框架
+ */
+package cn.iocoder.yudao.module.bpm.convert;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java
new file mode 100644
index 000000000..509408457
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.bpm.convert.task;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO;
+import org.flowable.engine.history.HistoricActivityInstance;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.Mappings;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+
+/**
+ * BPM 活动 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmActivityConvert {
+
+ BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class);
+
+ List convertList(List list);
+
+ @Mappings({
+ @Mapping(source = "activityId", target = "key"),
+ @Mapping(source = "activityType", target = "type")
+ })
+ BpmActivityRespVO convert(HistoricActivityInstance bean);
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java
new file mode 100644
index 000000000..a1eea62e9
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java
@@ -0,0 +1,114 @@
+package cn.iocoder.yudao.module.bpm.convert.task;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstancePageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
+import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
+import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
+import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingTarget;
+import org.mapstruct.factory.Mappers;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 流程实例 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmProcessInstanceConvert {
+
+ BpmProcessInstanceConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceConvert.class);
+
+ default PageResult convertPage(PageResult page,
+ Map> taskMap) {
+ List list = convertList(page.getList());
+ list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId()))));
+ return new PageResult<>(list, page.getTotal());
+ }
+
+ List convertList(List list);
+
+ @Mapping(source = "processInstanceId", target = "id")
+ BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean);
+
+ List convertList2(List tasks);
+
+ default BpmProcessInstanceRespVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt,
+ ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt,
+ String bpmnXml, AdminUserRespDTO startUser, DeptRespDTO dept) {
+ BpmProcessInstanceRespVO respVO = convert2(processInstance);
+ copyTo(processInstanceExt, respVO);
+ // definition
+ respVO.setProcessDefinition(convert2(processDefinition));
+ copyTo(processDefinitionExt, respVO.getProcessDefinition());
+ respVO.getProcessDefinition().setBpmnXml(bpmnXml);
+ // user
+ if (startUser != null) {
+ respVO.setStartUser(convert2(startUser));
+ if (dept != null) {
+ respVO.getStartUser().setDeptName(dept.getName());
+ }
+ }
+ return respVO;
+ }
+
+ BpmProcessInstanceRespVO convert2(HistoricProcessInstance bean);
+
+ @Mapping(source = "from.id", target = "to.id", ignore = true)
+ void copyTo(BpmProcessInstanceExtDO from, @MappingTarget BpmProcessInstanceRespVO to);
+
+ BpmProcessInstanceRespVO.ProcessDefinition convert2(ProcessDefinition bean);
+
+ @Mapping(source = "from.id", target = "to.id", ignore = true)
+ void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to);
+
+ BpmProcessInstanceRespVO.User convert2(AdminUserRespDTO bean);
+
+ default BpmProcessInstanceResultEvent convert(Object source, HistoricProcessInstance instance, Integer result) {
+ BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source);
+ event.setId(instance.getId());
+ event.setProcessDefinitionKey(instance.getProcessDefinitionKey());
+ event.setBusinessKey(instance.getBusinessKey());
+ event.setResult(result);
+ return event;
+ }
+
+ default BpmProcessInstanceResultEvent convert(Object source, ProcessInstance instance, Integer result) {
+ BpmProcessInstanceResultEvent event = new BpmProcessInstanceResultEvent(source);
+ event.setId(instance.getId());
+ event.setProcessDefinitionKey(instance.getProcessDefinitionKey());
+ event.setBusinessKey(instance.getBusinessKey());
+ event.setResult(result);
+ return event;
+ }
+
+ default BpmMessageSendWhenProcessInstanceApproveReqDTO convert2ApprovedReq(ProcessInstance instance){
+ return new BpmMessageSendWhenProcessInstanceApproveReqDTO()
+ .setStartUserId(NumberUtils.parseLong(instance.getStartUserId()))
+ .setProcessInstanceId(instance.getId())
+ .setProcessInstanceName(instance.getName());
+ }
+
+ default BpmMessageSendWhenProcessInstanceRejectReqDTO convert2RejectReq(ProcessInstance instance, String reason) {
+ return new BpmMessageSendWhenProcessInstanceRejectReqDTO()
+ .setProcessInstanceName(instance.getName())
+ .setProcessInstanceId(instance.getId())
+ .setReason(reason)
+ .setStartUserId(NumberUtils.parseLong(instance.getStartUserId()));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
new file mode 100644
index 000000000..91d405925
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
@@ -0,0 +1,168 @@
+package cn.iocoder.yudao.module.bpm.convert.task;
+
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskDonePageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskTodoPageItemRespVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
+import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import org.flowable.common.engine.impl.db.SuspensionState;
+import org.flowable.engine.history.HistoricProcessInstance;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.flowable.task.api.Task;
+import org.flowable.task.api.history.HistoricTaskInstance;
+import org.mapstruct.*;
+import org.mapstruct.factory.Mappers;
+import org.springframework.beans.BeanUtils;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Bpm 任务 Convert
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmTaskConvert {
+
+ BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class);
+
+ /**
+ * 复制对象
+ *
+ * @param source 源 要复制的对象
+ * @param target 目标 复制到此对象
+ * @param
+ *
+ * @return
+ */
+ public static T copy(Object source, Class target) {
+ if (source == null || target == null) {
+ return null;
+ }
+ try {
+ T newInstance = target.newInstance();
+ BeanUtils.copyProperties(source, newInstance);
+ return newInstance;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ default List copyList(List source, Class target) {
+ if (null == source || source.isEmpty()) {
+ return Collections.emptyList();
+ }
+ return source.stream().map(e -> copy(e, target)).collect(Collectors.toList());
+ }
+
+ default List convertList1(List tasks,
+ Map processInstanceMap, Map userMap) {
+ return CollectionUtils.convertList(tasks, task -> {
+ BpmTaskTodoPageItemRespVO respVO = convert1(task);
+ ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId());
+ if (processInstance != null) {
+ AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
+ respVO.setProcessInstance(convert(processInstance, startUser));
+ }
+ return respVO;
+ });
+ }
+
+ @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")
+ BpmTaskTodoPageItemRespVO convert1(Task bean);
+
+ @Named("convertSuspendedToSuspensionState")
+ default Integer convertSuspendedToSuspensionState(boolean suspended) {
+ return suspended ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode();
+ }
+
+ default List convertList2(List tasks,
+ Map bpmTaskExtDOMap, Map historicProcessInstanceMap,
+ Map userMap) {
+ return CollectionUtils.convertList(tasks, task -> {
+ BpmTaskDonePageItemRespVO respVO = convert2(task);
+ BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
+ copyTo(taskExtDO, respVO);
+ HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId());
+ if (processInstance != null) {
+ AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
+ respVO.setProcessInstance(convert(processInstance, startUser));
+ }
+ return respVO;
+ });
+ }
+
+ BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean);
+
+ @Mappings({@Mapping(source = "processInstance.id", target = "id"),
+ @Mapping(source = "processInstance.name", target = "name"),
+ @Mapping(source = "processInstance.startUserId", target = "startUserId"),
+ @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),
+ @Mapping(source = "startUser.nickname", target = "startUserNickname")})
+ BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser);
+
+ default List convertList3(List tasks,
+ Map bpmTaskExtDOMap, HistoricProcessInstance processInstance,
+ Map userMap, Map deptMap) {
+ return CollectionUtils.convertList(tasks, task -> {
+ BpmTaskRespVO respVO = convert3(task);
+ BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
+ copyTo(taskExtDO, respVO);
+ if (processInstance != null) {
+ AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
+ respVO.setProcessInstance(convert(processInstance, startUser));
+ }
+ AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee()));
+ if (assignUser != null) {
+ respVO.setAssigneeUser(convert3(assignUser));
+ DeptRespDTO dept = deptMap.get(assignUser.getDeptId());
+ if (dept != null) {
+ respVO.getAssigneeUser().setDeptName(dept.getName());
+ }
+ }
+ return respVO;
+ });
+ }
+
+ @Mapping(source = "taskDefinitionKey", target = "definitionKey")
+ BpmTaskRespVO convert3(HistoricTaskInstance bean);
+
+ BpmTaskRespVO.User convert3(AdminUserRespDTO bean);
+
+ @Mapping(target = "id", ignore = true)
+ void copyTo(BpmTaskExtDO from, @MappingTarget BpmTaskDonePageItemRespVO to);
+
+ @Mappings({@Mapping(source = "processInstance.id", target = "id"),
+ @Mapping(source = "processInstance.name", target = "name"),
+ @Mapping(source = "processInstance.startUserId", target = "startUserId"),
+ @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),
+ @Mapping(source = "startUser.nickname", target = "startUserNickname")})
+ BpmTaskTodoPageItemRespVO.ProcessInstance convert(HistoricProcessInstance processInstance,
+ AdminUserRespDTO startUser);
+
+ default BpmTaskExtDO convert2TaskExt(Task task) {
+ BpmTaskExtDO taskExtDO = new BpmTaskExtDO().setTaskId(task.getId())
+ .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())).setName(task.getName())
+ .setProcessDefinitionId(task.getProcessDefinitionId()).setProcessInstanceId(task.getProcessInstanceId());
+ taskExtDO.setCreateTime(task.getCreateTime());
+ return taskExtDO;
+ }
+
+ default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser,
+ Task task) {
+ BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO();
+ reqDTO.setProcessInstanceId(processInstance.getProcessInstanceId())
+ .setProcessInstanceName(processInstance.getName()).setStartUserId(startUser.getId())
+ .setStartUserNickname(startUser.getNickname()).setTaskId(task.getId()).setTaskName(task.getName())
+ .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee()));
+ return reqDTO;
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java
new file mode 100644
index 000000000..6a53114a8
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java
@@ -0,0 +1 @@
+package cn.iocoder.yudao.module.bpm.convert.task;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md
new file mode 100644
index 000000000..8153487b7
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md
@@ -0,0 +1 @@
+
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java
new file mode 100644
index 000000000..76bf777e5
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java
@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.*;
+
+import java.util.List;
+
+/**
+ * 工作流的表单定义
+ * 用于工作流的申请表单,需要动态配置的场景
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_form", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmFormDO extends BaseDO {
+
+ /**
+ * 编号
+ */
+ @TableId
+ private Long id;
+ /**
+ * 表单名
+ */
+ private String name;
+ /**
+ * 状态
+ */
+ private Integer status;
+ /**
+ * 表单的配置
+ */
+ private String conf;
+ /**
+ * 表单项的数组
+ *
+ * 目前直接将 https://github.com/JakHuang/form-generator 生成的 JSON 串,直接保存
+ * 定义:https://github.com/JakHuang/form-generator/issues/46
+ */
+ @TableField(typeHandler = JacksonTypeHandler.class)
+ private List fields;
+ /**
+ * 备注
+ */
+ private String remark;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java
new file mode 100644
index 000000000..57abc0b99
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java
@@ -0,0 +1,90 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.*;
+
+import java.util.List;
+
+/**
+ * Bpm 流程定义的拓展表
+ * 主要解决 Activiti {@link ProcessDefinition} 不支持拓展字段,所以新建拓展表
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_process_definition_ext", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmProcessDefinitionExtDO extends BaseDO {
+
+ /**
+ * 编号
+ */
+ @TableId
+ private Long id;
+ /**
+ * 流程定义的编号
+ *
+ * 关联 ProcessDefinition 的 id 属性
+ */
+ private String processDefinitionId;
+ /**
+ * 流程模型的编号
+ *
+ * 关联 Model 的 id 属性
+ */
+ private String modelId;
+ /**
+ * 描述
+ */
+ private String description;
+
+ /**
+ * 表单类型
+ *
+ * 关联 {@link BpmModelFormTypeEnum}
+ */
+ private Integer formType;
+ /**
+ * 动态表单编号
+ * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
+ *
+ * 关联 {@link BpmFormDO#getId()}
+ */
+ private Long formId;
+ /**
+ * 表单的配置
+ * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
+ *
+ * 冗余 {@link BpmFormDO#getConf()}
+ */
+ private String formConf;
+ /**
+ * 表单项的数组
+ * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
+ *
+ * 冗余 {@link BpmFormDO#getFields()} ()}
+ */
+ @TableField(typeHandler = JacksonTypeHandler.class)
+ private List formFields;
+ /**
+ * 自定义表单的提交路径,使用 Vue 的路由地址
+ * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
+ */
+ private String formCustomCreatePath;
+ /**
+ * 自定义表单的查看路径,使用 Vue 的路由地址
+ * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
+ */
+ private String formCustomViewPath;
+
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java
new file mode 100644
index 000000000..e65764f1a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java
@@ -0,0 +1,83 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.util.Set;
+
+/**
+ * Bpm 任务分配的规则表,用于自定义配置每个任务的负责人、候选人的分配规则。
+ * 也就是说,废弃 BPMN 原本的 UserTask 设置的 assignee、candidateUsers 等配置,而是通过使用该规则进行计算对应的负责人。
+ *
+ * 1. 默认情况下,{@link #processDefinitionId} 为 {@link #PROCESS_DEFINITION_ID_NULL} 值,表示贵改则与流程模型关联
+ * 2. 在流程模型部署后,会将他的所有规则记录,复制出一份新部署出来的流程定义,通过设置 {@link #processDefinitionId} 为新的流程定义的编号进行关联
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_task_assign_rule", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmTaskAssignRuleDO extends BaseDO {
+
+ /**
+ * {@link #processDefinitionId} 空串,用于标识属于流程模型,而不属于流程定义
+ */
+ public static final String PROCESS_DEFINITION_ID_NULL = "";
+
+ /**
+ * 编号
+ */
+ @TableId
+ private Long id;
+
+ /**
+ * 流程模型编号
+ *
+ * 关联 Model 的 id 属性
+ */
+ private String modelId;
+ /**
+ * 流程定义编号
+ *
+ * 关联 ProcessDefinition 的 id 属性
+ */
+ private String processDefinitionId;
+ /**
+ * 流程任务的定义 Key
+ *
+ * 关联 Task 的 taskDefinitionKey 属性
+ */
+ private String taskDefinitionKey;
+
+ /**
+ * 规则类型
+ *
+ * 枚举 {@link BpmTaskAssignRuleTypeEnum}
+ */
+ @TableField("`type`")
+ private Integer type;
+ /**
+ * 规则值数组,一般关联指定表的编号
+ * 根据 type 不同,对应的值是不同的:
+ *
+ * 1. {@link BpmTaskAssignRuleTypeEnum#ROLE} 时:角色编号
+ * 2. {@link BpmTaskAssignRuleTypeEnum#DEPT_MEMBER} 时:部门编号
+ * 3. {@link BpmTaskAssignRuleTypeEnum#DEPT_LEADER} 时:部门编号
+ * 4. {@link BpmTaskAssignRuleTypeEnum#USER} 时:用户编号
+ * 5. {@link BpmTaskAssignRuleTypeEnum#USER_GROUP} 时:用户组编号
+ * 6. {@link BpmTaskAssignRuleTypeEnum#SCRIPT} 时:脚本编号,目前通过 {@link BpmTaskRuleScriptEnum#getId()} 标识
+ */
+ @TableField(typeHandler = JsonLongSetTypeHandler.class)
+ private Set options;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java
new file mode 100644
index 000000000..db204c027
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java
@@ -0,0 +1,5 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
+
+// TODO 芋艿:先埋个坑。任务消息的配置规则。说白了,就是不同的
+public class BpmTaskMessageRuleDO {
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java
new file mode 100644
index 000000000..ec1168180
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java
@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.definition;
+
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.util.Set;
+
+/**
+ * Bpm 用户组
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_user_group", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmUserGroupDO extends BaseDO {
+
+ /**
+ * 编号,自增
+ */
+ @TableId
+ private Long id;
+ /**
+ * 组名
+ */
+ private String name;
+ /**
+ * 描述
+ */
+ private String description;
+ /**
+ * 状态
+ *
+ * 枚举 {@link CommonStatusEnum}
+ */
+ private Integer status;
+ /**
+ * 成员用户编号数组
+ */
+ @TableField(typeHandler = JsonLongSetTypeHandler.class)
+ private Set memberUserIds;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java
new file mode 100644
index 000000000..31381a556
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java
@@ -0,0 +1,73 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
+
+import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
+import lombok.*;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * OA 请假申请 DO
+ *
+ * {@link #day} 请假天数,目前先简单做。一般是分成请假上午和下午,可以是 1 整天,可以是 0.5 半天
+ *
+ * @author jason
+ * @author 芋道源码
+ */
+@TableName("bpm_oa_leave")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BpmOALeaveDO extends BaseDO {
+
+ /**
+ * 请假表单主键
+ */
+ @TableId
+ private Long id;
+ /**
+ * 申请人的用户编号
+ *
+ * 关联 AdminUserDO 的 id 属性
+ */
+ private Long userId;
+ /**
+ * 请假类型
+ */
+ @TableField("`type`")
+ private String type;
+ /**
+ * 原因
+ */
+ private String reason;
+ /**
+ * 开始时间
+ */
+ private Date startTime;
+ /**
+ * 结束时间
+ */
+ private Date endTime;
+ /**
+ * 请假天数
+ */
+ private Long day;
+ /**
+ * 请假的结果
+ *
+ * 枚举 {@link BpmProcessInstanceResultEnum}
+ * 考虑到简单,所以直接复用了 BpmProcessInstanceResultEnum 枚举,也可以自己定义一个枚举哈
+ */
+ private Integer result;
+
+ /**
+ * 对应的流程编号
+ *
+ * 关联 ProcessInstance 的 id 属性
+ */
+ private String processInstanceId;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmActivityDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmActivityDO.java
new file mode 100644
index 000000000..183a04147
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmActivityDO.java
@@ -0,0 +1,105 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
+
+/**
+ * 任务流程关联表
+ *
+ * @author kemengkai
+ * @create 2022-05-09 10:33
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class BpmActivityDO {
+
+ /**
+ * 任务流程关联id
+ */
+ private String id;
+
+ /**
+ * 审批结果
+ */
+ private Integer rev;
+
+ /**
+ * 任务流程部署id
+ */
+ private String procDefId;
+
+ /**
+ * 任务流程id
+ */
+ private String processInstanceId;
+
+ /**
+ * 任务执行id
+ */
+ private String executionId;
+
+ /**
+ * 任务key
+ */
+ private String activityId;
+
+ /**
+ * 任务id
+ */
+ private String taskId;
+
+ /**
+ * 调用流程id
+ */
+ private String callProcInstId;
+
+ /**
+ * 任务名称
+ */
+ private String activityName;
+
+ /**
+ * 任务类型
+ */
+ private String activityType;
+
+ /**
+ * 任务审批人id
+ */
+ private String assignee;
+
+ /**
+ * 任务开始时间
+ */
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
+ private Date startTime;
+
+ /**
+ * 任务结束时间
+ */
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
+ private Date endTime;
+
+ private Integer transactionOrder;
+
+ private Long duration;
+
+ /**
+ * 删除结果
+ */
+ private String deleteReason;
+
+ /**
+ * 租户id
+ */
+ private String tenantId;
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java
new file mode 100644
index 000000000..b37709962
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java
@@ -0,0 +1,90 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
+import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * Bpm 流程实例的拓展表
+ * 主要解决 Activiti ProcessInstance 和 HistoricProcessInstance 不支持拓展字段,所以新建拓展表
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_process_instance_ext", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmProcessInstanceExtDO extends BaseDO {
+
+ /**
+ * 编号,自增
+ */
+ @TableId
+ private Long id;
+ /**
+ * 发起流程的用户编号
+ *
+ * 冗余 HistoricProcessInstance 的 startUserId 属性
+ */
+ private Long startUserId;
+ /**
+ * 流程实例的名字
+ *
+ * 冗余 ProcessInstance 的 name 属性,用于筛选
+ */
+ private String name;
+ /**
+ * 流程实例的编号
+ *
+ * 关联 ProcessInstance 的 id 属性
+ */
+ private String processInstanceId;
+ /**
+ * 流程定义的编号
+ *
+ * 关联 ProcessDefinition 的 id 属性
+ */
+ private String processDefinitionId;
+ /**
+ * 流程分类
+ *
+ * 冗余 ProcessDefinition 的 category 属性
+ * 数据字典 bpm_model_category
+ */
+ private String category;
+ /**
+ * 流程实例的状态
+ *
+ * 枚举 {@link BpmProcessInstanceStatusEnum}
+ */
+ private Integer status;
+ /**
+ * 流程实例的结果
+ *
+ * 枚举 {@link BpmProcessInstanceResultEnum}
+ */
+ private Integer result;
+ /**
+ * 结束时间
+ *
+ * 冗余 HistoricProcessInstance 的 endTime 属性
+ */
+ private Date endTime;
+
+ /**
+ * 提交的表单值
+ */
+ @TableField(typeHandler = JacksonTypeHandler.class)
+ private Map formVariables;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java
new file mode 100644
index 000000000..5c6b70fc3
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java
@@ -0,0 +1,85 @@
+package cn.iocoder.yudao.module.bpm.dal.dataobject.task;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Date;
+
+/**
+ * Bpm 流程任务的拓展表
+ * 主要解决 Flowable Task 和 HistoricTaskInstance 不支持拓展字段,所以新建拓展表
+ *
+ * @author 芋道源码
+ */
+@TableName(value = "bpm_task_ext", autoResultMap = true)
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmTaskExtDO extends BaseDO {
+
+ /**
+ * 编号,自增
+ */
+ @TableId
+ private Long id;
+
+ /**
+ * 任务的审批人
+ *
+ * 冗余 Task 的 assignee 属性
+ */
+ private Long assigneeUserId;
+ /**
+ * 任务的名字
+ *
+ * 冗余 Task 的 name 属性,为了筛选
+ */
+ private String name;
+ /**
+ * 任务的编号
+ *
+ * 关联 Task 的 id 属性
+ */
+ private String taskId;
+// /**
+// * 任务的标识
+// *
+// * 关联 {@link Task#getTaskDefinitionKey()}
+// */
+// private String definitionKey;
+ /**
+ * 任务的结果
+ *
+ * 枚举 {@link BpmProcessInstanceResultEnum}
+ */
+ private Integer result;
+ /**
+ * 审批建议
+ */
+ private String reason;
+ /**
+ * 任务的结束时间
+ *
+ * 冗余 HistoricTaskInstance 的 endTime 属性
+ */
+ private Date endTime;
+
+ /**
+ * 流程实例的编号
+ *
+ * 关联 ProcessInstance 的 id 属性
+ */
+ private String processInstanceId;
+ /**
+ * 流程定义的编号
+ *
+ * 关联 ProcessDefinition 的 id 属性
+ */
+ private String processDefinitionId;
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java
new file mode 100644
index 000000000..53c01d92e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
+
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 动态表单 Mapper
+ *
+ * @author 风里雾里
+ */
+@Mapper
+public interface BpmFormMapper extends BaseMapperX {
+
+ default PageResult selectPage(BpmFormPageReqVO reqVO) {
+ return selectPage(reqVO, new QueryWrapperX()
+ .likeIfPresent("name", reqVO.getName())
+ .orderByDesc("id"));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java
new file mode 100644
index 000000000..3ff53f2d9
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
+
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Collection;
+import java.util.List;
+
+@Mapper
+public interface BpmProcessDefinitionExtMapper extends BaseMapperX {
+
+ default List selectListByProcessDefinitionIds(Collection processDefinitionIds) {
+ return selectList("process_definition_id", processDefinitionIds);
+ }
+
+ default BpmProcessDefinitionExtDO selectByProcessDefinitionId(String processDefinitionId) {
+ return selectOne("process_definition_id", processDefinitionId);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java
new file mode 100644
index 000000000..c4061c0f8
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java
@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
+
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.lang.Nullable;
+
+import java.util.List;
+
+@Mapper
+public interface BpmTaskAssignRuleMapper extends BaseMapperX {
+
+ default List selectListByProcessDefinitionId(String processDefinitionId,
+ @Nullable String taskDefinitionKey) {
+ return selectList(new QueryWrapperX()
+ .eq("process_definition_id", processDefinitionId)
+ .eqIfPresent("task_definition_key", taskDefinitionKey));
+ }
+
+ default List selectListByModelId(String modelId) {
+ return selectList(new QueryWrapperX()
+ .eq("model_id", modelId)
+ .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL));
+ }
+
+ default BpmTaskAssignRuleDO selectListByModelIdAndTaskDefinitionKey(String modelId,
+ String taskDefinitionKey) {
+ return selectOne(new QueryWrapperX()
+ .eq("model_id", modelId)
+ .eq("process_definition_id", BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL)
+ .eq("task_definition_key", taskDefinitionKey));
+ }
+
+
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java
new file mode 100644
index 000000000..ed076276c
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java
@@ -0,0 +1,32 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 用户组 Mapper
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmUserGroupMapper extends BaseMapperX {
+
+ default PageResult selectPage(BpmUserGroupPageReqVO reqVO) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .likeIfPresent(BpmUserGroupDO::getName, reqVO.getName())
+ .eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus())
+ .betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(BpmUserGroupDO::getId));
+ }
+
+ default List selectListByStatus(Integer status) {
+ return selectList(BpmUserGroupDO::getStatus, status);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java
new file mode 100644
index 000000000..ad05b9804
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 请假申请 Mapper
+ *
+ * @author jason
+ * @author 芋道源码
+ */
+@Mapper
+public interface BpmOALeaveMapper extends BaseMapperX {
+
+ default PageResult selectPage(Long userId, BpmOALeavePageReqVO reqVO) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .eqIfPresent(BpmOALeaveDO::getUserId, userId)
+ .eqIfPresent(BpmOALeaveDO::getResult, reqVO.getResult())
+ .eqIfPresent(BpmOALeaveDO::getType, reqVO.getType())
+ .likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason())
+ .betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(BpmOALeaveDO::getId));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java
new file mode 100644
index 000000000..7e93b240f
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmActivityMapper.java
@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.task;
+
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmActivityDO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface BpmActivityMapper extends BaseMapperX {
+
+
+ // TODO @ke:可以试试,把 activiti 的表,映射成对应的实体,然后读取下。我们尽量避免 xml 操作,因为要做多 db 类型的支持,例如说 oracle 等。通过 mybatis plus 帮助我们生成不同数据库的表操作
+ /**
+ * 获取指定流程的历史任务
+ *
+ * @param procInstId 流程id
+ *
+ * @return 返回历史任务
+ */
+ List listAllByProcInstIdAndDelete(@Param("procInstId") String procInstId);
+
+ /**
+ * 逻辑删除hiActInst表任务
+ *
+ * @param taskIdList 任务列表
+ *
+ * @return 返回是否成功
+ */
+ Boolean delHiActInstByTaskId(@Param("taskIdList") List taskIdList);
+
+ /**
+ * 逻辑删除hiTaskInst任务
+ *
+ * @param taskIdList 任务列表
+ *
+ * @return 返回是否成功
+ */
+ Boolean delHiTaskInstByTaskId(@Param("taskIdList") List taskIdList);
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java
new file mode 100644
index 000000000..52e66219c
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.task;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceMyPageReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface BpmProcessInstanceExtMapper extends BaseMapperX {
+
+ default PageResult selectPage(Long userId, BpmProcessInstanceMyPageReqVO reqVO) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .eqIfPresent(BpmProcessInstanceExtDO::getStartUserId, userId)
+ .likeIfPresent(BpmProcessInstanceExtDO::getName, reqVO.getName())
+ .eqIfPresent(BpmProcessInstanceExtDO::getProcessDefinitionId, reqVO.getProcessDefinitionId())
+ .eqIfPresent(BpmProcessInstanceExtDO::getCategory, reqVO.getCategory())
+ .eqIfPresent(BpmProcessInstanceExtDO::getStatus, reqVO.getStatus())
+ .eqIfPresent(BpmProcessInstanceExtDO::getResult, reqVO.getResult())
+ .betweenIfPresent(BpmProcessInstanceExtDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(BpmProcessInstanceExtDO::getId));
+ }
+
+ default BpmProcessInstanceExtDO selectByProcessInstanceId(String processInstanceId) {
+ return selectOne(BpmProcessInstanceExtDO::getProcessInstanceId, processInstanceId);
+ }
+
+ default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) {
+ update(updateObj, new LambdaQueryWrapperX()
+ .eq(BpmProcessInstanceExtDO::getProcessInstanceId, updateObj.getProcessInstanceId()));
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java
new file mode 100644
index 000000000..6683b536d
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.bpm.dal.mysql.task;
+
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Collection;
+import java.util.List;
+
+@Mapper
+public interface BpmTaskExtMapper extends BaseMapperX {
+
+ default void updateByTaskId(BpmTaskExtDO entity) {
+ update(entity, new LambdaQueryWrapper().eq(BpmTaskExtDO::getTaskId, entity.getTaskId()));
+ }
+
+ default List selectListByTaskIds(Collection taskIds) {
+ return selectList(BpmTaskExtDO::getTaskId, taskIds);
+ }
+
+ default BpmTaskExtDO selectByTaskId(String taskId) {
+ return selectOne(BpmTaskExtDO::getTaskId, taskId);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java
new file mode 100644
index 000000000..8915fc6b5
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bpm.framework.bpm.config;
+
+import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable
+ */
+@Configuration
+public class BpmCommonConfiguration {
+
+ @Bean
+ public BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher(ApplicationEventPublisher publisher) {
+ return new BpmProcessInstanceResultEventPublisher(publisher);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmSecurityConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmSecurityConfiguration.java
new file mode 100644
index 000000000..2069f7d11
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmSecurityConfiguration.java
@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.bpm.framework.bpm.config;
+
+import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
+
+/**
+ * @author kemengkai
+ * @create 2022-05-07 08:15
+ */
+@Configuration("bpmSecurityConfiguration")
+public class BpmSecurityConfiguration {
+
+ @Bean("bpmAuthorizeRequestsCustomizer")
+ public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
+ return new AuthorizeRequestsCustomizer() {
+
+ @Override
+ public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) {
+ // 任务回退接口
+ registry.antMatchers(buildAdminApi("/bpm/task/back")).permitAll();
+ }
+
+ };
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java
new file mode 100644
index 000000000..9fccbab8e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java
@@ -0,0 +1,44 @@
+package cn.iocoder.yudao.module.bpm.framework.bpm.core.event;
+
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
+import lombok.Data;
+import org.springframework.context.ApplicationEvent;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 流程实例的结果发生变化的 Event
+ * 定位:由于额外增加了 {@link BpmProcessInstanceExtDO#getResult()} 结果,所以增加该事件
+ *
+ * @author 芋道源码
+ */
+@SuppressWarnings("ALL")
+@Data
+public class BpmProcessInstanceResultEvent extends ApplicationEvent {
+
+ /**
+ * 流程实例的编号
+ */
+ @NotNull(message = "流程实例的编号不能为空")
+ private String id;
+ /**
+ * 流程实例的 key
+ */
+ @NotNull(message = "流程实例的 key 不能为空")
+ private String processDefinitionKey;
+ /**
+ * 流程实例的结果
+ */
+ @NotNull(message = "流程实例的结果不能为空")
+ private Integer result;
+ /**
+ * 流程实例对应的业务标识
+ * 例如说,请假
+ */
+ private String businessKey;
+
+ public BpmProcessInstanceResultEvent(Object source) {
+ super(source);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java
new file mode 100644
index 000000000..c2b215394
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.bpm.framework.bpm.core.event;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.context.ApplicationListener;
+
+/**
+ * {@link BpmProcessInstanceResultEvent} 的监听器
+ *
+ * @author 芋道源码
+ */
+public abstract class BpmProcessInstanceResultEventListener
+ implements ApplicationListener {
+
+ @Override
+ public final void onApplicationEvent(BpmProcessInstanceResultEvent event) {
+ if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) {
+ return;
+ }
+ onEvent(event);
+ }
+
+ /**
+ * @return 返回监听的流程定义 Key
+ */
+ protected abstract String getProcessDefinitionKey();
+
+ /**
+ * 处理事件
+ *
+ * @param event 事件
+ */
+ protected abstract void onEvent(BpmProcessInstanceResultEvent event);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java
new file mode 100644
index 000000000..dc5c21b75
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.bpm.framework.bpm.core.event;
+
+import lombok.AllArgsConstructor;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.Valid;
+
+/**
+ * {@link BpmProcessInstanceResultEvent} 的生产者
+ *
+ * @author 芋道源码
+ */
+@AllArgsConstructor
+@Validated
+public class BpmProcessInstanceResultEventPublisher {
+
+ private final ApplicationEventPublisher publisher;
+
+ public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceResultEvent event) {
+ publisher.publishEvent(event);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java
new file mode 100644
index 000000000..c4a131128
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 自定义 Event 实现,提供方便业务接入的 Listener!
+ *
+ * @author 芋道源码
+ */
+package cn.iocoder.yudao.module.bpm.framework.bpm.core.event;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java
new file mode 100644
index 000000000..b97cb4c8a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 占位
+ */
+package cn.iocoder.yudao.module.bpm.framework.bpm.core;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java
new file mode 100644
index 000000000..9a5e3ea96
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 提供给 Activiti 和 Flowable 的通用封装
+ *
+ * @author 芋道源码
+ */
+package cn.iocoder.yudao.module.bpm.framework.bpm;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java
new file mode 100644
index 000000000..cb2b52e61
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java
@@ -0,0 +1,46 @@
+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.service.definition.BpmTaskAssignRuleService;
+import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
+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;
+
+/**
+ * BPM 模块的 Flowable 配置类
+ *
+ * @author jason
+ */
+@Configuration
+public class BpmFlowableConfiguration {
+
+ /**
+ * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类:
+ *
+ * 1. 设置各种监听器
+ * 2. 设置自定义的 ActivityBehaviorFactory 实现
+ */
+ @Bean
+ public EngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer(
+ ObjectProvider listeners,
+ BpmActivityBehaviorFactory bpmActivityBehaviorFactory) {
+ return configuration -> {
+ // 注册监听器,例如说 BpmActivityEventListener
+ configuration.setEventListeners(ListUtil.toList(listeners.iterator()));
+ // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义
+ configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory);
+ };
+ }
+
+ @Bean
+ public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService) {
+ BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory();
+ bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService);
+ return bpmActivityBehaviorFactory;
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java
new file mode 100644
index 000000000..dced1c5bd
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java
@@ -0,0 +1,44 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior;
+
+import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Setter;
+import lombok.ToString;
+import org.flowable.bpmn.model.Activity;
+import org.flowable.bpmn.model.UserTask;
+import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
+import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
+import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
+import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
+
+/**
+ * 自定义的 ActivityBehaviorFactory 实现类,目的如下:
+ * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配
+ *
+ * @author 芋道源码
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {
+
+ @Setter
+ private BpmTaskAssignRuleService bpmTaskRuleService;
+
+ @Override
+ public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
+ return new BpmUserTaskActivityBehavior(userTask)
+ .setBpmTaskRuleService(bpmTaskRuleService);
+ }
+
+ @Override
+ public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity,
+ AbstractBpmnActivityBehavior innerActivityBehavior) {
+ return new BpmParallelMultiInstanceBehavior(activity, innerActivityBehavior)
+ .setBpmTaskRuleService(bpmTaskRuleService);
+ }
+
+ // TODO @ke:SequentialMultiInstanceBehavior 这个抽空也可以看看
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java
new file mode 100644
index 000000000..0b60faa06
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java
@@ -0,0 +1,58 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior;
+
+import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.bpmn.model.Activity;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
+import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
+
+import java.util.Set;
+
+/**
+ * 自定义的【并行】的【多个】流程任务的 assignee 负责人的分配
+ * 第一步,基于分配规则,计算出分配任务的【多个】候选人们。
+ * 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它
+ *
+ * @author kemengkai
+ * @date 2022-04-21 16:57
+ */
+@Slf4j
+public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior {
+
+ @Setter
+ private BpmTaskAssignRuleService bpmTaskRuleService;
+
+ public BpmParallelMultiInstanceBehavior(Activity activity,
+ AbstractBpmnActivityBehavior innerActivityBehavior) {
+ super(activity, innerActivityBehavior);
+ }
+
+ /**
+ * 重写该方法,主要实现两个功能:
+ * 1. 忽略原有的 collectionVariable、collectionElementVariable 表达式,而是采用自己定义的
+ * 2. 获得任务的处理人,并设置到 collectionVariable 中,用于 BpmUserTaskActivityBehavior 从中可以获取任务的处理人
+ *
+ * 注意,多个任务实例,每个任务实例对应一个处理人,所以返回的数量就是任务处理人的数量
+ *
+ * @param execution 执行任务
+ * @return 数量
+ */
+ @Override
+ protected int resolveNrOfInstances(DelegateExecution execution) {
+ // 第一步,设置 collectionVariable 和 CollectionVariable
+ // 从 execution.getVariable() 读取所有任务处理人的 key
+ super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的
+ super.collectionVariable = FlowableUtils.formatCollectionVariable(execution.getCurrentActivityId());
+ // 从 execution.getVariable() 读取当前所有任务处理的人的 key
+ super.collectionElementVariable = FlowableUtils.formatCollectionElementVariable(execution.getCurrentActivityId());
+
+ // 第二步,获取任务的所有处理人
+ Set assigneeUserIds = bpmTaskRuleService.calculateTaskCandidateUsers(execution);
+ execution.setVariable(super.collectionVariable, assigneeUserIds);
+ return assigneeUserIds.size();
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java
new file mode 100644
index 000000000..aeda4d52c
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java
@@ -0,0 +1,66 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.lang.Assert;
+import cn.hutool.core.util.RandomUtil;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.bpmn.model.UserTask;
+import org.flowable.common.engine.impl.el.ExpressionManager;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
+import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
+import org.flowable.engine.impl.util.TaskHelper;
+import org.flowable.task.service.TaskService;
+import org.flowable.task.service.impl.persistence.entity.TaskEntity;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 自定义的【单个】流程任务的 assignee 负责人的分配
+ * 第一步,基于分配规则,计算出分配任务的【单个】候选人。如果找不到,则直接报业务异常,不继续执行后续的流程;
+ * 第二步,随机选择一个候选人,则选择作为 assignee 负责人。
+ *
+ * @author 芋道源码
+ */
+@Slf4j
+public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior {
+
+ @Setter
+ private BpmTaskAssignRuleService bpmTaskRuleService;
+
+ public BpmUserTaskActivityBehavior(UserTask userTask) {
+ super(userTask);
+ }
+
+ @Override
+ protected void handleAssignments(TaskService taskService, String assignee, String owner,
+ List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager,
+ DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) {
+ // 第一步,获得任务的候选用户
+ Long assigneeUserId = calculateTaskCandidateUsers(execution);
+ Assert.notNull(assigneeUserId, "任务处理人不能为空");
+ // 第二步,设置作为负责人
+ TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId));
+ }
+
+ private Long calculateTaskCandidateUsers(DelegateExecution execution) {
+ // 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。它的任务处理人在 BpmParallelMultiInstanceBehavior 中已经被分配了
+ if (super.multiInstanceActivityBehavior != null) {
+ return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class);
+ }
+
+ // 情况二,如果非多实例的任务,则计算任务处理人
+ // 第一步,先计算可处理该任务的处理人们
+ Set candidateUserIds = bpmTaskRuleService.calculateTaskCandidateUsers(execution);
+ // 第二步,后随机选择一个任务的处理人
+ // 疑问:为什么一定要选择一个任务处理人?
+ // 解答:项目对 bpm 的任务是责任到人,所以每个任务有且仅有一个处理人。
+ // 如果希望一个任务可以同时被多个人处理,可以考虑使用 BpmParallelMultiInstanceBehavior 实现的会签 or 或签。
+ int index = RandomUtil.randomInt(candidateUserIds.size());
+ return CollUtil.get(candidateUserIds, index);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java
new file mode 100644
index 000000000..b5c91ebad
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script;
+
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
+import org.flowable.engine.delegate.DelegateExecution;
+
+import java.util.Set;
+
+/**
+ * Bpm 任务分配的自定义 Script 脚本
+ * 使用场景:
+ * 1. 设置审批人为发起人
+ * 2. 设置审批人为发起人的 Leader
+ * 3. 甚至审批人为发起人的 Leader 的 Leader
+ *
+ * @author 芋道源码
+ */
+public interface BpmTaskAssignScript {
+
+ /**
+ * 基于执行任务,获得任务的候选用户们
+ *
+ * @param execution 执行任务
+ * @return 候选人用户的编号数组
+ */
+ Set calculateTaskCandidateUsers(DelegateExecution execution);
+
+ /**
+ * 获得枚举值
+ *
+ * @return 枚举值
+ */
+ BpmTaskRuleScriptEnum getEnum();
+}
+
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java
new file mode 100644
index 000000000..7f77a1b3b
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java
@@ -0,0 +1,70 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
+
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.util.Assert;
+
+import javax.annotation.Resource;
+import java.util.Set;
+
+import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
+import static java.util.Collections.emptySet;
+
+/**
+ * 分配给发起人的 Leader 审批的 Script 实现类
+ * 目前 Leader 的定义是,
+ *
+ * @author 芋道源码
+ */
+public abstract class BpmTaskAssignLeaderAbstractScript implements BpmTaskAssignScript {
+
+ @Resource
+ private AdminUserApi adminUserApi;
+ @Resource
+ private DeptApi deptApi;
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmProcessInstanceService bpmProcessInstanceService;
+
+ protected Set calculateTaskCandidateUsers(DelegateExecution execution, int level) {
+ Assert.isTrue(level > 0, "level 必须大于 0");
+ // 获得发起人
+ ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(execution.getProcessInstanceId());
+ Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
+ // 获得对应 leve 的部门
+ DeptRespDTO dept = null;
+ for (int i = 0; i < level; i++) {
+ // 获得 level 对应的部门
+ if (dept == null) {
+ dept = getStartUserDept(startUserId);
+ if (dept == null) { // 找不到发起人的部门,所以无法使用该规则
+ return emptySet();
+ }
+ } else {
+ DeptRespDTO parentDept = deptApi.getDept(dept.getParentId()).getCheckedData();
+ if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少
+ break;
+ }
+ dept = parentDept;
+ }
+ }
+ return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet();
+ }
+
+ private DeptRespDTO getStartUserDept(Long startUserId) {
+ AdminUserRespDTO startUser = adminUserApi.getUser(startUserId).getCheckedData();
+ if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则
+ return null;
+ }
+ return deptApi.getDept(startUser.getDeptId()).getCheckedData();
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java
new file mode 100644
index 000000000..af7d8b5a7
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
+
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.springframework.stereotype.Component;
+
+import java.util.Set;
+
+/**
+ * 分配给发起人的一级 Leader 审批的 Script 实现类
+ *
+ * @author 芋道源码
+ */
+@Component
+public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript {
+
+ @Override
+ public Set calculateTaskCandidateUsers(DelegateExecution execution) {
+ return calculateTaskCandidateUsers(execution, 1);
+ }
+
+ @Override
+ public BpmTaskRuleScriptEnum getEnum() {
+ return BpmTaskRuleScriptEnum.LEADER_X1;
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java
new file mode 100644
index 000000000..068ab3d2f
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
+
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.springframework.stereotype.Component;
+
+import java.util.Set;
+
+/**
+ * 分配给发起人的二级 Leader 审批的 Script 实现类
+ *
+ * @author 芋道源码
+ */
+@Component
+public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript {
+
+ @Override
+ public Set calculateTaskCandidateUsers(DelegateExecution execution) {
+ return calculateTaskCandidateUsers(execution, 2);
+ }
+
+ @Override
+ public BpmTaskRuleScriptEnum getEnum() {
+ return BpmTaskRuleScriptEnum.LEADER_X2;
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java
new file mode 100644
index 000000000..1363f3979
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
+
+import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Set;
+
+/**
+ * 分配给发起人审批的 Script 实现类
+ *
+ * @author 芋道源码
+ */
+@Component
+public class BpmTaskAssignStartUserScript implements BpmTaskAssignScript {
+
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmProcessInstanceService bpmProcessInstanceService;
+
+ @Override
+ public Set calculateTaskCandidateUsers(DelegateExecution execution) {
+ ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(execution.getProcessInstanceId());
+ Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
+ return SetUtils.asSet(startUserId);
+ }
+
+ @Override
+ public BpmTaskRuleScriptEnum getEnum() {
+ return BpmTaskRuleScriptEnum.START_USER;
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java
new file mode 100644
index 000000000..98bc37f9f
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java
@@ -0,0 +1,53 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener;
+
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
+import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
+import com.google.common.collect.ImmutableSet;
+import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
+import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
+import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
+import org.flowable.engine.delegate.event.FlowableCancelledEvent;
+import org.flowable.engine.runtime.ProcessInstance;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Set;
+
+/**
+ * 监听 {@link ProcessInstance} 的开始与完成,创建与更新对应的 {@link BpmProcessInstanceExtDO} 记录
+ *
+ * @author jason
+ */
+@Component
+public class BpmProcessInstanceEventListener extends AbstractFlowableEngineEventListener {
+
+ @Resource
+ @Lazy
+ private BpmProcessInstanceService processInstanceService;
+
+ public static final Set PROCESS_INSTANCE_EVENTS = ImmutableSet.builder()
+ .add(FlowableEngineEventType.PROCESS_CREATED)
+ .add(FlowableEngineEventType.PROCESS_CANCELLED)
+ .add(FlowableEngineEventType.PROCESS_COMPLETED)
+ .build();
+
+ public BpmProcessInstanceEventListener(){
+ super(PROCESS_INSTANCE_EVENTS);
+ }
+
+ @Override
+ protected void processCreated(FlowableEngineEntityEvent event) {
+ processInstanceService.createProcessInstanceExt((ProcessInstance)event.getEntity());
+ }
+
+ @Override
+ protected void processCancelled(FlowableCancelledEvent event) {
+ processInstanceService.updateProcessInstanceExtCancel(event);
+ }
+
+ @Override
+ protected void processCompleted(FlowableEngineEntityEvent event) {
+ processInstanceService.updateProcessInstanceExtComplete((ProcessInstance)event.getEntity());
+ }
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java
new file mode 100644
index 000000000..745561993
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java
@@ -0,0 +1,82 @@
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
+import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService;
+import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
+import com.google.common.collect.ImmutableSet;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
+import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
+import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
+import org.flowable.engine.delegate.event.FlowableActivityCancelledEvent;
+import org.flowable.engine.history.HistoricActivityInstance;
+import org.flowable.task.api.Task;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 监听 {@link org.flowable.task.api.Task} 的开始与完成,创建与更新对应的 {@link BpmTaskExtDO} 记录
+ *
+ * @author jason
+ */
+@Component
+@Slf4j
+public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
+
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmTaskService taskService;
+
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmActivityService activityService;
+
+ public static final Set TASK_EVENTS = ImmutableSet.builder()
+ .add(FlowableEngineEventType.TASK_CREATED)
+ .add(FlowableEngineEventType.TASK_ASSIGNED)
+ .add(FlowableEngineEventType.TASK_COMPLETED)
+ .add(FlowableEngineEventType.ACTIVITY_CANCELLED)
+ .build();
+
+ public BpmTaskEventListener(){
+ super(TASK_EVENTS);
+ }
+
+ @Override
+ protected void taskCreated(FlowableEngineEntityEvent event) {
+ taskService.createTaskExt((Task) event.getEntity());
+ }
+
+ @Override
+ protected void taskCompleted(FlowableEngineEntityEvent event) {
+ taskService.updateTaskExtComplete((Task)event.getEntity());
+ }
+
+ @Override
+ protected void taskAssigned(FlowableEngineEntityEvent event) {
+ taskService.updateTaskExtAssign((Task)event.getEntity());
+ }
+
+ @Override
+ protected void activityCancelled(FlowableActivityCancelledEvent event) {
+ List activityList = activityService.getHistoricActivityListByExecutionId(event.getExecutionId());
+ if (CollUtil.isEmpty(activityList)) {
+ log.error("[activityCancelled][使用 executionId({}) 查找不到对应的活动实例]", event.getExecutionId());
+ return;
+ }
+ // 遍历处理
+ activityList.forEach(activity -> {
+ if (StrUtil.isEmpty(activity.getTaskId())) {
+ return;
+ }
+ taskService.updateTaskExtCancel(activity.getTaskId());
+ });
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java
new file mode 100644
index 000000000..52fdb7f93
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 属于 bpm 模块的 framework 封装
+ *
+ * @author 芋道源码
+ */
+package cn.iocoder.yudao.module.bpm.framework;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java
new file mode 100644
index 000000000..6459263cb
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/config/RpcConfiguration.java
@@ -0,0 +1,15 @@
+package cn.iocoder.yudao.module.bpm.framework.rpc.config;
+
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.PostApi;
+import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
+import cn.iocoder.yudao.module.system.api.permission.RoleApi;
+import cn.iocoder.yudao.module.system.api.sms.SmsSendApi;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration(proxyBeanMethods = false)
+@EnableFeignClients(clients = {RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class})
+public class RpcConfiguration {
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java
new file mode 100644
index 000000000..d34205cec
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/rpc/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 占位
+ */
+package cn.iocoder.yudao.module.bpm.framework.rpc;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java
new file mode 100644
index 000000000..333ae35a4
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java
@@ -0,0 +1,12 @@
+/**
+ * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 activiti 7 版本实现。
+ * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等
+ *
+ * bpm 解释:https://baike.baidu.com/item/BPM/1933
+ *
+ * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突
+ * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分
+ *
+ * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Bpm 的前缀~
+ */
+package cn.iocoder.yudao.module.bpm;
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java
new file mode 100644
index 000000000..80355ef5e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java
@@ -0,0 +1,99 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+
+import javax.validation.Valid;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 动态表单 Service 接口
+ *
+ * @author @风里雾里
+ */
+public interface BpmFormService {
+
+ /**
+ * 创建动态表单
+ *
+ * @param createReqVO 创建信息
+ * @return 编号
+ */
+ Long createForm(@Valid BpmFormCreateReqVO createReqVO);
+
+ /**
+ * 更新动态表单
+ *
+ * @param updateReqVO 更新信息
+ */
+ void updateForm(@Valid BpmFormUpdateReqVO updateReqVO);
+
+ /**
+ * 删除动态表单
+ *
+ * @param id 编号
+ */
+ void deleteForm(Long id);
+
+ /**
+ * 获得动态表单
+ *
+ * @param id 编号
+ * @return 动态表单
+ */
+ BpmFormDO getForm(Long id);
+
+ /**
+ * 获得动态表单列表
+ *
+ * @return 动态表单列表
+ */
+ List getFormList();
+
+ /**
+ * 获得动态表单列表
+ *
+ * @param ids 编号
+ * @return 动态表单列表
+ */
+ List getFormList(Collection ids);
+
+ /**
+ * 获得动态表单 Map
+ *
+ * @param ids 编号
+ * @return 动态表单 Map
+ */
+ default Map getFormMap(Collection ids) {
+ if (CollUtil.isEmpty(ids)) {
+ return Collections.emptyMap();
+ }
+ return CollectionUtils.convertMap(this.getFormList(ids), BpmFormDO::getId);
+ }
+
+ /**
+ * 获得动态表单分页
+ *
+ * @param pageReqVO 分页查询
+ * @return 动态表单分页
+ */
+ PageResult getFormPage(BpmFormPageReqVO pageReqVO);
+
+ /**
+ * 校验流程表单已配置
+ *
+ * @param configStr configStr 字段
+ * @return 流程表单
+ */
+ BpmFormDO checkFormConfig(String configStr);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java
new file mode 100644
index 000000000..967ab8f49
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java
@@ -0,0 +1,135 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.hutool.core.lang.Assert;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmFormConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmFormMapper;
+import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
+
+/**
+ * 动态表单 Service 实现类
+ *
+ * @author 风里雾里
+ */
+@Service
+@Validated
+public class BpmFormServiceImpl implements BpmFormService {
+
+ @Resource
+ private BpmFormMapper formMapper;
+
+ @Override
+ public Long createForm(BpmFormCreateReqVO createReqVO) {
+ this.checkFields(createReqVO.getFields());
+ // 插入
+ BpmFormDO form = BpmFormConvert.INSTANCE.convert(createReqVO);
+ formMapper.insert(form);
+ // 返回
+ return form.getId();
+ }
+
+ @Override
+ public void updateForm(BpmFormUpdateReqVO updateReqVO) {
+ this.checkFields(updateReqVO.getFields());
+ // 校验存在
+ this.validateFormExists(updateReqVO.getId());
+ // 更新
+ BpmFormDO updateObj = BpmFormConvert.INSTANCE.convert(updateReqVO);
+ formMapper.updateById(updateObj);
+ }
+
+ @Override
+ public void deleteForm(Long id) {
+ // 校验存在
+ this.validateFormExists(id);
+ // 删除
+ formMapper.deleteById(id);
+ }
+
+ private void validateFormExists(Long id) {
+ if (formMapper.selectById(id) == null) {
+ throw exception(ErrorCodeConstants.FORM_NOT_EXISTS);
+ }
+ }
+
+ @Override
+ public BpmFormDO getForm(Long id) {
+ return formMapper.selectById(id);
+ }
+
+ @Override
+ public List getFormList() {
+ return formMapper.selectList();
+ }
+
+ @Override
+ public List getFormList(Collection ids) {
+ return formMapper.selectBatchIds(ids);
+ }
+
+ @Override
+ public PageResult getFormPage(BpmFormPageReqVO pageReqVO) {
+ return formMapper.selectPage(pageReqVO);
+ }
+
+
+ @Override
+ public BpmFormDO checkFormConfig(String configStr) {
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(configStr, BpmModelMetaInfoRespDTO.class);
+ if (metaInfo == null || metaInfo.getFormType() == null) {
+ throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
+ }
+ // 校验表单存在
+ if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) {
+ BpmFormDO form = getForm(metaInfo.getFormId());
+ if (form == null) {
+ throw exception(FORM_NOT_EXISTS);
+ }
+ return form;
+ }
+ return null;
+ }
+
+ private void checkKeyNCName(String key) {
+ if (!ValidationUtils.isXmlNCName(key)) {
+ throw exception(MODEL_KEY_VALID);
+ }
+ }
+ /**
+ * 校验 Field,避免 field 重复
+ *
+ * @param fields field 数组
+ */
+ private void checkFields(List fields) {
+ Map fieldMap = new HashMap<>(); // key 是 vModel,value 是 label
+ for (String field : fields) {
+ BpmFormFieldRespDTO fieldDTO = JsonUtils.parseObject(field, BpmFormFieldRespDTO.class);
+ Assert.notNull(fieldDTO);
+ String oldLabel = fieldMap.put(fieldDTO.getVModel(), fieldDTO.getLabel());
+ // 如果不存在,则直接返回
+ if (oldLabel == null) {
+ continue;
+ }
+ // 如果存在,则报错
+ throw exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel());
+ }
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
new file mode 100644
index 000000000..a4e4f83d1
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+import org.flowable.bpmn.model.BpmnModel;
+
+import javax.validation.Valid;
+
+/**
+ * Flowable流程模型接口
+ *
+ * @author yunlongn
+ */
+public interface BpmModelService {
+ /**
+ * 获得流程模型分页
+ *
+ * @param pageVO 分页查询
+ * @return 流程模型分页
+ */
+ PageResult getModelPage(BpmModelPageReqVO pageVO);
+
+ /**
+ * 创建流程模型
+ *
+ * @param modelVO 创建信息
+ * @param bpmnXml BPMN XML
+ * @return 创建的流程模型的编号
+ */
+ String createModel(@Valid BpmModelCreateReqVO modelVO, String bpmnXml);
+
+ /**
+ * 获得流程模块
+ *
+ * @param id 编号
+ * @return 流程模型
+ */
+ BpmModelRespVO getModel(String id);
+
+ /**
+ * 修改流程模型
+ *
+ * @param updateReqVO 更新信息
+ */
+ void updateModel(@Valid BpmModelUpdateReqVO updateReqVO);
+
+ /**
+ * 将流程模型,部署成一个流程定义
+ *
+ * @param id 编号
+ */
+ void deployModel(String id);
+
+ /**
+ * 删除模型
+ *
+ * @param id 编号
+ */
+ void deleteModel(String id);
+
+ /**
+ * 修改模型的状态,实际更新的部署的流程定义的状态
+ *
+ * @param id 编号
+ * @param state 状态
+ */
+ void updateModelState(String id, Integer state);
+
+ /**
+ * 获得流程模型编号对应的 BPMN Model
+ *
+ * @param id 流程模型编号
+ * @return BPMN Model
+ */
+ BpmnModel getBpmnModel(String id);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
new file mode 100644
index 000000000..a4a2d9182
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
@@ -0,0 +1,287 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
+import cn.iocoder.yudao.framework.common.util.object.PageUtils;
+import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.bpmn.converter.BpmnXMLConverter;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.common.engine.impl.db.SuspensionState;
+import org.flowable.common.engine.impl.util.io.BytesStreamSource;
+import org.flowable.engine.RepositoryService;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.Model;
+import org.flowable.engine.repository.ModelQuery;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.*;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
+
+/**
+ * Flowable流程模型实现
+ * 主要进行 Flowable {@link Model} 的维护
+ *
+ * @author yunlongn
+ * @author 芋道源码
+ * @author jason
+ */
+@Service
+@Validated
+@Slf4j
+public class BpmModelServiceImpl implements BpmModelService {
+
+ @Resource
+ private RepositoryService repositoryService;
+ @Resource
+ private BpmProcessDefinitionService processDefinitionService;
+ @Resource
+ private BpmFormService bpmFormService;
+ @Resource
+ private BpmTaskAssignRuleService taskAssignRuleService;
+
+ @Override
+ public PageResult getModelPage(BpmModelPageReqVO pageVO) {
+ ModelQuery modelQuery = repositoryService.createModelQuery();
+ if (StrUtil.isNotBlank(pageVO.getKey())) {
+ modelQuery.modelKey(pageVO.getKey());
+ }
+ if (StrUtil.isNotBlank(pageVO.getName())) {
+ modelQuery.modelNameLike("%" + pageVO.getName() + "%"); // 模糊匹配
+ }
+ if (StrUtil.isNotBlank(pageVO.getCategory())) {
+ modelQuery.modelCategory(pageVO.getCategory());
+ }
+ // 执行查询
+ List models = modelQuery.orderByCreateTime().desc()
+ .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
+
+ // 获得 Form Map
+ Set formIds = CollectionUtils.convertSet(models, model -> {
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class);
+ return metaInfo != null ? metaInfo.getFormId() : null;
+ });
+ Map formMap = bpmFormService.getFormMap(formIds);
+
+ // 获得 Deployment Map
+ Set deploymentIds = new HashSet<>();
+ models.forEach(model -> CollectionUtils.addIfNotNull(deploymentIds, model.getDeploymentId()));
+ Map deploymentMap = processDefinitionService.getDeploymentMap(deploymentIds);
+ // 获得 ProcessDefinition Map
+ List processDefinitions = processDefinitionService.getProcessDefinitionListByDeploymentIds(deploymentIds);
+ Map processDefinitionMap = convertMap(processDefinitions, ProcessDefinition::getDeploymentId);
+
+ // 拼接结果
+ long modelCount = modelQuery.count();
+ return new PageResult<>(BpmModelConvert.INSTANCE.convertList(models, formMap, deploymentMap, processDefinitionMap), modelCount);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public String createModel(@Valid BpmModelCreateReqVO createReqVO, String bpmnXml) {
+ checkKeyNCName(createReqVO.getKey());
+ // 校验流程标识已经存在
+ Model keyModel = getModelByKey(createReqVO.getKey());
+ if (keyModel != null) {
+ throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
+ }
+
+ // 创建流程定义
+ Model model = repositoryService.newModel();
+ BpmModelConvert.INSTANCE.copy(model, createReqVO);
+ // 保存流程定义
+ repositoryService.saveModel(model);
+ // 保存 BPMN XML
+ saveModelBpmnXml(model, bpmnXml);
+ return model.getId();
+ }
+
+ private Model getModelByKey(String key) {
+ return repositoryService.createModelQuery().modelKey(key).singleResult();
+ }
+
+ @Override
+ public BpmModelRespVO getModel(String id) {
+ Model model = repositoryService.getModel(id);
+ if (model == null) {
+ return null;
+ }
+ BpmModelRespVO modelRespVO = BpmModelConvert.INSTANCE.convert(model);
+ // 拼接 bpmn XML
+ byte[] bpmnBytes = repositoryService.getModelEditorSource(id);
+ modelRespVO.setBpmnXml(StrUtil.utf8Str(bpmnBytes));
+ return modelRespVO;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
+ public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) {
+ // 校验流程模型存在
+ Model model = repositoryService.getModel(updateReqVO.getId());
+ if (model == null) {
+ throw exception(MODEL_NOT_EXISTS);
+ }
+
+ // 修改流程定义
+ BpmModelConvert.INSTANCE.copy(model, updateReqVO);
+ // 更新模型
+ repositoryService.saveModel(model);
+ // 更新 BPMN XML
+ saveModelBpmnXml(model, updateReqVO.getBpmnXml());
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
+ public void deployModel(String id) {
+ // 1.1 校验流程模型存在
+ Model model = repositoryService.getModel(id);
+ if (ObjectUtils.isEmpty(model)) {
+ throw exception(MODEL_NOT_EXISTS);
+ }
+ // 1.2 校验流程图
+ // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素;
+ byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId());
+ if (bpmnBytes == null) {
+ throw exception(MODEL_NOT_EXISTS);
+ }
+ // 1.3 校验表单已配
+ BpmFormDO form = checkFormConfig(model.getMetaInfo());
+ // 1.4 校验任务分配规则已配置
+ taskAssignRuleService.checkTaskAssignRuleAllConfig(id);
+
+ // 1.5 校验模型是否发生修改。如果未修改,则不允许创建
+ BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes);
+ if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等
+ ProcessDefinition oldProcessDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
+ if (oldProcessDefinition != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessDefinition.getId())) {
+ throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS);
+ }
+ }
+
+ // 2.1 创建流程定义
+ String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO);
+
+ // 2.2 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。
+ updateProcessDefinitionSuspended(model.getDeploymentId());
+
+ // 2.3 更新 model 的 deploymentId,进行关联
+ ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId);
+ model.setDeploymentId(definition.getDeploymentId());
+ repositoryService.saveModel(model);
+
+ // 2.4 复制任务分配规则
+ taskAssignRuleService.copyTaskAssignRules(id, definition.getId());
+ }
+
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void deleteModel(String id) {
+ // 校验流程模型存在
+ Model model = repositoryService.getModel(id);
+ if (model == null) {
+ throw exception(MODEL_NOT_EXISTS);
+ }
+ // 执行删除
+ repositoryService.deleteModel(id);
+ // 禁用流程实例
+ updateProcessDefinitionSuspended(model.getDeploymentId());
+ }
+
+ @Override
+ public void updateModelState(String id, Integer state) {
+ // 校验流程模型存在
+ Model model = repositoryService.getModel(id);
+ if (model == null) {
+ throw exception(MODEL_NOT_EXISTS);
+ }
+ // 校验流程定义存在
+ ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
+ if (definition == null) {
+ throw exception(PROCESS_DEFINITION_NOT_EXISTS);
+ }
+
+ // 更新状态
+ processDefinitionService.updateProcessDefinitionState(definition.getId(), state);
+ }
+
+ @Override
+ public BpmnModel getBpmnModel(String id) {
+ byte[] bpmnBytes = repositoryService.getModelEditorSource(id);
+ if (ArrayUtil.isEmpty(bpmnBytes)) {
+ return null;
+ }
+ BpmnXMLConverter converter = new BpmnXMLConverter();
+ return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true);
+ }
+
+ private void checkKeyNCName(String key) {
+ if (!ValidationUtils.isXmlNCName(key)) {
+ throw exception(MODEL_KEY_VALID);
+ }
+ }
+
+ /**
+ * 校验流程表单已配置
+ *
+ * @param metaInfoStr 流程模型 metaInfo 字段
+ * @return 流程表单
+ */
+ private BpmFormDO checkFormConfig(String metaInfoStr) {
+ BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(metaInfoStr, BpmModelMetaInfoRespDTO.class);
+ if (metaInfo == null || metaInfo.getFormType() == null) {
+ throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
+ }
+ // 校验表单存在
+ if (Objects.equals(metaInfo.getFormType(), BpmModelFormTypeEnum.NORMAL.getType())) {
+ BpmFormDO form = bpmFormService.getForm(metaInfo.getFormId());
+ if (form == null) {
+ throw exception(FORM_NOT_EXISTS);
+ }
+ return form;
+ }
+ return null;
+ }
+
+ private void saveModelBpmnXml(Model model, String bpmnXml) {
+ if (StrUtil.isEmpty(bpmnXml)) {
+ return;
+ }
+ repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml));
+ }
+
+ /**
+ * 挂起 deploymentId 对应的流程定义。 这里一个deploymentId 只关联一个流程定义
+ * @param deploymentId 流程发布Id.
+ */
+ private void updateProcessDefinitionSuspended(String deploymentId) {
+ if (StrUtil.isEmpty(deploymentId)) {
+ return;
+ }
+ ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId);
+ if (oldDefinition == null) {
+ return;
+ }
+ processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode());
+ }
+
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java
new file mode 100644
index 000000000..7c26b644e
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java
@@ -0,0 +1,159 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.ProcessDefinition;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+/**
+ * Flowable流程定义接口
+ *
+ * @author yunlong.li
+ * @author ZJQ
+ * @author 芋道源码
+ */
+public interface BpmProcessDefinitionService {
+
+ /**
+ * 获得流程定义分页
+ *
+ * @param pageReqVO 分页入参
+ * @return 流程定义 Page
+ */
+ PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO);
+
+ /**
+ * 获得流程定义列表
+ *
+ * @param listReqVO 列表入参
+ * @return 流程定义列表
+ */
+ List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO);
+
+ /**
+ * 创建流程定义
+ *
+ * @param createReqDTO 创建信息
+ * @return 流程编号
+ */
+ String createProcessDefinition(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO);
+
+ /**
+ * 更新流程定义状态
+ *
+ * @param id 流程定义的编号
+ * @param state 状态
+ */
+ void updateProcessDefinitionState(String id, Integer state);
+
+ /**
+ * 获得流程定义对应的 BPMN XML
+ *
+ * @param id 流程定义编号
+ * @return BPMN XML
+ */
+ String getProcessDefinitionBpmnXML(String id);
+
+ /**
+ * 获得需要创建的流程定义,是否和当前激活的流程定义相等
+ *
+ * @param createReqDTO 创建信息
+ * @return 是否相等
+ */
+ boolean isProcessDefinitionEquals(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO);
+
+ /**
+ * 获得编号对应的 BpmProcessDefinitionExtDO
+ *
+ * @param id 编号
+ * @return 流程定义拓展
+ */
+ BpmProcessDefinitionExtDO getProcessDefinitionExt(String id);
+
+ /**
+ * 获得编号对应的 ProcessDefinition
+ *
+ * @param id 编号
+ * @return 流程定义
+ */
+ ProcessDefinition getProcessDefinition(String id);
+
+ /**
+ * 获得编号对应的 ProcessDefinition
+ *
+ * 相比 {@link #getProcessDefinition(String)} 方法,category 的取值是正确
+ *
+ * @param id 编号
+ * @return 流程定义
+ */
+ ProcessDefinition getProcessDefinition2(String id);
+
+ /**
+ * 获得 deploymentId 对应的 ProcessDefinition
+ *
+ * @param deploymentId 部署编号
+ * @return 流程定义
+ */
+ ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId);
+
+ /**
+ * 获得 deploymentIds 对应的 ProcessDefinition 数组
+ *
+ * @param deploymentIds 部署编号的数组
+ * @return 流程定义的数组
+ */
+ List getProcessDefinitionListByDeploymentIds(Set deploymentIds);
+
+ /**
+ * 获得流程定义标识对应的激活的流程定义
+ *
+ * @param key 流程定义的标识
+ * @return 流程定义
+ */
+ ProcessDefinition getActiveProcessDefinition(String key);
+
+ /**
+ * 获得 ids 对应的 Deployment Map
+ *
+ * @param ids 部署编号的数组
+ * @return 流程部署 Map
+ */
+ default Map getDeploymentMap(Set ids) {
+ return CollectionUtils.convertMap(getDeployments(ids), Deployment::getId);
+ }
+
+ /**
+ * 获得 ids 对应的 Deployment 数组
+ *
+ * @param ids 部署编号的数组
+ * @return 流程部署的数组
+ */
+ List getDeployments(Set ids);
+
+ /**
+ * 获得 id 对应的 Deployment
+ *
+ * @param id 部署编号
+ * @return 流程部署
+ */
+ Deployment getDeployment(String id);
+
+ /**
+ * 获得 Bpmn 模型
+ *
+ * @param processDefinitionId 流程定义的编号
+ * @return Bpmn 模型
+ */
+ BpmnModel getBpmnModel(String processDefinitionId);
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
new file mode 100644
index 000000000..35464ab6a
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
@@ -0,0 +1,286 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.PageUtils;
+import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmProcessDefinitionConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
+import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper;
+import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.bpmn.converter.BpmnXMLConverter;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.common.engine.impl.db.SuspensionState;
+import org.flowable.common.engine.impl.util.io.BytesStreamSource;
+import org.flowable.engine.RepositoryService;
+import org.flowable.engine.repository.Deployment;
+import org.flowable.engine.repository.ProcessDefinition;
+import org.flowable.engine.repository.ProcessDefinitionQuery;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.*;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH;
+import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH;
+import static java.util.Collections.emptyList;
+
+/**
+ * 流程定义实现
+ * 主要进行 Flowable {@link ProcessDefinition} 和 {@link Deployment} 的维护
+ *
+ * @author yunlongn
+ * @author ZJQ
+ * @author 芋道源码
+ */
+@Service
+@Validated
+@Slf4j
+public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService {
+
+ private static final String BPMN_FILE_SUFFIX = ".bpmn";
+
+ @Resource
+ private RepositoryService repositoryService;
+
+ @Resource
+ private BpmProcessDefinitionExtMapper processDefinitionMapper;
+
+ @Resource
+ private BpmFormService formService;
+
+ @Override
+ public ProcessDefinition getProcessDefinition(String id) {
+ return repositoryService.getProcessDefinition(id);
+ }
+
+ @Override
+ public ProcessDefinition getProcessDefinition2(String id) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
+ }
+
+ @Override
+ public ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId) {
+ if (StrUtil.isEmpty(deploymentId)) {
+ return null;
+ }
+ return repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
+ }
+
+ @Override
+ public List getProcessDefinitionListByDeploymentIds(Set deploymentIds) {
+ if (CollUtil.isEmpty(deploymentIds)) {
+ return emptyList();
+ }
+ return repositoryService.createProcessDefinitionQuery().deploymentIds(deploymentIds).list();
+ }
+
+ @Override
+ public ProcessDefinition getActiveProcessDefinition(String key) {
+ return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult();
+ }
+
+ @Override
+ public List getDeployments(Set ids) {
+ if (CollUtil.isEmpty(ids)) {
+ return emptyList();
+ }
+ List list = new ArrayList<>(ids.size());
+ for (String id : ids) {
+ addIfNotNull(list, getDeployment(id));
+ }
+ return list;
+ }
+
+ @Override
+ public Deployment getDeployment(String id) {
+ if (StrUtil.isEmpty(id)) {
+ return null;
+ }
+ return repositoryService.createDeploymentQuery().deploymentId(id).singleResult();
+ }
+
+ @Override
+ public BpmnModel getBpmnModel(String processDefinitionId) {
+ return repositoryService.getBpmnModel(processDefinitionId);
+ }
+
+ @Override
+ public String createProcessDefinition(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO) {
+ // 创建 Deployment 部署
+ Deployment deploy = repositoryService.createDeployment()
+ .key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory())
+ .addBytes(createReqDTO.getKey() + BPMN_FILE_SUFFIX, createReqDTO.getBpmnBytes())
+ .deploy();
+
+ // 设置 ProcessDefinition 的 category 分类
+ ProcessDefinition definition = repositoryService.createProcessDefinitionQuery()
+ .deploymentId(deploy.getId()).singleResult();
+ repositoryService.setProcessDefinitionCategory(definition.getId(), createReqDTO.getCategory());
+ // 注意 1,ProcessDefinition 的 key 和 name 是通过 BPMN 中的 的 id 和 name 决定
+ // 注意 2,目前该项目的设计上,需要保证 Model、Deployment、ProcessDefinition 使用相同的 key,保证关联性。
+ // 否则,会导致 ProcessDefinition 的分页无法查询到。
+ if (!Objects.equals(definition.getKey(), createReqDTO.getKey())) {
+ throw exception(PROCESS_DEFINITION_KEY_NOT_MATCH, createReqDTO.getKey(), definition.getKey());
+ }
+ if (!Objects.equals(definition.getName(), createReqDTO.getName())) {
+ throw exception(PROCESS_DEFINITION_NAME_NOT_MATCH, createReqDTO.getName(), definition.getName());
+ }
+
+ // 插入拓展表
+ BpmProcessDefinitionExtDO definitionDO = BpmProcessDefinitionConvert.INSTANCE.convert2(createReqDTO)
+ .setProcessDefinitionId(definition.getId());
+ processDefinitionMapper.insert(definitionDO);
+ return definition.getId();
+ }
+
+ @Override
+ public void updateProcessDefinitionState(String id, Integer state) {
+ // 激活
+ if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), state)) {
+ repositoryService.activateProcessDefinitionById(id, false, null);
+ return;
+ }
+ // 挂起
+ if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), state)) {
+ // suspendProcessInstances = false,进行中的任务,不进行挂起。
+ // 原因:只要新的流程不允许发起即可,老流程继续可以执行。
+ repositoryService.suspendProcessDefinitionById(id, false, null);
+ return;
+ }
+ log.error("[updateProcessDefinitionState][流程定义({}) 修改未知状态({})]", id, state);
+ }
+
+ @Override
+ public String getProcessDefinitionBpmnXML(String id) {
+ BpmnModel bpmnModel = repositoryService.getBpmnModel(id);
+ if (bpmnModel == null) {
+ return null;
+ }
+ BpmnXMLConverter converter = new BpmnXMLConverter();
+ return StrUtil.utf8Str(converter.convertToXML(bpmnModel));
+ }
+
+ @Override
+ public boolean isProcessDefinitionEquals(@Valid BpmProcessDefinitionCreateReqDTO createReqDTO) {
+ // 校验 name、description 是否更新
+ ProcessDefinition oldProcessDefinition = getActiveProcessDefinition(createReqDTO.getKey());
+ if (oldProcessDefinition == null) {
+ return false;
+ }
+ BpmProcessDefinitionExtDO oldProcessDefinitionExt = getProcessDefinitionExt(oldProcessDefinition.getId());
+ if (!StrUtil.equals(createReqDTO.getName(), oldProcessDefinition.getName())
+ || !StrUtil.equals(createReqDTO.getDescription(), oldProcessDefinitionExt.getDescription())
+ || !StrUtil.equals(createReqDTO.getCategory(), oldProcessDefinition.getCategory())) {
+ return false;
+ }
+ // 校验 form 信息是否更新
+ if (!ObjectUtil.equal(createReqDTO.getFormType(), oldProcessDefinitionExt.getFormType())
+ || !ObjectUtil.equal(createReqDTO.getFormId(), oldProcessDefinitionExt.getFormId())
+ || !ObjectUtil.equal(createReqDTO.getFormConf(), oldProcessDefinitionExt.getFormConf())
+ || !ObjectUtil.equal(createReqDTO.getFormFields(), oldProcessDefinitionExt.getFormFields())
+ || !ObjectUtil.equal(createReqDTO.getFormCustomCreatePath(), oldProcessDefinitionExt.getFormCustomCreatePath())
+ || !ObjectUtil.equal(createReqDTO.getFormCustomViewPath(), oldProcessDefinitionExt.getFormCustomViewPath())) {
+ return false;
+ }
+ // 校验 BPMN XML 信息
+ BpmnModel newModel = buildBpmnModel(createReqDTO.getBpmnBytes());
+ BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId());
+ // TODO 貌似 flowable 不修改这个也不同。需要看看。 sourceSystemId 不同
+ if (FlowableUtils.equals(oldModel, newModel)) {
+ return false;
+ }
+ // 最终发现都一致,则返回 true
+ return true;
+ }
+
+ /**
+ * 构建对应的 BPMN Model
+ *
+ * @param bpmnBytes 原始的 BPMN XML 字节数组
+ * @return BPMN Model
+ */
+ private BpmnModel buildBpmnModel(byte[] bpmnBytes) {
+ // 转换成 BpmnModel 对象
+ BpmnXMLConverter converter = new BpmnXMLConverter();
+ return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true);
+ }
+
+ @Override
+ public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) {
+ return processDefinitionMapper.selectByProcessDefinitionId(id);
+ }
+
+ @Override
+ public List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO) {
+ // 拼接查询条件
+ ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
+ if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), listReqVO.getSuspensionState())) {
+ definitionQuery.suspended();
+ } else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), listReqVO.getSuspensionState())) {
+ definitionQuery.active();
+ }
+ // 执行查询
+ List processDefinitions = definitionQuery.list();
+ if (CollUtil.isEmpty(processDefinitions)) {
+ return Collections.emptyList();
+ }
+
+ // 获得 BpmProcessDefinitionDO Map
+ List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
+ convertList(processDefinitions, ProcessDefinition::getId));
+ Map processDefinitionDOMap = convertMap(processDefinitionDOs,
+ BpmProcessDefinitionExtDO::getProcessDefinitionId);
+ // 执行查询,并返回
+ return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap);
+ }
+
+ @Override
+ public PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
+ ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
+ if (StrUtil.isNotBlank(pageVO.getKey())) {
+ definitionQuery.processDefinitionKey(pageVO.getKey());
+ }
+
+ // 执行查询
+ List processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc()
+ .listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
+
+ if (CollUtil.isEmpty(processDefinitions)) {
+ return new PageResult<>(emptyList(), definitionQuery.count());
+ }
+ // 获得 Deployment Map
+ Set deploymentIds = new HashSet<>();
+ processDefinitions.forEach(definition -> addIfNotNull(deploymentIds, definition.getDeploymentId()));
+ Map deploymentMap = getDeploymentMap(deploymentIds);
+
+ // 获得 BpmProcessDefinitionDO Map
+ List processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(
+ convertList(processDefinitions, ProcessDefinition::getId));
+ Map processDefinitionDOMap = convertMap(processDefinitionDOs,
+ BpmProcessDefinitionExtDO::getProcessDefinitionId);
+
+ // 获得 Form Map
+ Set formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId);
+ Map formMap = formService.getFormMap(formIds);
+
+ // 拼接结果
+ long definitionCount = definitionQuery.count();
+ return new PageResult<>(BpmProcessDefinitionConvert.INSTANCE.convertList(processDefinitions, deploymentMap,
+ processDefinitionDOMap, formMap), definitionCount);
+ }
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java
new file mode 100644
index 000000000..051dd63d3
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java
@@ -0,0 +1,97 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.springframework.lang.Nullable;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * BPM 任务分配规则 Service 接口
+ *
+ * @author 芋道源码
+ */
+public interface BpmTaskAssignRuleService {
+
+ /**
+ * 获得流程定义的任务分配规则数组
+ *
+ * @param processDefinitionId 流程定义的编号
+ * @param taskDefinitionKey 流程任务定义的 Key。允许空
+ * @return 任务规则数组
+ */
+ List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
+ @Nullable String taskDefinitionKey);
+
+ /**
+ * 获得流程模型的任务规则数组
+ *
+ * @param modelId 流程模型的编号
+ * @return 任务规则数组
+ */
+ List getTaskAssignRuleListByModelId(String modelId);
+
+ /**
+ * 获得流程定义的任务分配规则数组
+ *
+ * @param modelId 流程模型的编号
+ * @param processDefinitionId 流程定义的编号
+ * @return 任务规则数组
+ */
+ List getTaskAssignRuleList(String modelId, String processDefinitionId);
+
+ /**
+ * 创建任务分配规则
+ *
+ * @param reqVO 创建信息
+ * @return 规则编号
+ */
+ Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO);
+
+ /**
+ * 更新任务分配规则
+ *
+ * @param reqVO 创建信息
+ */
+ void updateTaskAssignRule(@Valid BpmTaskAssignRuleUpdateReqVO reqVO);
+
+ /**
+ * 判断指定流程模型和流程定义的分配规则是否相等
+ *
+ * @param modelId 流程模型编号
+ * @param processDefinitionId 流程定义编号
+ * @return 是否相等
+ */
+ boolean isTaskAssignRulesEquals(String modelId, String processDefinitionId);
+
+ /**
+ * 将流程流程模型的任务分配规则,复制一份给流程定义
+ * 目的:每次流程模型部署时,都会生成一个新的流程定义,此时考虑到每次部署的流程不可变性,所以需要复制一份给该流程定义
+ *
+ * @param fromModelId 流程模型编号
+ * @param toProcessDefinitionId 流程定义编号
+ */
+ void copyTaskAssignRules(String fromModelId, String toProcessDefinitionId);
+
+ /**
+ * 校验流程模型的任务分配规则全部都配置了
+ * 目的:如果有规则未配置,会导致流程任务找不到负责人,进而流程无法进行下去!
+ *
+ * @param id 流程模型编号
+ */
+ void checkTaskAssignRuleAllConfig(String id);
+
+ /**
+ * 计算当前执行任务的处理人
+ *
+ * @param execution 执行任务
+ * @return 处理人的编号数组
+ */
+ Set calculateTaskCandidateUsers(DelegateExecution execution);
+
+}
diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
new file mode 100644
index 000000000..aa84b83b7
--- /dev/null
+++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java
@@ -0,0 +1,344 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
+import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
+import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
+import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
+import cn.iocoder.yudao.module.bpm.convert.definition.BpmTaskAssignRuleConvert;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
+import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
+import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
+import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
+import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.PostApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
+import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
+import cn.iocoder.yudao.module.system.api.permission.RoleApi;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import com.google.common.annotations.VisibleForTesting;
+import lombok.extern.slf4j.Slf4j;
+import org.flowable.bpmn.model.BpmnModel;
+import org.flowable.bpmn.model.UserTask;
+import org.flowable.common.engine.api.FlowableException;
+import org.flowable.engine.delegate.DelegateExecution;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.*;
+
+import static cn.hutool.core.text.CharSequenceUtil.format;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
+import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
+import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
+
+/**
+ * BPM 任务分配规则 Service 实现类
+ */
+@Service
+@Validated
+@Slf4j
+public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
+
+ @Resource
+ private BpmTaskAssignRuleMapper taskRuleMapper;
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmModelService modelService;
+ @Resource
+ @Lazy // 解决循环依赖
+ private BpmProcessDefinitionService processDefinitionService;
+ @Resource
+ private BpmUserGroupService userGroupService;
+ @Resource
+ private RoleApi roleApi;
+ @Resource
+ private DeptApi deptApi;
+ @Resource
+ private PostApi postApi;
+ @Resource
+ private AdminUserApi adminUserApi;
+ @Resource
+ private DictDataApi dictDataApi;
+ @Resource
+ private PermissionApi permissionApi;
+ /**
+ * 任务分配脚本
+ */
+ private Map scriptMap = Collections.emptyMap();
+
+ @Resource
+ public void setScripts(List scripts) {
+ this.scriptMap = convertMap(scripts, script -> script.getEnum().getId());
+ }
+
+ @Override
+ public List getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
+ String taskDefinitionKey) {
+ return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey);
+ }
+
+ @Override
+ public List getTaskAssignRuleListByModelId(String modelId) {
+ return taskRuleMapper.selectListByModelId(modelId);
+ }
+
+ @Override
+ public List getTaskAssignRuleList(String modelId, String processDefinitionId) {
+ // 获得规则
+ List rules = Collections.emptyList();
+ BpmnModel model = null;
+ if (StrUtil.isNotEmpty(modelId)) {
+ rules = getTaskAssignRuleListByModelId(modelId);
+ model = modelService.getBpmnModel(modelId);
+ } else if (StrUtil.isNotEmpty(processDefinitionId)) {
+ rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null);
+ model = processDefinitionService.getBpmnModel(processDefinitionId);
+ }
+ if (model == null) {
+ return Collections.emptyList();
+ }
+ // 获得用户任务,只有用户任务才可以设置分配规则
+ List userTasks = FlowableUtils.getBpmnModelElements(model, UserTask.class);
+ if (CollUtil.isEmpty(userTasks)) {
+ return Collections.emptyList();
+ }
+ // 转换数据
+ return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules);
+ }
+
+ @Override
+ public Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO) {
+ // 校验参数
+ validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
+ // 校验是否已经配置
+ BpmTaskAssignRuleDO existRule =
+ taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(reqVO.getModelId(), reqVO.getTaskDefinitionKey());
+ if (existRule != null) {
+ throw exception(TASK_ASSIGN_RULE_EXISTS, reqVO.getModelId(), reqVO.getTaskDefinitionKey());
+ }
+
+ // 存储
+ BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO)
+ .setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型,才允许新建
+ taskRuleMapper.insert(rule);
+ return rule.getId();
+ }
+
+ @Override
+ public void updateTaskAssignRule(@Valid BpmTaskAssignRuleUpdateReqVO reqVO) {
+ // 校验参数
+ validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
+ // 校验是否存在
+ BpmTaskAssignRuleDO existRule = taskRuleMapper.selectById(reqVO.getId());
+ if (existRule == null) {
+ throw exception(TASK_ASSIGN_RULE_NOT_EXISTS);
+ }
+ // 只允许修改流程模型的规则
+ if (!Objects.equals(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL, existRule.getProcessDefinitionId())) {
+ throw exception(TASK_UPDATE_FAIL_NOT_MODEL);
+ }
+
+ // 执行更新
+ taskRuleMapper.updateById(BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO));
+ }
+
+ @Override
+ public boolean isTaskAssignRulesEquals(String modelId, String processDefinitionId) {
+ // 调用 VO 接口的原因是,过滤掉流程模型不需要的规则,保持和 copyTaskAssignRules 方法的一致性
+ List modelRules = getTaskAssignRuleList(modelId, null);
+ List processInstanceRules = getTaskAssignRuleList(null, processDefinitionId);
+ if (modelRules.size() != processInstanceRules.size()) {
+ return false;
+ }
+
+ // 遍历,匹配对应的规则
+ Map processInstanceRuleMap =
+ CollectionUtils.convertMap(processInstanceRules, BpmTaskAssignRuleRespVO::getTaskDefinitionKey);
+ for (BpmTaskAssignRuleRespVO modelRule : modelRules) {
+ BpmTaskAssignRuleRespVO processInstanceRule = processInstanceRuleMap.get(modelRule.getTaskDefinitionKey());
+ if (processInstanceRule == null) {
+ return false;
+ }
+ if (!ObjectUtil.equals(modelRule.getType(), processInstanceRule.getType()) || !ObjectUtil.equal(
+ modelRule.getOptions(), processInstanceRule.getOptions())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void copyTaskAssignRules(String fromModelId, String toProcessDefinitionId) {
+ List rules = getTaskAssignRuleList(fromModelId, null);
+ if (CollUtil.isEmpty(rules)) {
+ return;
+ }
+ // 开始复制
+ List newRules = BpmTaskAssignRuleConvert.INSTANCE.convertList2(rules);
+ newRules.forEach(rule -> rule.setProcessDefinitionId(toProcessDefinitionId).setId(null).setCreateTime(null)
+ .setUpdateTime(null));
+ taskRuleMapper.insertBatch(newRules);
+ }
+
+ @Override
+ public void checkTaskAssignRuleAllConfig(String id) {
+ // 一个用户任务都没配置,所以无需配置规则
+ List taskAssignRules = getTaskAssignRuleList(id, null);
+ if (CollUtil.isEmpty(taskAssignRules)) {
+ return;
+ }
+ // 校验未配置规则的任务
+ taskAssignRules.forEach(rule -> {
+ if (CollUtil.isEmpty(rule.getOptions())) {
+ throw exception(MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG, rule.getTaskDefinitionName());
+ }
+ });
+ }
+
+ private void validTaskAssignRuleOptions(Integer type, Set options) {
+ if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) {
+ roleApi.validRoles(options);
+ } else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
+ BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) {
+ deptApi.validDepts(options);
+ } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) {
+ postApi.validPosts(options);
+ } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) {
+ adminUserApi.validUsers(options);
+ } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) {
+ userGroupService.validUserGroups(options);
+ } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) {
+ dictDataApi.validDictDatas(DictTypeConstants.TASK_ASSIGN_SCRIPT,
+ CollectionUtils.convertSet(options, String::valueOf));
+ } else {
+ throw new IllegalArgumentException(format("未知的规则类型({})", type));
+ }
+ }
+
+ @Override
+ @DataPermission(enable = false) // 忽略数据权限,不然分配会存在问题
+ public Set calculateTaskCandidateUsers(DelegateExecution execution) {
+ BpmTaskAssignRuleDO rule = getTaskRule(execution);
+ return calculateTaskCandidateUsers(execution, rule);
+ }
+
+ @VisibleForTesting
+ BpmTaskAssignRuleDO getTaskRule(DelegateExecution execution) {
+ List taskRules = getTaskAssignRuleListByProcessDefinitionId(
+ execution.getProcessDefinitionId(), execution.getCurrentActivityId());
+ if (CollUtil.isEmpty(taskRules)) {
+ throw new FlowableException(format("流程任务({}/{}/{}) 找不到符合的任务规则",
+ execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId()));
+ }
+ if (taskRules.size() > 1) {
+ throw new FlowableException(format("流程任务({}/{}/{}) 找到过多任务规则({})",
+ execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId()));
+ }
+ return taskRules.get(0);
+ }
+
+ @VisibleForTesting
+ Set calculateTaskCandidateUsers(DelegateExecution execution, BpmTaskAssignRuleDO rule) {
+ Set assigneeUserIds = null;
+ if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByRole(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByDeptMember(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByPost(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByUser(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByUserGroup(rule);
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), rule.getType())) {
+ assigneeUserIds = calculateTaskCandidateUsersByScript(execution, rule);
+ }
+
+ // 移除被禁用的用户
+ removeDisableUsers(assigneeUserIds);
+ // 如果候选人为空,抛出异常
+ if (CollUtil.isEmpty(assigneeUserIds)) {
+ log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", execution.getId(),
+ execution.getProcessDefinitionId(), execution.getCurrentActivityId(), toJsonString(rule));
+ throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER);
+ }
+ return assigneeUserIds;
+ }
+
+ private Set calculateTaskCandidateUsersByRole(BpmTaskAssignRuleDO rule) {
+ return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()).getCheckedData();
+ }
+
+ private Set calculateTaskCandidateUsersByDeptMember(BpmTaskAssignRuleDO rule) {
+ List users = adminUserApi.getUsersByDeptIds(rule.getOptions()).getCheckedData();
+ return convertSet(users, AdminUserRespDTO::getId);
+ }
+
+ private Set calculateTaskCandidateUsersByDeptLeader(BpmTaskAssignRuleDO rule) {
+ List depts = deptApi.getDepts(rule.getOptions()).getCheckedData();
+ return convertSet(depts, DeptRespDTO::getLeaderUserId);
+ }
+
+ private Set calculateTaskCandidateUsersByPost(BpmTaskAssignRuleDO rule) {
+ List