diff --git a/README.md b/README.md deleted file mode 100644 index dc5cfbd4..00000000 --- a/README.md +++ /dev/null @@ -1,228 +0,0 @@ -**严肃声明:现在、未来都不会有商业版本,所有功能全部开源!** - -**拒绝虚假开源,售卖商业版,程序员不骗程序员!!** - -**「我喜欢写代码,乐此不疲」** -**「我喜欢做开源,以此为乐」** - -## 🐯 平台简介 - -**芋道**,以开发者为中心,打造中国第一流的快速开发平台,全部开源,个人与企业可 100% 免费使用。 - -> 有任何问题,或者想要的功能,可以在 _Issues_ 中提给艿艿。 -> -> 😜 给项目点点 Star 吧,这对我们真的很重要! - -* 前端采用 [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin) ,正在支持 Vue 3 + ElementUI Plus 最新方案。 -* 后端采用 Spring Boot、MySQL + MyBatis Plus、Redis + Redisson。 -* 权限认证使用 Spring Security & Token & Redis,支持多终端、多种用户的认证系统。 -* 支持加载动态权限菜单,按钮级别权限控制,本地缓存提升性能。 -* 支持 SaaS 多租户系统,可自定义每个租户的权限,提供透明化的多租户底层封装。 -* 工作流使用 Activiti + Flowable,支持动态表单、在线设计流程、多种任务分配方式。 -* 高效率开发,使用代码生成器可以一键生成前后端代码 + 单元测试 + Swagger 接口文档 + Validator 参数校验。 -* 集成微信小程序、微信公众号、企业微信、钉钉等三方登陆,集成支付宝、微信等支付与退款。 -* 集成阿里云、腾讯云、云片等短信渠道,集成 MinIO、阿里云、腾讯云、七牛云等云存储服务。 - -| 项目名 | 说明 | 传说门 | -|--------------------|------------------------|-------------------------------------------------------------------------------------------------------------------------------------| -| `ruoyi-vue-pro` | Spring Boot 多模块 | **[Gitee](https://gitee.com/zhijiantianya/ruoyi-vue-pro)**     [Github](https://github.com/YunaiV/ruoyi-vue-pro) | -| `ruoyi-vue-cloud` | Spring Cloud 微服务 | **[Gitee](https://gitee.com/zhijiantianya/ruoyi-vue-cloud)**     [Github](https://github.com/YunaiV/onemall) | -| `Spring-Boot-Labs` | Spring Boot & Cloud 入门 | **[Gitee](https://gitee.com/zhijiantianya/SpringBoot-Labs)**     [Github](https://github.com/YunaiV/SpringBoot-Labs) | - -## 🐶 在线体验 - -演示地址: -* 账号密码:admin/admin123 - -文档地址: -* [《如何搭建环境》](http://www.iocoder.cn/categories/Yudao/?yudao) - -> 未来会补充文档和视频,方便胖友冲冲冲! - -## 🐼 内置功能 - -分成多种内置功能: -* 系统功能 -* 工作流程 -* 支付系统 -* 商城系统 -* 基础设施 - -> 友情提示:本项目基于 RuoYi-Vue 修改,**重构优化**后端的代码,**美化**前端的界面。 -> -> * 额外新增的功能,我们使用 🚀 标记。 -> * 重新实现的功能,我们使用 ⭐️ 标记。 - -🙂 所有功能,都通过 **单元测试** 保证高质量。 - -### 系统功能 - -| | 功能 | 描述 | -|-----|-------|---------------------------------| -| | 用户管理 | 用户是系统操作者,该功能主要完成系统用户配置 | -| ⭐️ | 在线用户 | 当前系统中活跃用户状态监控,支持手动踢下线 | -| | 角色管理 | 角色菜单权限分配、设置角色按机构进行数据范围权限划分 | -| | 菜单管理 | 配置系统菜单、操作权限、按钮权限标识等,本地缓存提供性能 | -| | 部门管理 | 配置系统组织机构(公司、部门、小组),树结构展现支持数据权限 | -| | 岗位管理 | 配置系统用户所属担任职务 | -| 🚀 | 租户管理 | 配置系统租户,支持 SaaS 场景下的多租户功能 | -| 🚀 | 租户套餐 | 配置租户套餐,自定每个租户的菜单、操作、按钮的权限 | -| | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 | -| 🚀 | 短信管理 | 短信渠道、短息模板、短信日志,对接阿里云、云片等主流短信平台 | -| 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 | -| ⭐️ | 登录日志 | 系统登录日志记录查询,包含登录异常 | -| 🚀 | 错误码管理 | 系统所有错误码的管理,可在线修改错误提示,无需重启服务 | -| | 通知公告 | 系统通知公告信息发布维护 | - -### 工作流程 - -| | 功能 | 描述 | -|-----|-------|----------------------------------------| -| 🚀 | 流程模型 | 配置工作流的流程模型,支持文件导入与在线设计流程图,提供 7 种任务分配规则 | -| 🚀 | 流程表单 | 拖动表单元素生成相应的工作流表单,覆盖 Element UI 所有的表单组件 | -| 🚀 | 用户分组 | 自定义用户分组,可用于工作流的审批分组 | -| 🚀 | 我的流程 | 查看我发起的工作流程,支持新建、取消流程等操作,高亮流程图、审批时间线 | -| 🚀 | 待办任务 | 查看自己【未】审批的工作任务,支持通过、不通过、转发、委派、退回等操作 | -| 🚀 | 已办任务 | 查看自己【已】审批的工作任务,未来会支持回退操作 | -| 🚀 | OA 请假 | 作为业务自定义接入工作流的使用示例,只需创建请求对应的工作流程,即可进行审批 | - -### 支付系统 - -| | 功能 | 描述 | -|-----|------|---------------------------| -| 🚀 | 商户信息 | 管理商户信息,支持 Saas 场景下的多商户功能 | -| 🚀 | 应用信息 | 配置商户的应用信息,对接支付宝、微信等多个支付渠道 | -| 🚀 | 支付订单 | 查看用户发起的支付宝、微信等的【支付】订单 | -| 🚀 | 退款订单 | 查看用户发起的支付宝、微信等的【退款】订单 | - -ps:核心功能已经实现,正在对接微信小程序中... - -### 商城系统 - -正在开发中,大体计划如下: -* 2022 Q2 => 完成对 的迁移,作为 onemall 的 Spring Boot 单体版本。 -* 2022 Q4 => 完成对 > 的重构,作为 onemall 的 Spring Cloud 微服务版本。 - -### 会员中心 - -正在开发中,大体计划如下: -* 2021 Q1 =》完成对 的迁移 - -### 基础设施 - -| | 功能 | 描述 | -|-----|----------|----------------------------------------------| -| 🚀 | 代码生成 | 前后端代码的生成(Java、Vue、SQL、单元测试),支持 CRUD 下载 | -| 🚀 | 系统接口 | 基于 Swagger 自动生成相关的 RESTful API 接口文档 | -| 🚀 | 数据库文档 | 基于 Screw 自动生成数据库文档,支持导出 Word、HTML、MD 格式 | -| | 表单构建 | 拖动表单元素生成相应的 HTML 代码,支持导出 JSON、Vue 文件 | -| 🚀 | 配置管理 | 对系统动态配置常用参数,支持 SpringBoot 加载 | -| ⭐️ | 定时任务 | 在线(添加、修改、删除)任务调度包含执行结果日志 | -| 🚀 | 文件服务 | 支持将文件存储到 S3(MinIO、阿里云、腾讯云、七牛云)、本地、FTP、数据库等 | -| 🚀 | API 日志 | 包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题 | -| | MySQL 监控 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 | -| | Redis 监控 | 监控 Redis 数据库的使用情况,使用的 Redis Key 管理 | -| 🚀 | 消息队列 | 基于 Redis 实现消息队列,Stream 提供集群消费,Pub/Sub 提供广播消费 | -| 🚀 | Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 | -| 🚀 | 链路追踪 | 接入 SkyWalking 组件,实现链路追踪 | -| 🚀 | 日志中心 | 接入 SkyWalking 组件,实现日志中心 | -| 🚀 | 分布式锁 | 基于 Redis 实现分布式锁,满足并发场景 | -| 🚀 | 幂等组件 | 基于 Redis 实现幂等组件,解决重复请求问题 | -| 🚀 | 服务保障 | 基于 Resilience4j 实现服务的稳定性,包括限流、熔断等功能 | -| 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 | -| 🚀 | 单元测试 | 基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 | - -## 🐨 技术栈 - -| 项目 | 说明 | -|-----------------------|--------------------| -| `yudao-dependencies` | Maven 依赖版本管理 | -| `yudao-framework` | Java 框架拓展 | -| `yudao-server` | 管理后台 + 用户 APP 的服务端 | -| `yudao-admin-ui` | 管理后台的 UI 界面 | -| `yudao-user-ui` | 用户 APP 的 UI 界面 | -| `yudao-module-system` | 系统功能的 Module 模块 | -| `yudao-module-member` | 会员中心的 Module 模块 | -| `yudao-module-infra` | 基础设施的 Module 模块 | -| `yudao-module-tool` | 研发工具的 Module 模块 | -| `yudao-module-bpm` | 工作流程的 Module 模块 | -| `yudao-module-pay` | 支付系统的 Module 模块 | - -### 后端 - -| 框架 | 说明 | 版本 | 学习指南 | -|---------------------------------------------------------------------------------------------|------------------|----------|----------------------------------------------------------------| -| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.5.10 | [文档](https://github.com/YunaiV/SpringBoot-Labs) | -| [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 | | -| [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.8 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | -| [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.1 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) | -| [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | -| [Redis](https://redis.io/) | key-value 数据库 | 5.0 | | -| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.16.8 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) | -| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架 | 5.3.16 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) | -| [Spring Security](https://github.com/spring-projects/spring-security) | Spring 安全框架 | 5.5.5 | [文档](http://www.iocoder.cn/Spring-Boot/Spring-Security/?yudao) | -| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.2.2 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) | -| [Activiti](https://github.com/Activiti/Activiti) | 工作流引擎 | 7.1.0.M6 | [文档](TODO) | -| [Quartz](https://github.com/quartz-scheduler) | 任务调度组件 | 2.3.2 | [文档](http://www.iocoder.cn/Spring-Boot/Job/?yudao) | -| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.2 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) | -| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.0 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) | -| [SkyWalking](https://skywalking.apache.org/) | 分布式应用追踪系统 | 8.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/SkyWalking/?yudao) | -| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 2.4.2 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) | -| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.12.6 | | -| [MapStruct](https://mapstruct.org/) | Java Bean 转换 | 1.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao) | -| [Lombok](https://projectlombok.org/) | 消除冗长的 Java 代码 | 1.16.14 | [文档](http://www.iocoder.cn/Spring-Boot/Lombok/?yudao) | -| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.7.2 | - | -| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 3.9.0 | - | - -### 前端 - -| 框架 | 说明 | 版本 | -|------------------------------------------------------------------------------|---------------|--------| -| [Vue](https://cn.vuejs.org/index.html) | JavaScript 框架 | 2.6.12 | -| [Vue Element Admin](https://panjiachen.github.io/vue-element-admin-site/zh/) | 后台前端解决方案 | - | - -## 🐷 演示图 - -### 系统功能 - -| 模块 | biu | biu | biu | -|----------|--------------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------| -| 登录 & 首页 | ![登录](https://static.iocoder.cn/images/ruoyi-vue-pro/登录.jpg) | ![首页](https://static.iocoder.cn/images/ruoyi-vue-pro/首页.jpg) | ![个人中心](https://static.iocoder.cn/images/ruoyi-vue-pro/个人中心.jpg) | -| 用户 | ![用户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/用户管理.jpg) | ![在线用户](https://static.iocoder.cn/images/ruoyi-vue-pro/在线用户.jpg) | - | -| 租户 & 套餐 | ![租户管理](https://static.iocoder.cn/images/ruoyi-vue-pro/租户管理.jpg) | ![租户套餐](https://static.iocoder.cn/images/ruoyi-vue-pro/租户套餐.png) | - | -| 部门 & 岗位 | ![部门管理](https://static.iocoder.cn/images/ruoyi-vue-pro/部门管理.jpg) | ![岗位管理](https://static.iocoder.cn/images/ruoyi-vue-pro/岗位管理.jpg) | - | -| 菜单 & 角色 | ![菜单管理](https://static.iocoder.cn/images/ruoyi-vue-pro/菜单管理.jpg) | ![角色管理](https://static.iocoder.cn/images/ruoyi-vue-pro/角色管理.jpg) | - | -| 审计日志 | ![操作日志](https://static.iocoder.cn/images/ruoyi-vue-pro/操作日志.jpg) | ![登录日志](https://static.iocoder.cn/images/ruoyi-vue-pro/登录日志.jpg) | - | -| 短信 | ![短信渠道](https://static.iocoder.cn/images/ruoyi-vue-pro/短信渠道.jpg) | ![短信模板](https://static.iocoder.cn/images/ruoyi-vue-pro/短信模板.jpg) | ![短信日志](https://static.iocoder.cn/images/ruoyi-vue-pro/短信日志.jpg) | -| 字典 | ![字典类型](https://static.iocoder.cn/images/ruoyi-vue-pro/字典类型.jpg) | ![字典数据](https://static.iocoder.cn/images/ruoyi-vue-pro/字典数据.jpg) | - | -| 错误码 & 通知 | ![错误码管理](https://static.iocoder.cn/images/ruoyi-vue-pro/错误码管理.jpg) | ![通知公告](https://static.iocoder.cn/images/ruoyi-vue-pro/通知公告.jpg) | - | - -### 工作流程 - -| 模块 | biu | biu | biu | -|---------|------------------------------------------------------------------------|------------------------------------------------------------------------|------------------------------------------------------------------------| -| 流程模型 | ![流程模型-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-列表.jpg) | ![流程模型-设计](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-设计.jpg) | ![流程模型-定义](https://static.iocoder.cn/images/ruoyi-vue-pro/流程模型-定义.jpg) | -| 表单 & 分组 | ![流程表单](https://static.iocoder.cn/images/ruoyi-vue-pro/流程表单.jpg) | ![用户分组](https://static.iocoder.cn/images/ruoyi-vue-pro/用户分组.jpg) | - | -| 我的流程 | ![我的流程-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-列表.jpg) | ![我的流程-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-发起.jpg) | ![我的流程-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/我的流程-详情.jpg) | -| 待办 & 已办 | ![任务列表-审批](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-审批.jpg) | ![任务列表-待办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-待办.jpg) | ![任务列表-已办](https://static.iocoder.cn/images/ruoyi-vue-pro/任务列表-已办.jpg) | -| OA 请假 | ![OA请假-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-列表.jpg) | ![OA请假-发起](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-发起.jpg) | ![OA请假-详情](https://static.iocoder.cn/images/ruoyi-vue-pro/OA请假-详情.jpg) | - -### 支付系统 - -| 模块 | biu | biu | biu | -|---------|------------------------------------------------------------------|------------------------------------------------------------------------|------------------------------------------------------------------------| -| 商家 & 应用 | ![商户信息](https://static.iocoder.cn/images/ruoyi-vue-pro/商户信息.jpg) | ![应用信息-列表](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-列表.jpg) | ![应用信息-编辑](https://static.iocoder.cn/images/ruoyi-vue-pro/应用信息-编辑.jpg) | -| 支付 & 退款 | ![支付订单](https://static.iocoder.cn/images/ruoyi-vue-pro/支付订单.jpg) | ![退款订单](https://static.iocoder.cn/images/ruoyi-vue-pro/退款订单.jpg) | --- | - -### 基础设施 - -| 模块 | biu | biu | biu | -|---------------|----------------------------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------| -| 代码生成 | ![代码生成](https://static.iocoder.cn/images/ruoyi-vue-pro/代码生成.jpg) | ![生成效果](https://static.iocoder.cn/images/ruoyi-vue-pro/生成效果.jpg) | - | -| 文档 | ![系统接口](https://static.iocoder.cn/images/ruoyi-vue-pro/系统接口.jpg) | ![数据库文档](https://static.iocoder.cn/images/ruoyi-vue-pro/数据库文档.jpg) | - | -| 文件 & 配置 | ![文件配置](https://static.iocoder.cn/images/ruoyi-vue-pro/文件配置.jpg) | ![文件管理](https://static.iocoder.cn/images/ruoyi-vue-pro/文件管理2.jpg) | ![配置管理](https://static.iocoder.cn/images/ruoyi-vue-pro/配置管理.jpg) | -| 定时任务 | ![定时任务](https://static.iocoder.cn/images/ruoyi-vue-pro/定时任务.jpg) | ![任务日志](https://static.iocoder.cn/images/ruoyi-vue-pro/任务日志.jpg) | - | -| API 日志 | ![访问日志](https://static.iocoder.cn/images/ruoyi-vue-pro/访问日志.jpg) | ![错误日志](https://static.iocoder.cn/images/ruoyi-vue-pro/错误日志.jpg) | - | -| MySQL & Redis | ![MySQL](https://static.iocoder.cn/images/ruoyi-vue-pro/MySQL.jpg) | ![Redis](https://static.iocoder.cn/images/ruoyi-vue-pro/Redis.jpg) | - | -| 监控平台 | ![Java监控](https://static.iocoder.cn/images/ruoyi-vue-pro/Java监控.jpg) | ![链路追踪](https://static.iocoder.cn/images/ruoyi-vue-pro/链路追踪.jpg) | ![日志中心](https://static.iocoder.cn/images/ruoyi-vue-pro/日志中心.jpg) | - diff --git a/yudao-module-bpm/pom.xml b/yudao-module-bpm/pom.xml deleted file mode 100644 index 6ecdc809..00000000 --- a/yudao-module-bpm/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - yudao - cn.iocoder.boot - ${revision} - - 4.0.0 - - yudao-module-bpm-api - yudao-module-bpm-base - yudao-module-bpm-impl-flowable - yudao-module-bpm-impl-activiti - - yudao-module-bpm - pom - - ${project.artifactId} - - bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。 - 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - bpm 解释:https://baike.baidu.com/item/BPM/1933 - - 目前提供两套实现方案: - 1. 基于 Activiti 7 实现的 yudao-module-bpm-impl-activiti - 2. 基于 Flowable 6 实现的 yudao-module-bpm-impl-flowable - 两套实现会存在共享的逻辑,所以会继承 yudao-module-impl-base - - - diff --git a/yudao-module-bpm/yudao-module-bpm-api/pom.xml b/yudao-module-bpm/yudao-module-bpm-api/pom.xml deleted file mode 100644 index 06554d7f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-api - jar - - ${project.artifactId} - - bpm 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.boot - 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 deleted file mode 100644 index 37a92219..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 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 deleted file mode 100644 index e94a2c84..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApi.java +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 5d7edbe8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 7abb3e1d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/DictTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 9451f6d4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java +++ /dev/null @@ -1,64 +0,0 @@ -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-base/pom.xml b/yudao-module-bpm/yudao-module-bpm-base/pom.xml deleted file mode 100644 index 1980a094..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-base - - ${project.artifactId} - - bpm-base 模块,实现公用的工作流的逻辑,提供给 bpm-activiti 和 bpm-flowable 复用 - - - - - cn.iocoder.boot - yudao-module-bpm-api - ${revision} - - - cn.iocoder.boot - yudao-module-system-api - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-operatelog - - - cn.iocoder.boot - yudao-spring-boot-starter-biz-data-permission - - - - - cn.iocoder.boot - yudao-spring-boot-starter-web - - - - cn.iocoder.boot - yudao-spring-boot-starter-security - - - - - cn.iocoder.boot - yudao-spring-boot-starter-mybatis - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - - - diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java deleted file mode 100644 index 217067f3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmFormController.java +++ /dev/null @@ -1,79 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java deleted file mode 100644 index 4267f090..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmUserGroupController.java +++ /dev/null @@ -1,85 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java deleted file mode 100644 index 11fee5c0..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormBaseVO.java +++ /dev/null @@ -1,25 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java deleted file mode 100644 index d9a62812..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormCreateReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java deleted file mode 100644 index a8097c43..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormPageReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java deleted file mode 100644 index 76cf6204..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormRespVO.java +++ /dev/null @@ -1,33 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java deleted file mode 100644 index 3a6b3c09..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormSimpleRespVO.java +++ /dev/null @@ -1,17 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java deleted file mode 100644 index 55b99767..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/form/BpmFormUpdateReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java deleted file mode 100644 index e0dfe568..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupBaseVO.java +++ /dev/null @@ -1,31 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java deleted file mode 100644 index 48b44d38..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupCreateReqVO.java +++ /dev/null @@ -1,12 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java deleted file mode 100644 index 44631737..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupPageReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -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 beginCreateTime; - - @DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束创建时间") - private Date endCreateTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java deleted file mode 100644 index 55018d50..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java deleted file mode 100644 index 0b47f447..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupSimpleRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java deleted file mode 100644 index 14aa25c5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/group/BpmUserGroupUpdateReqVO.java +++ /dev/null @@ -1,17 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java deleted file mode 100644 index 7240ba15..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java +++ /dev/null @@ -1,22 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java deleted file mode 100644 index 542a177e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelBaseVO.java +++ /dev/null @@ -1,41 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java deleted file mode 100644 index c85ef3ae..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java deleted file mode 100644 index 7442b5ab..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageItemRespVO.java +++ /dev/null @@ -1,49 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java deleted file mode 100644 index 945da139..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelPageReqVO.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java deleted file mode 100644 index bce0f910..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java deleted file mode 100644 index 972aa31b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java +++ /dev/null @@ -1,40 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java deleted file mode 100644 index 9cfcebbd..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateStateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java deleted file mode 100644 index 5e45b8bd..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionListReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java deleted file mode 100644 index 75990f08..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageItemRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java deleted file mode 100644 index a9657e9a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionPageReqVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java deleted file mode 100644 index 6f8fd4e5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/process/BpmProcessDefinitionRespVO.java +++ /dev/null @@ -1,52 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java deleted file mode 100644 index bcb9fc0f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleBaseVO.java +++ /dev/null @@ -1,25 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java deleted file mode 100644 index cbbc108c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleCreateReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java deleted file mode 100644 index c0786e52..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleRespVO.java +++ /dev/null @@ -1,29 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java deleted file mode 100644 index 8f1c1270..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/rule/BpmTaskAssignRuleUpdateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http deleted file mode 100644 index 96bbf964..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.http +++ /dev/null @@ -1,12 +0,0 @@ -### 请求 /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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java deleted file mode 100644 index dd66580d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/BpmOALeaveController.java +++ /dev/null @@ -1,63 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java deleted file mode 100644 index 7028708b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * OA 示例,用于演示外部业务接入 BPM 工作流的示例 - * 一般的接入方式,只需要调用 接口,后续 Admin 用户在管理后台的【待办事务】进行审批 - */ -package cn.iocoder.yudao.module.bpm.controller.admin.oa; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java deleted file mode 100644 index cbc568a1..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveBaseVO.java +++ /dev/null @@ -1,33 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java deleted file mode 100644 index 2ebab63e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveCreateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java deleted file mode 100644 index 0443d44f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeavePageReqVO.java +++ /dev/null @@ -1,34 +0,0 @@ -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 beginCreateTime; - - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @ApiModelProperty(value = "结束申请时间") - private Date endCreateTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java deleted file mode 100644 index 908c48e0..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/oa/vo/BpmOALeaveRespVO.java +++ /dev/null @@ -1,32 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/package-info.java deleted file mode 100644 index 6cf7f955..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java deleted file mode 100644 index ef9d11ac..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/activity/BpmActivityRespVO.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java deleted file mode 100644 index 928f187e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCancelReqVO.java +++ /dev/null @@ -1,23 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java deleted file mode 100644 index 2085253d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceCreateReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java deleted file mode 100644 index e1e4327e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceMyPageReqVO.java +++ /dev/null @@ -1,44 +0,0 @@ -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 beginCreateTime; - - @ApiModelProperty(value = "结束的创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private Date endCreateTime; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java deleted file mode 100644 index 5b5d5797..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstancePageItemRespVO.java +++ /dev/null @@ -1,55 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java deleted file mode 100644 index a1547b17..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/instance/BpmProcessInstanceRespVO.java +++ /dev/null @@ -1,97 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java deleted file mode 100644 index 6effcc8a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -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 javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.Map; - -@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 comment; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java deleted file mode 100644 index 6d186557..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java +++ /dev/null @@ -1,27 +0,0 @@ -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 comment; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java deleted file mode 100644 index 99145b43..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java deleted file mode 100644 index 7196718f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRejectReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -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 comment; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java deleted file mode 100644 index 9100eb3c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java +++ /dev/null @@ -1,39 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java deleted file mode 100644 index e25e3aa4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java +++ /dev/null @@ -1,54 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java deleted file mode 100644 index 9f248e19..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java +++ /dev/null @@ -1,32 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java deleted file mode 100644 index 0dd0ffed..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskUpdateAssigneeReqVO.java +++ /dev/null @@ -1,25 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 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-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java deleted file mode 100644 index 6ba75741..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmFormConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java deleted file mode 100644 index bbf00ba5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmUserGroupConvert.java +++ /dev/null @@ -1,38 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java deleted file mode 100644 index 92683f4c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/message/BpmMessageConvert.java +++ /dev/null @@ -1,16 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java deleted file mode 100644 index f87531bf..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/oa/BpmOALeaveConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java deleted file mode 100644 index 6a53114a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java deleted file mode 100644 index 76bf777e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmFormDO.java +++ /dev/null @@ -1,57 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java deleted file mode 100644 index 57abc0b9..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionExtDO.java +++ /dev/null @@ -1,90 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java deleted file mode 100644 index e65764f1..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskAssignRuleDO.java +++ /dev/null @@ -1,83 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java deleted file mode 100644 index db204c02..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmTaskMessageRuleDO.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.dataobject.definition; - -// TODO 芋艿:先埋个坑。任务消息的配置规则。说白了,就是不同的 -public class BpmTaskMessageRuleDO { -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java deleted file mode 100644 index ec116818..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmUserGroupDO.java +++ /dev/null @@ -1,52 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java deleted file mode 100644 index 31381a55..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/oa/BpmOALeaveDO.java +++ /dev/null @@ -1,73 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java deleted file mode 100644 index b3770996..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java +++ /dev/null @@ -1,90 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java deleted file mode 100644 index 780ac505..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java +++ /dev/null @@ -1,84 +0,0 @@ -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 流程任务的拓展表 - * 主要解决 Activiti 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 comment; - /** - * 任务的结束时间 - * - * 冗余 HistoricTaskInstance 的 endTime 属性 - */ - private Date endTime; - - /** - * 流程实例的编号 - * - * 关联 ProcessInstance 的 id 属性 - */ - private String processInstanceId; - /** - * 流程定义的编号 - * - * 关联 ProcessDefinition 的 id 属性 - */ - private String processDefinitionId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java deleted file mode 100644 index 53c01d92..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmFormMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java deleted file mode 100644 index 3ff53f2d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java deleted file mode 100644 index 1205d30e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmTaskAssignRuleMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java deleted file mode 100644 index 982e678b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/definition/BpmUserGroupMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -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.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(BpmUserGroupDO::getId)); - } - - default List selectListByStatus(Integer status) { - return selectList(BpmUserGroupDO::getStatus, status); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java deleted file mode 100644 index ba781e35..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOALeaveMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -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.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(BpmOALeaveDO::getId)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java deleted file mode 100644 index ee31b08c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceMyPageReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface BpmProcessInstanceExtMapper extends BaseMapperX { - - default PageResult selectPage(Long userId, BpmProcessInstanceMyPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .eqIfPresent("start_user_id", userId) - .likeIfPresent("name", reqVO.getName()) - .eqIfPresent("process_definition_id", reqVO.getProcessDefinitionId()) - .eqIfPresent("category", reqVO.getCategory()) - .eqIfPresent("status", reqVO.getStatus()) - .eqIfPresent("result", reqVO.getResult()) - .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc("id")); - } - - default BpmProcessInstanceExtDO selectByProcessInstanceId(String processDefinitionId) { - return selectOne("process_instance_id", processDefinitionId); - } - - default void updateByProcessInstanceId(BpmProcessInstanceExtDO updateObj) { - update(updateObj, new QueryWrapper() - .eq("process_instance_id", updateObj.getProcessInstanceId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java deleted file mode 100644 index b2927a65..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.dal.mysql.task; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -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 List selectListByProcessInstanceId(String processInstanceId) { - return selectList("process_instance_id", processInstanceId); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java deleted file mode 100644 index c21d6f99..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelFormTypeEnum.java +++ /dev/null @@ -1,21 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java deleted file mode 100644 index de3c3516..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskAssignRuleTypeEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java deleted file mode 100644 index 7fc0e3b8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmTaskRuleScriptEnum.java +++ /dev/null @@ -1,30 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java deleted file mode 100644 index 79001fcc..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/message/BpmMessageEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java deleted file mode 100644 index e41930bb..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java +++ /dev/null @@ -1,37 +0,0 @@ -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("主动取消任务,原因:{}"); - - 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, "不通过任务,原因:"); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java deleted file mode 100644 index 39bf22ad..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.enums.task; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -/** - * 流程实例的结果 - * - * @author jason - */ -@Getter -@AllArgsConstructor -public enum BpmProcessInstanceResultEnum { - - PROCESS(1, "处理中"), - APPROVE(2, "通过"), - REJECT(3, "不通过"), - CANCEL(4, "已取消"); - - /** - * 结果 - */ - private final Integer result; - /** - * 描述 - */ - private final String desc; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java deleted file mode 100644 index 70a31dd3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusEnum.java +++ /dev/null @@ -1,27 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java deleted file mode 100644 index 8915fc6b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCommonConfiguration.java +++ /dev/null @@ -1,19 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java deleted file mode 100644 index 9fccbab8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java deleted file mode 100644 index c2b21539..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventListener.java +++ /dev/null @@ -1,34 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java deleted file mode 100644 index dc5c21b7..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/BpmProcessInstanceResultEventPublisher.java +++ /dev/null @@ -1,24 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java deleted file mode 100644 index c4a13112..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/event/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 自定义 Event 实现,提供方便业务接入的 Listener! - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm.core.event; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java deleted file mode 100644 index b97cb4c8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/core/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm.core; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java deleted file mode 100644 index 9a5e3ea9..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供给 Activiti 和 Flowable 的通用封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f9..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 6d399cf2..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java deleted file mode 100644 index 80355ef5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormService.java +++ /dev/null @@ -1,99 +0,0 @@ -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-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java deleted file mode 100644 index d64684b8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.lang.Assert; -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.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -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 ServiceExceptionUtil.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 ServiceExceptionUtil.exception(ErrorCodeConstants.FORM_FIELD_REPEAT, oldLabel, fieldDTO.getLabel(), fieldDTO.getVModel()); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java deleted file mode 100644 index da185105..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupService.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import java.util.*; -import javax.validation.*; - -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.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -/** - * 用户组 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmUserGroupService { - - /** - * 创建用户组 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createUserGroup(@Valid BpmUserGroupCreateReqVO createReqVO); - - /** - * 更新用户组 - * - * @param updateReqVO 更新信息 - */ - void updateUserGroup(@Valid BpmUserGroupUpdateReqVO updateReqVO); - - /** - * 删除用户组 - * - * @param id 编号 - */ - void deleteUserGroup(Long id); - - /** - * 获得用户组 - * - * @param id 编号 - * @return 用户组 - */ - BpmUserGroupDO getUserGroup(Long id); - - /** - * 获得用户组列表 - * - * @param ids 编号 - * @return 用户组列表 - */ - List getUserGroupList(Collection ids); - - /** - * 获得指定状态的用户组列表 - * - * @param status 状态 - * @return 用户组列表 - */ - List getUserGroupListByStatus(Integer status); - - /** - * 获得用户组分页 - * - * @param pageReqVO 分页查询 - * @return 用户组分页 - */ - PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO); - - /** - * 校验用户组们是否有效。如下情况,视为无效: - * 1. 用户组编号不存在 - * 2. 用户组被禁用 - * - * @param ids 用户组编号数组 - */ - void validUserGroups(Set ids); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java deleted file mode 100644 index e6a93b45..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -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.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.dal.mysql.definition.BpmUserGroupMapper; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -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 BpmUserGroupServiceImpl implements BpmUserGroupService { - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Override - public Long createUserGroup(BpmUserGroupCreateReqVO createReqVO) { - // 插入 - BpmUserGroupDO userGroup = BpmUserGroupConvert.INSTANCE.convert(createReqVO); - userGroupMapper.insert(userGroup); - // 返回 - return userGroup.getId(); - } - - @Override - public void updateUserGroup(BpmUserGroupUpdateReqVO updateReqVO) { - // 校验存在 - this.validateUserGroupExists(updateReqVO.getId()); - // 更新 - BpmUserGroupDO updateObj = BpmUserGroupConvert.INSTANCE.convert(updateReqVO); - userGroupMapper.updateById(updateObj); - } - - @Override - public void deleteUserGroup(Long id) { - // 校验存在 - this.validateUserGroupExists(id); - // 删除 - userGroupMapper.deleteById(id); - } - - private void validateUserGroupExists(Long id) { - if (userGroupMapper.selectById(id) == null) { - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); - } - } - - @Override - public BpmUserGroupDO getUserGroup(Long id) { - return userGroupMapper.selectById(id); - } - - @Override - public List getUserGroupList(Collection ids) { - return userGroupMapper.selectBatchIds(ids); - } - - - @Override - public List getUserGroupListByStatus(Integer status) { - return userGroupMapper.selectListByStatus(status); - } - - @Override - public PageResult getUserGroupPage(BpmUserGroupPageReqVO pageReqVO) { - return userGroupMapper.selectPage(pageReqVO); - } - - @Override - public void validUserGroups(Set ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - // 获得用户组信息 - List userGroups = userGroupMapper.selectBatchIds(ids); - Map userGroupMap = CollectionUtils.convertMap(userGroups, BpmUserGroupDO::getId); - // 校验 - ids.forEach(id -> { - BpmUserGroupDO userGroup = userGroupMap.get(id); - if (userGroup == null) { - throw ServiceExceptionUtil.exception(USER_GROUP_NOT_EXISTS); - } - if (!CommonStatusEnum.ENABLE.getStatus().equals(userGroup.getStatus())) { - throw exception(USER_GROUP_IS_DISABLE, userGroup.getName()); - } - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java deleted file mode 100644 index 1606192c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmFormFieldRespDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -/** - * Bpm 表单的 Field 表单项 Response DTO - * 字段的定义,可见 https://github.com/JakHuang/form-generator/issues/46 文档 - * - * @author 芋道源码 - */ -@Data -public class BpmFormFieldRespDTO { - - /** - * 表单标题 - */ - private String label; - /** - * 表单字段的属性名,可自定义 - */ - @JsonProperty(value = "vModel") - private String vModel; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java deleted file mode 100644 index 3a36b0ee..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -/** - * BPM 流程 MetaInfo Response DTO - * 主要用于 { Model#setMetaInfo(String)} 的存储 - * - * @author 芋道源码 - */ -@Data -public class BpmModelMetaInfoRespDTO { - - /** - * 流程描述 - */ - private String description; - /** - * 表单类型 - */ - private Integer formType; - /** - * 表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java deleted file mode 100644 index 8b2d22ad..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java +++ /dev/null @@ -1,104 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition.dto; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum; -import lombok.Data; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Objects; - -/** - * 流程定义创建 Request DTO - */ -@Data -public class BpmProcessDefinitionCreateReqDTO { - - // ========== 模型相关 ========== - - /** - * 流程模型的编号 - */ - @NotEmpty(message = "流程模型编号不能为空") - private String modelId; - /** - * 流程标识 - */ - @NotEmpty(message = "流程标识不能为空") - private String key; - /** - * 流程名称 - */ - @NotEmpty(message = "流程名称不能为空") - private String name; - /** - * 流程描述 - */ - private String description; - /** - * 流程分类 - * 参见 bpm_model_category 数据字典 - */ - @NotEmpty(message = "流程分类不能为空") - private String category; - /** - * BPMN XML - */ - @NotEmpty(message = "BPMN XML 不能为空") - private byte[] bpmnBytes; - - // ========== 表单相关 ========== - - /** - * 表单类型 - */ - @NotNull(message = "表单类型不能为空") - private Integer formType; - /** - * 动态表单编号 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private Long formId; - /** - * 表单的配置 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private String formConf; - /** - * 表单项的数组 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 - */ - private List formFields; - /** - * 自定义表单的提交路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomCreatePath; - /** - * 自定义表单的查看路径,使用 Vue 的路由地址 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 - */ - private String formCustomViewPath; - - @AssertTrue(message = "流程表单信息不全") - public boolean isNormalFormTypeValid() { - // 如果非业务表单,则直接通过 - if (!Objects.equals(formType, BpmModelFormTypeEnum.NORMAL.getType())) { - return true; - } - return formId != null && StrUtil.isNotEmpty(formConf) && CollUtil.isNotEmpty(formFields); - } - - @AssertTrue(message = "业务表单信息不全") - public boolean isNormalCustomTypeValid() { - // 如果非业务表单,则直接通过 - if (!Objects.equals(formType, BpmModelFormTypeEnum.CUSTOM.getType())) { - return true; - } - return StrUtil.isNotEmpty(formCustomCreatePath) && StrUtil.isNotEmpty(formCustomViewPath); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java deleted file mode 100644 index ff51ae30..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageService.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -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.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; - -import javax.validation.Valid; - -/** - * BPM 消息 Service 接口 - * - * TODO 芋艿:未来支持消息的可配置;不同的流程,在什么场景下,需要发送什么消息,消息的内容是什么; - * - * @author 芋道源码 - */ -public interface BpmMessageService { - - /** - * 发送流程实例被通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceApprove(@Valid BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO); - - /** - * 发送流程实例被不通过的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenProcessInstanceReject(@Valid BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO); - - /** - * 发送任务被分配的消息 - * - * @param reqDTO 发送信息 - */ - void sendMessageWhenTaskAssigned(@Valid BpmMessageSendWhenTaskCreatedReqDTO reqDTO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java deleted file mode 100644 index 61b3c57d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/BpmMessageServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message; - -import cn.iocoder.yudao.framework.web.config.WebProperties; -import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; -import cn.iocoder.yudao.module.bpm.enums.message.BpmMessageEnum; -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.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; -import cn.iocoder.yudao.module.system.api.sms.SmsSendApi; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -/** - * BPM 消息 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmMessageServiceImpl implements BpmMessageService { - - @Resource - private SmsSendApi smsSendApi; - - @Resource - private WebProperties webProperties; - - @Override - public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("comment", reqDTO.getComment()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); - } - - @Override - public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { - Map templateParams = new HashMap<>(); - templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); - templateParams.put("taskName", reqDTO.getTaskName()); - templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); - templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); - smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), - BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); - } - - private String getProcessInstanceDetailUrl(String taskId) { - return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java deleted file mode 100644 index 7c37734f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceApproveReqDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceApproveReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java deleted file mode 100644 index 0194d03a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenProcessInstanceRejectReqDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送流程实例被不通过 Request DTO - */ -@Data -public class BpmMessageSendWhenProcessInstanceRejectReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - - /** - * 不通过理由 - */ - @NotEmpty(message = "不通过理由不能为空") - private String comment; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java deleted file mode 100644 index 7cb0e3d7..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/message/dto/BpmMessageSendWhenTaskCreatedReqDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.message.dto; - -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * BPM 发送任务被分配 Request DTO - */ -@Data -public class BpmMessageSendWhenTaskCreatedReqDTO { - - /** - * 流程实例的编号 - */ - @NotEmpty(message = "流程实例的编号不能为空") - private String processInstanceId; - /** - * 流程实例的名字 - */ - @NotEmpty(message = "流程实例的名字不能为空") - private String processInstanceName; - @NotNull(message = "发起人的用户编号") - private Long startUserId; - @NotEmpty(message = "发起人的昵称") - private String startUserNickname; - - /** - * 流程任务的编号 - */ - @NotEmpty(message = "流程任务的编号不能为空") - private String taskId; - /** - * 流程任务的名字 - */ - @NotEmpty(message = "流程任务的名字不能为空") - private String taskName; - - /** - * 审批人的用户编号 - */ - @NotNull(message = "审批人的用户编号不能为空") - private Long assigneeUserId; - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java deleted file mode 100644 index a851f403..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveService.java +++ /dev/null @@ -1,53 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -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.dal.dataobject.oa.BpmOALeaveDO; - -import javax.validation.Valid; - -/** - * 请假申请 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmOALeaveService { - - /** - * 创建请假申请 - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO); - - /** - * 更新请假申请的状态 - * - * @param id 编号 - * @param result 结果 - */ - void updateLeaveResult(Long id, Integer result); - - /** - * 获得请假申请 - * - * @param id 编号 - * @return 请假申请 - */ - BpmOALeaveDO getLeave(Long id); - - /** - * 获得请假申请分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页查询 - * @return 请假申请分页 - */ - PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java deleted file mode 100644 index d0aadd95..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOALeaveServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa; - -import cn.hutool.core.date.DateUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -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.convert.oa.BpmOALeaveConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_LEAVE_NOT_EXISTS; - -/** - * OA 请假申请 Service 实现类 - * - * @author jason - * @author 芋道源码 - */ -@Service -@Validated -public class BpmOALeaveServiceImpl implements BpmOALeaveService { - - /** - * OA 请假对应的流程定义 KEY - */ - public static final String PROCESS_KEY = "oa_leave"; - - @Resource - private BpmOALeaveMapper leaveMapper; - - @Resource - private BpmProcessInstanceApi processInstanceApi; - - @Override - @Transactional(rollbackFor = Exception.class) - public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { - // 插入 OA 请假单 - long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false); - BpmOALeaveDO leave = BpmOALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - leaveMapper.insert(leave); - - // 发起 BPM 流程 - Map processInstanceVariables = new HashMap<>(); - processInstanceVariables.put("day", day); - String processInstanceId = processInstanceApi.createProcessInstance(userId, - new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) - .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId()))); - - // 将工作流的编号,更新到 OA 请假单中 - leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); - return leave.getId(); - } - - @Override - public void updateLeaveResult(Long id, Integer result) { - validateLeaveExists(id); - leaveMapper.updateById(new BpmOALeaveDO().setId(id).setResult(result)); - } - - private void validateLeaveExists(Long id) { - if (leaveMapper.selectById(id) == null) { - throw exception(OA_LEAVE_NOT_EXISTS); - } - } - - @Override - public BpmOALeaveDO getLeave(Long id) { - return leaveMapper.selectById(id); - } - - @Override - public PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) { - return leaveMapper.selectPage(userId, pageReqVO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java deleted file mode 100644 index 2354070f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/listener/BpmOALeaveResultListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.oa.listener; - -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent; -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveService; -import cn.iocoder.yudao.module.bpm.service.oa.BpmOALeaveServiceImpl; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * OA 请假单的结果的监听器实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListener { - - @Resource - private BpmOALeaveService leaveService; - - @Override - protected String getProcessDefinitionKey() { - return BpmOALeaveServiceImpl.PROCESS_KEY; - } - - @Override - protected void onEvent(BpmProcessInstanceResultEvent event) { - leaveService.updateLeaveResult(Long.parseLong(event.getBusinessKey()), event.getResult()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java deleted file mode 100644 index eaa61530..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java deleted file mode 100644 index bdd88afe..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -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.module.bpm.dal.mysql.definition.BpmFormMapper; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmFormFieldRespDTO; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.FORM_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; - -/** - * {@link BpmFormServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(BpmFormServiceImpl.class) -public class BpmFormServiceTest extends BaseDbUnitTest { - - @Resource - private BpmFormServiceImpl formService; - - @Resource - private BpmFormMapper formMapper; - - @Test - public void testCreateForm_success() { - // 准备参数 - BpmFormCreateReqVO reqVO = randomPojo(BpmFormCreateReqVO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - - // 调用 - Long formId = formService.createForm(reqVO); - // 断言 - assertNotNull(formId); - // 校验记录的属性是否正确 - BpmFormDO form = formMapper.selectById(formId); - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { - o.setConf("{}"); - o.setFields(randomFields()); - }); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> { - o.setId(dbForm.getId()); // 设置更新的 ID - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用 - formService.updateForm(reqVO); - // 校验是否更新正确 - BpmFormDO form = formMapper.selectById(reqVO.getId()); // 获取最新的 - assertPojoEquals(reqVO, form); - } - - @Test - public void testUpdateForm_notExists() { - // 准备参数 - BpmFormUpdateReqVO reqVO = randomPojo(BpmFormUpdateReqVO.class, o -> { - o.setConf("{'yudao': 'yuanma'}"); - o.setFields(randomFields()); - }); - - // 调用, 并断言异常 - assertServiceException(() -> formService.updateForm(reqVO), FORM_NOT_EXISTS); - } - - @Test - public void testDeleteForm_success() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class); - formMapper.insert(dbForm);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbForm.getId(); - - // 调用 - formService.deleteForm(id); - // 校验数据不存在了 - assertNull(formMapper.selectById(id)); - } - - @Test - public void testDeleteForm_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> formService.deleteForm(id), FORM_NOT_EXISTS); - } - - @Test - public void testGetFormPage() { - // mock 数据 - BpmFormDO dbForm = randomPojo(BpmFormDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - }); - formMapper.insert(dbForm); - // 测试 name 不匹配 - formMapper.insert(cloneIgnoreId(dbForm, o -> o.setName("源码"))); - // 准备参数 - BpmFormPageReqVO reqVO = new BpmFormPageReqVO(); - reqVO.setName("芋道"); - - // 调用 - PageResult pageResult = formService.getFormPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbForm, pageResult.getList().get(0)); - } - - private List randomFields() { - int size = RandomUtil.randomInt(1, 3); - return Stream.iterate(0, i -> i).limit(size) - .map(i -> JsonUtils.toJsonString(randomPojo(BpmFormFieldRespDTO.class))) - .collect(Collectors.toList()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java deleted file mode 100644 index 78e38870..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.DateUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.framework.test.core.util.AssertUtils; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -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.BpmUserGroupUpdateReqVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmUserGroupMapper; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Import; - -import javax.annotation.Resource; - -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.USER_GROUP_NOT_EXISTS; - -/** -* {@link BpmUserGroupServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ -@Import(BpmUserGroupServiceImpl.class) -public class BpmUserGroupServiceTest extends BaseDbUnitTest { - - @Resource - private BpmUserGroupServiceImpl userGroupService; - - @Resource - private BpmUserGroupMapper userGroupMapper; - - @Test - public void testCreateUserGroup_success() { - // 准备参数 - BpmUserGroupCreateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupCreateReqVO.class); - - // 调用 - Long userGroupId = userGroupService.createUserGroup(reqVO); - // 断言 - Assertions.assertNotNull(userGroupId); - // 校验记录的属性是否正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(userGroupId); - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class, o -> { - o.setId(dbUserGroup.getId()); // 设置更新的 ID - }); - - // 调用 - userGroupService.updateUserGroup(reqVO); - // 校验是否更新正确 - BpmUserGroupDO userGroup = userGroupMapper.selectById(reqVO.getId()); // 获取最新的 - AssertUtils.assertPojoEquals(reqVO, userGroup); - } - - @Test - public void testUpdateUserGroup_notExists() { - // 准备参数 - BpmUserGroupUpdateReqVO reqVO = RandomUtils.randomPojo(BpmUserGroupUpdateReqVO.class); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.updateUserGroup(reqVO), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testDeleteUserGroup_success() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class); - userGroupMapper.insert(dbUserGroup);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbUserGroup.getId(); - - // 调用 - userGroupService.deleteUserGroup(id); - // 校验数据不存在了 - Assertions.assertNull(userGroupMapper.selectById(id)); - } - - @Test - public void testDeleteUserGroup_notExists() { - // 准备参数 - Long id = RandomUtils.randomLongId(); - - // 调用, 并断言异常 - AssertUtils.assertServiceException(() -> userGroupService.deleteUserGroup(id), USER_GROUP_NOT_EXISTS); - } - - @Test - public void testGetUserGroupPage() { - // mock 数据 - BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 - o.setName("芋道源码"); - o.setStatus(CommonStatusEnum.ENABLE.getStatus()); - o.setCreateTime(DateUtils.buildTime(2021, 11, 11)); - }); - userGroupMapper.insert(dbUserGroup); - // 测试 name 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道"))); - // 测试 status 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); - // 测试 createTime 不匹配 - userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(DateUtils.buildTime(2021, 12, 12)))); - // 准备参数 - BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO(); - reqVO.setName("源码"); - reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); - reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10)); - reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12)); - - // 调用 - PageResult pageResult = userGroupService.getUserGroupPage(reqVO); - // 断言 - Assertions.assertEquals(1, pageResult.getTotal()); - Assertions.assertEquals(1, pageResult.getList().size()); - AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml deleted file mode 100644 index c4a0f303..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,43 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback.xml b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback.xml deleted file mode 100644 index daf756bf..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/clean.sql deleted file mode 100644 index 6e42d3cf..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/clean.sql +++ /dev/null @@ -1,2 +0,0 @@ -DELETE FROM "bpm_form"; -DELETE FROM "bpm_user_group"; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/create_tables.sql deleted file mode 100644 index 20a939b7..00000000 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/sql/create_tables.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE IF NOT EXISTS "bpm_user_group" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "description" varchar(255) NOT NULL, - "status" tinyint NOT NULL, - "member_user_ids" varchar(255) NOT NULL, - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '用户组'; - -CREATE TABLE IF NOT EXISTS "bpm_form" ( - "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, - "name" varchar(63) NOT NULL, - "status" tinyint NOT NULL, - "fields" varchar(255) NOT NULL, - "conf" varchar(255) NOT NULL, - "remark" varchar(255), - "creator" varchar(64) DEFAULT '', - "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updater" varchar(64) DEFAULT '', - "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "deleted" bit NOT NULL DEFAULT FALSE, - PRIMARY KEY ("id") -) COMMENT '动态表单'; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/pom.xml b/yudao-module-bpm/yudao-module-bpm-impl-activiti/pom.xml deleted file mode 100644 index 839150b3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-impl-activiti - jar - - ${project.artifactId} - - bpm-activiti 模块,基于 Activiti 7 实现工作流 - - - - - cn.iocoder.boot - yudao-module-bpm-base - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-activiti - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 2137e220..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java deleted file mode 100644 index ff396602..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.yudao.module.bpm.api.task; - -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; - -/** - * Activiti 流程实例 Api 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class BpmProcessInstanceApiImpl implements BpmProcessInstanceApi { - - @Resource - private BpmProcessInstanceService processInstanceService; - - @Override - public String createProcessInstance(Long userId, BpmProcessInstanceCreateReqDTO reqDTO) { - return processInstanceService.createProcessInstance(userId, reqDTO); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java deleted file mode 100644 index 5d8b4bfc..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java +++ /dev/null @@ -1,96 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -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 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 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 bpmModelService; - - @GetMapping("/page") - @ApiOperation(value = "获得模型分页") - public CommonResult> getModelPage(BpmModelPageReqVO pageVO) { - return success(bpmModelService.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 = bpmModelService.getModel(id); - return success(model); - } - - @PostMapping("/create") - @ApiOperation(value = "新建模型") - @PreAuthorize("@ss.hasPermission('bpm:model:create')") - public CommonResult createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) { - return success(bpmModelService.createModel(createRetVO, null)); - } - - @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(bpmModelService.createModel(createReqVO, bpmnXml)); - } - - @PutMapping("/update") - @ApiOperation(value = "修改模型") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) { - bpmModelService.updateModel(modelVO); - 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) { - bpmModelService.deleteModel(id); - return success(true); - } - - @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) { - bpmModelService.deployModel(id); - return success(true); - } - - @PutMapping("/update-state") - @ApiOperation(value = "修改模型的状态", notes = "实际更新的部署的流程定义的状态") - @PreAuthorize("@ss.hasPermission('bpm:model:update')") - public CommonResult updateModelState(@Valid @RequestBody BpmModelUpdateStateReqVO reqVO) { - bpmModelService.updateModelState(reqVO.getId(), reqVO.getState()); - return success(true); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.http b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.http deleted file mode 100644 index 492960ed..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 请求 /bpm/process-definition/list 接口 => 成功 -GET {{baseUrl}}/bpm/process-definition/list?suspensionState=1 -tenant-id: 1 -Authorization: Bearer {{token}} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java deleted file mode 100644 index 769e53ec..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.definition; - -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 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.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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.http b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.http deleted file mode 100644 index e5d8fe96..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.http +++ /dev/null @@ -1,4 +0,0 @@ -### 请求 /bpm/task-assign-rule/list 接口 => 成功 -GET {{baseUrl}}/bpm/task-assign-rule/list?processDefinitionId=leave:9:59689ba0-7284-11ec-965c-a2380e71991a -tenant-id: 1 -Authorization: Bearer {{token}} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java deleted file mode 100644 index b51a4661..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java +++ /dev/null @@ -1,59 +0,0 @@ -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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java deleted file mode 100644 index 224a942f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.service.task.BpmActivityService; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; -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 javax.servlet.http.HttpServletResponse; -import java.io.IOException; -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)); - } - - @GetMapping("/generate-highlight-diagram") - @ApiOperation(value = "生成指定流程实例的高亮流程图", - notes = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成") - @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class) - @PreAuthorize("@ss.hasPermission('bpm:task:query')") - public void generateHighlightDiagram(@RequestParam("processInstanceId") String processInstanceId, - HttpServletResponse response) throws IOException { - byte[] bytes = activityService.generateHighlightDiagram(processInstanceId); - ServletUtils.writeAttachment(response, StrUtil.format("流程图-{}.svg", processInstanceId), bytes); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.http b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.http deleted file mode 100644 index e9243ed6..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.http +++ /dev/null @@ -1,29 +0,0 @@ -### 请求 /bpm/process-instance/create 接口 => 成功 -POST {{baseUrl}}/bpm/process-instance/create -Content-Type: application/json -tenant-id: 1 -Authorization: Bearer {{token}} - -{ - "processDefinitionId": "gateway_test:2:00e52d8e-701b-11ec-aca9-a2380e71991a", - "variables": { - "a": 1, - "b": "2" - } -} - -### 请求 /bpm/process-instance/cancel 接口 => 成功 -DELETE {{baseUrl}}/bpm/process-instance/cancel -Content-Type: application/json -tenant-id: 1 -Authorization: Bearer {{token}} - -{ - "id": "b9220387-7088-11ec-bcae-a2380e71991a", - "reason": "我就取消" -} - -### 请求 /bpm/process-instance/get 接口 => 成功 -GET {{baseUrl}}/bpm/process-instance/get?id=537cceb3-768c-11ec-afcd-a2380e71991a -tenant-id: 1 -Authorization: Bearer {{token}} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java deleted file mode 100644 index e859968e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ /dev/null @@ -1,60 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -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 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; - - @PostMapping("/create") - @ApiOperation("新建流程实例") - @PreAuthorize("@ss.hasPermission('bpm:process-instance:query')") - public CommonResult createProcessInstance(@Valid @RequestBody BpmProcessInstanceCreateReqVO createReqVO) { - return success(processInstanceService.createProcessInstance(getLoginUserId(), createReqVO)); - } - - @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); - } - - @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)); - } - - @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)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.http b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.http deleted file mode 100644 index ee4bf0c2..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.http +++ /dev/null @@ -1,14 +0,0 @@ -### 请求 /bpm/task/todo-page 接口 => 成功 -GET {{baseUrl}}/bpm/task/todo-page -tenant-id: 1 -Authorization: Bearer {{token}} - -### 请求 /bpm/task/done-page 接口 => 成功 -GET {{baseUrl}}/bpm/task/done-page?pageSize=100 -tenant-id: 1 -Authorization: Bearer {{token}} - -### 请求 /bpm/task/list-by-process-instance-id 接口 => 成功 -GET {{baseUrl}}/bpm/task/list-by-process-instance-id?processInstanceId=537cceb3-768c-11ec-afcd-a2380e71991a -tenant-id: 1 -Authorization: Bearer {{token}} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java deleted file mode 100644 index 6b8f6dff..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ /dev/null @@ -1,77 +0,0 @@ -package cn.iocoder.yudao.module.bpm.controller.admin.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -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; -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)); - } - - @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); - } - - @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)); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java deleted file mode 100644 index 171bbbb5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java +++ /dev/null @@ -1,142 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.definition; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -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.activiti.engine.impl.persistence.entity.SuspensionState; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.Model; -import org.activiti.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); - } - - void copyTo(BpmModelMetaInfoRespDTO from, @MappingTarget BpmModelBaseVO to); - - 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); - - 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); - } - - BpmModelPageItemRespVO.ProcessDefinition convert(ProcessDefinition bean); - - BpmModelCreateReqVO convert(BpmModeImportReqVO bean); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java deleted file mode 100644 index b789bc00..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ /dev/null @@ -1,83 +0,0 @@ -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.activiti.engine.impl.persistence.entity.SuspensionState; -import org.activiti.engine.repository.Deployment; -import org.activiti.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); - - 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 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; - } - - BpmProcessDefinitionPageItemRespVO convert(ProcessDefinition bean); - - BpmProcessDefinitionExtDO convert2(BpmProcessDefinitionCreateReqDTO bean); - - 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(); - } - - @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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java deleted file mode 100644 index 4be54fe7..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.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 cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.activiti.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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java deleted file mode 100644 index 6db6ebc4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.bpm.convert; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java deleted file mode 100644 index 02bfaa24..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import org.activiti.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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java deleted file mode 100644 index abc94d89..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java +++ /dev/null @@ -1,135 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -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 cn.iocoder.yudao.framework.common.pojo.PageResult; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.MappingTarget; -import org.mapstruct.Mappings; -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 BpmProcessInstanceExtDO convert3(ProcessInstance instance, ProcessDefinition definition) { - BpmProcessInstanceExtDO ext = new BpmProcessInstanceExtDO(); - copyTo(instance, ext); - copyTo(definition, ext); - return ext; - } - - @Mappings({ - @Mapping(source = "from.id", target = "id", ignore = true), - @Mapping(source = "from.startTime", target = "createTime"), - }) - void copyTo(ProcessInstance from, @MappingTarget BpmProcessInstanceExtDO to); - @Mapping(source = "from.id", target = "id", ignore = true) - void copyTo(ProcessDefinition from, @MappingTarget BpmProcessInstanceExtDO to); - - 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); - - List convertList2(List tasks); - - @Mapping(source = "processInstanceId", target = "id") - BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean); - - @Mappings({ - @Mapping(source = "id", target = "processInstanceId"), - @Mapping(source = "id", target = "id", ignore = true), - @Mapping(source = "startDate", target = "createTime"), - @Mapping(source = "initiator", target = "startUserId"), - @Mapping(source = "status", target = "status", ignore = true) - }) - BpmProcessInstanceExtDO convert(org.activiti.api.process.model.ProcessInstance bean); - - 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, 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 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 BpmMessageSendWhenProcessInstanceRejectReqDTO convert(ProcessInstance processInstance, String comment) { - BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO = new BpmMessageSendWhenProcessInstanceRejectReqDTO(); - copyTo(processInstance, reqDTO); - reqDTO.setComment(comment); - return reqDTO; - } - @Mapping(source = "name", target = "processInstanceName") - void copyTo(ProcessInstance from, @MappingTarget BpmMessageSendWhenProcessInstanceRejectReqDTO to); - - @Mappings({ - @Mapping(source = "id", target = "processInstanceId"), - @Mapping(source = "name", target = "processInstanceName"), - @Mapping(source = "initiator", target = "startUserId") - }) - BpmMessageSendWhenProcessInstanceApproveReqDTO convert2(org.activiti.api.process.model.ProcessInstance processInstance); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java deleted file mode 100644 index d74cc16b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.bpm.convert.task; - -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 cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.history.HistoricTaskInstance; -import org.activiti.engine.impl.persistence.entity.SuspensionState; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.mapstruct.*; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; - -/** - * Bpm 任务 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmTaskConvert { - - BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - - 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 = "id", target = "taskId"), - @Mapping(source = "assignee", target = "assigneeUserId"), - @Mapping(source = "createdDate", target = "createTime"), - @Mapping(target = "id", ignore = true) - }) - BpmTaskExtDO convert(org.activiti.api.task.model.Task bean); - - 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(ProcessInstance processInstance, AdminUserRespDTO startUser); - - @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 BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, org.activiti.api.task.model.Task task) { - BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO(); - copyTo(processInstance, reqDTO); - copyTo(startUser, reqDTO); - copyTo(task, reqDTO); - return reqDTO; - } - @Mapping(source = "name", target = "processInstanceName") - void copyTo(ProcessInstance from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to); - @Mappings({ - @Mapping(source = "id", target = "startUserId"), - @Mapping(source = "nickname", target = "startUserNickname") - }) - void copyTo(AdminUserRespDTO from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to); - @Mappings({ - @Mapping(source = "id", target = "taskId"), - @Mapping(source = "name", target = "taskName"), - @Mapping(source = "assignee", target = "assigneeUserId") - }) - void copyTo(org.activiti.api.task.model.Task task, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to); -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md deleted file mode 100644 index 8153487b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/config/BpmActivitiConfiguration.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/config/BpmActivitiConfiguration.java deleted file mode 100644 index 181cc2d5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/config/BpmActivitiConfiguration.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.config; - -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.BpmActivityBehaviorFactory; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.identity.EmptyUserGroupManager; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.listener.BpmTackActivitiEventListener; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.activiti.api.runtime.shared.identity.UserGroupManager; -import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.Collections; -import java.util.List; - -import static org.activiti.spring.boot.ProcessEngineAutoConfiguration.BEHAVIOR_FACTORY_MAPPING_CONFIGURER; - -/** - * BPM 模块的 Activiti 配置类 - */ -@Configuration -public class BpmActivitiConfiguration { - - /** - * 空用户组的 Bean - */ - @Bean - public UserGroupManager userGroupManager() { - return new EmptyUserGroupManager(); - } - - /** - * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类,主要设置各种监听器 - */ - @Bean - public ProcessEngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer( - BpmTackActivitiEventListener taskActivitiEventListener) { - return configuration -> { - // 注册监听器,例如说 BpmActivitiEventListener - configuration.setEventListeners(Collections.singletonList(taskActivitiEventListener)); - }; - } - - /** - * 用于设置自定义的 ActivityBehaviorFactory 实现的 ProcessEngineConfigurationConfigurer 实现类 - * - * 目的:覆盖 {@link org.activiti.spring.boot.ProcessEngineAutoConfiguration} 的 - * defaultActivityBehaviorFactoryMappingConfigurer 方法创建的 Bean - */ - @Bean(name = BEHAVIOR_FACTORY_MAPPING_CONFIGURER) - public ProcessEngineConfigurationConfigurer defaultActivityBehaviorFactoryMappingConfigurer( - BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { - return configuration -> { - // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 - configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); - }; - } - - @Bean - public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService, - BpmUserGroupService userGroupService, - PermissionApi permissionApi, - DeptApi deptApi, - AdminUserApi adminUserApi, - List scripts) { - BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); - bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService); - bpmActivityBehaviorFactory.setUserGroupService(userGroupService); - bpmActivityBehaviorFactory.setAdminUserApi(adminUserApi); - bpmActivityBehaviorFactory.setPermissionApi(permissionApi); - bpmActivityBehaviorFactory.setDeptApi(deptApi); - bpmActivityBehaviorFactory.setScripts(scripts); - return bpmActivityBehaviorFactory; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java deleted file mode 100644 index 76f0d97a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Setter; -import lombok.ToString; -import org.activiti.bpmn.model.UserTask; -import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; - -import java.util.List; - -/** - * 自定义的 ActivityBehaviorFactory 实现类,目的如下: - * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 - * - * @author 芋道源码 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - @Setter - private BpmUserGroupService userGroupService; - - @Setter - private PermissionApi permissionApi; - @Setter - private DeptApi deptApi; - @Setter - private AdminUserApi adminUserApi; - - @Setter - private List scripts; - - @Override - public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { - BpmUserTaskActivityBehavior userTaskActivityBehavior = new BpmUserTaskActivityBehavior(userTask); - userTaskActivityBehavior.setBpmTaskRuleService(bpmTaskRuleService); - userTaskActivityBehavior.setPermissionApi(permissionApi); - userTaskActivityBehavior.setDeptApi(deptApi); - userTaskActivityBehavior.setUserGroupService(userGroupService); - userTaskActivityBehavior.setAdminUserApi(adminUserApi); - userTaskActivityBehavior.setScripts(scripts); - return userTaskActivityBehavior; - } - - // TODO 芋艿:并行任务 ParallelMultiInstanceBehavior - - // TODO 芋艿:并行任务 SequentialMultiInstanceBehavior - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehavior.java deleted file mode 100644 index ed95b4c8..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehavior.java +++ /dev/null @@ -1,196 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -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.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -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.Setter; -import lombok.extern.slf4j.Slf4j; -import org.activiti.bpmn.model.UserTask; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.activiti.engine.impl.el.ExpressionManager; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.activiti.engine.impl.persistence.entity.TaskEntityManager; - -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.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.TASK_ASSIGN_SCRIPT_NOT_EXISTS; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; - -/** - * 自定义的流程任务的 assignee 负责人的分配 - * 第一步,获得对应的分配规则; - * 第二步,根据分配规则,计算出分配任务的候选人。如果找不到,则直接报业务异常,不继续执行后续的流程; - * 第三步,随机选择一个候选人,则选择作为 assignee 负责人。 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - - @Setter - private BpmUserGroupService userGroupService; - - @Setter - private DeptApi deptApi; - @Setter - private AdminUserApi adminUserApi; - @Setter - private PermissionApi permissionApi; - - /** - * 任务分配脚本 - */ - private Map scriptMap = Collections.emptyMap(); - - public BpmUserTaskActivityBehavior(UserTask userTask) { - super(userTask); - } - - public void setScripts(List scripts) { - this.scriptMap = convertMap(scripts, script -> script.getEnum().getId()); - } - - @Override - protected void handleAssignments(TaskEntityManager taskEntityManager, - String assignee, String owner, List candidateUsers, List candidateGroups, - TaskEntity task, ExpressionManager expressionManager, DelegateExecution execution) { - // 第一步,获得任务的规则 - BpmTaskAssignRuleDO rule = getTaskRule(task); - // 第二步,获得任务的候选用户们 - Set candidateUserIds = calculateTaskCandidateUsers(task, rule); - // 第三步,设置一个作为负责人 - Long assigneeUserId = chooseTaskAssignee(candidateUserIds); - taskEntityManager.changeTaskAssignee(task, String.valueOf(assigneeUserId)); - } - - private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { - List taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(), - task.getTaskDefinitionKey()); - if (CollUtil.isEmpty(taskRules)) { - throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey())); - } - if (taskRules.size() > 1) { - throw new ActivitiException(StrUtil.format("流程任务({}/{}/{}) 找到过多任务规则({})", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), taskRules.size())); - } - return taskRules.get(0); - } - - private Long chooseTaskAssignee(Set candidateUserIds) { - // TODO 芋艿:未来可以优化下,改成轮询的策略 - int index = RandomUtil.randomInt(candidateUserIds.size()); - return CollUtil.get(candidateUserIds, index); - } - - @VisibleForTesting - Set calculateTaskCandidateUsers(TaskEntity task, BpmTaskAssignRuleDO rule) { - Set assigneeUserIds = null; - if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByRole(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptMember(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByPost(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUser(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUserGroup(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByScript(task, rule); - } - - // 移除被禁用的用户 - removeDisableUsers(assigneeUserIds); - // 如果候选人为空,抛出异常 TODO 芋艿:没候选人的策略选择。1 - 挂起;2 - 直接结束;3 - 强制一个兜底人 - if (CollUtil.isEmpty(assigneeUserIds)) { - log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), toJsonString(rule)); - throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER); - } - return assigneeUserIds; - } - - private Set calculateTaskCandidateUsersByRole(TaskEntity task, BpmTaskAssignRuleDO rule) { - return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()); - } - - private Set calculateTaskCandidateUsersByDeptMember(TaskEntity task, BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUsersByDeptIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByDeptLeader(TaskEntity task, BpmTaskAssignRuleDO rule) { - List depts = deptApi.getDepts(rule.getOptions()); - return convertSet(depts, DeptRespDTO::getLeaderUserId); - } - - private Set calculateTaskCandidateUsersByPost(TaskEntity task, BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUsersByPostIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByUser(TaskEntity task, BpmTaskAssignRuleDO rule) { - return rule.getOptions(); - } - - private Set calculateTaskCandidateUsersByUserGroup(TaskEntity task, BpmTaskAssignRuleDO rule) { - List userGroups = userGroupService.getUserGroupList(rule.getOptions()); - Set userIds = new HashSet<>(); - userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds())); - return userIds; - } - - private Set calculateTaskCandidateUsersByScript(TaskEntity task, BpmTaskAssignRuleDO rule) { - // 获得对应的脚本 - List scripts = new ArrayList<>(rule.getOptions().size()); - rule.getOptions().forEach(id -> { - BpmTaskAssignScript script = scriptMap.get(id); - if (script == null) { - throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id); - } - scripts.add(script); - }); - // 逐个计算任务 - Set userIds = new HashSet<>(); - scripts.forEach(script -> CollUtil.addAll(userIds, script.calculateTaskCandidateUsers(task))); - return userIds; - } - - @VisibleForTesting - void removeDisableUsers(Set assigneeUserIds) { - if (CollUtil.isEmpty(assigneeUserIds)) { - return; - } - Map userMap = adminUserApi.getUserMap(assigneeUserIds); - assigneeUserIds.removeIf(id -> { - AdminUserRespDTO user = userMap.get(id); - return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); - }); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/package-info.java deleted file mode 100644 index e627479a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * 拓展 {@link org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior} 实现,基于 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO} 实现自定义的任务分配规则。 - * 原因:BPMN 默认的 assign、candidateUsers、candidateGroups 拓展起来有一定的难度,所以选择放弃它们,使用自己定义的规则。 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java deleted file mode 100644 index eee0d3f4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/BpmTaskAssignScript.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.activiti.engine.impl.persistence.entity.TaskEntity; - -import java.util.Set; - -/** - * Bpm 任务分配的自定义 Script 脚本 - * 使用场景: - * 1. 设置审批人为发起人 - * 2. 设置审批人为发起人的 Leader - * 3. 甚至审批人为发起人的 Leader 的 Leader - * - * @author 芋道源码 - */ -public interface BpmTaskAssignScript { - - /** - * 基于流程任务,获得任务的候选用户们 - * - * @param task 任务 - * @return 候选人用户的编号数组 - */ - Set calculateTaskCandidateUsers(TaskEntity task); - - /** - * 获得枚举值 - * - * @return 枚举值 - */ - BpmTaskRuleScriptEnum getEnum(); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java deleted file mode 100644 index c2756701..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl; - -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; - -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.activiti.engine.impl.persistence.entity.TaskEntity; -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; - - protected Set calculateTaskCandidateUsers(TaskEntity task, int level) { - Assert.isTrue(level > 0, "level 必须大于 0"); - // 获得发起人 - Long startUserId = Long.parseLong(task.getProcessInstance().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()); - if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 - break; - } - dept = parentDept; - } - } - return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet(); - } - - private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId); - if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 - return null; - } - return deptApi.getDept(startUser.getDeptId()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java deleted file mode 100644 index 4b0a7c1e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的一级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 - public Set calculateTaskCandidateUsers(TaskEntity task) { - return calculateTaskCandidateUsers(task, 1); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X1; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java deleted file mode 100644 index 41ee8254..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的二级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 - public Set calculateTaskCandidateUsers(TaskEntity task) { - return calculateTaskCandidateUsers(task, 2); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X2; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignStartUserScript.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignStartUserScript.java deleted file mode 100644 index af8846cb..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignStartUserScript.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.framework.common.util.collection.SetUtils; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignStartUserScript implements BpmTaskAssignScript { - - @Override - public Set calculateTaskCandidateUsers(TaskEntity task) { - Long userId = Long.parseLong(task.getProcessInstance().getStartUserId()); - return SetUtils.asSet(userId); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.START_USER; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/identity/EmptyUserGroupManager.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/identity/EmptyUserGroupManager.java deleted file mode 100644 index 22786da1..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/identity/EmptyUserGroupManager.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.identity; - -import org.activiti.api.runtime.shared.identity.UserGroupManager; - -import java.util.Collections; -import java.util.List; - -/** - * 空的 UserGroupManager 实现类,用于禁用 Activiti 自带的用户组实现。 - * 原因是,我们使用了自己实现的任务分配规则,所以不需要 Activiti。 - * 如果不去禁用,会存在一些场景下,会去查询用户所在的用户组,导致报错。 - * - * @author 芋道源码 - */ -public class EmptyUserGroupManager implements UserGroupManager { - - @Override - public List getUserGroups(String s) { - return Collections.emptyList(); - } - - @Override - public List getUserRoles(String s) { - return Collections.emptyList(); - } - - @Override - public List getGroups() { - return Collections.emptyList(); - } - - @Override - public List getUsers() { - return Collections.emptyList(); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java deleted file mode 100644 index 6ed7297d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.listener; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; -import org.activiti.api.model.shared.event.RuntimeEvent; -import org.activiti.api.process.model.ProcessInstance; -import org.activiti.api.process.model.events.ProcessRuntimeEvent; -import org.activiti.api.process.runtime.events.ProcessCancelledEvent; -import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 监听 {@link ProcessInstance} 的开始与完成,创建与更新对应的 {@link BpmProcessInstanceExtDO} 记录 - * - * @author 芋道源码 - */ -@Component -public class BpmProcessInstanceEventListener> - implements ProcessRuntimeEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmProcessInstanceService processInstanceService; - - @Override - @SuppressWarnings("unchecked") - public void onEvent(T rawEvent) { - // 由于 ProcessRuntimeEventListener 无法保证只监听 ProcessRuntimeEvent 事件,所以通过这样的方式 - if (!(rawEvent instanceof ProcessRuntimeEvent)) { - return; - } - ProcessRuntimeEvent event = (ProcessRuntimeEvent) rawEvent; - - // 创建时,插入拓展表 - if (event.getEventType() == ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED) { - processInstanceService.createProcessInstanceExt(event.getEntity()); - return; - } - // 取消时,更新拓展表为取消 - if (event.getEventType() == ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED) { - processInstanceService.updateProcessInstanceExtCancel(event.getEntity(), - ((ProcessCancelledEvent) event).getCause()); - return; - } - // 完成时,更新拓展表为已完成 - if (event.getEventType() == ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED) { - processInstanceService.updateProcessInstanceExtComplete(event.getEntity()); - return; - } - - // 其它事件,进行更新拓展表 - processInstanceService.updateProcessInstanceExt(event.getEntity()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTackActivitiEventListener.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTackActivitiEventListener.java deleted file mode 100644 index 4b6c21cf..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTackActivitiEventListener.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.listener; - -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import org.activiti.api.task.runtime.events.listener.TaskEventListener; -import org.activiti.engine.delegate.event.ActivitiEvent; -import org.activiti.engine.delegate.event.ActivitiEventListener; -import org.activiti.engine.delegate.event.ActivitiEventType; -import org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.activiti.engine.repository.ProcessDefinition; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 监听 {@link TaskEntity} 相关的事件,设置相关属性。 - * 目的:解决 {@link TaskEventListener} 无法解决的场景 - * - * @author 芋道源码 - */ -@Component -public class BpmTackActivitiEventListener implements ActivitiEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmProcessDefinitionService processDefinitionService; - - @Override - public void onEvent(ActivitiEvent event) { - // Task 创建时,设置其分类,解决 TaskService 未提供 name 的设置方法 - if (ActivitiEventType.TASK_CREATED == event.getType()) { - TaskEntity task = ((TaskEntity) ((ActivitiEntityEventImpl) event).getEntity()); - if (StrUtil.isNotEmpty(task.getCategory())) { - return; - } - // 设置 name - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition2(task.getProcessDefinitionId()); - if (processDefinition == null) { - return; - } - task.setCategory(processDefinition.getCategory()); - } - } - - @Override - public boolean isFailOnException() { - return true; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTaskEventListener.java deleted file mode 100644 index da8c6238..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/BpmTaskEventListener.java +++ /dev/null @@ -1,63 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.listener; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -import org.activiti.api.model.shared.event.RuntimeEvent; -import org.activiti.api.task.model.Task; -import org.activiti.api.task.model.events.TaskRuntimeEvent; -import org.activiti.api.task.runtime.events.listener.TaskRuntimeEventListener; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 监听 {@link Task} 的开始与完成,创建与更新对应的 {@link BpmTaskExtDO} 记录 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskEventListener> - implements TaskRuntimeEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - - @Override - @SuppressWarnings("unchecked") - public void onEvent(T rawEvent) { - // 由于 TaskRuntimeEventListener 无法保证只监听 TaskRuntimeEvent 事件,所以通过这样的方式 - if (!(rawEvent instanceof TaskRuntimeEvent)) { - return; - } - TaskRuntimeEvent event = (TaskRuntimeEvent) rawEvent; - - // 创建时,插入拓展表 - if (event.getEventType() == TaskRuntimeEvent.TaskEvents.TASK_CREATED) { - taskService.createTaskExt(event.getEntity()); - return; - } - - // 取消时,更新拓展表为取消 - if (event.getEventType() == TaskRuntimeEvent.TaskEvents.TASK_CANCELLED) { - taskService.updateTaskExtCancel(event.getEntity()); - return; - } - // 完成时,更新拓展表为已完成。要注意,在调用 delete ProcessInstance 才会触发该逻辑 - if (event.getEventType() == TaskRuntimeEvent.TaskEvents.TASK_COMPLETED) { - taskService.updateTaskExtComplete(event.getEntity()); - return; - } - - // 审核人修改时,进行拓展表,并额外发送通知 - if (event.getEventType() == TaskRuntimeEvent.TaskEvents.TASK_ASSIGNED) { - taskService.updateTaskExtAssign(event.getEntity()); - return; - } - - // 其它事件,进行更新拓展表 - taskService.updateTaskExt(event.getEntity()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/package-info.java deleted file mode 100644 index eca41904..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/listener/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * 自定义各种 Activiti 的监听器,实现流程示例、流程任务的拓展表信息的同步 - * 例如说,{@link org.activiti.api.task.model.Task} 新建时,我们也要新建对应的 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO} 记录 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.listener; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f9..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 5713e495..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 activiti 7 版本实现。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - * - * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Pay 的前缀~ - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java deleted file mode 100644 index fea5398a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java +++ /dev/null @@ -1,77 +0,0 @@ -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.activiti.bpmn.model.BpmnModel; - -import javax.validation.Valid; - -/** - * 流程模型接口 - * - * @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-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java deleted file mode 100644 index bbeadd6b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ /dev/null @@ -1,282 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; -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.enums.definition.BpmModelFormTypeEnum; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; -import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; -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.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO; -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import lombok.extern.slf4j.Slf4j; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.impl.persistence.entity.SuspensionState; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.Model; -import org.activiti.engine.repository.ModelQuery; -import org.activiti.engine.repository.ProcessDefinition; -import org.springframework.context.annotation.Lazy; -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 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.*; - -/** - * 流程定义实现 - * 主要进行 Activiti {@link Model} 的维护 - * - * @author yunlongn - * @author 芋道源码 - */ -@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 - 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) // 因为进行多个 activiti 操作,所以开启事务 - public String createModel(BpmModelCreateReqVO createReqVO, String bpmnXml) { - checkKeyNCName(createReqVO.getKey()); - // 校验流程标识已经存在 - Model keyModel = this.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(); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 - public void updateModel(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()); - } - - private void saveModelBpmnXml(Model model, String bpmnXml) { - if (StrUtil.isEmpty(bpmnXml)) { - return; - } - repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml)); - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 - public void deployModel(String id) { - // 校验流程模型存在 - Model model = repositoryService.getModel(id); - if (ObjectUtils.isEmpty(model)) { - throw exception(MODEL_NOT_EXISTS); - } - // 校验流程图 - byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); - if (bpmnBytes == null) { - throw exception(MODEL_NOT_EXISTS); - } - // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; - // 校验表单已配 - BpmFormDO form = checkFormConfig(model.getMetaInfo()); - // 校验任务分配规则已配置 - taskAssignRuleService.checkTaskAssignRuleAllConfig(id); - - // 校验模型是否发生修改。如果未修改,则不允许创建 - BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes); - if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等 - ProcessDefinition oldProcessInstance = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (oldProcessInstance != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessInstance.getId())) { - throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS); - } - } - // 创建流程定义 - String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); - - // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - updateProcessDefinitionSuspended(model.getDeploymentId()); - - // 更新 model 的 deploymentId,进行关联 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); - model.setDeploymentId(definition.getDeploymentId()); - repositoryService.saveModel(model); - - // 复制任务分配规则 - 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()); - } - - private void updateProcessDefinitionSuspended(String deploymentId) { - if (StrUtil.isEmpty(deploymentId)) { - return; - } - ProcessDefinition oldDefinition = processDefinitionService.getProcessDefinitionByDeploymentId(deploymentId); - if (oldDefinition == null) { - return; - } - if(oldDefinition.isSuspended()) { - return; - } - processDefinitionService.updateProcessDefinitionState(oldDefinition.getId(), SuspensionState.SUSPENDED.getStateCode()); - } - - @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; - } - return ActivitiUtils.buildBpmnModel(bpmnBytes); - } - - private Model getModelByKey(String key) { - return repositoryService.createModelQuery().modelKey(key).singleResult(); - } - - 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; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java deleted file mode 100644 index 46be4b64..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java +++ /dev/null @@ -1,161 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.definition; - -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.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.ProcessDefinition; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * 流程定义接口 - * - * @author yunlong.li - * @author ZJQ - * @author 芋道源码 - */ -public interface BpmProcessDefinitionService { - - /** - * 获得流程定义分页 - * - * @param pageReqVO 分页入参 - * @return 流程定义 Page - */ - PageResult getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageReqVO); - - /** - * 创建流程定义 - * - * @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); - - /** - * 获得流程定义列表 - * - * @param listReqVO 列表入参 - * @return 流程定义列表 - */ - List getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO); - - /** - * 获得 Bpmn 模型 - * - * @param processDefinitionId 流程定义的编号 - * @return Bpmn 模型 - */ - BpmnModel getBpmnModel(String processDefinitionId); - - /** - * 获得编号对应的 ProcessDefinition - * - * @param id 编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition(String id); - - /** - * 获得编号对应的 ProcessDefinition - * - * 相比 {@link #getProcessDefinition(String)} 方法,category 的取值是正确 - * - * @param id 编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinition2(String id); - - /** - * 获得流程定义标识对应的激活的流程定义 - * - * @param key 流程定义的标识 - * @return 流程定义 - */ - ProcessDefinition getActiveProcessDefinition(String key); - - /** - * 获得 id 对应的 Deployment - * - * @param id 部署编号 - * @return 流程部署 - */ - Deployment getDeployment(String id); - - /** - * 获得 ids 对应的 Deployment 数组 - * - * @param ids 部署编号的数组 - * @return 流程部署的数组 - */ - List getDeployments(Set ids); - - /** - * 获得 ids 对应的 Deployment Map - * - * @param ids 部署编号的数组 - * @return 流程部署 Map - */ - default Map getDeploymentMap(Set ids) { - return CollectionUtils.convertMap(getDeployments(ids), Deployment::getId); - } - - /** - * 获得 deploymentId 对应的 ProcessDefinition - * - * @param deploymentId 部署编号 - * @return 流程定义 - */ - ProcessDefinition getProcessDefinitionByDeploymentId(String deploymentId); - - /** - * 获得 deploymentIds 对应的 ProcessDefinition 数组 - * - * @param deploymentIds 部署编号的数组 - * @return 流程定义的数组 - */ - List getProcessDefinitionListByDeploymentIds(Set deploymentIds); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java deleted file mode 100644 index 011a948b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ /dev/null @@ -1,267 +0,0 @@ -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.module.bpm.convert.definition.BpmProcessDefinitionConvert; -import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -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.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.activiti.bpmn.model.BpmnModel; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.impl.persistence.entity.SuspensionState; -import org.activiti.engine.repository.Deployment; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.repository.ProcessDefinitionQuery; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -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.framework.common.util.collection.CollectionUtils.*; -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; - -/** - * 流程定义实现 - * 主要进行 Activiti {@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 BpmFormService formService; - - @Resource - private BpmProcessDefinitionExtMapper processDefinitionMapper; - - @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); - } - - @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 String getProcessDefinitionBpmnXML(String id) { - BpmnModel bpmnModel = repositoryService.getBpmnModel(id); - if (bpmnModel == null) { - return null; - } - return ActivitiUtils.getBpmnXml(bpmnModel); - } - - @Override - public BpmnModel getBpmnModel(String processDefinitionId) { - return repositoryService.getBpmnModel(processDefinitionId); - } - - @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 getActiveProcessDefinition(String key) { - return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult(); - } - - @Override - public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) { - return processDefinitionMapper.selectByProcessDefinitionId(id); - } - - @Override - public Deployment getDeployment(String id) { - if (StrUtil.isEmpty(id)) { - return null; - } - return repositoryService.createDeploymentQuery().deploymentId(id).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 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 boolean isProcessDefinitionEquals(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 = ActivitiUtils.buildBpmnModel(createReqDTO.getBpmnBytes()); - BpmnModel oldModel = getBpmnModel(oldProcessDefinition.getId()); - if (!ActivitiUtils.equals(oldModel, newModel)) { - return false; - } - // 最终发现都一致,则返回 true - return true; - } - - @Override - @Transactional(rollbackFor = Exception.class) // 因为进行多个 activiti 操作,所以开启事务 - public String createProcessDefinition(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); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java deleted file mode 100644 index 07945159..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java +++ /dev/null @@ -1,87 +0,0 @@ -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.springframework.lang.Nullable; - -import javax.validation.Valid; -import java.util.List; - -/** - * 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); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java deleted file mode 100644 index 93eedb51..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java +++ /dev/null @@ -1,211 +0,0 @@ -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.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.mysql.definition.BpmTaskAssignRuleMapper; -import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -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.user.AdminUserApi; -import lombok.extern.slf4j.Slf4j; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.bpmn.model.UserTask; -import org.springframework.context.annotation.Lazy; -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.*; - -/** - * 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; - - @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 = ActivitiUtils.getBpmnModelElements(model, UserTask.class); - if (CollUtil.isEmpty(userTasks)) { - return Collections.emptyList(); - } - - // 转换数据 - return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules); - } - - @Override - public Long createTaskAssignRule(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(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(StrUtil.format("未知的规则类型({})", type)); - } - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java deleted file mode 100644 index e7c28648..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; - -import java.util.List; - -/** - * BPM 活动实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmActivityService { - - /** - * 获得指定流程实例的活动实例列表 - * - * @param processInstanceId 流程实例的编号 - * @return 活动实例列表 - */ - List getActivityListByProcessInstanceId(String processInstanceId); - - /** - * 生成指定流程实例的高亮流程图,只高亮进行中的任务 - * - * 友情提示,非该方法的注释。如果想实现更高级的高亮流程图(当前节点红色 + 完成节点为绿色),可参考如下内容: - * 博客一:https://blog.csdn.net/qq_40109075/article/details/110939639 - * 博客二:https://gitee.com/tony2y/RuoYi-flowable/blob/master/ruoyi-flowable/src/main/java/com/ruoyi/flowable/flow/CustomProcessDiagramGenerator.java - * 这里不实现的原理,需要自定义实现 ProcessDiagramGenerator 和 ProcessDiagramCanvas,代码量有点大 - * - * 如果你想实现高亮已完成的任务,可参考 https://blog.csdn.net/qiuxinfa123/article/details/119579863 博客。不过测试下来,貌似不太对~ - * - * @param processInstanceId 流程实例的编号 - * @return 图的字节数组 - */ - byte[] generateHighlightDiagram(String processInstanceId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java deleted file mode 100644 index 2db1dc3e..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import lombok.extern.slf4j.Slf4j; -import org.activiti.bpmn.model.BpmnModel; -import org.activiti.engine.HistoryService; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.task.Task; -import org.activiti.image.ProcessDiagramGenerator; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * BPM 活动实例 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Slf4j -@Validated -public class BpmActivityServiceImpl implements BpmActivityService { - - private static final String FONT_NAME = "宋体"; - - @Resource - private ProcessDiagramGenerator processDiagramGenerator; - @Resource - private HistoryService historyService; - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmTaskService taskService; - - @Override - public List getActivityListByProcessInstanceId(String processInstanceId) { - List activityList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId).list(); - return BpmActivityConvert.INSTANCE.convertList(activityList); - } - - @Override - public byte[] generateHighlightDiagram(String processInstanceId) { - // 获得流程实例 - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - if (processInstance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - // 获得流程定义的 BPMN 模型 - BpmnModel bpmnModel = processDefinitionService.getBpmnModel(processInstance.getProcessDefinitionId()); - if (bpmnModel == null) { - throw exception(PROCESS_DEFINITION_BPMN_MODEL_NOT_EXISTS); - } - - // 如果流程已经结束,则无进行中的任务,无法高亮 - // 如果流程未结束,才需要高亮 - List highLightedActivities = Collections.emptyList(); - if (processInstance.getEndTime() == null) { - List tasks = taskService.getTasksByProcessInstanceId(processInstanceId); - highLightedActivities = CollectionUtils.convertList(tasks, Task::getTaskDefinitionKey); - } - - // 生成高亮流程图 - InputStream inputStream = processDiagramGenerator.generateDiagram(bpmnModel, highLightedActivities, Collections.emptyList(), - FONT_NAME, FONT_NAME, FONT_NAME); - return IoUtil.readBytes(inputStream); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java deleted file mode 100644 index 6dcacac1..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java +++ /dev/null @@ -1,165 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.runtime.ProcessInstance; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * 流程实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceService { - - /** - * 创建流程实例(提供给前端) - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO); - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param createReqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO); - - /** - * 取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 删除流程实例 - * - * @param id 流程编号 - * @param reason 删除原因。可选 {@link BpmProcessInstanceDeleteReasonEnum} - */ - @Deprecated - void deleteProcessInstance(String id, String reason); - - /** - * 获得流程实例的分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程实例的分页 - */ - PageResult getMyProcessInstancePage(Long userId, - @Valid BpmProcessInstanceMyPageReqVO pageReqVO); - - /** - * 获得流程实例 VO 信息 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - BpmProcessInstanceRespVO getProcessInstanceVO(String id); - - /** - * 获得流程实例 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - ProcessInstance getProcessInstance(String id); - - /** - * 获得流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 - */ - List getProcessInstances(Set ids); - - /** - * 获得流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 Map - */ - default Map getProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); - } - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - HistoricProcessInstance getHistoricProcessInstance(String id); - - /** - * 获得历史的流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 - */ - List getHistoricProcessInstances(Set ids); - - /** - * 获得历史的流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 Map - */ - default Map getHistoricProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); - } - - /** - * 创建 ProcessInstance 拓展记录 - * - * @param instance 流程任务 - */ - void createProcessInstanceExt(org.activiti.api.process.model.ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录 - * - * @param instance 流程任务 - */ - void updateProcessInstanceExt(org.activiti.api.process.model.ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为取消 - * - * @param instance 流程任务 - * @param reason 取消原因 - */ - void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance, String reason); - - /** - * 更新 ProcessInstance 拓展记录为完成 - * - * @param instance 流程任务 - */ - void updateProcessInstanceExtComplete(org.activiti.api.process.model.ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为不通过 - * - * @param id 流程编号 - * @param comment 理由。例如说,审批不通过时,需要传递该值 - */ - void updateProcessInstanceExtReject(String id, String comment); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java deleted file mode 100644 index 190170b3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ /dev/null @@ -1,310 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; -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.dal.mysql.task.BpmProcessInstanceExtMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -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 lombok.extern.slf4j.Slf4j; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -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.framework.common.util.collection.CollectionUtils.convertList; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程实例 Service 实现类 - * - * ProcessDefinition & ProcessInstance & Execution & Task 的关系: - * 1. https://blog.csdn.net/bobozai86/article/details/105210414 - * - * HistoricProcessInstance & ProcessInstance 的关系: - * 1.https://my.oschina.net/843294669/blog/719024 - * 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService { - - @Resource - private RuntimeService runtimeService; - @Resource - private HistoryService historyService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private BpmMessageService messageService; - - @Resource - private BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher; - - @Resource - private BpmProcessInstanceExtMapper processInstanceExtMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public String createProcessInstance(Long userId, BpmProcessInstanceCreateReqVO createReqVO) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId()); - // 发起流程 - return createProcessInstance0(userId, definition, createReqVO.getVariables(), null); - } - - @Override - public String createProcessInstance(Long userId, BpmProcessInstanceCreateReqDTO createReqDTO) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey()); - // 发起流程 - return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey()); - } - - private String createProcessInstance0(Long userId, ProcessDefinition definition, - Map variables, String businessKey) { - // 校验流程定义 - if (definition == null) { - throw exception(PROCESS_DEFINITION_NOT_EXISTS); - } - if (definition.isSuspended()) { - throw exception(PROCESS_DEFINITION_IS_SUSPENDED); - } - - // 创建流程实例 - ProcessInstance instance = runtimeService.startProcessInstanceById(definition.getId(), businessKey, variables); - // 设置流程名字 - runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); - - // 补全流程实例的拓展表 - processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) - .setFormVariables(variables)); - - // 添加初始的评论 TODO 芋艿:在思考下 -// Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); -// if (task != null) { -// SysUserDO user = userService.getUser(userId); -// Assert.notNull(user, "用户({})不存在", userId); -// String type = "normal"; -// taskService.addComment(task.getId(), instance.getProcessInstanceId(), type, -// String.format("%s 发起流程申请", user.getNickname())); -// } - return instance.getId(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancelProcessInstance(Long userId, BpmProcessInstanceCancelReqVO cancelReqVO) { - // 校验流程实例存在 - ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); - } - // 只能取消自己的 - if (!Objects.equals(instance.getStartUserId(), String.valueOf(userId))) { - throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF); - } - - // 通过删除流程实例,实现流程实例的取消 - runtimeService.deleteProcessInstance(cancelReqVO.getId(), - BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(cancelReqVO.getReason())); - } - - @Override - public void deleteProcessInstance(String id, String reason) { - runtimeService.deleteProcessInstance(id, reason); - } - - @Override - public PageResult getMyProcessInstancePage(Long userId, - BpmProcessInstanceMyPageReqVO pageReqVO) { - // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 - PageResult pageResult = processInstanceExtMapper.selectPage(userId, pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return new PageResult<>(pageResult.getTotal()); - } - - // 获得流程 Task Map - List processInstanceIds = convertList(pageResult.getList(), BpmProcessInstanceExtDO::getProcessInstanceId); - Map> taskMap = taskService.getTaskMapByProcessInstanceIds(processInstanceIds); - // 转换返回 - return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap); - } - - @Override - public BpmProcessInstanceRespVO getProcessInstanceVO(String id) { - // 获得流程实例 - HistoricProcessInstance processInstance = getHistoricProcessInstance(id); - if (processInstance == null) { - return null; - } - BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(id); - Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", id); - - // 获得流程定义 - ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition( - processInstance.getProcessDefinitionId()); - Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId()); - BpmProcessDefinitionExtDO processDefinitionExt = processDefinitionService.getProcessDefinitionExt( - processInstance.getProcessDefinitionId()); - Assert.notNull(processDefinitionExt, "流程定义拓展({}) 不存在", id); - String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(processInstance.getProcessDefinitionId()); - - // 获得 User - AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())); - DeptRespDTO dept = null; - if (startUser != null) { - dept = deptApi.getDept(startUser.getDeptId()); - } - - // 拼接结果 - return BpmProcessInstanceConvert.INSTANCE.convert2(processInstance, processInstanceExt, - processDefinition, processDefinitionExt, bpmnXml, startUser, dept); - } - - @Override - public List getProcessInstances(Set ids) { - return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list(); - } - - @Override - public ProcessInstance getProcessInstance(String id) { - return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult(); - } - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - @Override - public HistoricProcessInstance getHistoricProcessInstance(String id) { - return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult(); - } - - @Override - public List getHistoricProcessInstances(Set ids) { - return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); - } - - @Override - public void createProcessInstanceExt(org.activiti.api.process.model.ProcessInstance instance) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getProcessDefinition2(instance.getProcessDefinitionId()); - // 插入 BpmProcessInstanceExtDO 对象 - BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance) - .setCategory(definition.getCategory()) - .setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus()) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - processInstanceExtMapper.insert(instanceExtDO); - } - - @Override - public void updateProcessInstanceExt(org.activiti.api.process.model.ProcessInstance instance) { - BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance); - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - } - - @Override - public void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance, String reason) { - // 判断是否为 Reject 不通过。如果是,则不进行更新 - if (BpmProcessInstanceDeleteReasonEnum.isRejectReason(reason)) { - return; - } - - // 需要主动查询,因为 instance 只有 id 属性 - // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance - HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); - // 更新拓展表 - BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance) - .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()); - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - - @Override - public void updateProcessInstanceExtComplete(org.activiti.api.process.model.ProcessInstance instance) { - // 需要主动查询,因为 instance 只有 id 属性 - // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance - HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); - // 更新拓展表 - BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance) - .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); // 如果正常完全,说明审批通过 - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程被通过的消息 - messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.convert2(instance)); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - - @Transactional(rollbackFor = Exception.class) - public void updateProcessInstanceExtReject(String id, String comment) { - // 需要主动查询,因为 instance 只有 id 属性 - ProcessInstance processInstance = getProcessInstance(id); - // 删除流程实例,以实现驳回任务时,取消整个审批流程 - deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(comment))); - - // 更新 status + result - // 注意,不能和上面的逻辑更换位置。因为 deleteProcessInstance 会触发流程的取消,进而调用 updateProcessInstanceExtCancel 方法, - // 设置 result 为 BpmProcessInstanceStatusEnum.CANCEL,显然和 result 不一定是一致的 - BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(id) - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()); - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程被不通过的消息 - messageService.sendMessageWhenProcessInstanceReject(BpmProcessInstanceConvert.INSTANCE.convert(processInstance, comment)); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java deleted file mode 100644 index 025ee461..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.activiti.engine.task.Task; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * 流程任务实例 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmTaskService { - - /** - * 获得指定流程实例的 Running 进行中的流程任务列表 - * - * @param processInstanceId 流程实例的编号 - */ - List getRunningTaskListByProcessInstanceId(String processInstanceId); - - /** - * 获得指令流程实例的流程任务列表,包括所有状态的 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTaskListByProcessInstanceId(String processInstanceId); - - /** - * 获得流程任务列表 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceId(String processInstanceId); - - /** - * 获得流程任务列表 - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceIds(List processInstanceIds); - - /** - * 获得流程任务 Map - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务 Map - */ - default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { - return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), - Task::getProcessInstanceId); - } - - /** - * 获得待办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); - - /** - * 获得已办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param userId 用户编号 - * @param reqVO 分配请求 - */ - void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param id 流程任务编号 - * @param userId 用户编号 - */ - void updateTaskAssignee(String id, Long userId); - - /** - * 通过任务 - * - * @param userId 用户编号 - * @param reqVO 通过请求 - */ - void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); - - /** - * 不通过任务 - * - * @param userId 用户编号 - * @param reqVO 不通过请求 - */ - void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); - - // ========== Task 拓展表相关 ========== - - /** - * 创建 Task 拓展记录 - * - * @param task 任务实体 - */ - void createTaskExt(org.activiti.api.task.model.Task task); - - /** - * 更新 Task 拓展记录 - * - * @param task 任务实体 - */ - void updateTaskExt(org.activiti.api.task.model.Task task); - - /** - * 更新 Task 拓展记录,并发送通知 - * - * @param task 任务实体 - */ - void updateTaskExtAssign(org.activiti.api.task.model.Task task); - - /** - * 更新 Task 拓展记录为取消 - * - * @param task 任务实体 - */ - void updateTaskExtCancel(org.activiti.api.task.model.Task task); - - /** - * 更新 Task 拓展记录为完成 - * - * @param task 任务实体 - */ - void updateTaskExtComplete(org.activiti.api.task.model.Task task); - - /** - * 获得流程实例对应的 Task 拓展列表 - * - * @param processInstanceId 流程实例的编号 - * @return Task 拓展列表 - */ - List getTaskExtListByProcessInstanceId(String processInstanceId); - - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java deleted file mode 100644 index b4cb99fb..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ /dev/null @@ -1,319 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; - -import cn.iocoder.yudao.framework.activiti.core.util.ActivitiUtils; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -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 lombok.extern.slf4j.Slf4j; -import org.activiti.engine.HistoryService; -import org.activiti.engine.TaskService; -import org.activiti.engine.history.HistoricProcessInstance; -import org.activiti.engine.history.HistoricTaskInstance; -import org.activiti.engine.history.HistoricTaskInstanceQuery; -import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Task; -import org.activiti.engine.task.TaskQuery; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -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.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程任务实例 Service 实现类 - * - * @author jason - * @author 芋道源码 - */ -@Slf4j -@Service -public class BpmTaskServiceImpl implements BpmTaskService { - - @Resource - private TaskService taskService; - @Resource - private HistoryService historyService; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - @Lazy // 解决循环依赖 - private BpmProcessInstanceService processInstanceService; - @Resource - private BpmMessageService messageService; - - @Resource - private BpmTaskExtMapper taskExtMapper; - - @Override - public List getRunningTaskListByProcessInstanceId(String processInstanceId) { - return taskService.createTaskQuery().processInstanceId(processInstanceId).list(); - } - - @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { - // 获得任务列表 - List tasks = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(processInstanceId) - .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 - .list(); - if (CollUtil.isEmpty(tasks)) { - return Collections.emptyList(); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - // 获得 User Map - Set userIds = convertSet(tasks, task -> NumberUtils.parseLong(task.getAssignee())); - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); - Map userMap = adminUserApi.getUserMap(userIds); - // 获得 Dept Map - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - - // 拼接数据 - return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); - } - - @Override - public List getTasksByProcessInstanceId(String processInstanceId) { - if (StrUtil.isEmpty(processInstanceId)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceId(processInstanceId).list(); - } - - @Override - public List getTasksByProcessInstanceIds(List processInstanceIds) { - if (CollUtil.isEmpty(processInstanceIds)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); - } - - @Override - public PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { - // 查询待办任务 - TaskQuery taskQuery = taskService.createTaskQuery() - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByTaskCreateTime().desc(); // 创建时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (pageVO.getBeginCreateTime() != null) { - taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime()); - } - if (pageVO.getEndCreateTime() != null) { - taskQuery.taskCreatedBefore(pageVO.getEndCreateTime()); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 ProcessInstance Map - Map processInstanceMap = processInstanceService.getProcessInstanceMap( - convertSet(tasks, Task::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) { - // 查询已办任务 - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .finished() // 已完成 - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (pageVO.getBeginCreateTime() != null) { - taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime()); - } - if (pageVO.getEndCreateTime() != null) { - taskQuery.taskCreatedBefore(pageVO.getEndCreateTime()); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - Map historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { - // 校验任务存在 - Task task = getTask(reqVO.getId()); - if (task == null) { - throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); - } - if (!ActivitiUtils.equals(task.getAssignee(), userId)) { - throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); - } - - // 更新负责人 - updateTaskAssignee(task.getId(), reqVO.getAssigneeUserId()); - } - - @Override - public void updateTaskAssignee(String id, Long userId) { - taskService.setAssignee(id, String.valueOf(userId)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void approveTask(Long userId, BpmTaskApproveReqVO reqVO) { - // 校验任务存在 - Task task = getTask(reqVO.getId()); - if (task == null) { - throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); - } - if (!ActivitiUtils.equals(task.getAssignee(), userId)) { - throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); - } - // 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 完成任务,审批通过 - taskService.complete(task.getId(), instance.getProcessVariables()); // TODO 芋艿:variables 的选择 - // 更新任务拓展表为通过 - taskExtMapper.updateByTaskId(new BpmTaskExtDO().setTaskId(task.getId()) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()).setComment(reqVO.getComment())); - - // TODO 芋艿:添加评论 -// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { - // 校验任务存在 - Task task = getTask(reqVO.getId()); - if (task == null) { - throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); - } - if (!ActivitiUtils.equals(task.getAssignee(), userId)) { - throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); - } - // 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 更新流程实例为不通过 - processInstanceService.updateProcessInstanceExtReject(instance.getProcessInstanceId(), reqVO.getComment()); - - // 更新任务拓展表为不通过 - taskExtMapper.updateByTaskId(new BpmTaskExtDO().setTaskId(task.getId()) - .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()).setComment(reqVO.getComment())); - - // TODO 芋艿:添加评论 -// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment()); - } - - private Task getTask(String id) { - return taskService.createTaskQuery().taskId(id).singleResult(); - } - - // ========== Task 拓展表相关 ========== - - @Override - public void createTaskExt(org.activiti.api.task.model.Task task) { - // 插入 BpmTaskExtDO 记录 - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - taskExtMapper.insert(taskExtDO); - } - - @Override - public void updateTaskExt(org.activiti.api.task.model.Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task); - taskExtMapper.updateByTaskId(taskExtDO); - } - - @Override - public void updateTaskExtAssign(org.activiti.api.task.model.Task task) { - // 更新 - updateTaskExt(task); - // 发送通知。由于 Activiti 操作是在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); - messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); - } - }); - } - - @Override - public void updateTaskExtCancel(org.activiti.api.task.model.Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task) - .setEndTime(new Date()) // 由于 Task 里没有办法拿到 endTime,所以这里设置 - .setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()); - taskExtMapper.updateByTaskId(taskExtDO); - } - - @Override - public void updateTaskExtComplete(org.activiti.api.task.model.Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task) - .setEndTime(new Date()) // 此时不能使用 task 的 completeData,因为还是空的。 - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); - taskExtMapper.updateByTaskId(taskExtDO); - } - - @Override - public List getTaskExtListByProcessInstanceId(String processInstanceId) { - return taskExtMapper.selectListByProcessInstanceId(processInstanceId); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java deleted file mode 100644 index 0ffb3a89..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/main/java/cn/iocoder/yudao/module/bpm/service/task/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * task 包下,存放的都是 xxx 实例。例如说: - * 1. ProcessInstance 是 ProcessDefinition 创建而来的实例; - * 2. TaskInstance 是 TaskDefinition 创建而来的实例; - * 3. ActivityInstance 是 BPMN 流程图的每个元素创建的实例; - * - * 考虑到 Task 和 Activity 可以比较明确表示名字,所以对应的 Service 就没有使用 Instance 后缀~ - * 嘿嘿,其实也是实现到比较后面的阶段,所以就暂时没去统一和修改了~ - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.service.task; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehaviorTest.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehaviorTest.java deleted file mode 100644 index dad383a5..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/BpmUserTaskActivityBehaviorTest.java +++ /dev/null @@ -1,214 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior; - -import cn.hutool.core.map.MapUtil; -import cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -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.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -public class BpmUserTaskActivityBehaviorTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmUserTaskActivityBehavior behavior; - @Mock - private BpmTaskAssignRuleService bpmTaskRuleService; - @Mock - private BpmUserGroupService userGroupService; - - @Mock - private DeptApi deptApi; - @Mock - private AdminUserApi adminUserApi; - @Mock - private PermissionApi permissionApi; - - @Test - public void testCalculateTaskCandidateUsers_Role() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.ROLE.getType()); - // mock 方法 - when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions()))) - .thenReturn(asSet(11L, 22L)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_DeptMember() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType()); - // mock 方法 - List users = CollectionUtils.convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUsersByDeptIds(eq(rule.getOptions()))).thenReturn(users); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_DeptLeader() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType()); - // mock 方法 - DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); - DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L)); - when(deptApi.getDepts(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_Post() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.POST.getType()); - // mock 方法 - List users = CollectionUtils.convertList(asSet(11L, 22L), - id -> new AdminUserRespDTO().setId(id)); - when(adminUserApi.getUsersByPostIds(eq(rule.getOptions()))).thenReturn(users); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_User() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.USER.getType()); - // mock 方法 - mockGetUserMap(asSet(1L, 2L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(1L, 2L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_UserGroup() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) - .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); - // mock 方法 - BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); - BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L))); - when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2)); - mockGetUserMap(asSet(11L, 12L, 21L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 12L, 21L, 22L), results); - } - - @Test - public void testCalculateTaskCandidateUsers_Script() { - // 准备参数 - BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(20L, 21L)) - .setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType()); - // mock 方法 - BpmTaskAssignScript script1 = new BpmTaskAssignScript() { - - @Override - public Set calculateTaskCandidateUsers(TaskEntity task) { - return singleton(11L); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X1; - } - }; - BpmTaskAssignScript script2 = new BpmTaskAssignScript() { - - @Override - public Set calculateTaskCandidateUsers(TaskEntity task) { - return singleton(22L); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X2; - } - }; - behavior.setScripts(Arrays.asList(script1, script2)); - mockGetUserMap(asSet(11L, 22L)); - - // 调用 - Set results = behavior.calculateTaskCandidateUsers(null, rule); - // 断言 - assertEquals(asSet(11L, 22L), results); - } - - @Test - public void testRemoveDisableUsers() { - // 准备参数. 1L 可以找到;2L 是禁用的;3L 找不到 - Set assigneeUserIds = asSet(1L, 2L, 3L); - // mock 方法 - AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L) - .setStatus(CommonStatusEnum.ENABLE.getStatus())); - AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L) - .setStatus(CommonStatusEnum.DISABLE.getStatus())); - Map userMap = MapUtil.builder(user1.getId(), user1) - .put(user2.getId(), user2).build(); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - - // 调用 - behavior.removeDisableUsers(assigneeUserIds); - // 断言 - assertEquals(asSet(1L), assigneeUserIds); - } - - private void mockGetUserMap(Set assigneeUserIds) { - Map userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id, - id -> new AdminUserRespDTO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus())); - when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java deleted file mode 100644 index d44c5c80..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/framework/activiti/core/behavior/script/impl/BpmTaskAssignLeaderX2ScriptTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.activiti.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; -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.activiti.engine.impl.persistence.entity.ExecutionEntityImpl; -import org.activiti.engine.impl.persistence.entity.TaskEntity; -import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.boot.test.mock.mockito.MockBean; - -import java.util.Set; - -import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -class BpmTaskAssignLeaderX2ScriptTest extends BaseMockitoUnitTest { - - @InjectMocks - private BpmTaskAssignLeaderX2Script script; - - @Mock - private AdminUserApi adminUserApi; - @Mock - private DeptApi deptApi; - - @Test - public void testCalculateTaskCandidateUsers_noDept() { - // 准备参数 - TaskEntity task = buildTaskEntity(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - - // 调用 - Set result = script.calculateTaskCandidateUsers(task); - // 断言 - assertEquals(0, result.size()); - } - - @Test - public void testCalculateTaskCandidateUsers_noParentDept() { - // 准备参数 - TaskEntity task = buildTaskEntity(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); - - // 调用 - Set result = script.calculateTaskCandidateUsers(task); - // 断言 - assertEquals(asSet(20L), result); - } - - @Test - public void testCalculateTaskCandidateUsers_existParentDept() { - // 准备参数 - TaskEntity task = buildTaskEntity(1L); - // mock 方法(startUser) - AdminUserRespDTO startUser = randomPojo(AdminUserRespDTO.class, o -> o.setDeptId(10L)); - when(adminUserApi.getUser(eq(1L))).thenReturn(startUser); - DeptRespDTO startUserDept = randomPojo(DeptRespDTO.class, o -> o.setId(10L).setParentId(100L) - .setLeaderUserId(20L)); - when(deptApi.getDept(eq(10L))).thenReturn(startUserDept); - // mock 方法(父 dept) - DeptRespDTO parentDept = randomPojo(DeptRespDTO.class, o -> o.setId(100L).setParentId(1000L) - .setLeaderUserId(200L)); - when(deptApi.getDept(eq(100L))).thenReturn(parentDept); - - // 调用 - Set result = script.calculateTaskCandidateUsers(task); - // 断言 - assertEquals(asSet(200L), result); - } - - @SuppressWarnings("SameParameterValue") - private TaskEntity buildTaskEntity(Long startUserId) { - TaskEntityImpl task = new TaskEntityImpl(); - task.setProcessInstance(new ExecutionEntityImpl()); - task.getProcessInstance().setStartUserId(String.valueOf(startUserId)); - return task; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/service/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/service/package-info.java deleted file mode 100644 index bda0cb8c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/java/cn/iocoder/yudao/module/bpm/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/application-unit-test.yaml deleted file mode 100644 index 60914d97..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/application-unit-test.yaml +++ /dev/null @@ -1,49 +0,0 @@ -spring: - main: - lazy-initialization: true # 开启懒加载,加快速度 - banner-mode: off # 单元测试,禁用 Banner - ---- #################### 数据库相关配置 #################### - -spring: - # 数据源配置项 - datasource: - name: ruoyi-vue-pro - url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 - driver-class-name: org.h2.Driver - username: sa - password: - druid: - async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 - initial-size: 1 # 单元测试,配置为 1,提升启动速度 - sql: - init: - schema-locations: classpath:/sql/create_tables.sql - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 16379 # 端口(单元测试,使用 16379 端口) - database: 0 # 数据库索引 - -mybatis: - lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 - ---- #################### 定时任务相关配置 #################### - ---- #################### 配置中心相关配置 #################### - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项(单元测试,禁用 Lock4j) - -# Resilience4j 配置项 - ---- #################### 监控相关配置 #################### - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - info: - base-package: cn.iocoder.yudao.module diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/logback.xml b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/logback.xml deleted file mode 100644 index daf756bf..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/logback.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/sql/clean.sql b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/sql/clean.sql deleted file mode 100644 index e69de29b..00000000 diff --git a/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/sql/create_tables.sql b/yudao-module-bpm/yudao-module-bpm-impl-activiti/src/test/resources/sql/create_tables.sql deleted file mode 100644 index e69de29b..00000000 diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/pom.xml b/yudao-module-bpm/yudao-module-bpm-impl-flowable/pom.xml deleted file mode 100644 index 1b039b8c..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - cn.iocoder.boot - yudao-module-bpm - ${revision} - - 4.0.0 - yudao-module-bpm-impl-flowable - jar - - ${project.artifactId} - - bpm-flowable 模块,基于 Flowable 6 实现工作流 - - - - - cn.iocoder.boot - yudao-module-bpm-base - ${revision} - - - - - cn.iocoder.boot - yudao-spring-boot-starter-flowable - - - - - cn.iocoder.boot - yudao-spring-boot-starter-test - test - - - - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java deleted file mode 100644 index 2137e220..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * bpm API 实现类,定义暴露给其它模块的 API - */ -package cn.iocoder.yudao.module.bpm.api; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java deleted file mode 100644 index 596c9981..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/api/task/BpmProcessInstanceApiImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java deleted file mode 100644 index 3dd0a0a4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java +++ /dev/null @@ -1,97 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java deleted file mode 100644 index ebcaad05..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java +++ /dev/null @@ -1,59 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java deleted file mode 100644 index 3e946707..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmTaskAssignRuleController.java +++ /dev/null @@ -1,58 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java deleted file mode 100644 index 24d89cd3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmActivityController.java +++ /dev/null @@ -1,39 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java deleted file mode 100644 index 851a83ce..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceController.java +++ /dev/null @@ -1,58 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java deleted file mode 100644 index 52b16297..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ /dev/null @@ -1,79 +0,0 @@ -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.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.TaskService; -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java deleted file mode 100644 index e8d285e3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/app/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位 - */ -package cn.iocoder.yudao.module.bpm.controller.app; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java deleted file mode 100644 index d1930bd6..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java deleted file mode 100644 index 4d1b2a00..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java +++ /dev/null @@ -1,140 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java deleted file mode 100644 index 8f5bfcd2..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmProcessDefinitionConvert.java +++ /dev/null @@ -1,82 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java deleted file mode 100644 index c616e90b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmTaskAssignRuleConvert.java +++ /dev/null @@ -1,40 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java deleted file mode 100644 index 6db6ebc4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 提供 POJO 类的实体转换 - * - * 目前使用 MapStruct 框架 - */ -package cn.iocoder.yudao.module.bpm.convert; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java deleted file mode 100644 index 50940845..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmActivityConvert.java +++ /dev/null @@ -1,29 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java deleted file mode 100644 index c6f6cbee..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmProcessInstanceConvert.java +++ /dev/null @@ -1,116 +0,0 @@ -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.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * 流程实例 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 comment) { - return new BpmMessageSendWhenProcessInstanceRejectReqDTO() - .setProcessInstanceName(instance.getName()) - .setProcessInstanceId(instance.getId()) - .setComment(comment) - .setStartUserId(NumberUtils.parseLong(instance.getStartUserId())); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java deleted file mode 100644 index d128dba2..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java +++ /dev/null @@ -1,147 +0,0 @@ -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 java.util.List; -import java.util.Map; - -/** - * Bpm 任务 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface BpmTaskConvert { - - BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - - 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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md deleted file mode 100644 index 8153487b..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java deleted file mode 100644 index bf2feb84..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/config/BpmFlowableConfiguration.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.config; - -import cn.hutool.core.collection.ListUtil; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.BpmActivityBehaviorFactory; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import org.flowable.common.engine.api.delegate.event.FlowableEventListener; -import org.flowable.spring.SpringProcessEngineConfiguration; -import org.flowable.spring.boot.EngineConfigurationConfigurer; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.List; - -/** - * BPM 模块的 Flowable 配置类 - * - * @author jason - */ -@Configuration -public class BpmFlowableConfiguration { - - /** - * BPM 模块的 ProcessEngineConfigurationConfigurer 实现类: - * - * 1. 设置各种监听器 - * 2. 设置自定义的 ActivityBehaviorFactory 实现 - */ - @Bean - public EngineConfigurationConfigurer bpmProcessEngineConfigurationConfigurer( - ObjectProvider listeners, - BpmActivityBehaviorFactory bpmActivityBehaviorFactory) { - return configuration -> { - // 注册监听器,例如说 BpmActivitiEventListener - configuration.setEventListeners(ListUtil.toList(listeners.iterator())); - // 设置 ActivityBehaviorFactory 实现类,用于流程任务的审核人的自定义 - configuration.setActivityBehaviorFactory(bpmActivityBehaviorFactory); - }; - } - - @Bean - public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService, - BpmUserGroupService userGroupService, - PermissionApi permissionApi, - DeptApi deptApi, - AdminUserApi adminUserApi, - List scripts) { - BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); - bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService); - bpmActivityBehaviorFactory.setUserGroupService(userGroupService); - bpmActivityBehaviorFactory.setAdminUserApi(adminUserApi); - bpmActivityBehaviorFactory.setPermissionApi(permissionApi); - bpmActivityBehaviorFactory.setDeptApi(deptApi); - bpmActivityBehaviorFactory.setScripts(scripts); - return bpmActivityBehaviorFactory; - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java deleted file mode 100644 index 0d8de4f6..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmActivityBehaviorFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Setter; -import lombok.ToString; -import org.flowable.bpmn.model.UserTask; -import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior; -import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; - -import java.util.List; - -/** - * 自定义的 ActivityBehaviorFactory 实现类,目的如下: - * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 - * - * @author 芋道源码 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - @Setter - private BpmUserGroupService userGroupService; - - @Setter - private PermissionApi permissionApi; - @Setter - private DeptApi deptApi; - @Setter - private AdminUserApi adminUserApi; - @Setter - private List scripts; - - @Override - public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { - BpmUserTaskActivityBehavior userTaskActivityBehavior = new BpmUserTaskActivityBehavior(userTask); - userTaskActivityBehavior.setBpmTaskRuleService(bpmTaskRuleService); - userTaskActivityBehavior.setPermissionApi(permissionApi); - userTaskActivityBehavior.setDeptApi(deptApi); - userTaskActivityBehavior.setUserGroupService(userGroupService); - userTaskActivityBehavior.setAdminUserApi(adminUserApi); - userTaskActivityBehavior.setScripts(scripts); - return userTaskActivityBehavior; - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java deleted file mode 100644 index d4ab5b67..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmUserTaskActivityBehavior.java +++ /dev/null @@ -1,195 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -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.enums.definition.BpmTaskAssignRuleTypeEnum; -import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleService; -import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; -import cn.iocoder.yudao.module.system.api.permission.PermissionApi; -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.Setter; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.UserTask; -import org.flowable.common.engine.api.FlowableException; -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.*; - -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.TASK_ASSIGN_SCRIPT_NOT_EXISTS; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; - -/** - * 自定义的流程任务的 assignee 负责人的分配 - * 第一步,获得对应的分配规则; - * 第二步,根据分配规则,计算出分配任务的候选人。如果找不到,则直接报业务异常,不继续执行后续的流程; - * 第三步,随机选择一个候选人,则选择作为 assignee 负责人。 - * - * @author 芋道源码 - */ -@Slf4j -public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior { - - @Setter - private BpmTaskAssignRuleService bpmTaskRuleService; - @Setter - private BpmUserGroupService userGroupService; - @Setter - private DeptApi deptApi; - @Setter - private AdminUserApi adminUserApi; - @Setter - private PermissionApi permissionApi; - - /** - * 任务分配脚本 - */ - private Map scriptMap = Collections.emptyMap(); - - public BpmUserTaskActivityBehavior(UserTask userTask) { - super(userTask); - } - - public void setScripts(List scripts) { - this.scriptMap = convertMap(scripts, script -> script.getEnum().getId()); - } - - @Override - @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 - protected void handleAssignments(TaskService taskService, String assignee, String owner, List candidateUsers, List candidateGroups, TaskEntity task, ExpressionManager expressionManager, DelegateExecution execution, ProcessEngineConfigurationImpl processEngineConfiguration) { - // 第一步,获得任务的规则 - BpmTaskAssignRuleDO rule = getTaskRule(task); - // 第二步,获得任务的候选用户们 - Set candidateUserIds = calculateTaskCandidateUsers(task, rule); - // 第三步,设置一个作为负责人 - Long assigneeUserId = chooseTaskAssignee(candidateUserIds); - TaskHelper.changeTaskAssignee(task, String.valueOf(assigneeUserId)); - } - - private BpmTaskAssignRuleDO getTaskRule(TaskEntity task) { - List taskRules = bpmTaskRuleService.getTaskAssignRuleListByProcessDefinitionId(task.getProcessDefinitionId(), - task.getTaskDefinitionKey()); - if (CollUtil.isEmpty(taskRules)) { - throw new FlowableException(StrUtil.format("流程任务({}/{}/{}) 找不到符合的任务规则", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey())); - } - if (taskRules.size() > 1) { - throw new FlowableException(StrUtil.format("流程任务({}/{}/{}) 找到过多任务规则({})", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), taskRules.size())); - } - return taskRules.get(0); - } - - Set calculateTaskCandidateUsers(TaskEntity task, BpmTaskAssignRuleDO rule) { - Set assigneeUserIds = null; - if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByRole(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptMember(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByPost(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUser(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByUserGroup(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByScript(task, rule); - } - - // 移除被禁用的用户 - removeDisableUsers(assigneeUserIds); - // 如果候选人为空,抛出异常 TODO 芋艿:没候选人的策略选择。1 - 挂起;2 - 直接结束;3 - 强制一个兜底人 - if (CollUtil.isEmpty(assigneeUserIds)) { - log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", - task.getId(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), toJsonString(rule)); - throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER); - } - return assigneeUserIds; - } - - private Set calculateTaskCandidateUsersByRole(TaskEntity task, BpmTaskAssignRuleDO rule) { - return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()); - } - - private Set calculateTaskCandidateUsersByDeptMember(TaskEntity task, BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUsersByDeptIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByDeptLeader(TaskEntity task, BpmTaskAssignRuleDO rule) { - List depts = deptApi.getDepts(rule.getOptions()); - return convertSet(depts, DeptRespDTO::getLeaderUserId); - } - - private Set calculateTaskCandidateUsersByPost(TaskEntity task, BpmTaskAssignRuleDO rule) { - List users = adminUserApi.getUsersByPostIds(rule.getOptions()); - return convertSet(users, AdminUserRespDTO::getId); - } - - private Set calculateTaskCandidateUsersByUser(TaskEntity task, BpmTaskAssignRuleDO rule) { - return rule.getOptions(); - } - - private Set calculateTaskCandidateUsersByUserGroup(TaskEntity task, BpmTaskAssignRuleDO rule) { - List userGroups = userGroupService.getUserGroupList(rule.getOptions()); - Set userIds = new HashSet<>(); - userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds())); - return userIds; - } - - private Set calculateTaskCandidateUsersByScript(TaskEntity task, BpmTaskAssignRuleDO rule) { - // 获得对应的脚本 - List scripts = new ArrayList<>(rule.getOptions().size()); - rule.getOptions().forEach(id -> { - BpmTaskAssignScript script = scriptMap.get(id); - if (script == null) { - throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id); - } - scripts.add(script); - }); - // 逐个计算任务 - Set userIds = new HashSet<>(); - scripts.forEach(script -> CollUtil.addAll(userIds, script.calculateTaskCandidateUsers(task))); - return userIds; - } - - private Long chooseTaskAssignee(Set candidateUserIds) { - // TODO 芋艿:未来可以优化下,改成轮询的策略 - int index = RandomUtil.randomInt(candidateUserIds.size()); - return CollUtil.get(candidateUserIds, index); - } - - @VisibleForTesting - void removeDisableUsers(Set assigneeUserIds) { - if (CollUtil.isEmpty(assigneeUserIds)) { - return; - } - //TODO 芋艿 这里有数据权限的问题。默认会加上数据权限 dept_id IN (deptId). 导致查询不到数据 - Map userMap = adminUserApi.getUserMap(assigneeUserIds); - assigneeUserIds.removeIf(id -> { - AdminUserRespDTO user = userMap.get(id); - return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); - }); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java deleted file mode 100644 index 10392c71..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/BpmTaskAssignScript.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; - -import java.util.Set; - -/** - * Bpm 任务分配的自定义 Script 脚本 - * 使用场景: - * 1. 设置审批人为发起人 - * 2. 设置审批人为发起人的 Leader - * 3. 甚至审批人为发起人的 Leader 的 Leader - * - * @author 芋道源码 - */ -public interface BpmTaskAssignScript { - - /** - * 基于流程任务,获得任务的候选用户们 - * - * @param task 任务 - * @return 候选人用户的编号数组 - */ - Set calculateTaskCandidateUsers(TaskEntity task); - - /** - * 获得枚举值 - * - * @return 枚举值 - */ - BpmTaskRuleScriptEnum getEnum(); -} - diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java deleted file mode 100644 index 06b8c52f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderAbstractScript.java +++ /dev/null @@ -1,71 +0,0 @@ -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.runtime.ProcessInstance; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -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(TaskEntity task, int level) { - Assert.isTrue(level > 0, "level 必须大于 0"); - // 获得发起人 - ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(task.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()); - if (parentDept == null) { // 找不到父级部门,所以只好结束寻找。原因是:例如说,级别比较高的人,所在部门层级比较少 - break; - } - dept = parentDept; - } - } - return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet(); - } - - private DeptRespDTO getStartUserDept(Long startUserId) { - AdminUserRespDTO startUser = adminUserApi.getUser(startUserId); - if (startUser.getDeptId() == null) { // 找不到部门,所以无法使用该规则 - return null; - } - return deptApi.getDept(startUser.getDeptId()); - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java deleted file mode 100644 index adcece67..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX1Script.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的一级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 - public Set calculateTaskCandidateUsers(TaskEntity task) { - return calculateTaskCandidateUsers(task, 1); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X1; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java deleted file mode 100644 index 9ead7a6f..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignLeaderX2Script.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl; - -import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.springframework.stereotype.Component; - -import java.util.Set; - -/** - * 分配给发起人的二级 Leader 审批的 Script 实现类 - * - * @author 芋道源码 - */ -@Component -public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript { - - @Override - @DataPermission(enable = false) // 不需要处理数据权限, 不然会有问题,查询不到数据 - public Set calculateTaskCandidateUsers(TaskEntity task) { - return calculateTaskCandidateUsers(task, 2); - } - - @Override - public BpmTaskRuleScriptEnum getEnum() { - return BpmTaskRuleScriptEnum.LEADER_X2; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java deleted file mode 100644 index 653918b0..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/script/impl/BpmTaskAssignStartUserScript.java +++ /dev/null @@ -1,41 +0,0 @@ -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.runtime.ProcessInstance; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -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(TaskEntity task) { - ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(task.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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java deleted file mode 100644 index 82d5e9be..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmProcessInstanceEventListener.java +++ /dev/null @@ -1,53 +0,0 @@ -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.delegate.event.FlowableProcessStartedEvent; -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java deleted file mode 100644 index f9c9cb76..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; - -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; -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.task.api.Task; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.Set; - -/** - * 监听 {@link org.flowable.task.api.Task} 的开始与完成,创建与更新对应的 {@link BpmTaskExtDO} 记录 - * - * @author jason - */ -@Component -public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { - - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - - public static final Set TASK_EVENTS = ImmutableSet.builder() - .add(FlowableEngineEventType.TASK_CREATED) - .add(FlowableEngineEventType.TASK_ASSIGNED) - .add(FlowableEngineEventType.TASK_COMPLETED) - .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()); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java deleted file mode 100644 index 52fdb7f9..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/framework/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * 属于 bpm 模块的 framework 封装 - * - * @author 芋道源码 - */ -package cn.iocoder.yudao.module.bpm.framework; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java deleted file mode 100644 index 5713e495..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * bpm 包下,业务流程管理(Business Process Management),我们放工作流的功能,基于 activiti 7 版本实现。 - * 例如说:流程定义、表单配置、审核中心(我的申请、我的待办、我的已办)等等 - * - * bpm 解释:https://baike.baidu.com/item/BPM/1933 - * - * 1. Controller URL:以 /bpm/ 开头,避免和其它 Module 冲突 - * 2. DataObject 表名:以 bpm_ 开头,方便在数据库中区分 - * - * 注意,由于 Bpm 模块下,容易和其它模块重名,所以类名都加载 Pay 的前缀~ - */ -package cn.iocoder.yudao.module.bpm; diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java deleted file mode 100644 index a4e4f83d..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java +++ /dev/null @@ -1,77 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java deleted file mode 100644 index dcb0b9e4..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java +++ /dev/null @@ -1,286 +0,0 @@ -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 = this.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) { - // 校验流程模型存在 - Model model = repositoryService.getModel(id); - if (ObjectUtils.isEmpty(model)) { - throw exception(MODEL_NOT_EXISTS); - } - // 校验流程图 - byte[] bpmnBytes = repositoryService.getModelEditorSource(model.getId()); - if (bpmnBytes == null) { - throw exception(MODEL_NOT_EXISTS); - } - // TODO 芋艿:校验流程图的有效性;例如说,是否有开始的元素,是否有结束的元素; - // 校验表单已配 - BpmFormDO form = checkFormConfig(model.getMetaInfo()); - //校验任务分配规则已配置 - taskAssignRuleService.checkTaskAssignRuleAllConfig(id); - - BpmProcessDefinitionCreateReqDTO definitionCreateReqDTO = BpmModelConvert.INSTANCE.convert2(model, form).setBpmnBytes(bpmnBytes); - //校验模型是否发生修改。如果未修改,则不允许创建 - if (processDefinitionService.isProcessDefinitionEquals(definitionCreateReqDTO)) { // 流程定义的信息相等 - ProcessDefinition oldProcessInstance = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); - if (oldProcessInstance != null && taskAssignRuleService.isTaskAssignRulesEquals(model.getId(), oldProcessInstance.getId())) { - throw exception(MODEL_DEPLOY_FAIL_TASK_INFO_EQUALS); - } - } - // 创建流程定义 - String definitionId = processDefinitionService.createProcessDefinition(definitionCreateReqDTO); - - // 将老的流程定义进行挂起。也就是说,只有最新部署的流程定义,才可以发起任务。 - updateProcessDefinitionSuspended(model.getDeploymentId()); - - // 更新 model 的 deploymentId,进行关联 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(definitionId); - model.setDeploymentId(definition.getDeploymentId()); - repositoryService.saveModel(model); - - //复制任务分配规则 - 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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java deleted file mode 100644 index 7c26b644..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java +++ /dev/null @@ -1,159 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java deleted file mode 100644 index b54e9581..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java +++ /dev/null @@ -1,287 +0,0 @@ -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-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java deleted file mode 100644 index 07945159..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleService.java +++ /dev/null @@ -1,87 +0,0 @@ -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.springframework.lang.Nullable; - -import javax.validation.Valid; -import java.util.List; - -/** - * 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); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java deleted file mode 100644 index 7ed096cc..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmTaskAssignRuleServiceImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -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.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; -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.mysql.definition.BpmTaskAssignRuleMapper; -import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; -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.user.AdminUserApi; -import lombok.extern.slf4j.Slf4j; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.UserTask; -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.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -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; - - @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(StrUtil.format("未知的规则类型({})", type)); - } - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java deleted file mode 100644 index 20d71ec2..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityService.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; - -import java.util.List; - -/** - * BPM 活动实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmActivityService { - - /** - * 获得指定流程实例的活动实例列表 - * - * @param processInstanceId 流程实例的编号 - * @return 活动实例列表 - */ - List getActivityListByProcessInstanceId(String processInstanceId); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java deleted file mode 100644 index fdab5a88..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmActivityServiceImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.activity.BpmActivityRespVO; -import cn.iocoder.yudao.module.bpm.convert.task.BpmActivityConvert; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import lombok.extern.slf4j.Slf4j; - -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.engine.HistoryService; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.image.ProcessDiagramGenerator; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.io.InputStream; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_BPMN_MODEL_NOT_EXISTS; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS; - -/** - * BPM 活动实例 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Slf4j -@Validated -public class BpmActivityServiceImpl implements BpmActivityService { - - @Resource - private HistoryService historyService; - - @Override - public List getActivityListByProcessInstanceId(String processInstanceId) { - List activityList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId).list(); - return BpmActivityConvert.INSTANCE.convertList(activityList); - } - - - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java deleted file mode 100644 index 831af4d3..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceService.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * 流程实例 Service 接口 - * - * @author 芋道源码 - */ -public interface BpmProcessInstanceService { - - /** - * 获得流程实例 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - ProcessInstance getProcessInstance(String id); - - /** - * 获得流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 - */ - List getProcessInstances(Set ids); - - /** - * 获得流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 流程实例列表 Map - */ - default Map getProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); - } - - /** - * 获得流程实例的分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程实例的分页 - */ - PageResult getMyProcessInstancePage(Long userId, - @Valid BpmProcessInstanceMyPageReqVO pageReqVO); - /** - * 创建流程实例(提供给前端) - * - * @param userId 用户编号 - * @param createReqVO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO); - - /** - * 创建流程实例(提供给内部) - * - * @param userId 用户编号 - * @param createReqDTO 创建信息 - * @return 实例的编号 - */ - String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO); - - /** - * 获得流程实例 VO 信息 - * - * @param id 流程实例的编号 - * @return 流程实例 - */ - BpmProcessInstanceRespVO getProcessInstanceVO(String id); - - /** - * 取消流程实例 - * - * @param userId 用户编号 - * @param cancelReqVO 取消信息 - */ - void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO); - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - HistoricProcessInstance getHistoricProcessInstance(String id); - - /** - * 获得历史的流程实例列表 - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 - */ - List getHistoricProcessInstances(Set ids); - - /** - * 获得历史的流程实例 Map - * - * @param ids 流程实例的编号集合 - * @return 历史的流程实例列表 Map - */ - default Map getHistoricProcessInstanceMap(Set ids) { - return CollectionUtils.convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); - } - - /** - * 创建 ProcessInstance 拓展记录 - * - * @param instance 流程任务 - */ - void createProcessInstanceExt(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为取消 - * - * @param event 流程取消事件 - */ - void updateProcessInstanceExtCancel(FlowableCancelledEvent event); - - /** - * 更新 ProcessInstance 拓展记录为完成 - * - * @param instance 流程任务 - */ - void updateProcessInstanceExtComplete(ProcessInstance instance); - - /** - * 更新 ProcessInstance 拓展记录为不通过 - * - * @param id 流程编号 - * @param comment 理由。例如说,审批不通过时,需要传递该值 - */ - void updateProcessInstanceExtReject(String id, String comment); - - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java deleted file mode 100644 index 9c21bd8a..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ /dev/null @@ -1,300 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert; -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.dal.mysql.task.BpmProcessInstanceExtMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; -import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventPublisher; -import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -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 lombok.extern.slf4j.Slf4j; -import org.flowable.engine.HistoryService; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.delegate.event.FlowableCancelledEvent; -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.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -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.convertList; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF; - -/** - * 流程实例 Service 实现类 - * - * ProcessDefinition & ProcessInstance & Execution & Task 的关系: - * 1. https://blog.csdn.net/bobozai86/article/details/105210414 - * - * HistoricProcessInstance & ProcessInstance 的关系: - * 1.https://my.oschina.net/843294669/blog/719024 - * 简单来说,前者 = 历史 + 运行中的流程实例,后者仅是运行中的流程实例 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService { - - @Resource - private RuntimeService runtimeService; - @Resource - private BpmProcessInstanceExtMapper processInstanceExtMapper; - @Resource - @Lazy // 解决循环依赖 - private BpmTaskService taskService; - @Resource - private BpmProcessDefinitionService processDefinitionService; - @Resource - private HistoryService historyService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - private BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher; - @Resource - private BpmMessageService messageService; - @Override - public ProcessInstance getProcessInstance(String id) { - return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult(); - } - - @Override - public List getProcessInstances(Set ids) { - return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list(); - } - - @Override - public PageResult getMyProcessInstancePage(Long userId, - BpmProcessInstanceMyPageReqVO pageReqVO) { - // 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页 - PageResult pageResult = processInstanceExtMapper.selectPage(userId, pageReqVO); - if (CollUtil.isEmpty(pageResult.getList())) { - return new PageResult<>(pageResult.getTotal()); - } - - // 获得流程 Task Map - List processInstanceIds = convertList(pageResult.getList(), BpmProcessInstanceExtDO::getProcessInstanceId); - Map> taskMap = taskService.getTaskMapByProcessInstanceIds(processInstanceIds); - // 转换返回 - return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId()); - // 发起流程 - return createProcessInstance0(userId, definition, createReqVO.getVariables(), null); - } - - @Override - public String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey()); - // 发起流程 - return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey()); - } - - @Override - public BpmProcessInstanceRespVO getProcessInstanceVO(String id) { - // 获得流程实例 - HistoricProcessInstance processInstance = getHistoricProcessInstance(id); - if (processInstance == null) { - return null; - } - BpmProcessInstanceExtDO processInstanceExt = processInstanceExtMapper.selectByProcessInstanceId(id); - Assert.notNull(processInstanceExt, "流程实例拓展({}) 不存在", id); - - // 获得流程定义 - ProcessDefinition processDefinition = processDefinitionService - .getProcessDefinition(processInstance.getProcessDefinitionId()); - Assert.notNull(processDefinition, "流程定义({}) 不存在", processInstance.getProcessDefinitionId()); - BpmProcessDefinitionExtDO processDefinitionExt = processDefinitionService.getProcessDefinitionExt( - processInstance.getProcessDefinitionId()); - Assert.notNull(processDefinitionExt, "流程定义拓展({}) 不存在", id); - String bpmnXml = processDefinitionService.getProcessDefinitionBpmnXML(processInstance.getProcessDefinitionId()); - - // 获得 User - AdminUserRespDTO startUser = adminUserApi.getUser(NumberUtils.parseLong(processInstance.getStartUserId())); - DeptRespDTO dept = null; - if (startUser != null) { - dept = deptApi.getDept(startUser.getDeptId()); - } - - // 拼接结果 - return BpmProcessInstanceConvert.INSTANCE.convert2(processInstance, processInstanceExt, - processDefinition, processDefinitionExt, bpmnXml, startUser, dept); - } - - @Override - public void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO) { - // 校验流程实例存在 - ProcessInstance instance = getProcessInstance(cancelReqVO.getId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS); - } - // 只能取消自己的 - if (!Objects.equals(instance.getStartUserId(), String.valueOf(userId))) { - throw exception(PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF); - } - - // 通过删除流程实例,实现流程实例的取消, - // 删除流程实例,正则执行任务ACT_RU_TASK. 任务会被删除。通过历史表查询 - deleteProcessInstance(cancelReqVO.getId(), - BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(cancelReqVO.getReason())); - } - - /** - * 获得历史的流程实例 - * - * @param id 流程实例的编号 - * @return 历史的流程实例 - */ - @Override - public HistoricProcessInstance getHistoricProcessInstance(String id) { - return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult(); - } - - @Override - public List getHistoricProcessInstances(Set ids) { - return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); - } - - @Override - public void createProcessInstanceExt(ProcessInstance instance) { - // 获得流程定义 - ProcessDefinition definition = processDefinitionService.getProcessDefinition2(instance.getProcessDefinitionId()); - // 插入 BpmProcessInstanceExtDO 对象 - BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() - .setProcessInstanceId(instance.getId()) - .setProcessDefinitionId(definition.getId()) - .setName(instance.getProcessDefinitionName()) - .setStartUserId(Long.valueOf(instance.getStartUserId())) - .setCategory(definition.getCategory()) - .setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus()) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - - processInstanceExtMapper.insert(instanceExtDO); - } - - @Override - public void updateProcessInstanceExtCancel(FlowableCancelledEvent event) { - // 判断是否为 Reject 不通过。如果是,则不进行更新 - if (BpmProcessInstanceDeleteReasonEnum.isRejectReason((String)event.getCause())) { - return; - } - - // 需要主动查询,因为 instance 只有 id 属性 - // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance - HistoricProcessInstance processInstance = getHistoricProcessInstance(event.getProcessInstanceId()); - // 更新拓展表 - BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() - .setProcessInstanceId(event.getProcessInstanceId()) - .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()); - - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - - @Override - public void updateProcessInstanceExtComplete(ProcessInstance instance) { - // 需要主动查询,因为 instance 只有 id 属性 - // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance - HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); - // 更新拓展表 - BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO() - .setProcessInstanceId(instance.getProcessInstanceId()) - .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); // 如果正常完全,说明审批通过 - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程被通过的消息 - messageService.sendMessageWhenProcessInstanceApprove(BpmProcessInstanceConvert.INSTANCE.convert2ApprovedReq(instance)); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - - @Transactional(rollbackFor = Exception.class) - public void updateProcessInstanceExtReject(String id, String comment) { - // 需要主动查询,因为 instance 只有 id 属性 - ProcessInstance processInstance = getProcessInstance(id); - // 删除流程实例,以实现驳回任务时,取消整个审批流程 - deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(comment))); - - // 更新 status + result - // 注意,不能和上面的逻辑更换位置。因为 deleteProcessInstance 会触发流程的取消,进而调用 updateProcessInstanceExtCancel 方法, - // 设置 result 为 BpmProcessInstanceStatusEnum.CANCEL,显然和 result 不一定是一致的 - BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(id) - .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()); - processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); - - // 发送流程被不通过的消息 - messageService.sendMessageWhenProcessInstanceReject(BpmProcessInstanceConvert.INSTANCE.convert2RejectReq(processInstance, comment)); - - // 发送流程实例的状态事件 - processInstanceResultEventPublisher.sendProcessInstanceResultEvent( - BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); - } - - private void deleteProcessInstance(String id, String reason) { - runtimeService.deleteProcessInstance(id, reason); - } - - private String createProcessInstance0(Long userId, ProcessDefinition definition, - Map variables, String businessKey) { - // 校验流程定义 - if (definition == null) { - throw exception(PROCESS_DEFINITION_NOT_EXISTS); - } - if (definition.isSuspended()) { - throw exception(PROCESS_DEFINITION_IS_SUSPENDED); - } - - // 创建流程实例 - ProcessInstance instance = runtimeService.startProcessInstanceById(definition.getId(), businessKey, variables); - // 设置流程名字 - runtimeService.setProcessInstanceName(instance.getId(), definition.getName()); - - // 补全流程实例的拓展表 - processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId()) - .setFormVariables(variables)); - - return instance.getId(); - } -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java deleted file mode 100644 index e8aab6aa..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ /dev/null @@ -1,117 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -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.task.vo.task.*; -import org.flowable.task.api.Task; - - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -/** - * 流程任务实例 Service 接口 - * - * @author jason - * @author 芋道源码 - */ -public interface BpmTaskService { - /** - * 获得待办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); - /** - * 获得已办的流程任务分页 - * - * @param userId 用户编号 - * @param pageReqVO 分页请求 - * @return 流程任务分页 - */ - PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); - - /** - * 获得流程任务 Map - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务 Map - */ - default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { - return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), - Task::getProcessInstanceId); - } - - /** - * 获得流程任务列表 - * - * @param processInstanceIds 流程实例的编号数组 - * @return 流程任务列表 - */ - List getTasksByProcessInstanceIds(List processInstanceIds); - - /** - * 获得指令流程实例的流程任务列表,包括所有状态的 - * - * @param processInstanceId 流程实例的编号 - * @return 流程任务列表 - */ - List getTaskListByProcessInstanceId(String processInstanceId); - - /** - * 通过任务 - * - * @param userId 用户编号 - * @param reqVO 通过请求 - */ - void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO); - - /** - * 不通过任务 - * - * @param userId 用户编号 - * @param reqVO 不通过请求 - */ - void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param userId 用户编号 - * @param reqVO 分配请求 - */ - void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO); - - /** - * 将流程任务分配给指定用户 - * - * @param id 流程任务编号 - * @param userId 用户编号 - */ - void updateTaskAssignee(String id, Long userId); - - /** - * 创建 Task 拓展记录 - * - * @param task 任务实体 - */ - void createTaskExt(Task task); - - /** - * 更新 Task 拓展记录为完成 - * - * @param task 任务实体 - */ - void updateTaskExtComplete(Task task); - - /** - * 更新 Task 拓展记录,并发送通知 - * - * @param task 任务实体 - */ - void updateTaskExtAssign(Task task); - -} diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java deleted file mode 100644 index 5c004977..00000000 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ /dev/null @@ -1,270 +0,0 @@ -package cn.iocoder.yudao.module.bpm.service.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.number.NumberUtils; -import cn.iocoder.yudao.framework.common.util.object.PageUtils; -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; -import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; -import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; -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 lombok.extern.slf4j.Slf4j; -import org.flowable.engine.HistoryService; -import org.flowable.engine.TaskService; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.TaskQuery; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskInstanceQuery; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -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.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; - -/** - * 流程任务实例 Service 实现类 - * - * @author 芋道源码 - * @author jason - */ -@Slf4j -@Service -public class BpmTaskServiceImpl implements BpmTaskService{ - - @Resource - private TaskService taskService; - @Resource - private HistoryService historyService; - - @Resource - private BpmProcessInstanceService processInstanceService; - @Resource - private AdminUserApi adminUserApi; - @Resource - private DeptApi deptApi; - @Resource - private BpmTaskExtMapper taskExtMapper; - @Resource - private BpmMessageService messageService; - - @Override - public PageResult getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { - // 查询待办任务 - TaskQuery taskQuery = taskService.createTaskQuery() - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByTaskCreateTime().desc(); // 创建时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (pageVO.getBeginCreateTime() != null) { - taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime()); - } - if (pageVO.getEndCreateTime() != null) { - taskQuery.taskCreatedBefore(pageVO.getEndCreateTime()); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 ProcessInstance Map - Map processInstanceMap = processInstanceService.getProcessInstanceMap( - convertSet(tasks, Task::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public PageResult getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) { - // 查询已办任务 - HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery() - .finished() // 已完成 - .taskAssignee(String.valueOf(userId)) // 分配给自己 - .orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序 - if (StrUtil.isNotBlank(pageVO.getName())) { - taskQuery.taskNameLike("%" + pageVO.getName() + "%"); - } - if (pageVO.getBeginCreateTime() != null) { - taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime()); - } - if (pageVO.getEndCreateTime() != null) { - taskQuery.taskCreatedBefore(pageVO.getEndCreateTime()); - } - // 执行查询 - List tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); - if (CollUtil.isEmpty(tasks)) { - return PageResult.empty(taskQuery.count()); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - Map historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( - convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); - // 获得 User Map - Map userMap = adminUserApi.getUserMap( - convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); - // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap), - taskQuery.count()); - } - - @Override - public List getTasksByProcessInstanceIds(List processInstanceIds) { - if (CollUtil.isEmpty(processInstanceIds)) { - return Collections.emptyList(); - } - return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); - } - - @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { - // 获得任务列表 - List tasks = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(processInstanceId) - .orderByHistoricTaskInstanceStartTime().desc() // 创建时间倒序 - .list(); - if (CollUtil.isEmpty(tasks)) { - return Collections.emptyList(); - } - - // 获得 TaskExtDO Map - List bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); - Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); - // 获得 ProcessInstance Map - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId); - // 获得 User Map - Set userIds = convertSet(tasks, task -> NumberUtils.parseLong(task.getAssignee())); - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId())); - Map userMap = adminUserApi.getUserMap(userIds); - // 获得 Dept Map - Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - - // 拼接数据 - return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO) { - // 校验任务存在 - Task task = checkTask(userId, reqVO.getId()); - // 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 完成任务,审批通过 - taskService.complete(task.getId(), instance.getProcessVariables()); - // 更新任务拓展表为通过 - taskExtMapper.updateByTaskId(new BpmTaskExtDO().setTaskId(task.getId()) - .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()).setComment(reqVO.getComment())); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) { - Task task = checkTask(userId, reqVO.getId()); - // 校验流程实例存在 - ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - if (instance == null) { - throw exception(PROCESS_INSTANCE_NOT_EXISTS); - } - - // 更新流程实例为不通过 - processInstanceService.updateProcessInstanceExtReject(instance.getProcessInstanceId(), reqVO.getComment()); - - // 更新任务拓展表为不通过 - taskExtMapper.updateByTaskId(new BpmTaskExtDO().setTaskId(task.getId()) - .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()).setComment(reqVO.getComment())); - } - - @Override - public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { - // 校验任务存在 - Task task = checkTask(userId, reqVO.getId()); - // 更新负责人 - updateTaskAssignee(task.getId(), reqVO.getAssigneeUserId()); - } - - @Override - public void updateTaskAssignee(String id, Long userId) { - taskService.setAssignee(id, String.valueOf(userId)); - } - - - @Override - public void createTaskExt(Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert2TaskExt(task) - .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); - taskExtMapper.insert(taskExtDO); - } - - @Override - public void updateTaskExtComplete(Task task) { - BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert2TaskExt(task) - .setEndTime(new Date()); - taskExtMapper.updateByTaskId(taskExtDO); - } - - @Override - public void updateTaskExtAssign(Task task) { - BpmTaskExtDO taskExtDO = new BpmTaskExtDO() - .setAssigneeUserId(NumberUtils.parseLong(task.getAssignee())) - .setTaskId(task.getId()); - taskExtMapper.updateByTaskId(taskExtDO); - // 发送通知。在事务提交时,批量执行操作,所以直接查询会无法查询到 ProcessInstance,所以这里是通过监听事务的提交来实现。 - TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { - @Override - public void afterCommit() { - ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); - messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); - } - }); - } - - /** - * 校验任务是否存在, 并且是否是分配给自己的任务 - * @param userId 用户 id - * @param taskId task id - */ - private Task checkTask(Long userId, String taskId) { - Task task = getTask(taskId); - if (task == null) { - throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS); - } - if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) { - throw exception(TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF); - } - return task; - } - - private Task getTask(String id) { - return taskService.createTaskQuery().taskId(id).singleResult(); - } -} diff --git a/yudao-ui-admin b/yudao-ui-admin deleted file mode 160000 index c7b0740f..00000000 --- a/yudao-ui-admin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c7b0740fa3d4d78923c86b4c236d3fae2424d52a diff --git a/yudao-ui-app-tmp/.eslintrc.js b/yudao-ui-app-tmp/.eslintrc.js deleted file mode 100755 index 115cc02b..00000000 --- a/yudao-ui-app-tmp/.eslintrc.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Eslint config file - * Documentation: https://eslint.org/docs/user-guide/configuring/ - * Install the Eslint extension before using this feature. - */ -module.exports = { - env: { - es6: true, - browser: true, - node: true, - }, - ecmaFeatures: { - modules: true, - }, - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - globals: { - wx: true, - App: true, - Page: true, - getCurrentPages: true, - getApp: true, - Component: true, - requirePlugin: true, - requireMiniProgram: true, - }, - // extends: 'eslint:recommended', - rules: {}, -} diff --git a/yudao-ui-app-tmp/README.md b/yudao-ui-app-tmp/README.md deleted file mode 100644 index 4e5737cc..00000000 --- a/yudao-ui-app-tmp/README.md +++ /dev/null @@ -1 +0,0 @@ -临时项目,作为测试微信小程序登陆之用 diff --git a/yudao-ui-app-tmp/app.js b/yudao-ui-app-tmp/app.js deleted file mode 100755 index 1ed57c47..00000000 --- a/yudao-ui-app-tmp/app.js +++ /dev/null @@ -1,19 +0,0 @@ -// app.js -App({ - onLaunch() { - // 展示本地存储能力 - const logs = wx.getStorageSync('logs') || [] - logs.unshift(Date.now()) - wx.setStorageSync('logs', logs) - - // 登录 - wx.login({ - success: res => { - // 发送 res.code 到后台换取 openId, sessionKey, unionId - } - }) - }, - globalData: { - userInfo: null - } -}) diff --git a/yudao-ui-app-tmp/app.json b/yudao-ui-app-tmp/app.json deleted file mode 100755 index 3d7616ff..00000000 --- a/yudao-ui-app-tmp/app.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pages":[ - "pages/index/index", - "pages/logs/logs" - ], - "window":{ - "backgroundTextStyle":"light", - "navigationBarBackgroundColor": "#fff", - "navigationBarTitleText": "Weixin", - "navigationBarTextStyle":"black" - }, - "style": "v2", - "sitemapLocation": "sitemap.json" -} diff --git a/yudao-ui-app-tmp/app.wxss b/yudao-ui-app-tmp/app.wxss deleted file mode 100755 index 06c6fc9c..00000000 --- a/yudao-ui-app-tmp/app.wxss +++ /dev/null @@ -1,10 +0,0 @@ -/**app.wxss**/ -.container { - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: space-between; - padding: 200rpx 0; - box-sizing: border-box; -} diff --git a/yudao-ui-app-tmp/pages/index/index.js b/yudao-ui-app-tmp/pages/index/index.js deleted file mode 100755 index eadb684c..00000000 --- a/yudao-ui-app-tmp/pages/index/index.js +++ /dev/null @@ -1,91 +0,0 @@ -// index.js - -const common=require('../../utils/common.js') -// 获取应用实例 -const app = getApp() - -Page({ - data: { - motto: 'Hello World', - userInfo: {}, - hasUserInfo: false, - canIUse: wx.canIUse('button.open-type.getUserInfo'), - canIUseGetUserProfile: false, - canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName'), // 如需尝试获取用户信息可改为false - holderText: 'to be auth' - }, - // 事件处理函数 - bindViewTap() { - wx.navigateTo({ - url: '../logs/logs' - }) - }, - onLoad() { - if (wx.getUserProfile) { - this.setData({ - canIUseGetUserProfile: true - }) - } - }, - getUserProfile(e) { - // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 - wx.getUserProfile({ - desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 - success: (res) => { - console.log(res) - this.setData({ - userInfo: res.userInfo, - hasUserInfo: true - }) - } - }) - }, - getUserInfo(e) { - // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 - console.log(e) - this.setData({ - userInfo: e.detail.userInfo, - hasUserInfo: true - }) - }, - // 小程序登录 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html - wxLogin(e){ - let page=this; - wx.login({ - success (res) { - console.log("res:") - console.log(res) - if (res.code) { - //发起网络请求 - console.log('发起网络请求'+common.baseurl) - wx.request({ - url: common.baseurl+'/api/social-login2', - method: "POST", - data: { - code: res.code, - state: 'empty', - type: 33, - username: '15601691300', - password: 'admin123' - }, - header: { - 'content-type': 'application/json' // 默认值 - }, - success: function(res) { - console.log(res.data) - let holder="auth success, token:"+res.data.data.token - page.setData({holderText: holder}) - }, - fail: function(data){ - console.error("请求出错"); - console.error(data) - } - - }) - } else { - console.log('登录失败!' + res.errMsg) - } - } - }) - } -}) diff --git a/yudao-ui-app-tmp/pages/index/index.json b/yudao-ui-app-tmp/pages/index/index.json deleted file mode 100755 index 8835af06..00000000 --- a/yudao-ui-app-tmp/pages/index/index.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "usingComponents": {} -} \ No newline at end of file diff --git a/yudao-ui-app-tmp/pages/index/index.wxml b/yudao-ui-app-tmp/pages/index/index.wxml deleted file mode 100755 index e3243c3e..00000000 --- a/yudao-ui-app-tmp/pages/index/index.wxml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - 请使用1.4.4及以上版本基础库 - - - - {{userInfo.nickName}} - - - - - - - - - 授权登录测试1024 - - - - {{holderText}} - diff --git a/yudao-ui-app-tmp/pages/index/index.wxss b/yudao-ui-app-tmp/pages/index/index.wxss deleted file mode 100755 index eb642035..00000000 --- a/yudao-ui-app-tmp/pages/index/index.wxss +++ /dev/null @@ -1,19 +0,0 @@ -/**index.wxss**/ -.userinfo { - display: flex; - flex-direction: column; - align-items: center; - color: #aaa; -} - -.userinfo-avatar { - overflow: hidden; - width: 128rpx; - height: 128rpx; - margin: 20rpx; - border-radius: 50%; -} - -.usermotto { - margin-top: 200px; -} \ No newline at end of file diff --git a/yudao-ui-app-tmp/pages/logs/logs.js b/yudao-ui-app-tmp/pages/logs/logs.js deleted file mode 100755 index 85f6aac5..00000000 --- a/yudao-ui-app-tmp/pages/logs/logs.js +++ /dev/null @@ -1,18 +0,0 @@ -// logs.js -const util = require('../../utils/util.js') - -Page({ - data: { - logs: [] - }, - onLoad() { - this.setData({ - logs: (wx.getStorageSync('logs') || []).map(log => { - return { - date: util.formatTime(new Date(log)), - timeStamp: log - } - }) - }) - } -}) diff --git a/yudao-ui-app-tmp/pages/logs/logs.json b/yudao-ui-app-tmp/pages/logs/logs.json deleted file mode 100755 index 3ee76c18..00000000 --- a/yudao-ui-app-tmp/pages/logs/logs.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "查看启动日志", - "usingComponents": {} -} \ No newline at end of file diff --git a/yudao-ui-app-tmp/pages/logs/logs.wxml b/yudao-ui-app-tmp/pages/logs/logs.wxml deleted file mode 100755 index 0b6b6456..00000000 --- a/yudao-ui-app-tmp/pages/logs/logs.wxml +++ /dev/null @@ -1,6 +0,0 @@ - - - - {{index + 1}}. {{log.date}} - - diff --git a/yudao-ui-app-tmp/pages/logs/logs.wxss b/yudao-ui-app-tmp/pages/logs/logs.wxss deleted file mode 100755 index 94d4b88a..00000000 --- a/yudao-ui-app-tmp/pages/logs/logs.wxss +++ /dev/null @@ -1,8 +0,0 @@ -.log-list { - display: flex; - flex-direction: column; - padding: 40rpx; -} -.log-item { - margin: 10rpx; -} diff --git a/yudao-ui-app-tmp/project.config.json b/yudao-ui-app-tmp/project.config.json deleted file mode 100755 index 2fbe955c..00000000 --- a/yudao-ui-app-tmp/project.config.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "description": "项目配置文件", - "packOptions": { - "ignore": [ - { - "type": "file", - "value": ".eslintrc.js" - } - ] - }, - "setting": { - "bundle": false, - "userConfirmedBundleSwitch": false, - "urlCheck": true, - "scopeDataCheck": false, - "coverView": true, - "es6": true, - "postcss": true, - "compileHotReLoad": false, - "lazyloadPlaceholderEnable": false, - "preloadBackgroundData": false, - "minified": true, - "autoAudits": false, - "newFeature": false, - "uglifyFileName": false, - "uploadWithSourceMap": true, - "useIsolateContext": true, - "nodeModules": false, - "enhance": true, - "useMultiFrameRuntime": true, - "useApiHook": true, - "useApiHostProcess": true, - "showShadowRootInWxmlPanel": true, - "packNpmManually": false, - "enableEngineNative": false, - "packNpmRelationList": [], - "minifyWXSS": true, - "showES6CompileOption": false, - "minifyWXML": true - }, - "compileType": "miniprogram", - "libVersion": "2.19.4", - "appid": "wx44d047d87e6284d8", - "appid1": "wx63c280fe3248a3e7", - "projectname": "mini-program-test", - "debugOptions": { - "hidedInDevtools": [] - }, - "scripts": {}, - "staticServerOptions": { - "baseURL": "", - "servePath": "" - }, - "isGameTourist": false, - "condition": { - "search": { - "list": [] - }, - "conversation": { - "list": [] - }, - "game": { - "list": [] - }, - "plugin": { - "list": [] - }, - "gamePlugin": { - "list": [] - }, - "miniprogram": { - "list": [] - } - } -} \ No newline at end of file diff --git a/yudao-ui-app-tmp/sitemap.json b/yudao-ui-app-tmp/sitemap.json deleted file mode 100755 index ca02add2..00000000 --- a/yudao-ui-app-tmp/sitemap.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", - "rules": [{ - "action": "allow", - "page": "*" - }] -} \ No newline at end of file diff --git a/yudao-ui-app-tmp/utils/common.js b/yudao-ui-app-tmp/utils/common.js deleted file mode 100755 index a52d7252..00000000 --- a/yudao-ui-app-tmp/utils/common.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - baseurl: "http://127.0.0.1:28080" -} diff --git a/yudao-ui-app-tmp/utils/util.js b/yudao-ui-app-tmp/utils/util.js deleted file mode 100755 index 764bc2ce..00000000 --- a/yudao-ui-app-tmp/utils/util.js +++ /dev/null @@ -1,19 +0,0 @@ -const formatTime = date => { - const year = date.getFullYear() - const month = date.getMonth() + 1 - const day = date.getDate() - const hour = date.getHours() - const minute = date.getMinutes() - const second = date.getSeconds() - - return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` -} - -const formatNumber = n => { - n = n.toString() - return n[1] ? n : `0${n}` -} - -module.exports = { - formatTime -} diff --git a/yudao-ui-app-v1/.hbuilderx/launch.json b/yudao-ui-app-v1/.hbuilderx/launch.json deleted file mode 100644 index 07c1d5fa..00000000 --- a/yudao-ui-app-v1/.hbuilderx/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ - // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 - "version": "0.0", - "configurations": [{ - "default" : - { - "launchtype" : "local" - }, - "h5" : - { - "launchtype" : "local" - }, - "type" : "uniCloud" - } - ] -} diff --git a/yudao-ui-app-v1/App.vue b/yudao-ui-app-v1/App.vue deleted file mode 100644 index a2622840..00000000 --- a/yudao-ui-app-v1/App.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - diff --git a/yudao-ui-app-v1/api/member/userProfile.js b/yudao-ui-app-v1/api/member/userProfile.js deleted file mode 100644 index 2effa1eb..00000000 --- a/yudao-ui-app-v1/api/member/userProfile.js +++ /dev/null @@ -1,23 +0,0 @@ -import { request } from '@/common/js/request.js' - -// 获得用户的基本信息 -export function getUserInfo() { - return request({ - url: 'member/user/profile/get', - method: 'get' - }) -} - -// 修改 -export function updateNickname(nickname) { - return request({ - url: 'member/user/profile/update-nickname', - method: 'post', - header: { - "Content-Type": "application/x-www-form-urlencoded" - }, - data: { - nickname - } - }) -} \ No newline at end of file diff --git a/yudao-ui-app-v1/api/system/auth.js b/yudao-ui-app-v1/api/system/auth.js deleted file mode 100644 index 42865559..00000000 --- a/yudao-ui-app-v1/api/system/auth.js +++ /dev/null @@ -1,34 +0,0 @@ -import { request } from '@/common/js/request.js' - -// 手机号 + 密码登陆 -export function login(mobile, password) { - return request({ - url: 'login', - method: 'post', - data: { - mobile, password - } - }) -} - -// 手机号 + 验证码登陆 -export function smsLogin(mobile, code) { - return request({ - url: 'sms-login', - method: 'post', - data: { - mobile, code - } - }) -} - -// 发送手机验证码 -export function sendSmsCode(mobile, scene) { - return request({ - url: 'send-sms-code', - method: 'post', - data: { - mobile, scene - } - }) -} \ No newline at end of file diff --git a/yudao-ui-app-v1/common/css/common.css b/yudao-ui-app-v1/common/css/common.css deleted file mode 100644 index 2f22c237..00000000 --- a/yudao-ui-app-v1/common/css/common.css +++ /dev/null @@ -1,182 +0,0 @@ -/* #ifndef APP-PLUS-NVUE */ -view, -scroll-view, -swiper, -swiper-item, -cover-view, -cover-image, -icon, -text, -rich-text, -progress, -button, -checkbox, -form, -input, -label, -radio, -slider, -switch, -textarea, -navigator, -audio, -camera, -image, -video { - box-sizing: border-box; -} -image{ - display: block; -} -text{ - line-height: 1; - /* font-family: Helvetica Neue, Helvetica, sans-serif; */ -} -button{ - padding: 0; - margin: 0; - background-color: rgba(0,0,0,0) !important; -} -button:after{ - border: 0; -} -.bottom-fill{ - height: constant(safe-area-inset-bottom); - height: env(safe-area-inset-bottom); -} -.fix-bot{ - box-sizing: content-box; - padding-bottom: constant(safe-area-inset-bottom); - padding-bottom: env(safe-area-inset-bottom); -} - -/* 边框 */ -.round{ - position: relative; - border-radius: 100rpx; -} -.round:after{ - content: ''; - position: absolute; - left: 0; - top: 0; - width: 200%; - height: 200%; - transform: scale(.5) translate(-50%,-50%); - border: 1px solid #878787; - border-radius: 100rpx; - box-sizing: border-box; -} -.b-b:after{ - position: absolute; - z-index: 3; - left: 0; - top: auto; - bottom: 0; - right: 0; - height: 0; - content: ''; - transform: scaleY(.5); - border-bottom: 1px solid #e0e0e0; -} -.b-t:before{ - position: absolute; - z-index: 3; - left: 0; - top: 0; - right: 0; - height: 0; - content: ''; - transform: scaleY(.5); - border-bottom: 1px solid #e5e5e5; -} -.b-r:after{ - position: absolute; - z-index: 3; - right: 0; - top: 0; - bottom: 0; - width: 0; - content: ''; - transform: scaleX(.5); - border-right: 1px solid #e5e5e5; -} -.b-l:before{ - position: absolute; - z-index: 3; - left: 0; - top: 0; - bottom: 0; - width: 0; - content: ''; - transform: scaleX(.5); - border-left: 1px solid #e5e5e5; -} -.b-b, .b-t, .b-l, .b-r{ - position: relative; -} -/* 点击态 */ -.hover-gray { - background: #fafafa !important; -} -.hover-dark { - background: #f0f0f0 !important; -} - -.hover-opacity { - opacity: 0.7; -} - -/* #endif */ - -.clamp { - /* #ifdef APP-PLUS-NVUE */ - lines: 1; - /* #endif */ - /* #ifndef APP-PLUS-NVUE */ - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - display: block; - /* #endif */ -} -.clamp2 { - /* #ifdef APP-PLUS-NVUE */ - lines: 2; - /* #endif */ - /* #ifndef APP-PLUS-NVUE */ - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - overflow: hidden; - /* #endif */ -} - -/* 布局 */ -.row{ - /* #ifndef APP-PLUS-NVUE */ - display:flex; - /* #endif */ - flex-direction:row; - align-items: center; -} -.column{ - /* #ifndef APP-PLUS-NVUE */ - display:flex; - /* #endif */ - flex-direction: column; -} -.center{ - /* #ifndef APP-PLUS-NVUE */ - display:flex; - /* #endif */ - align-items: center; - justify-content: center; -} -.fill{ - flex: 1; -} -/* input */ -.placeholder{ - color: #999 !important; -} \ No newline at end of file diff --git a/yudao-ui-app-v1/common/css/icon.css b/yudao-ui-app-v1/common/css/icon.css deleted file mode 100644 index 653ba4d0..00000000 --- a/yudao-ui-app-v1/common/css/icon.css +++ /dev/null @@ -1,271 +0,0 @@ -@font-face { - font-family: "mix-icon"; - font-weight: normal; - font-style: normal; - src: url('https://at.alicdn.com/t/font_1913318_2ui3nitf38x.ttf') format('truetype'); // TODO 芋艿: icon 怎么搞? -} - -.mix-icon { - font-family: "mix-icon" !important; - font-size: 16px; - font-style: normal; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.icon-fanhui:before { - content: "\e7d5"; -} - -.icon-shoujihaoma:before { - content: "\e7ec"; -} - -.icon-close:before { - content: "\e60f"; -} - -.icon-xingbie-nv:before { - content: "\e60e"; -} - -.icon-wuliuyunshu:before { - content: "\e7ed"; -} - -.icon-jingpin:before { - content: "\e608"; -} - -.icon-zhangdanmingxi01:before { - content: "\e637"; -} - -.icon-tixian1:before { - content: "\e625"; -} - -.icon-chongzhi:before { - content: "\e605"; -} - -.icon-wodezhanghu_zijinjilu:before { - content: "\e615"; -} - -.icon-tixian:before { - content: "\e6ab"; -} - -.icon-qianbao:before { - content: "\e6c4"; -} - -.icon-guanbi1:before { - content: "\e61a"; -} - -.icon-daipingjia:before { - content: "\e604"; -} - -.icon-daifahuo:before { - content: "\e6bd"; -} - -.icon-yue:before { - content: "\e600"; -} - -.icon-wxpay:before { - content: "\e602"; -} - -.icon-alipay:before { - content: "\e603"; -} - -.icon-tishi:before { - content: "\e662"; -} - -.icon-shoucang-1:before { - content: "\e607"; -} - -.icon-gouwuche:before { - content: "\e657"; -} - -.icon-shoucang:before { - content: "\e645"; -} - -.icon-home:before { - content: "\e60c"; -} - -/* .icon-bangzhu1:before { - content: "\e63d"; // 帮助 -} */ - -.icon-xingxing:before { - content: "\e70b"; -} - -.icon-shuxiangliebiao:before { - content: "\e635"; -} - -.icon-hengxiangliebiao:before { - content: "\e636"; -} - -.icon-guanbi2:before { - content: "\e7be"; -} - -.icon-down:before { - content: "\e65c"; -} - -.icon-arrow-top:before { - content: "\e63e"; -} - -.icon-xiaoxi:before { - content: "\e634"; -} - -.icon-saoma:before { - content: "\e655"; -} - -.icon-dizhi1:before { - content: "\e618"; -} - -.icon-ditu-copy:before { - content: "\e609"; -} - -.icon-lajitong:before { - content: "\e682"; -} - -.icon-bianji:before { - content: "\e60d"; // 编辑 -} - -.icon-yanzhengma1:before { - content: "\e613"; -} - -.icon-yanjing:before { - content: "\e65b"; -} - -.icon-mima:before { - content: "\e628"; -} - -.icon-biyan:before { - content: "\e633"; -} - -.icon-iconfontweixin:before { - content: "\e611"; -} - -.icon-shouye:before { - content: "\e626"; -} - -.icon-daifukuan:before { - content: "\e68f"; -} - -.icon-pinglun-copy:before { - content: "\e612"; -} - -.icon-lishijilu:before { - content: "\e6b9"; -} - -.icon-shoucang_xuanzhongzhuangtai:before { - content: "\e6a9"; -} - -.icon-share:before { - content: "\e656"; -} - -.icon-shezhi1:before { - content: "\e61d"; -} - -.icon-shouhoutuikuan:before { - content: "\e631"; -} - -.icon-dizhi:before { - content: "\e614"; -} - -.icon-yishouhuo:before { - content: "\e71a"; -} - -.icon-xuanzhong:before { - content: "\e632"; -} - -.icon-xiangzuo:before { - content: "\e653"; -} - -.icon-iconfontxingxing:before { - content: "\e6b0"; -} - -.icon-jia2:before { - content: "\e60a"; -} - -.icon-sousuo:before { - content: "\e7ce"; -} - -.icon-xiala:before { - content: "\e644"; -} - -.icon-xia:before { - content: "\e62d"; -} - -.icon--jianhao:before { - content: "\e60b"; -} - -.icon-you:before { - content: "\e606"; -} - -.icon-yk_yuanquan:before { - content: "\e601"; -} - -.icon-xing:before { - content: "\e627"; -} - -.icon-guanbi:before { - content: "\e71d"; -} - -.icon-loading:before { - content: "\e646"; -} - diff --git a/yudao-ui-app-v1/common/js/request.js b/yudao-ui-app-v1/common/js/request.js deleted file mode 100644 index 4b817866..00000000 --- a/yudao-ui-app-v1/common/js/request.js +++ /dev/null @@ -1,59 +0,0 @@ -import store from '@/store' -import { msg, getAuthToken } from './util' - -const BASE_URL = 'http://127.0.0.1:48080/app-api/'; - -export const request = (options) => { - return new Promise((resolve, reject) => { - // 发起请求 - const authToken = getAuthToken(); - uni.request({ - url: BASE_URL + options.url, - method: options.method || 'GET', - data: options.data || {}, - header: { - ...options.header, - 'Authorization': authToken ? `Bearer ${authToken}` : '' - } - }).then(res => { - res = res[1]; - const statusCode = res.statusCode; - if (statusCode !== 200) { - msg('请求失败,请重试'); - return; - } - - const code = res.data.code; - const message = res.data.msg; - // Token 过期,引导重新登陆 - if (code === 401) { - msg('登录信息已过期,请重新登录'); - store.commit('logout'); - // reject('无效的登录信息'); - return; - } - // 系统异常 - if (code === 500) { - msg('系统异常,请稍后重试'); - reject(new Error(message)); - return; - } - // 其它失败情况 - if (code > 0) { - msg(message); - // 提供 code + msg,可以基于 code 做进一步的处理。当然,一般情况下是不需要的。 - // 不需要的场景:手机登录时,密码不正确; - // 需要的场景:微信登录时,未绑定手机,后端会返回一个 code 码,前端需要基于它跳转到绑定手机界面; - reject({ - 'code': code, - 'msg': message - }); - return; - } - // 处理成功,则只返回成功的 data 数据,不返回 code 和 msg - resolve(res.data.data); - }).catch((err) => { - reject(err); - }) - }) -} diff --git a/yudao-ui-app-v1/common/js/util.js b/yudao-ui-app-v1/common/js/util.js deleted file mode 100644 index 68826553..00000000 --- a/yudao-ui-app-v1/common/js/util.js +++ /dev/null @@ -1,136 +0,0 @@ -let _debounceTimeout = null, - _throttleRunning = false - -/** - * 防抖 - * 参考文章 https://juejin.cn/post/6844903669389885453 - * - * @param {Function} 执行函数 - * @param {Number} delay 延时ms - */ -export const debounce = (fn, delay=500) => { - clearTimeout(_debounceTimeout); - _debounceTimeout = setTimeout(() => { - fn(); - }, delay); -} - -/** - * 节流 - * 参考文章 https://juejin.cn/post/6844903669389885453 - * - * @param {Function} 执行函数 - * @param {Number} delay 延时ms - */ -export const throttle = (fn, delay=500) => { - if(_throttleRunning){ - return; - } - _throttleRunning = true; - fn(); - setTimeout(() => { - _throttleRunning = false; - }, delay); -} - -/** - * toast 提示 - * - * @param {String} title 标题 - * @param {Object} param 拓展参数 - * @param {Integer} param.duration 持续时间 - * @param {Boolean} param.mask 是否遮罩 - * @param {Boolean} param.icon 图标 - */ -export const msg = (title = '', param={}) => { - if (!title) { - return; - } - uni.showToast({ - title, - duration: param.duration || 1500, - mask: param.mask || false, - icon: param.icon || 'none' // TODO 芋艿:是否要区分下 error 的提示,或者专门的封装 - }); -} - -/** - * 检查登录 - * - * @param {Boolean} options.nav 如果未登陆,是否跳转到登陆页。默认为 true - * @return {Boolean} 是否登陆 - */ -export const isLogin = (options = {}) => { - const token = getAuthToken(); - if (token) { - return true; - } - // 若 nav 不为 false,则进行跳转登陆页 - if (options.nav !== false) { - uni.navigateTo({ - url: '/pages/auth/login' - }) - } - return false; -} - -/** - * 获得认证 Token - * - * @return 认证 Token - */ -export const getAuthToken = () => { - return uni.getStorageSync('token'); -} - -/** - * 校验参数 - * - * @param {String} 字符串 - * @param {String} 数据的类型。例如说 mobile 手机号、tel 座机 TODO 芋艿:是否组件里解决 - */ -export const checkStr = (str, type) => { - switch (type) { - case 'mobile': //手机号码 - return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str); - case 'tel': //座机 - return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str); - case 'card': //身份证 - return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str); - case 'mobileCode': //6位数字验证码 - return /^[0-9]{6}$/.test(str) - case 'pwd': //密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线 - return /^([a-zA-Z0-9_]){6,18}$/.test(str) - case 'payPwd': //支付密码 6位纯数字 - return /^[0-9]{6}$/.test(str) - case 'postal': //邮政编码 - return /[1-9]\d{5}(?!\d)/.test(str); - case 'QQ': //QQ号 - return /^[1-9][0-9]{4,9}$/.test(str); - case 'email': //邮箱 - return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(str); - case 'money': //金额(小数点2位) - return /^\d*(?:\.\d{0,2})?$/.test(str); - case 'URL': //网址 - return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str) - case 'IP': //IP - return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str); - case 'date': //日期时间 - return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})\-(\d{2})\-(\d{2})$/ - .test(str) - case 'number': //数字 - return /^[0-9]$/.test(str); - case 'english': //英文 - return /^[a-zA-Z]+$/.test(str); - case 'chinese': //中文 - return /^[\\u4E00-\\u9FA5]+$/.test(str); - case 'lower': //小写 - return /^[a-z]+$/.test(str); - case 'upper': //大写 - return /^[A-Z]+$/.test(str); - case 'HTML': //HTML标记 - return /<("[^"]*"|'[^']*'|[^'">])*>/.test(str); - default: - return true; - } -} \ No newline at end of file diff --git a/yudao-ui-app-v1/common/mixin/mixin.js b/yudao-ui-app-v1/common/mixin/mixin.js deleted file mode 100644 index 701d7022..00000000 --- a/yudao-ui-app-v1/common/mixin/mixin.js +++ /dev/null @@ -1,96 +0,0 @@ -// import {request} from '@/common/js/request' - -export default{ - data() { - return { - page: 0, // 页码 - pageNum: 6, // 每页加载数据量 - loadingType: 1, // 加载类型。0 加载前;1 加载中;2 没有更多 - isLoading: false, // 刷新数据 - loaded: false, // 加载完毕 - } - }, - methods: { - /** - * 打印日志,方便调试 - * - * @param {Object} data 数据 - */ - log(data) { - console.log(JSON.parse(JSON.stringify(data))) - }, - - /** - * navigatorTo 跳转页面 - * - * @param {String} url - * @param {Object} options 可选参数 - * @param {Boolean} options.login 是否检测登录 - */ - navTo(url, options={}) { - this.$util.throttle(() => { - if (!url) { - return; - } - // 如果需要登陆,并且未登陆,则跳转到登陆界面 - if ((~url.indexOf('login=1') || options.login) && !this.$store.getters.hasLogin){ - url = '/pages/auth/login'; - } - // 跳转到指定 url 地址 - uni.navigateTo({ - url - }) - }, 300) - }, - - /** - * $request云函数请求 TODO 芋艿:需要改成自己的 - * @param {String} module - * @param {String} operation - * @param {Boolean} data 请求参数 - * @param {Boolean} ext 附加参数 - * @param {Boolean} ext.showLoading 是否显示loading状态,默认不显示 - * @param {Boolean} ext.hideLoading 是否关闭loading状态,默认关闭 - * @param {Boolean} ext.login 未登录拦截 - * @param {Boolean} ext.setLoaded 加载完成是设置页面加载完毕 - */ - $request(module, operation, data={}, ext={}){ - if(ext.login && !this.$util.isLogin()){ - return; - } - if(ext.showLoading){ - this.isLoading = true; - } - return new Promise((resolve, reject)=> { - request(module, operation, data, ext).then(result => { - if(ext.hideLoading !== false){ - this.isLoading = false; - } - setTimeout(()=>{ - if(this.setLoaded !== false){ - this.loaded = true; - } - }, 100) - this.$refs.confirmBtn && this.$refs.confirmBtn.stop(); - resolve(result); - }).catch((err) => { - reject(err); - }) - }) - }, - imageOnLoad(data, key){ // TODO 芋艿:需要改成自己的 - setTimeout(()=>{ - this.$set(data, 'loaded', true); - }, 100) - }, - showPopup(key){ // TODO 芋艿:需要改成自己的 - this.$util.throttle(()=>{ - this.$refs[key].open(); - }, 200) - }, - hidePopup(key){ // TODO 芋艿:需要改成自己的 - this.$refs[key].close(); - }, - stopPrevent(){}, // TODO 芋艿:需要改成自己的 - }, -} \ No newline at end of file diff --git a/yudao-ui-app-v1/components/jyf-parser/jyf-parser.vue b/yudao-ui-app-v1/components/jyf-parser/jyf-parser.vue deleted file mode 100644 index 01484f9d..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/jyf-parser.vue +++ /dev/null @@ -1,630 +0,0 @@ - - - - - diff --git a/yudao-ui-app-v1/components/jyf-parser/libs/CssHandler.js b/yudao-ui-app-v1/components/jyf-parser/libs/CssHandler.js deleted file mode 100644 index 8000377d..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/libs/CssHandler.js +++ /dev/null @@ -1,97 +0,0 @@ -const cfg = require('./config.js'), - isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - -function CssHandler(tagStyle) { - var styles = Object.assign(Object.create(null), cfg.userAgentStyles); - for (var item in tagStyle) - styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item]; - this.styles = styles; -} -CssHandler.prototype.getStyle = function(data) { - this.styles = new parser(data, this.styles).parse(); -} -CssHandler.prototype.match = function(name, attrs) { - var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : ''; - if (attrs.class) { - var items = attrs.class.split(' '); - for (var i = 0, item; item = items[i]; i++) - if (tmp = this.styles['.' + item]) - matched += tmp + ';'; - } - if (tmp = this.styles['#' + attrs.id]) - matched += tmp + ';'; - return matched; -} -module.exports = CssHandler; - -function parser(data, init) { - this.data = data; - this.floor = 0; - this.i = 0; - this.list = []; - this.res = init; - this.state = this.Space; -} -parser.prototype.parse = function() { - for (var c; c = this.data[this.i]; this.i++) - this.state(c); - return this.res; -} -parser.prototype.section = function() { - return this.data.substring(this.start, this.i); -} -// 状态机 -parser.prototype.Space = function(c) { - if (c == '.' || c == '#' || isLetter(c)) { - this.start = this.i; - this.state = this.Name; - } else if (c == '/' && this.data[this.i + 1] == '*') - this.Comment(); - else if (!cfg.blankChar[c] && c != ';') - this.state = this.Ignore; -} -parser.prototype.Comment = function() { - this.i = this.data.indexOf('*/', this.i) + 1; - if (!this.i) this.i = this.data.length; - this.state = this.Space; -} -parser.prototype.Ignore = function(c) { - if (c == '{') this.floor++; - else if (c == '}' && !--this.floor) this.state = this.Space; -} -parser.prototype.Name = function(c) { - if (cfg.blankChar[c]) { - this.list.push(this.section()); - this.state = this.NameSpace; - } else if (c == '{') { - this.list.push(this.section()); - this.Content(); - } else if (c == ',') { - this.list.push(this.section()); - this.Comma(); - } else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_') - this.state = this.Ignore; -} -parser.prototype.NameSpace = function(c) { - if (c == '{') this.Content(); - else if (c == ',') this.Comma(); - else if (!cfg.blankChar[c]) this.state = this.Ignore; -} -parser.prototype.Comma = function() { - while (cfg.blankChar[this.data[++this.i]]); - if (this.data[this.i] == '{') this.Content(); - else { - this.start = this.i--; - this.state = this.Name; - } -} -parser.prototype.Content = function() { - this.start = ++this.i; - if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length; - var content = this.section(); - for (var i = 0, item; item = this.list[i++];) - if (this.res[item]) this.res[item] += ';' + content; - else this.res[item] = content; - this.list = []; - this.state = this.Space; -} diff --git a/yudao-ui-app-v1/components/jyf-parser/libs/MpHtmlParser.js b/yudao-ui-app-v1/components/jyf-parser/libs/MpHtmlParser.js deleted file mode 100644 index 8911e36d..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/libs/MpHtmlParser.js +++ /dev/null @@ -1,534 +0,0 @@ -/** - * html 解析器 - * @tutorial https://github.com/jin-yufeng/Parser - * @version 20200719 - * @author JinYufeng - * @listens MIT - */ -const cfg = require('./config.js'), - blankChar = cfg.blankChar, - CssHandler = require('./CssHandler.js'), - windowWidth = uni.getSystemInfoSync().windowWidth; -var emoji; - -function MpHtmlParser(data, options = {}) { - this.attrs = {}; - this.CssHandler = new CssHandler(options.tagStyle, windowWidth); - this.data = data; - this.domain = options.domain; - this.DOM = []; - this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0; - options.prot = (this.domain || '').includes('://') ? this.domain.split('://')[0] : 'http'; - this.options = options; - this.state = this.Text; - this.STACK = []; - // 工具函数 - this.bubble = () => { - for (var i = this.STACK.length, item; item = this.STACK[--i];) { - if (cfg.richOnlyTags[item.name]) { - if (item.name == 'table' && !Object.hasOwnProperty.call(item, 'c')) item.c = 1; - return false; - } - item.c = 1; - } - return true; - } - this.decode = (val, amp) => { - var i = -1, - j, en; - while (1) { - if ((i = val.indexOf('&', i + 1)) == -1) break; - if ((j = val.indexOf(';', i + 2)) == -1) break; - if (val[i + 1] == '#') { - en = parseInt((val[i + 2] == 'x' ? '0' : '') + val.substring(i + 2, j)); - if (!isNaN(en)) val = val.substr(0, i) + String.fromCharCode(en) + val.substr(j + 1); - } else { - en = val.substring(i + 1, j); - if (cfg.entities[en] || en == amp) - val = val.substr(0, i) + (cfg.entities[en] || '&') + val.substr(j + 1); - } - } - return val; - } - this.getUrl = url => { - if (url[0] == '/') { - if (url[1] == '/') url = this.options.prot + ':' + url; - else if (this.domain) url = this.domain + url; - } else if (this.domain && url.indexOf('data:') != 0 && !url.includes('://')) - url = this.domain + '/' + url; - return url; - } - this.isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>'); - this.section = () => this.data.substring(this.start, this.i); - this.parent = () => this.STACK[this.STACK.length - 1]; - this.siblings = () => this.STACK.length ? this.parent().children : this.DOM; -} -MpHtmlParser.prototype.parse = function() { - if (emoji) this.data = emoji.parseEmoji(this.data); - for (var c; c = this.data[this.i]; this.i++) - this.state(c); - if (this.state == this.Text) this.setText(); - while (this.STACK.length) this.popNode(this.STACK.pop()); - return this.DOM; -} -// 设置属性 -MpHtmlParser.prototype.setAttr = function() { - var name = this.attrName.toLowerCase(), - val = this.attrVal; - if (cfg.boolAttrs[name]) this.attrs[name] = 'T'; - else if (val) { - if (name == 'src' || (name == 'data-src' && !this.attrs.src)) this.attrs.src = this.getUrl(this.decode(val, 'amp')); - else if (name == 'href' || name == 'style') this.attrs[name] = this.decode(val, 'amp'); - else if (name.substr(0, 5) != 'data-') this.attrs[name] = val; - } - this.attrVal = ''; - while (blankChar[this.data[this.i]]) this.i++; - if (this.isClose()) this.setNode(); - else { - this.start = this.i; - this.state = this.AttrName; - } -} -// 设置文本节点 -MpHtmlParser.prototype.setText = function() { - var back, text = this.section(); - if (!text) return; - text = (cfg.onText && cfg.onText(text, () => back = true)) || text; - if (back) { - this.data = this.data.substr(0, this.start) + text + this.data.substr(this.i); - let j = this.start + text.length; - for (this.i = this.start; this.i < j; this.i++) this.state(this.data[this.i]); - return; - } - if (!this.pre) { - // 合并空白符 - var tmp = []; - for (let i = text.length, c; c = text[--i];) - if (!blankChar[c] || (!blankChar[tmp[0]] && (c = ' '))) tmp.unshift(c); - text = tmp.join(''); - } - this.siblings().push({ - type: 'text', - text: this.decode(text) - }); -} -// 设置元素节点 -MpHtmlParser.prototype.setNode = function() { - var node = { - name: this.tagName.toLowerCase(), - attrs: this.attrs - }, - close = cfg.selfClosingTags[node.name]; - this.attrs = {}; - if (!cfg.ignoreTags[node.name]) { - // 处理属性 - var attrs = node.attrs, - style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''), - styleObj = {}; - if (attrs.id) { - if (this.options.compress & 1) attrs.id = void 0; - else if (this.options.useAnchor) this.bubble(); - } - if ((this.options.compress & 2) && attrs.class) attrs.class = void 0; - switch (node.name) { - case 'a': - case 'ad': // #ifdef APP-PLUS - case 'iframe': - // #endif - this.bubble(); - break; - case 'font': - if (attrs.color) { - styleObj['color'] = attrs.color; - attrs.color = void 0; - } - if (attrs.face) { - styleObj['font-family'] = attrs.face; - attrs.face = void 0; - } - if (attrs.size) { - var size = parseInt(attrs.size); - if (size < 1) size = 1; - else if (size > 7) size = 7; - var map = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']; - styleObj['font-size'] = map[size - 1]; - attrs.size = void 0; - } - break; - case 'embed': - // #ifndef APP-PLUS - var src = node.attrs.src || '', - type = node.attrs.type || ''; - if (type.includes('video') || src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8')) - node.name = 'video'; - else if (type.includes('audio') || src.includes('.m4a') || src.includes('.wav') || src.includes('.mp3') || src.includes( - '.aac')) - node.name = 'audio'; - else break; - if (node.attrs.autostart) - node.attrs.autoplay = 'T'; - node.attrs.controls = 'T'; - // #endif - // #ifdef APP-PLUS - this.bubble(); - break; - // #endif - case 'video': - case 'audio': - if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]); - else this[`${node.name}Num`]++; - if (node.name == 'video') { - if (this.videoNum > 3) - node.lazyLoad = 1; - if (attrs.width) { - styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px'); - attrs.width = void 0; - } - if (attrs.height) { - styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px'); - attrs.height = void 0; - } - } - attrs.source = []; - if (attrs.src) { - attrs.source.push(attrs.src); - attrs.src = void 0; - } - this.bubble(); - break; - case 'td': - case 'th': - if (attrs.colspan || attrs.rowspan) - for (var k = this.STACK.length, item; item = this.STACK[--k];) - if (item.name == 'table') { - item.c = void 0; - break; - } - } - if (attrs.align) { - styleObj['text-align'] = attrs.align; - attrs.align = void 0; - } - // 压缩 style - var styles = style.split(';'); - style = ''; - for (var i = 0, len = styles.length; i < len; i++) { - var info = styles[i].split(':'); - if (info.length < 2) continue; - let key = info[0].trim().toLowerCase(), - value = info.slice(1).join(':').trim(); - if (value.includes('-webkit') || value.includes('-moz') || value.includes('-ms') || value.includes('-o') || value.includes( - 'safe')) - style += `;${key}:${value}`; - else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) - styleObj[key] = value; - } - if (node.name == 'img') { - if (attrs.src && !attrs.ignore) { - if (this.bubble()) - attrs.i = (this.imgNum++).toString(); - else attrs.ignore = 'T'; - } - if (attrs.ignore) { - style += ';-webkit-touch-callout:none'; - styleObj['max-width'] = '100%'; - } - var width; - if (styleObj.width) width = styleObj.width; - else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : attrs.width + 'px'; - if (width) { - styleObj.width = width; - attrs.width = '100%'; - if (parseInt(width) > windowWidth) { - styleObj.height = ''; - if (attrs.height) attrs.height = void 0; - } - } - if (styleObj.height) { - attrs.height = styleObj.height; - styleObj.height = ''; - } else if (attrs.height && !attrs.height.includes('%')) - attrs.height += 'px'; - } - for (var key in styleObj) { - var value = styleObj[key]; - if (!value) continue; - if (key.includes('flex') || key == 'order' || key == 'self-align') node.c = 1; - // 填充链接 - if (value.includes('url')) { - var j = value.indexOf('('); - if (j++ != -1) { - while (value[j] == '"' || value[j] == "'" || blankChar[value[j]]) j++; - value = value.substr(0, j) + this.getUrl(value.substr(j)); - } - } - // 转换 rpx - else if (value.includes('rpx')) - value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px'); - else if (key == 'white-space' && value.includes('pre') && !close) - this.pre = node.pre = true; - style += `;${key}:${value}`; - } - style = style.substr(1); - if (style) attrs.style = style; - if (!close) { - node.children = []; - if (node.name == 'pre' && cfg.highlight) { - this.remove(node); - this.pre = node.pre = true; - } - this.siblings().push(node); - this.STACK.push(node); - } else if (!cfg.filter || cfg.filter(node, this) != false) - this.siblings().push(node); - } else { - if (!close) this.remove(node); - else if (node.name == 'source') { - var parent = this.parent(); - if (parent && (parent.name == 'video' || parent.name == 'audio') && node.attrs.src) - parent.attrs.source.push(node.attrs.src); - } else if (node.name == 'base' && !this.domain) this.domain = node.attrs.href; - } - if (this.data[this.i] == '/') this.i++; - this.start = this.i + 1; - this.state = this.Text; -} -// 移除标签 -MpHtmlParser.prototype.remove = function(node) { - var name = node.name, - j = this.i; - // 处理 svg - var handleSvg = () => { - var src = this.data.substring(j, this.i + 1); - if (!node.attrs.xmlns) src = ' xmlns="http://www.w3.org/2000/svg"' + src; - var i = j; - while (this.data[j] != '<') j--; - src = this.data.substring(j, i).replace("viewbox", "viewBox") + src; - var parent = this.parent(); - if (node.attrs.width == '100%' && parent && (parent.attrs.style || '').includes('inline')) - parent.attrs.style = 'width:300px;max-width:100%;' + parent.attrs.style; - this.siblings().push({ - name: 'img', - attrs: { - src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'), - style: (/vertical[^;]+/.exec(node.attrs.style) || []).shift(), - ignore: 'T' - } - }) - } - if (node.name == 'svg' && this.data[j] == '/') return handleSvg(this.i++); - while (1) { - if ((this.i = this.data.indexOf('', this.i)) == -1) this.i = this.data.length; - if (name == 'svg') handleSvg(); - return; - } - } -} -// 节点出栈处理 -MpHtmlParser.prototype.popNode = function(node) { - // 空白符处理 - if (node.pre) { - node.pre = this.pre = void 0; - for (let i = this.STACK.length; i--;) - if (this.STACK[i].pre) - this.pre = true; - } - var siblings = this.siblings(), - len = siblings.length, - childs = node.children; - if (node.name == 'head' || (cfg.filter && cfg.filter(node, this) == false)) - return siblings.pop(); - var attrs = node.attrs; - // 替换一些标签名 - if (cfg.blockTags[node.name]) node.name = 'div'; - else if (!cfg.trustTags[node.name]) node.name = 'span'; - // 去除块标签前后空串 - if (node.name == 'div' || node.name == 'p' || node.name[0] == 't') { - if (len > 1 && siblings[len - 2].text == ' ') - siblings.splice(--len - 1, 1); - if (childs.length && childs[childs.length - 1].text == ' ') - childs.pop(); - } - // 处理列表 - if (node.c && (node.name == 'ul' || node.name == 'ol')) { - if ((node.attrs.style || '').includes('list-style:none')) { - for (let i = 0, child; child = childs[i++];) - if (child.name == 'li') - child.name = 'div'; - } else if (node.name == 'ul') { - var floor = 1; - for (let i = this.STACK.length; i--;) - if (this.STACK[i].name == 'ul') floor++; - if (floor != 1) - for (let i = childs.length; i--;) - childs[i].floor = floor; - } else { - for (let i = 0, num = 1, child; child = childs[i++];) - if (child.name == 'li') { - child.type = 'ol'; - child.num = ((num, type) => { - if (type == 'a') return String.fromCharCode(97 + (num - 1) % 26); - if (type == 'A') return String.fromCharCode(65 + (num - 1) % 26); - if (type == 'i' || type == 'I') { - num = (num - 1) % 99 + 1; - var one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], - ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], - res = (ten[Math.floor(num / 10) - 1] || '') + (one[num % 10 - 1] || ''); - if (type == 'i') return res.toLowerCase(); - return res; - } - return num; - })(num++, attrs.type) + '.'; - } - } - } - // 处理表格的边框 - if (node.name == 'table') { - var padding = attrs.cellpadding, - spacing = attrs.cellspacing, - border = attrs.border; - if (node.c) { - this.bubble(); - attrs.style = (attrs.style || '') + ';display:table'; - if (!padding) padding = 2; - if (!spacing) spacing = 2; - } - if (border) attrs.style = `border:${border}px solid gray;${attrs.style || ''}`; - if (spacing) attrs.style = `border-spacing:${spacing}px;${attrs.style || ''}`; - if (border || padding || node.c) - (function f(ns) { - for (var i = 0, n; n = ns[i]; i++) { - if (n.type == 'text') continue; - var style = n.attrs.style || ''; - if (node.c && n.name[0] == 't') { - n.c = 1; - style += ';display:table-' + (n.name == 'th' || n.name == 'td' ? 'cell' : (n.name == 'tr' ? 'row' : 'row-group')); - } - if (n.name == 'th' || n.name == 'td') { - if (border) style = `border:${border}px solid gray;${style}`; - if (padding) style = `padding:${padding}px;${style}`; - } else f(n.children || []); - if (style) n.attrs.style = style; - } - })(childs) - if (this.options.autoscroll) { - var table = Object.assign({}, node); - node.name = 'div'; - node.attrs = { - style: 'overflow:scroll' - } - node.children = [table]; - } - } - this.CssHandler.pop && this.CssHandler.pop(node); - // 自动压缩 - if (node.name == 'div' && !Object.keys(attrs).length && childs.length == 1 && childs[0].name == 'div') - siblings[len - 1] = childs[0]; -} -// 状态机 -MpHtmlParser.prototype.Text = function(c) { - if (c == '<') { - var next = this.data[this.i + 1], - isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - if (isLetter(next)) { - this.setText(); - this.start = this.i + 1; - this.state = this.TagName; - } else if (next == '/') { - this.setText(); - if (isLetter(this.data[++this.i + 1])) { - this.start = this.i + 1; - this.state = this.EndTag; - } else this.Comment(); - } else if (next == '!' || next == '?') { - this.setText(); - this.Comment(); - } - } -} -MpHtmlParser.prototype.Comment = function() { - var key; - if (this.data.substring(this.i + 2, this.i + 4) == '--') key = '-->'; - else if (this.data.substring(this.i + 2, this.i + 9) == '[CDATA[') key = ']]>'; - else key = '>'; - if ((this.i = this.data.indexOf(key, this.i + 2)) == -1) this.i = this.data.length; - else this.i += key.length - 1; - this.start = this.i + 1; - this.state = this.Text; -} -MpHtmlParser.prototype.TagName = function(c) { - if (blankChar[c]) { - this.tagName = this.section(); - while (blankChar[this.data[this.i]]) this.i++; - if (this.isClose()) this.setNode(); - else { - this.start = this.i; - this.state = this.AttrName; - } - } else if (this.isClose()) { - this.tagName = this.section(); - this.setNode(); - } -} -MpHtmlParser.prototype.AttrName = function(c) { - if (c == '=' || blankChar[c] || this.isClose()) { - this.attrName = this.section(); - if (blankChar[c]) - while (blankChar[this.data[++this.i]]); - if (this.data[this.i] == '=') { - while (blankChar[this.data[++this.i]]); - this.start = this.i--; - this.state = this.AttrValue; - } else this.setAttr(); - } -} -MpHtmlParser.prototype.AttrValue = function(c) { - if (c == '"' || c == "'") { - this.start++; - if ((this.i = this.data.indexOf(c, this.i + 1)) == -1) return this.i = this.data.length; - this.attrVal = this.section(); - this.i++; - } else { - for (; !blankChar[this.data[this.i]] && !this.isClose(); this.i++); - this.attrVal = this.section(); - } - this.setAttr(); -} -MpHtmlParser.prototype.EndTag = function(c) { - if (blankChar[c] || c == '>' || c == '/') { - var name = this.section().toLowerCase(); - for (var i = this.STACK.length; i--;) - if (this.STACK[i].name == name) break; - if (i != -1) { - var node; - while ((node = this.STACK.pop()).name != name) this.popNode(node); - this.popNode(node); - } else if (name == 'p' || name == 'br') - this.siblings().push({ - name, - attrs: {} - }); - this.i = this.data.indexOf('>', this.i); - this.start = this.i + 1; - if (this.i == -1) this.i = this.data.length; - else this.state = this.Text; - } -} -module.exports = MpHtmlParser; diff --git a/yudao-ui-app-v1/components/jyf-parser/libs/config.js b/yudao-ui-app-v1/components/jyf-parser/libs/config.js deleted file mode 100644 index 1cfc111b..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/libs/config.js +++ /dev/null @@ -1,93 +0,0 @@ -/* 配置文件 */ -// #ifdef MP-WEIXIN -const canIUse = wx.canIUse('editor'); // 高基础库标识,用于兼容 -// #endif -module.exports = { - // 出错占位图 - errorImg: null, - // 过滤器函数 - filter: null, - // 代码高亮函数 - highlight: null, - // 文本处理函数 - onText: null, - // 实体编码列表 - entities: { - quot: '"', - apos: "'", - semi: ';', - nbsp: '\xA0', - ensp: '\u2002', - emsp: '\u2003', - ndash: '–', - mdash: '—', - middot: '·', - lsquo: '‘', - rsquo: '’', - ldquo: '“', - rdquo: '”', - bull: '•', - hellip: '…' - }, - blankChar: makeMap(' ,\xA0,\t,\r,\n,\f'), - boolAttrs: makeMap('allowfullscreen,autoplay,autostart,controls,ignore,loop,muted'), - // 块级标签,将被转为 div - blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,section' + ( - // #ifdef MP-WEIXIN - canIUse ? '' : - // #endif - ',pre')), - // 将被移除的标签 - ignoreTags: makeMap( - 'area,base,canvas,frame,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr' - // #ifdef MP-WEIXIN - + (canIUse ? ',rp' : '') - // #endif - // #ifndef APP-PLUS - + ',iframe' - // #endif - ), - // 只能被 rich-text 显示的标签 - richOnlyTags: makeMap('a,colgroup,fieldset,legend,table' - // #ifdef MP-WEIXIN - + (canIUse ? ',bdi,bdo,caption,rt,ruby' : '') - // #endif - ), - // 自闭合的标签 - selfClosingTags: makeMap( - 'area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr' - ), - // 信任的标签 - trustTags: makeMap( - 'a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video' - // #ifdef MP-WEIXIN - + (canIUse ? ',bdi,bdo,caption,pre,rt,ruby' : '') - // #endif - // #ifdef APP-PLUS - + ',embed,iframe' - // #endif - ), - // 默认的标签样式 - userAgentStyles: { - address: 'font-style:italic', - big: 'display:inline;font-size:1.2em', - blockquote: 'background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px', - caption: 'display:table-caption;text-align:center', - center: 'text-align:center', - cite: 'font-style:italic', - dd: 'margin-left:40px', - mark: 'background-color:yellow', - pre: 'font-family:monospace;white-space:pre;overflow:scroll', - s: 'text-decoration:line-through', - small: 'display:inline;font-size:0.8em', - u: 'text-decoration:underline' - } -} - -function makeMap(str) { - var map = Object.create(null), - list = str.split(','); - for (var i = list.length; i--;) - map[list[i]] = true; - return map; -} diff --git a/yudao-ui-app-v1/components/jyf-parser/libs/handler.wxs b/yudao-ui-app-v1/components/jyf-parser/libs/handler.wxs deleted file mode 100644 index d3b1aaab..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/libs/handler.wxs +++ /dev/null @@ -1,22 +0,0 @@ -var inline = { - abbr: 1, - b: 1, - big: 1, - code: 1, - del: 1, - em: 1, - i: 1, - ins: 1, - label: 1, - q: 1, - small: 1, - span: 1, - strong: 1, - sub: 1, - sup: 1 -} -module.exports = { - use: function(item) { - return !item.c && !inline[item.name] && (item.attrs.style || '').indexOf('display:inline') == -1 - } -} diff --git a/yudao-ui-app-v1/components/jyf-parser/libs/trees.vue b/yudao-ui-app-v1/components/jyf-parser/libs/trees.vue deleted file mode 100644 index 8232aac1..00000000 --- a/yudao-ui-app-v1/components/jyf-parser/libs/trees.vue +++ /dev/null @@ -1,500 +0,0 @@ -