From b93ce4d1b2031f44dca4bdb82d4cb5aab9ee6ea8 Mon Sep 17 00:00:00 2001 From: cks Date: Fri, 7 Jan 2022 16:46:51 +0800 Subject: [PATCH 01/48] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=AE=A1=E7=90=86admin-ui=20=E7=94=A8=E6=88=B7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/src/views/system/user/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-admin-ui/src/views/system/user/index.vue b/yudao-admin-ui/src/views/system/user/index.vue index a9d418a7f..c164fffbd 100644 --- a/yudao-admin-ui/src/views/system/user/index.vue +++ b/yudao-admin-ui/src/views/system/user/index.vue @@ -72,7 +72,7 @@ + + + @@ -56,6 +63,9 @@ + + + @@ -65,11 +75,13 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import {getForm} from "@/api/bpm/form"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' +import taskAssignRuleDialog from "../taskAssignRule/taskAssignRuleDialog"; export default { name: "processDefinition", components: { - Parser + Parser, + taskAssignRuleDialog }, data() { return { @@ -141,6 +153,10 @@ export default { this.showBpmnOpen = true }) }, + /** 处理任务分配规则列表的按钮操作 */ + handleAssignRule(row) { + this.$refs['taskAssignRuleDialog'].initProcessDefinition(row.id); + }, } }; diff --git a/yudao-admin-ui/src/views/bpm/task/done.vue b/yudao-admin-ui/src/views/bpm/task/done.vue index 9d63a2f7e..c738d2211 100644 --- a/yudao-admin-ui/src/views/bpm/task/done.vue +++ b/yudao-admin-ui/src/views/bpm/task/done.vue @@ -87,7 +87,7 @@ export default { showSearch: true, // 总条数 total: 0, - // 待办任务列表 + // 已办任务列表 list: [], // 查询参数 dateRangeCreateTime: [], diff --git a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue index 654a2390e..093508599 100644 --- a/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue +++ b/yudao-admin-ui/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue @@ -10,14 +10,14 @@ {{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }} - + - + - + @@ -134,16 +137,19 @@ export default { }, /** 流程表单的详情按钮操作 */ handleFormDetail(row) { - getForm(row.formId).then(response => { + // 流程表单 + if (row.formId) { // 设置值 - const data = response.data this.detailForm = { - ...JSON.parse(data.conf), - fields: decodeFields(data.fields) + ...JSON.parse(row.formConf), + fields: decodeFields(row.formFields) } // 弹窗打开 this.detailOpen = true - }) + // 业务表单 + } else if (row.formCustomCreatePath) { + this.$router.push({ path: row.formCustomCreatePath}); + } }, /** 流程图的详情按钮操作 */ handleBpmnDetail(row) { diff --git a/yudao-admin-ui/src/views/bpm/model/index.vue b/yudao-admin-ui/src/views/bpm/model/index.vue index 96b4a3a3e..d290395c7 100644 --- a/yudao-admin-ui/src/views/bpm/model/index.vue +++ b/yudao-admin-ui/src/views/bpm/model/index.vue @@ -50,11 +50,14 @@ {{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }} - + @@ -450,16 +453,22 @@ export default { }, /** 流程表单的详情按钮操作 */ handleFormDetail(row) { - getForm(row.formId).then(response => { - // 设置值 - const data = response.data - this.detailForm = { - ...JSON.parse(data.conf), - fields: decodeFields(data.fields) - } - // 弹窗打开 - this.detailOpen = true - }) + // 流程表单 + if (row.formId) { + getForm(row.formId).then(response => { + // 设置值 + const data = response.data + this.detailForm = { + ...JSON.parse(data.conf), + fields: decodeFields(data.fields) + } + // 弹窗打开 + this.detailOpen = true + }) + // 业务表单 + } else if (row.formCustomCreatePath) { + this.$router.push({ path: row.formCustomCreatePath}); + } }, /** 流程图的详情按钮操作 */ handleBpmnDetail(row) { From 94c115a142e2a9e7fcc3c33dc8f09ccd9d3585d2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 02:55:25 +0800 Subject: [PATCH 09/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=20activiti=20=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=AE=80=E5=8D=95=20Mapper=20XML=20?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=8C=E4=B8=94=E5=87=8F=E5=B0=91?= =?UTF-8?q?=20Mapper=20=E7=9A=84=20SQL=20=E6=97=A5=E5=BF=97=E7=9A=84?= =?UTF-8?q?=E8=BE=93=E5=87=BA~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-local.yaml | 13 +++++ .../src/main/resources/application.yaml | 19 +------ .../mybatis-config/mybatis-config.xml | 53 ------------------- .../config/YudaoActivitiConfiguration.java | 10 ---- 4 files changed, 15 insertions(+), 80 deletions(-) delete mode 100644 yudao-admin-server/src/main/resources/mybatis-config/mybatis-config.xml diff --git a/yudao-admin-server/src/main/resources/application-local.yaml b/yudao-admin-server/src/main/resources/application-local.yaml index 5fc3e9eca..adc2755a0 100644 --- a/yudao-admin-server/src/main/resources/application-local.yaml +++ b/yudao-admin-server/src/main/resources/application-local.yaml @@ -148,6 +148,18 @@ spring: logging: file: name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + level: + # 配置自己写的 MyBatis Mapper 打印日志 + cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql: debug + cn.iocoder.yudao.adminserver.modules.infra.dal.mysql: debug + cn.iocoder.yudao.adminserver.modules.pay.dal.mysql: debug + cn.iocoder.yudao.adminserver.modules.system.dal.mysql: debug + cn.iocoder.yudao.adminserver.modules.tool.dal.mysql: debug + cn.iocoder.yudao.coreservice.modules.bpm.dal.mysql: debug + cn.iocoder.yudao.coreservice.modules.infra.dal.mysql: debug + cn.iocoder.yudao.coreservice.modules.pay.dal.mysql: debug + cn.iocoder.yudao.coreservice.modules.system.dal.mysql: debug + cn.iocoder.yudao.coreservice.modules.tool.dal.mysql: debug --- #################### 芋道相关配置 #################### @@ -194,3 +206,4 @@ justauth: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 + diff --git a/yudao-admin-server/src/main/resources/application.yaml b/yudao-admin-server/src/main/resources/application.yaml index fdb435e87..bc6abf5f1 100644 --- a/yudao-admin-server/src/main/resources/application.yaml +++ b/yudao-admin-server/src/main/resources/application.yaml @@ -35,28 +35,13 @@ spring: # MyBatis Plus 的配置项 mybatis-plus: -# 在 mybatis-config/mybatis-config.xml 中设置 TODO jason:看看有没其它解决方案 -# configuration: -# map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 -# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 global-config: db-config: id-type: AUTO # 自增 ID logic-delete-value: 1 # 逻辑已删除值(默认为 1) logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapper-locations: classpath*:mapper/*.xml - config-location: classpath:mybatis-config/mybatis-config.xml - configuration-properties: - prefix: "" - wildcardEscapeClause: "" - limitBefore: "" - limitAfter: "LIMIT #{maxResults} OFFSET #{firstResult}" - limitBetween: "" - limitOuterJoinBetween: "" - limitBeforeNativeQuery: "" - orderBy: "order by ${orderByColumns}" - blobType: "BLOB" - boolValue: "TRUE" type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject, ${yudao.core-service.base-package}.modules.*.dal.dataobject --- #################### 芋道相关配置 #################### diff --git a/yudao-admin-server/src/main/resources/mybatis-config/mybatis-config.xml b/yudao-admin-server/src/main/resources/mybatis-config/mybatis-config.xml deleted file mode 100644 index d459d9670..000000000 --- a/yudao-admin-server/src/main/resources/mybatis-config/mybatis-config.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java index f65c2a23c..0fbb6c636 100644 --- a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/config/YudaoActivitiConfiguration.java @@ -4,8 +4,6 @@ import cn.iocoder.yudao.framework.activiti.core.web.ActivitiWebFilter; import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; import org.activiti.image.ProcessDiagramGenerator; import org.activiti.image.impl.DefaultProcessDiagramGenerator; -import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; -import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -21,14 +19,6 @@ public class YudaoActivitiConfiguration { return new DefaultProcessDiagramGenerator(); } - /** - * ProcessEngineConfigurationConfigurer 实现类,设置使用 MyBatis SqlSessionFactory - */ - @Bean - public ProcessEngineConfigurationConfigurer processEngineConfigurationConfigurer(SqlSessionFactory sqlSessionFactory) { - return springProcessEngineConfiguration -> springProcessEngineConfiguration.setSqlSessionFactory(sqlSessionFactory); - } - @Bean public FilterRegistrationBean activitiWebFilter() { FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); From 0b4a4793d9b5cd24ae0c51298f7871dea62ce2eb Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 02:59:52 +0800 Subject: [PATCH 10/48] =?UTF-8?q?=E7=A6=81=E7=94=A8=20bpm=20=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=20/processes=20=E7=9B=AE=E5=BD=95=EF=BC=8C=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=20BPMN=20=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-server/src/main/resources/application.yaml | 8 +++----- .../processes/{oa-leave.bpmn_bak => oa-leave.bpmn} | 0 2 files changed, 3 insertions(+), 5 deletions(-) rename yudao-admin-server/src/main/resources/processes/{oa-leave.bpmn_bak => oa-leave.bpmn} (100%) diff --git a/yudao-admin-server/src/main/resources/application.yaml b/yudao-admin-server/src/main/resources/application.yaml index bc6abf5f1..9f3e76f6d 100644 --- a/yudao-admin-server/src/main/resources/application.yaml +++ b/yudao-admin-server/src/main/resources/application.yaml @@ -27,11 +27,9 @@ spring: # 3. create_drop: 启动时自动创建表,关闭时自动删除表 # 4. drop_create: 启动时,删除旧表,再创建新表 database-schema-update: false # 设置为 false,可通过 sql/activiti.sql 初始化 - # activiti7 默认不生成历史信息表,需手动设置开启 - db-history-used: true - check-process-definitions: true - # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数 - history-level: full + db-history-used: true # activiti7 默认不生成历史信息表,需手动设置开启 + check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程 + history-level: full # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数 # MyBatis Plus 的配置项 mybatis-plus: diff --git a/yudao-admin-server/src/main/resources/processes/oa-leave.bpmn_bak b/yudao-admin-server/src/main/resources/processes/oa-leave.bpmn similarity index 100% rename from yudao-admin-server/src/main/resources/processes/oa-leave.bpmn_bak rename to yudao-admin-server/src/main/resources/processes/oa-leave.bpmn From f9b6eef4d2bbc67dbca4e98bf8cbd23ad485858b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 11:42:25 +0800 Subject: [PATCH 11/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9A=84=20bpm=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=20todo=E3=80=81done=20=E7=9A=84=20v?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/task/BpmTaskController.java | 11 +++----- .../vo/task/BpmTaskDonePageItemRespVO.java | 6 ----- .../{TaskHandleVO.java => BpmTaskRespVO.java} | 10 +++---- .../task/vo/task/TaskQueryReqVO.java | 15 ----------- .../controller/task/vo/task/TaskStepVO.java | 24 ----------------- .../bpm/service/task/BpmTaskService.java | 26 +++++++------------ .../service/task/impl/BpmTaskServiceImpl.java | 26 +++++++++++-------- 7 files changed, 32 insertions(+), 86 deletions(-) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/{TaskHandleVO.java => BpmTaskRespVO.java} (51%) delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java index 92b9248c8..f7e309c29 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java @@ -56,16 +56,13 @@ public class BpmTaskController { return success(true); } - @PostMapping("/task-steps") - public CommonResult getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) { + @GetMapping("/list-by-process-instance-id") + @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") + public CommonResult> getTaskListByProcessInstanceId( + @RequestParam("processInstanceId") String processInstanceId) { return success(taskService.getTaskSteps(taskQuery)); } - @GetMapping("/process/history-steps") - public CommonResult> getHistorySteps(@RequestParam("id") String processInstanceId) { - return success(taskService.getHistorySteps(processInstanceId)); - } - /** * 返回高亮的流转图SVG * @param processInstanceId 流程Id diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java index 9779992fe..799c8ae30 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java @@ -57,10 +57,4 @@ public class BpmTaskDonePageItemRespVO { } - - // 任务编号、流程名称、任务节点、流程发起人、接收时间、审批时间、耗时【名称、开始时间】「流程记录、撤回」 - // 任务编号、任务名称、所属流程、委托代办人、流程发起人、优先级、审批操作、审批意见、耗时、创建时间【名称、开始时间】「申请详情」 - - // 任务编号、任务名称、流程名称、流程发起人、接收时间、审批时间、耗时【名称、接收时间】「详情」TODO 撤回 - } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java similarity index 51% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java index 2f28f4961..d52d6dd00 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java @@ -1,19 +1,15 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; +import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.ToString; import java.util.List; +@ApiModel("流程任务的 Response VO") @Data -@ToString -public class TaskHandleVO { - - private Object formObject; +public class BpmTaskRespVO extends Page{ - private List historyTask; - - private String taskVariable; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java deleted file mode 100644 index 97135bb66..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; - -import lombok.Data; -import lombok.ToString; - -@Data -@ToString -public class TaskQueryReqVO { - - private String processKey; - - private String taskId; - - private String businessKey; -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java deleted file mode 100644 index ad148a85d..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; - -import lombok.Data; -import lombok.ToString; - -import java.util.Date; - -@Data -@ToString -public class TaskStepVO { - - private String stepName; - - private Date startTime; - - private Date endTime; - - private String assignee; - - private String comment; - - private Integer status; - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java index ea53a0900..b46bf065a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java @@ -18,12 +18,20 @@ import java.util.Map; public interface BpmTaskService { /** - * 获得流程任务列表 + * 获得指定流程实例的 Running 进行中的流程任务列表 * * @param processInstanceId 流程实例的编号 * @return 流程任务列表 */ - List getTasksByProcessInstanceId(String processInstanceId); + List getRunningTaskListByProcessInstanceId(String processInstanceId); + + /** + * 获得指令流程实例的流程任务列表,包括所有状态的 + * + * @param processInstanceId 流程实例的编号 + * @return 流程任务列表 + */ + List getTaskListByProcessInstanceId(String processInstanceId); /** * 获得流程任务列表 @@ -84,20 +92,6 @@ public interface BpmTaskService { */ void rejectTask(@Valid BpmTaskRejectReqVO reqVO); - /** - * 根据任务id, 查询已经完成的用户任务,未完成的用户任务 - * @param taskQuery 查询参数 一般 taskId - */ - @Deprecated - TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery); - - /** - * 根据流程实例id, 查询历史用户任务,包括已完成,未完成 - * @param processInstanceId 流程实例id - */ - @Deprecated - List getHistorySteps(String processInstanceId); - /** * 返回高亮的流转进程 * @param processInstanceId 实例Id diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index 1b7715902..9b638d4d8 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -82,10 +82,24 @@ public class BpmTaskServiceImpl implements BpmTaskService { private BpmTaskExtMapper taskExtMapper; @Override - public List getTasksByProcessInstanceId(String processInstanceId) { + public List getRunningTaskListByProcessInstanceId(String processInstanceId) { return taskService.createTaskQuery().processInstanceId(processInstanceId).list(); } + @Override + public List getTaskListByProcessInstanceId(String processInstanceId) { + // 获得任务列表 + List tasks = historyService.createHistoricTaskInstanceQuery() + .processInstanceId(processInstanceId) + .orderByTaskCreateTime().list(); + if (CollUtil.isEmpty(tasks)) { + return Collections.emptyList(); + } + + // 拼接数据 + return null; + } + @Override public List getTasksByProcessInstanceIds(List processInstanceIds) { if (CollUtil.isEmpty(processInstanceIds)) { @@ -218,16 +232,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { // taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment()); } - @Override - public TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery) { -// TaskHandleVO handleVO = new TaskHandleVO(); -// final Task task = taskRuntime.task(taskQuery.getTaskId()); -// List steps = getTaskSteps(task.getProcessInstanceId()); -// handleVO.setHistoryTask(steps); -// return handleVO; - return null; - } - private List getTaskSteps(String processInstanceId) { // 获得已完成的活动 List finished = historyService.createHistoricActivityInstanceQuery() From a4d31f9c453bbaa7e2f7c9d653e3b454be22e84a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 13:27:09 +0800 Subject: [PATCH 12/48] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20bpm=20=E5=9F=BA?= =?UTF-8?q?=E4=BA=8E=E6=B5=81=E7=A8=8B=E5=AE=9E=E4=BE=8B=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/task/BpmTaskController.http | 5 ++ .../controller/task/BpmTaskController.java | 4 +- .../vo/task/BpmTaskDonePageItemRespVO.java | 43 ++---------- .../task/vo/task/BpmTaskRespVO.java | 25 ++++++- .../bpm/convert/task/BpmTaskConvert.java | 56 ++++++++++++---- .../service/task/impl/BpmTaskServiceImpl.java | 66 ++++++------------- .../common/util/number/NumberUtils.java | 16 +++++ 7 files changed, 115 insertions(+), 100 deletions(-) create mode 100644 yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/NumberUtils.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http index d974a83f1..ee4bf0c28 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http @@ -7,3 +7,8 @@ Authorization: Bearer {{token}} 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java index f7e309c29..ba60bfda6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java @@ -57,10 +57,10 @@ public class BpmTaskController { } @GetMapping("/list-by-process-instance-id") - @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") + @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") // TODO 芋艿:注解 public CommonResult> getTaskListByProcessInstanceId( @RequestParam("processInstanceId") String processInstanceId) { - return success(taskService.getTaskSteps(taskQuery)); + return success(taskService.getTaskListByProcessInstanceId(processInstanceId)); } /** diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java index 799c8ae30..b932c4e07 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java @@ -3,24 +3,17 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.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 -public class BpmTaskDonePageItemRespVO { +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BpmTaskDonePageItemRespVO extends 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) private Date endTime; @ApiModelProperty(value = "持续时间", required = true, example = "1000") @@ -31,30 +24,4 @@ public class BpmTaskDonePageItemRespVO { @ApiModelProperty(value = "审批建议", required = true, example = "不请假了!") private String comment; - /** - * 所属流程实例 - */ - 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java index d52d6dd00..61b3c65e0 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskRespVO.java @@ -1,15 +1,38 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.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.List; @ApiModel("流程任务的 Response VO") @Data -public class BpmTaskRespVO extends Page{ +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO { + /** + * 审核的用户信息 + */ + 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java index abaf25360..db91d544f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java @@ -1,21 +1,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.task; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskDonePageItemRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStepVO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import org.activiti.engine.history.HistoricActivityInstance; +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.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Mappings; -import org.mapstruct.Named; +import org.mapstruct.*; import org.mapstruct.factory.Mappers; import java.util.List; @@ -31,12 +29,6 @@ public interface BpmTaskConvert { BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - @Mappings(value = { - @Mapping(source = "activityName", target = "stepName"), - @Mapping(source = "assignee", target = "assignee") - }) - TaskStepVO convert(HistoricActivityInstance instance); - default List convertList(List tasks, Map processInstanceMap, Map userMap) { return CollectionUtils.convertList(tasks, task -> { @@ -89,9 +81,9 @@ public interface BpmTaskConvert { @Mapping(source = "processInstance.name", target = "processInstance.name"), @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), - @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") + @Mapping(source = "startUser.nickname", target = "processInstance.startUserNickname") }) - BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO user); + BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO startUser); @Mappings({ @Mapping(source = "id", target = "taskId"), @@ -100,4 +92,40 @@ public interface BpmTaskConvert { }) 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()); + copyTo3(taskExtDO, respVO); + if (processInstance != null) { + SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); + respVO.setProcessInstance(convert(processInstance, startUser)); + } + SysUserDO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee())); + if (assignUser != null) { + respVO.setAssigneeUser(convert3(assignUser)); + SysDeptDO dept = deptMap.get(assignUser.getDeptId()); + if (dept != null) { + respVO.getAssigneeUser().setDeptName(dept.getName()); + } + } + return respVO; + }); + } + + BpmTaskRespVO convert3(HistoricTaskInstance bean); + BpmTaskRespVO.User convert3(SysUserDO bean); + void copyTo3(BpmTaskExtDO from, @MappingTarget BpmTaskRespVO 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, SysUserDO startUser); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index 9b638d4d8..d059834b2 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert; @@ -10,10 +11,13 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmTaskExtMapper; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.common.util.object.PageUtils; import lombok.extern.slf4j.Slf4j; import org.activiti.bpmn.constants.BpmnXMLConstants; @@ -44,6 +48,7 @@ import javax.validation.Valid; import java.io.IOException; import java.io.InputStream; import java.util.*; +import java.util.function.Function; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -75,6 +80,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Resource private SysUserService userService; @Resource + private SysDeptService deptService; + @Resource @Lazy // 解决循环依赖 private BpmProcessInstanceService processInstanceService; @@ -91,13 +98,25 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 获得任务列表 List tasks = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId) - .orderByTaskCreateTime().list(); + .orderByTaskCreateTime().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 = userService.getUserMap(userIds); + // 获得 Dept Map + Map deptMap = deptService.getDeptMap(convertSet(userMap.values(), SysUserDO::getDeptId)); + // 拼接数据 - return null; + return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap); } @Override @@ -113,7 +132,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { // 查询待办任务 TaskQuery taskQuery = taskService.createTaskQuery() .taskAssignee(String.valueOf(userId)) // 分配给自己 - .taskCandidateUser(String.valueOf(userId)) .orderByTaskCreateTime().desc(); // 创建时间倒序 if (StrUtil.isNotBlank(pageVO.getName())) { taskQuery.taskNameLike("%" + pageVO.getName() + "%"); @@ -232,48 +250,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { // taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment()); } - private List getTaskSteps(String processInstanceId) { - // 获得已完成的活动 - List finished = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .activityType("userTask") - .finished() - .orderByHistoricActivityInstanceStartTime().asc().list(); - // 获得对应的步骤 - List steps = new ArrayList<>(); - finished.forEach(instance -> { - TaskStepVO stepVO = BpmTaskConvert.INSTANCE.convert(instance); - stepVO.setStatus(1); // TODO @jason:1 这个 magic number 要枚举起来。 - // TODO @jason:可以考虑把 comments 读取后,在统一调用 convert 拼接。另外 Comment 是废弃的类,有没其它可以使用的哈? - List comments = taskService.getTaskComments(instance.getTaskId()); - if (!CollUtil.isEmpty(comments)) { - stepVO.setComment(Optional.ofNullable(comments.get(0)).map(Comment::getFullMessage).orElse("")); - } - steps.add(stepVO); - }); - - // 获得未完成的活动 - List unfinished = historyService - .createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .activityType("userTask") - .unfinished().list(); - // 获得对应的步骤 - for (HistoricActivityInstance instance : unfinished) { - TaskStepVO stepVO = BpmTaskConvert.INSTANCE.convert(instance); - stepVO.setComment(""); - stepVO.setStatus(0); - steps.add(stepVO); - } - return steps; - } - - - @Override - public List getHistorySteps(String processInstanceId) { - return getTaskSteps(processInstanceId); - } - @Override public FileResp getHighlightImg(String processInstanceId) { // 查询历史 diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/NumberUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/NumberUtils.java new file mode 100644 index 000000000..822510096 --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/NumberUtils.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.framework.common.util.number; + +import cn.hutool.core.util.StrUtil; + +/** + * 数字的工具类,补全 {@link cn.hutool.core.util.NumberUtil} 的功能 + * + * @author 芋道源码 + */ +public class NumberUtils { + + public static Long parseLong(String str) { + return StrUtil.isNotEmpty(str) ? Long.valueOf(str) : null; + } + +} From 23eda6b1a90e7688bc804953103b4e2020ec5198 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 13:47:23 +0800 Subject: [PATCH 13/48] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20bpm=20=E5=9F=BA?= =?UTF-8?q?=E4=BA=8E=E6=B5=81=E7=A8=8B=E5=AE=9E=E4=BE=8B=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/convert/task/BpmTaskConvert.java | 66 +++++++++---------- .../service/task/impl/BpmTaskServiceImpl.java | 5 +- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java index db91d544f..d3c77f59a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java @@ -29,27 +29,21 @@ public interface BpmTaskConvert { BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - default List convertList(List tasks, Map processInstanceMap, - Map userMap) { + default List convertList1(List tasks, Map processInstanceMap, + Map userMap) { return CollectionUtils.convertList(tasks, task -> { + BpmTaskTodoPageItemRespVO respVO = convert1(task); ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId()); - return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId()))); + if (processInstance != null) { + SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); + respVO.setProcessInstance(convert(processInstance, startUser)); + } + return respVO; }); } - @Mappings({ - @Mapping(source = "task.id", target = "id"), - @Mapping(source = "task.name", target = "name"), - @Mapping(source = "task.claimTime", target = "claimTime"), - @Mapping(source = "task.createTime", target = "createTime"), - @Mapping(source = "task.suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState"), - @Mapping(source = "processInstance.id", target = "processInstance.id"), - @Mapping(source = "processInstance.name", target = "processInstance.name"), - @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), - @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") - }) - BpmTaskTodoPageItemRespVO convert(Task task, ProcessInstance processInstance, SysUserDO user); + @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState") + BpmTaskTodoPageItemRespVO convert1(Task bean); @Named("convertSuspendedToSuspensionState") default Integer convertSuspendedToSuspensionState(boolean suspended) { @@ -61,29 +55,19 @@ public interface BpmTaskConvert { 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()); - SysUserDO userDO = userMap.get(Long.valueOf(processInstance.getStartUserId())); - return convert(task, taskExtDO, processInstance, userDO); + if (processInstance != null) { + SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); + respVO.setProcessInstance(convert(processInstance, startUser)); + } + return respVO; }); } - @Mappings({ - @Mapping(source = "task.id", target = "id"), - @Mapping(source = "task.name", target = "name"), - @Mapping(source = "task.claimTime", target = "claimTime"), - @Mapping(source = "task.createTime", target = "createTime"), - @Mapping(source = "task.endTime", target = "endTime"), - @Mapping(source = "task.durationInMillis", target = "durationInMillis"), - @Mapping(source = "taskExtDO.result", target = "result"), - @Mapping(source = "taskExtDO.comment", target = "comment"), - @Mapping(source = "processInstance.id", target = "processInstance.id"), - @Mapping(source = "processInstance.name", target = "processInstance.name"), - @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), - @Mapping(source = "startUser.nickname", target = "processInstance.startUserNickname") - }) - BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO startUser); + BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean); @Mappings({ @Mapping(source = "id", target = "taskId"), @@ -98,7 +82,7 @@ public interface BpmTaskConvert { return CollectionUtils.convertList(tasks, task -> { BpmTaskRespVO respVO = convert3(task); BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); - copyTo3(taskExtDO, respVO); + copyTo(taskExtDO, respVO); if (processInstance != null) { SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); respVO.setProcessInstance(convert(processInstance, startUser)); @@ -117,7 +101,17 @@ public interface BpmTaskConvert { BpmTaskRespVO convert3(HistoricTaskInstance bean); BpmTaskRespVO.User convert3(SysUserDO bean); - void copyTo3(BpmTaskExtDO from, @MappingTarget BpmTaskRespVO to); + + 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, SysUserDO startUser); @Mappings({ @Mapping(source = "processInstance.id", target = "id"), diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index d059834b2..b15ef39ce 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert; @@ -34,7 +33,6 @@ import org.activiti.engine.history.HistoricTaskInstance; import org.activiti.engine.history.HistoricTaskInstanceQuery; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Comment; import org.activiti.engine.task.Task; import org.activiti.engine.task.TaskQuery; import org.activiti.image.ProcessDiagramGenerator; @@ -48,7 +46,6 @@ import javax.validation.Valid; import java.io.IOException; import java.io.InputStream; import java.util.*; -import java.util.function.Function; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -155,7 +152,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { Map userMap = userService.getUserMap( convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList(tasks, processInstanceMap, userMap), + return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap), taskQuery.count()); } From 93e02b36dd55fc7c8f4f83343eac67b141e25e00 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 17:31:44 +0800 Subject: [PATCH 14/48] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20bpm=20=E5=9F=BA?= =?UTF-8?q?=E4=BA=8E=E6=B5=81=E7=A8=8B=E5=AE=9E=E4=BE=8B=E7=9A=84=E8=AF=A6?= =?UTF-8?q?=E6=83=85=20API=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/BpmProcessInstanceController.http | 4 +- .../task/BpmProcessInstanceController.java | 13 ++- .../controller/task/BpmTaskController.java | 4 +- .../vo/instance/BpmProcessInstanceRespVO.java | 94 +++++++++++++++++++ .../task/BpmProcessInstanceConvert.java | 53 +++++++++-- .../task/BpmProcessInstanceExtDO.java | 8 +- .../BpmProcessDefinitionExtMapper.java | 9 +- .../task/BpmProcessInstanceExtMapper.java | 4 + .../BpmProcessDefinitionService.java | 9 ++ .../impl/BpmProcessDefinitionServiceImpl.java | 12 ++- .../task/BpmProcessInstanceService.java | 13 ++- .../impl/BpmProcessInstanceServiceImpl.java | 47 +++++++++- .../activiti/core/util/ActivitiUtils.java | 17 +++- 13 files changed, 256 insertions(+), 31 deletions(-) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstanceRespVO.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.http b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.http index 4775cbc24..e9243ed66 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.http +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.http @@ -23,7 +23,7 @@ Authorization: Bearer {{token}} "reason": "我就取消" } -### 请求 /bpm/process-instance/my-page 接口 => 成功 -GET {{baseUrl}}/bpm/process-instance/my-page +### 请求 /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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.java index c948a6fef..a389c0dc9 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmProcessInstanceController.java @@ -1,13 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.task; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*; import cn.iocoder.yudao.adminserver.modules.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.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -49,4 +47,11 @@ public class BpmProcessInstanceController { return success(processInstanceService.getMyProcessInstancePage(getLoginUserId(), pageReqVO)); } + @GetMapping("/get") + @ApiOperation(value = "获得指定流程实例", notes = "在【流程详细】界面中,进行调用") + @ApiImplicitParam(name = "id", value = "流程实例的编号", required = true, dataTypeClass = String.class) + public CommonResult getProcessInstance(@RequestParam("id") String id) { + return success(processInstanceService.getProcessInstanceVO(id)); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java index ba60bfda6..56b232ea6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -57,7 +58,8 @@ public class BpmTaskController { } @GetMapping("/list-by-process-instance-id") - @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") // TODO 芋艿:注解 + @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") + @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class) public CommonResult> getTaskListByProcessInstanceId( @RequestParam("processInstanceId") String processInstanceId) { return success(taskService.getTaskListByProcessInstanceId(processInstanceId)); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstanceRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstanceRespVO.java new file mode 100644 index 000000000..6d5ae6876 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstanceRespVO.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.controller.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; + + /** + * 发起流程的用户 + */ + 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java index 95fd9fc60..9f59be342 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java @@ -1,13 +1,20 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.task; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; 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; @@ -26,15 +33,20 @@ 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 = "instance.startUserId", target = "startUserId"), - @Mapping(source = "instance.id", target = "processInstanceId"), - @Mapping(source = "instance.startTime", target = "createTime"), - @Mapping(source = "definition.id", target = "processDefinitionId"), - @Mapping(source = "definition.name", target = "name"), - @Mapping(source = "definition.category", target = "category") + @Mapping(source = "from.id", target = "id", ignore = true), + @Mapping(source = "from.startTime", target = "createTime"), }) - BpmProcessInstanceExtDO convert(ProcessInstance instance, ProcessDefinition definition); + 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) { @@ -58,4 +70,31 @@ public interface BpmProcessInstanceConvert { }) BpmProcessInstanceExtDO convert(org.activiti.api.process.model.ProcessInstance bean); + default BpmProcessInstanceRespVO convert2(HistoricProcessInstance processInstance, BpmProcessInstanceExtDO processInstanceExt, + ProcessDefinition processDefinition, BpmProcessDefinitionExtDO processDefinitionExt, + String bpmnXml, SysUserDO startUser, SysDeptDO 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(SysUserDO bean); + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java index 6f4a2f0a6..861838749 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/task/BpmProcessInstanceExtDO.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceRes import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum; 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.Data; @@ -31,6 +32,11 @@ import java.util.Map; //@AllArgsConstructor public class BpmProcessInstanceExtDO extends BaseDO { + /** + * 编号,自增 + */ + @TableId + private Long id; /** * 发起流程的用户编号 * @@ -82,7 +88,7 @@ public class BpmProcessInstanceExtDO extends BaseDO { private Date endTime; /** - * 表单值 + * 提交的表单值 */ @TableField(typeHandler = JacksonTypeHandler.class) private Map formVariables; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java index 623db9e94..2a347eee4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/definition/BpmProcessDefinitionExtMapper.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -9,10 +10,14 @@ import java.util.Collection; import java.util.List; @Mapper -public interface BpmProcessDefinitionExtMapper extends BaseMapper { +public interface BpmProcessDefinitionExtMapper extends BaseMapperX { default List selectListByProcessDefinitionIds(Collection processDefinitionIds) { - return selectList(new QueryWrapper().in("process_definition_id", processDefinitionIds)); + return selectList("process_definition_id", processDefinitionIds); + } + + default BpmProcessDefinitionExtDO selectByProcessDefinitionId(String processDefinitionId) { + return selectOne("process_definition_id", processDefinitionId); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java index 344921884..0fbb455a6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmProcessInstanceExtMapper.java @@ -23,6 +23,10 @@ public interface BpmProcessInstanceExtMapper extends BaseMapperX() .eq("process_instance_id", updateObj.getProcessInstanceId())); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java index 3194070a4..8579a4239 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/BpmProcessDefinitionService.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageItemRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionPageReqVO; import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.process.BpmProcessDefinitionRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; @@ -74,6 +75,14 @@ public interface BpmProcessDefinitionService { */ ProcessDefinition getProcessDefinition2(String id); + /** + * 获得编号对应的 BpmProcessDefinitionExtDO + * + * @param id 编号 + * @return 流程定义拓展 + */ + BpmProcessDefinitionExtDO getProcessDefinitionExt(String id); + /** * 获得 id 对应的 Deployment * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java index 9b5ec5d36..a43e4589b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/impl/BpmProcessDefinitionServiceImpl.java @@ -13,6 +13,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.definition.BpmProcessD import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto.BpmDefinitionCreateReqDTO; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmFormService; +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.object.PageUtils; @@ -51,8 +52,6 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ private static final String BPMN_FILE_SUFFIX = ".bpmn"; - private static final BpmnXMLConverter BPMN_XML_CONVERTER = new BpmnXMLConverter(); - @Resource private RepositoryService repositoryService; @Resource @@ -122,9 +121,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ if (bpmnModel == null) { return null; } - // TODO 芋艿:重构到 activi util 里 - byte[] bpmnBytes = BPMN_XML_CONVERTER.convertToXML(bpmnModel); - return StrUtil.utf8Str(bpmnBytes); + return ActivitiUtils.getBpmnXml(bpmnModel); } @Override @@ -142,6 +139,11 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult(); } + @Override + public BpmProcessDefinitionExtDO getProcessDefinitionExt(String id) { + return processDefinitionMapper.selectByProcessDefinitionId(id); + } + @Override public Deployment getDeployment(String id) { if (StrUtil.isEmpty(id)) { diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java index 9c47e24e1..63ee8c51c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java @@ -1,9 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -68,6 +65,14 @@ public interface BpmProcessInstanceService { PageResult getMyProcessInstancePage(Long userId, @Valid BpmProcessInstanceMyPageReqVO pageReqVO); + /** + * 获得流程实例 VO 信息 + * + * @param id 流程实例的编号 + * @return 流程实例 + */ + BpmProcessInstanceRespVO getProcessInstanceVO(String id); + /** * 获得流程实例 * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index 8c9e0b919..41d4a28f7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -1,11 +1,12 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmProcessInstanceConvert; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanceExtMapper; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; @@ -14,8 +15,12 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceSta import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import lombok.extern.slf4j.Slf4j; import org.activiti.engine.HistoryService; import org.activiti.engine.RuntimeService; @@ -23,6 +28,7 @@ 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.ap.shaded.freemarker.template.utility.StringUtil; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +66,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService @Resource private SysUserService userService; @Resource + private SysDeptService deptService; + @Resource @Lazy // 解决循环依赖 private BpmTaskService taskService; @Resource @@ -152,6 +160,37 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService 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 + SysUserDO startUser = userService.getUser(NumberUtils.parseLong(processInstance.getStartUserId())); + SysDeptDO dept = null; + if (startUser != null) { + dept = deptService.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(); diff --git a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java index 465094331..f2b508ae2 100644 --- a/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-activiti/src/main/java/cn/iocoder/yudao/framework/activiti/core/util/ActivitiUtils.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.framework.activiti.core.util; import cn.hutool.core.util.ReflectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.ttl.TransmittableThreadLocal; import org.activiti.bpmn.converter.BpmnXMLConverter; import org.activiti.bpmn.model.BpmnModel; @@ -46,7 +47,6 @@ public class ActivitiUtils { // ========== BPMN XML 相关 ========== - /** * 构建对应的 BPMN Model * @@ -59,6 +59,13 @@ public class ActivitiUtils { return converter.convertToBpmnModel(new BytesStreamSource(bpmnBytes), true, true); } + /** + * 获得 BPMN 流程中,指定的元素们 + * + * @param model + * @param clazz 指定元素。例如说,{@link org.activiti.bpmn.model.UserTask}、{@link org.activiti.bpmn.model.Gateway} 等等 + * @return 元素们 + */ public static List getBpmnModelElements(BpmnModel model, Class clazz) { List result = new ArrayList<>(); model.getProcesses().forEach(process -> { @@ -71,4 +78,12 @@ public class ActivitiUtils { return result; } + public static String getBpmnXml(BpmnModel model) { + if (model == null) { + return null; + } + BpmnXMLConverter converter = new BpmnXMLConverter(); + return StrUtil.utf8Str(converter.convertToXML(model)); + } + } From f049bd7530d9f9d9178e49462f9c9754e1a7cfe7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 17:55:29 +0800 Subject: [PATCH 15/48] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/src/api/bpm/processInstance.js | 7 + yudao-admin-ui/src/api/bpm/task.js | 1 + .../src/views/bpm/processInstance/create.vue | 36 ++-- .../src/views/bpm/processInstance/detail.vue | 171 ++++++++++++++++++ .../src/views/bpm/processInstance/index.vue | 2 +- 5 files changed, 197 insertions(+), 20 deletions(-) create mode 100644 yudao-admin-ui/src/views/bpm/processInstance/detail.vue diff --git a/yudao-admin-ui/src/api/bpm/processInstance.js b/yudao-admin-ui/src/api/bpm/processInstance.js index 2340356f8..54feaedea 100644 --- a/yudao-admin-ui/src/api/bpm/processInstance.js +++ b/yudao-admin-ui/src/api/bpm/processInstance.js @@ -26,3 +26,10 @@ export function cancelProcessInstance(id, reason) { } }) } + +export function getMyProcessInstance(id) { + return request({ + url: '/bpm/process-instance/get?id=' + id, + method: 'get', + }) +} diff --git a/yudao-admin-ui/src/api/bpm/task.js b/yudao-admin-ui/src/api/bpm/task.js index 3b4dc305f..8a5704884 100644 --- a/yudao-admin-ui/src/api/bpm/task.js +++ b/yudao-admin-ui/src/api/bpm/task.js @@ -39,3 +39,4 @@ export function rejectTask(data) { data: data }) } + diff --git a/yudao-admin-ui/src/views/bpm/processInstance/create.vue b/yudao-admin-ui/src/views/bpm/processInstance/create.vue index d265bc9ee..1d3c09651 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/create.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/create.vue @@ -32,7 +32,7 @@
- {{ selectProcessInstance.name }} + 申请信息【{{ selectProcessInstance.name }}】 选择其它流程
@@ -58,10 +58,11 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import {getForm} from "@/api/bpm/form"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' -import {createProcessInstance} from "@/api/bpm/processInstance"; +import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance"; +// 流程实例的发起 export default { - name: "processDefinition", + name: "ProcessInstanceCreate", components: { Parser }, @@ -109,28 +110,25 @@ export default { }, /** 处理选择流程的按钮操作 **/ handleSelect(row) { - // 如果无表单,则无法发起流程 - if (!row.formId) { - this.$message.error('该流程未绑定表单,无法发起流程!请重新选择你要发起的流程'); - return; - } // 设置选择的流程 this.selectProcessInstance = row; - // 加载对应的表单 - getForm(row.formId).then(response => { - // 设置值 - const data = response.data + // 流程表单 + if (row.formId) { + // 设置对应的表单 this.detailForm = { - ...JSON.parse(data.conf), - fields: decodeFields(data.fields) + ...JSON.parse(row.formConf), + fields: decodeFields(row.formFields) } - }); - // 加载流程图 - getProcessDefinitionBpmnXML(row.id).then(response => { - this.bpmnXML = response.data - }) + // 加载流程图 + getProcessDefinitionBpmnXML(row.id).then(response => { + this.bpmnXML = response.data + }) + } else if (row.formCustomCreatePath) { + this.$router.push({ path: row.formCustomCreatePath}); + // 这里暂时无需加载流程图,因为跳出到另外个 Tab; + } }, /** 提交按钮 */ submitForm(params) { diff --git a/yudao-admin-ui/src/views/bpm/processInstance/detail.vue b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue new file mode 100644 index 000000000..1365e57c4 --- /dev/null +++ b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/yudao-admin-ui/src/views/bpm/processInstance/index.vue b/yudao-admin-ui/src/views/bpm/processInstance/index.vue index a339ffdb7..851ffec04 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/index.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/index.vue @@ -129,7 +129,7 @@ import { import {deleteErrorCode} from "@/api/system/errorCode"; export default { - name: "ProcessInstanceExt", + name: "ProcessInstance", components: { }, data() { From f0963c3941c34a510933c80759b0154d7d7696fd Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 22:16:49 +0800 Subject: [PATCH 16/48] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=2030%=20-=20=E8=A1=A8=E5=8D=95=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/task/BpmTaskController.java | 6 +- .../task/BpmProcessInstanceConvert.java | 1 + .../bpm/service/task/BpmTaskService.java | 2 +- .../service/task/impl/BpmTaskServiceImpl.java | 2 +- yudao-admin-ui/src/api/bpm/processInstance.js | 2 +- yudao-admin-ui/src/api/bpm/task.js | 6 + yudao-admin-ui/src/router/index.js | 6 + .../src/views/bpm/processInstance/create.vue | 2 - .../src/views/bpm/processInstance/detail.vue | 146 +++++++++--------- yudao-admin-ui/src/views/bpm/task/todo.vue | 6 +- 10 files changed, 100 insertions(+), 79 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java index 56b232ea6..67fc48b60 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.java @@ -57,12 +57,12 @@ public class BpmTaskController { return success(true); } - @GetMapping("/list-by-process-instance-id") + @GetMapping("/historic-list-by-process-instance-id") @ApiOperation(value = "获得指定流程实例的任务列表", notes = "包括完成的、未完成的") @ApiImplicitParam(name = "processInstanceId", value = "流程实例的编号", required = true, dataTypeClass = String.class) - public CommonResult> getTaskListByProcessInstanceId( + public CommonResult> getHistoricTaskListByProcessInstanceId( @RequestParam("processInstanceId") String processInstanceId) { - return success(taskService.getTaskListByProcessInstanceId(processInstanceId)); + return success(taskService.getHistoricTaskListByProcessInstanceId(processInstanceId)); } /** diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java index 9f59be342..8e1d2293f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java @@ -64,6 +64,7 @@ public interface BpmProcessInstanceConvert { @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) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java index b46bf065a..99df5dde7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmTaskService.java @@ -31,7 +31,7 @@ public interface BpmTaskService { * @param processInstanceId 流程实例的编号 * @return 流程任务列表 */ - List getTaskListByProcessInstanceId(String processInstanceId); + List getHistoricTaskListByProcessInstanceId(String processInstanceId); /** * 获得流程任务列表 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index b15ef39ce..21b9903a1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -91,7 +91,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { } @Override - public List getTaskListByProcessInstanceId(String processInstanceId) { + public List getHistoricTaskListByProcessInstanceId(String processInstanceId) { // 获得任务列表 List tasks = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId) diff --git a/yudao-admin-ui/src/api/bpm/processInstance.js b/yudao-admin-ui/src/api/bpm/processInstance.js index 54feaedea..58c456f71 100644 --- a/yudao-admin-ui/src/api/bpm/processInstance.js +++ b/yudao-admin-ui/src/api/bpm/processInstance.js @@ -27,7 +27,7 @@ export function cancelProcessInstance(id, reason) { }) } -export function getMyProcessInstance(id) { +export function getProcessInstance(id) { return request({ url: '/bpm/process-instance/get?id=' + id, method: 'get', diff --git a/yudao-admin-ui/src/api/bpm/task.js b/yudao-admin-ui/src/api/bpm/task.js index 8a5704884..650186e96 100644 --- a/yudao-admin-ui/src/api/bpm/task.js +++ b/yudao-admin-ui/src/api/bpm/task.js @@ -40,3 +40,9 @@ export function rejectTask(data) { }) } +export function getHistoricTaskListByProcessInstanceId(processInstanceId) { + return request({ + url: '/bpm/task/historic-list-by-process-instance-id?processInstanceId=' + processInstanceId, + method: 'get', + }) +} diff --git a/yudao-admin-ui/src/router/index.js b/yudao-admin-ui/src/router/index.js index 35a9deac8..810b63a0f 100644 --- a/yudao-admin-ui/src/router/index.js +++ b/yudao-admin-ui/src/router/index.js @@ -198,6 +198,12 @@ export const constantRoutes = [ component: (resolve) => require(['@/views/bpm/processInstance/create'], resolve), name: '发起流程', meta: { title: '发起流程' } + }, + { + path: 'process-instance/detail', + component: (resolve) => require(['@/views/bpm/processInstance/detail'], resolve), + name: '流程详情', + meta: { title: '流程详情' } } ] }, diff --git a/yudao-admin-ui/src/views/bpm/processInstance/create.vue b/yudao-admin-ui/src/views/bpm/processInstance/create.vue index 1d3c09651..1cdee0bcf 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/create.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/create.vue @@ -70,8 +70,6 @@ export default { return { // 遮罩层 loading: true, - // 总条数 - total: 0, // 表格数据 list: [], diff --git a/yudao-admin-ui/src/views/bpm/processInstance/detail.vue b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue index 1365e57c4..7b11a4145 100644 --- a/yudao-admin-ui/src/views/bpm/processInstance/detail.vue +++ b/yudao-admin-ui/src/views/bpm/processInstance/detail.vue @@ -1,54 +1,25 @@ @@ -58,7 +29,8 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict"; import {getForm} from "@/api/bpm/form"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' -import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance"; +import {createProcessInstance, getMyProcessInstancePage, getProcessInstance} from "@/api/bpm/processInstance"; +import {getHistoricTaskListByProcessInstanceId} from "@/api/bpm/task"; // 流程实例的详情页,可用于审批 export default { @@ -69,11 +41,10 @@ export default { data() { return { // 遮罩层 - loading: true, - // 总条数 - total: 0, - // 表格数据 - list: [], + processInstanceLoading: true, + // 流程实例 + id: undefined, // 流程实例的编号 + processInstance: {}, // 流程表单详情 detailForm: { @@ -86,27 +57,65 @@ export default { prefix: "activiti" }, - // 流程表单 - selectProcessInstance: undefined, // 选择的流程实例 + // 审批记录 + historicTasksLoad: true, + historicTasks: [], // 数据字典 categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY), }; }, created() { - this.getList(); + this.id = this.$route.query.id; + if (!this.id) { + this.$message.error('未传递 id 参数,无法查看流程信息'); + return; + } + this.getDetail(); }, methods: { - /** 查询流程定义列表 */ - getList() { - this.loading = true; - getProcessDefinitionList({ - suspensionState: 1 - }).then(response => { - this.list = response.data - this.loading = false + /** 获得流程实例 */ + getDetail() { + // 获得流程实例相关 + this.processInstanceLoading = true; + getProcessInstance(this.id).then(response => { + if (!response.data) { + this.$message.error('查询不到流程信息!'); + return; } - ); + // 设置流程信息 + this.processInstance = response.data; + + // 设置表单信息 + this.detailForm = { + ...JSON.parse(this.processInstance.processDefinition.formConf), + disabled: true, // 表单禁用 + formBtns: false, // 按钮隐藏 + fields: decodeFields(this.processInstance.processDefinition.formFields) + } + // 设置表单的值 + this.detailForm.fields.forEach(item => { + const val = this.processInstance.formVariables[item.__vModel__] + if (val) { + item.__config__.defaultValue = val + } + }) + + // 加载流程图 + getProcessDefinitionBpmnXML(this.processInstance.processDefinition.id).then(response => { + this.bpmnXML = response.data + }) + + // 取消加载中 + this.processInstanceLoading = false; + }); + + // 获得流程任务列表(审批记录) + this.historicTasksLoad = true; + getHistoricTaskListByProcessInstanceId(this.id).then(response => { + this.historicTasks = response.data; + this.historicTasksLoad = true; + }); }, /** 处理选择流程的按钮操作 **/ handleSelect(row) { @@ -121,10 +130,7 @@ export default { fields: decodeFields(row.formFields) } - // 加载流程图 - getProcessDefinitionBpmnXML(row.id).then(response => { - this.bpmnXML = response.data - }) + } else if (row.formCustomCreatePath) { this.$router.push({ path: row.formCustomCreatePath}); // 这里暂时无需加载流程图,因为跳出到另外个 Tab; diff --git a/yudao-admin-ui/src/views/bpm/task/todo.vue b/yudao-admin-ui/src/views/bpm/task/todo.vue index 2e919cb6f..9ea2bebde 100644 --- a/yudao-admin-ui/src/views/bpm/task/todo.vue +++ b/yudao-admin-ui/src/views/bpm/task/todo.vue @@ -36,7 +36,7 @@ @@ -156,17 +104,9 @@ export default { leaveType: null, reason: null, }, - // 表单参数 - form: {}, - // 表单校验 - rules: { - startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }], - endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }], - }, + leaveTypeDictData: getDictDatas(DICT_TYPE.BPM_OA_LEAVE_TYPE), leaveResultData: getDictDatas(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT), - - dialogDetailVisible: false, // TODO 芋艿:后面挪到详情页 }; }, created() { @@ -186,25 +126,6 @@ export default { this.loading = false; }); }, - /** 取消按钮 */ - cancel() { - this.open = false; - this.reset(); - }, - /** 表单重置 */ - reset() { - this.form = { - id: undefined, - status: undefined, - userId: undefined, - startTime: undefined, - endTime: undefined, - leaveType: undefined, - reason: undefined, - applyTime: undefined, - }; - this.resetForm("form"); - }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNo = 1; @@ -212,54 +133,22 @@ export default { }, /** 重置按钮操作 */ resetQuery() { - this.dateRangeStartTime = []; - this.dateRangeEndTime = []; this.dateRangeCreateTime = []; this.resetForm("queryForm"); this.handleQuery(); }, /** 新增按钮操作 */ handleAdd() { - getLeaveApplyMembers().then(response => { - const route = { - path: '/flow/leave/apply', - query: { - hr: response.data.hr, - pm: response.data.pm, - bm : response.data.bm - } - } - this.$router.replace(route); - }); + this.$router.push({ path: "/bpm/oa/leave/create"}); }, /** 详情按钮操作 */ handleDetail(row) { - this.reset(); - const id = row.id; - getLeave(id).then(response => { - this.form = response.data; - this.dialogDetailVisible = true - this.title = "请假详情"; - }); + this.$router.push({ path: "/bpm/oa/leave/detail", query: { id: row.id}}); }, /** 查看审批进度的操作 */ handleProcessDetail(row) { this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstanceId}}); }, - /** 提交按钮 */ - submitForm() { - this.$refs["form"].validate(valid => { - if (!valid) { - return; - } - // 添加的提交 - createLeave(this.form).then(response => { - this.msgSuccess("新增成功"); - this.open = false; - this.getList(); - }); - }); - }, resultFormat(row, column) { return getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, row.result) }, From 7c62b1a21186ce24996a11a87b890ceed8feb663 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 22 Jan 2022 22:44:42 +0800 Subject: [PATCH 42/48] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bpm=20=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E4=B8=8D=E9=80=9A=E8=BF=87=E7=9A=84=20Listener=20?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmProcessInstanceDeleteReasonEnum.java | 19 ++++++++++++++++++- .../BpmProcessInstanceEventListener.java | 4 +++- .../task/BpmProcessInstanceService.java | 4 +++- .../impl/BpmProcessInstanceServiceImpl.java | 10 ++++++++-- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java index 5032dd857..a458b2e30 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.enums.task; +import cn.hutool.core.util.StrUtil; import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,8 +13,24 @@ import lombok.Getter; @AllArgsConstructor public enum BpmProcessInstanceDeleteReasonEnum { - REJECT_TASK("不通过任务,原因:{}"); + REJECT_TASK("不通过任务,原因:{}"); // 修改文案时,需要注意 isRejectReason 方法 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java index 0fe462bf5..90c1f3ef1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/listener/BpmProcessInstanceEventListener.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceS 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.ProcessEventListener; import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener; import org.activiti.api.task.model.events.TaskRuntimeEvent; @@ -42,7 +43,8 @@ public class BpmProcessInstanceEventListener> } // 取消时,更新拓展表为取消 if (event.getEventType() == ProcessRuntimeEvent.ProcessEvents.PROCESS_CANCELLED) { - processInstanceService.updateProcessInstanceExtCancel(event.getEntity()); + processInstanceService.updateProcessInstanceExtCancel(event.getEntity(), + ((ProcessCancelledEvent) event).getCause()); return; } // 完成时,更新拓展表为已完成 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java index 99e993447..f3a9ad09c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java @@ -144,13 +144,15 @@ public interface BpmProcessInstanceService { * 更新 ProcessInstance 拓展记录为取消 * * @param instance 流程任务 + * @param reason 取消原因 */ - void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance); + void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance, String reason); /** * 更新 ProcessInstance 拓展记录为完成 * * @param instance 流程任务 + * @param reason 原因 */ void updateProcessInstanceExtComplete(org.activiti.api.process.model.ProcessInstance instance); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index c17c29e56..625f3b64e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -241,7 +241,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService } @Override - public void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance) { + public void updateProcessInstanceExtCancel(org.activiti.api.process.model.ProcessInstance instance, String reason) { + // 判断是否为 Reject 不通过。如果是,则不进行更新 + if (BpmProcessInstanceDeleteReasonEnum.isRejectReason(reason)) { + return; + } + + // 更新拓展表 BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance) .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) @@ -265,7 +271,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService public void updateProcessInstanceExtReject(String id, String comment) { ProcessInstance processInstance = getProcessInstance(id); // 删除流程实例,以实现驳回任务时,取消整个审批流程 - deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.getReason(), comment)); + deleteProcessInstance(id, StrUtil.format(BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.format(comment))); // 更新 status + result // 注意,不能和上面的逻辑更换位置。因为 deleteProcessInstance 会触发流程的取消,进而调用 updateProcessInstanceExtCancel 方法, From 5437775172bacfa97459e9b8158a17384a396b3a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 22 Jan 2022 23:56:15 +0800 Subject: [PATCH 43/48] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20BpmProcessInstanceRe?= =?UTF-8?q?sultEvent=20=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E6=B5=81=E7=A8=8B=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E7=9A=84=E7=8A=B6=E6=80=81=E7=9A=84=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oa/vo/BpmOALeaveCreateReqVO.java | 19 ++++---- .../task/BpmProcessInstanceConvert.java | 19 ++++++++ .../BpmProcessInstanceDeleteReasonEnum.java | 3 +- .../config/BpmActivitiConfiguration.java | 7 +++ .../event/BpmProcessInstanceResultEvent.java | 44 +++++++++++++++++++ ...BpmProcessInstanceResultEventListener.java | 34 ++++++++++++++ ...pmProcessInstanceResultEventPublisher.java | 24 ++++++++++ .../activiti/core/event/package-info.java | 6 +++ .../dto/BpmProcessDefinitionCreateReqDTO.java | 3 -- .../bpm/service/oa/BpmOALeaveService.java | 8 ++++ .../service/oa/LeaveApplyEndProcessor.java | 40 ----------------- .../service/oa/impl/OALeaveServiceImpl.java | 15 +++---- .../oa/listener/BpmOALeaveResultListener.java | 32 ++++++++++++++ .../task/BpmProcessInstanceService.java | 1 - .../impl/BpmProcessInstanceServiceImpl.java | 33 ++++++++++++-- 15 files changed, 224 insertions(+), 64 deletions(-) create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEvent.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventListener.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventPublisher.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/package-info.java delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java create mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveCreateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveCreateReqVO.java index b411e4a1a..f36e924b1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveCreateReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveCreateReqVO.java @@ -1,18 +1,21 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo; -import lombok.*; -import io.swagger.annotations.*; -import org.springframework.format.annotation.DateTimeFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; -import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java index 8e1d2293f..88405027f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmProcessInstanceConvert.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmP import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskRespVO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent; import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -98,4 +99,22 @@ public interface BpmProcessInstanceConvert { void copyTo(BpmProcessDefinitionExtDO from, @MappingTarget BpmProcessInstanceRespVO.ProcessDefinition to); BpmProcessInstanceRespVO.User convert2(SysUserDO 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; + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java index a458b2e30..65b2e953b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/task/BpmProcessInstanceDeleteReasonEnum.java @@ -13,7 +13,8 @@ import lombok.Getter; @AllArgsConstructor public enum BpmProcessInstanceDeleteReasonEnum { - REJECT_TASK("不通过任务,原因:{}"); // 修改文案时,需要注意 isRejectReason 方法 + REJECT_TASK("不通过任务,原因:{}"), // 修改文案时,需要注意 isRejectReason 方法 + CANCEL_TASK("主动取消任务,原因:{}"); private final String reason; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java index 940fc4d1d..ccb7cad78 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.config; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.BpmActivityBehaviorFactory; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventPublisher; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.identity.EmptyUserGroupManager; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.listener.BpmTackActivitiEventListener; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; @@ -11,6 +12,7 @@ import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermiss import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import org.activiti.api.runtime.shared.identity.UserGroupManager; import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -71,4 +73,9 @@ public class BpmActivitiConfiguration { return bpmActivityBehaviorFactory; } + @Bean + public BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher(ApplicationEventPublisher publisher) { + return new BpmProcessInstanceResultEventPublisher(publisher); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEvent.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEvent.java new file mode 100644 index 000000000..d9f9524a3 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEvent.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event; + +import cn.iocoder.yudao.adminserver.modules.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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventListener.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventListener.java new file mode 100644 index 000000000..6134a14cb --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventListener.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventPublisher.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventPublisher.java new file mode 100644 index 000000000..dba448a9c --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/BpmProcessInstanceResultEventPublisher.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/package-info.java new file mode 100644 index 000000000..5a05170f9 --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/event/package-info.java @@ -0,0 +1,6 @@ +/** + * 自定义 Event 实现,提供方便业务接入的 Listener! + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java index 559832c37..11a8245d5 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/definition/dto/BpmProcessDefinitionCreateReqDTO.java @@ -2,10 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.definition.dto; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmFormDO; import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmModelFormTypeEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import lombok.Data; import javax.validation.constraints.AssertTrue; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java index 7048d3b6e..11d5d9fb7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java @@ -24,6 +24,14 @@ public interface BpmOALeaveService { */ Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO); + /** + * 更新请假申请的状态 + * + * @param id 编号 + * @param result 结果 + */ + void updateLeaveResult(Long id, Integer result); + /** * 删除请假申请 * diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java deleted file mode 100644 index 7744a8990..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/LeaveApplyEndProcessor.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.service.oa; - -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper; -import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; -import org.activiti.engine.delegate.DelegateExecution; -import org.activiti.engine.delegate.ExecutionListener; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import javax.annotation.Resource; -import java.util.Objects; - - -/** - * 请假流程结束流程监听处理服务, 根据请假申请审批通过,还是未通过, 更新请假表单 - */ -@Component -public class LeaveApplyEndProcessor implements ExecutionListener { - - @Resource - private BpmOALeaveMapper leaveMapper; - - @Override - @Transactional(rollbackFor = Exception.class) - public void notify(DelegateExecution delegateExecution) { - final String businessKey = delegateExecution.getProcessInstanceBusinessKey(); - final Object approved = delegateExecution.getVariable("approved"); - OALeaveDO updateDo = new OALeaveDO(); - updateDo.setId(Long.valueOf(businessKey)); - if (Objects.equals(approved, true)) { - updateDo.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); - } else { - updateDo.setResult(BpmProcessInstanceResultEnum.REJECT.getResult()); - } - - leaveMapper.updateById(updateDo); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java index 05aecee3f..bde8ea620 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java @@ -34,7 +34,7 @@ public class OALeaveServiceImpl implements BpmOALeaveService { /** * OA 请假对应的流程定义 KEY */ - private static final String PROCESS_KEY = "oa_leave"; + public static final String PROCESS_KEY = "oa_leave"; @Resource private BpmOALeaveMapper leaveMapper; @@ -45,14 +45,8 @@ public class OALeaveServiceImpl implements BpmOALeaveService { @Override @Transactional(rollbackFor = Exception.class) public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { - // TODO 芋道源码 - // 校验是否超过请假天数的上限; - long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false); - if (day <= 0) { - throw ServiceExceptionUtil.exception(OA_DAY_LEAVE_ERROR); - } - // 插入 OA 请假单 + long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false); OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day) .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); leaveMapper.insert(leave); @@ -69,6 +63,11 @@ public class OALeaveServiceImpl implements BpmOALeaveService { return leave.getId(); } + @Override + public void updateLeaveResult(Long id, Integer result) { + leaveMapper.updateById(new OALeaveDO().setId(id).setResult(result)); + } + @Override public void cancelLeave(Long id) { // TODO 需要重新实现 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java new file mode 100644 index 000000000..2450fee0a --- /dev/null +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener; + +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener; +import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService; +import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.OALeaveServiceImpl; +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 OALeaveServiceImpl.PROCESS_KEY; + } + + @Override + protected void onEvent(BpmProcessInstanceResultEvent event) { + leaveService.updateLeaveResult(Long.parseLong(event.getBusinessKey()), event.getResult()); + } + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java index f3a9ad09c..8defdd23d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java @@ -152,7 +152,6 @@ public interface BpmProcessInstanceService { * 更新 ProcessInstance 拓展记录为完成 * * @param instance 流程任务 - * @param reason 原因 */ void updateProcessInstanceExtComplete(org.activiti.api.process.model.ProcessInstance instance); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index 625f3b64e..d43b6c9d4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -12,6 +12,9 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanc import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventPublisher; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService; import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService; @@ -76,6 +79,9 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService @Resource private BpmMessageService messageService; + @Resource + private BpmProcessInstanceResultEventPublisher processInstanceResultEventPublisher; + @Resource private BpmProcessInstanceExtMapper processInstanceExtMapper; @@ -141,7 +147,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService } // 通过删除流程实例,实现流程实例的取消 - runtimeService.deleteProcessInstance(cancelReqVO.getId(), cancelReqVO.getReason()); + runtimeService.deleteProcessInstance(cancelReqVO.getId(), + BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(cancelReqVO.getReason())); } @Override @@ -247,16 +254,26 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService return; } + // 需要主动查询,因为 instance 只有 id 属性 + ProcessInstance processInstance = getProcessInstance(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()) @@ -265,10 +282,15 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService // 发送流程被通过的消息 messageService.sendMessageWhenProcessInstanceApprove(BpmMessageConvert.INSTANCE.convert(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))); @@ -276,12 +298,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService // 更新 status + result // 注意,不能和上面的逻辑更换位置。因为 deleteProcessInstance 会触发流程的取消,进而调用 updateProcessInstanceExtCancel 方法, // 设置 result 为 BpmProcessInstanceStatusEnum.CANCEL,显然和 result 不一定是一致的 - processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(id) + BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(id) .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) - .setResult(BpmProcessInstanceResultEnum.REJECT.getResult())); + .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()); + processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); // 发送流程被不通过的消息 messageService.sendMessageWhenProcessInstanceReject(BpmMessageConvert.INSTANCE.convert(processInstance, comment)); + + // 发送流程实例的状态事件 + processInstanceResultEventPublisher.sendProcessInstanceResultEvent( + BpmProcessInstanceConvert.INSTANCE.convert(this, processInstance, instanceExtDO.getResult())); } } From e6142b53088f9b7de60c1b6e1a72ffb4dca82c60 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 23 Jan 2022 00:10:06 +0800 Subject: [PATCH 44/48] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=20OA=20=E8=AF=B7?= =?UTF-8?q?=E5=81=87=E7=9A=84=E5=8F=96=E6=B6=88=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/oa/BpmOALeaveController.java | 28 ++---- ...ageReqVO.java => BpmOALeavePageReqVO.java} | 2 +- ...LeaveRespVO.java => BpmOALeaveRespVO.java} | 2 +- ...aveConvert.java => BpmOALeaveConvert.java} | 16 ++-- .../{OALeaveDO.java => BpmOALeaveDO.java} | 2 +- .../dal/dataobject/leave/package-info.java | 4 - .../bpm/dal/mysql/oa/BpmOALeaveMapper.java | 22 ++--- .../bpm/service/oa/BpmOALeaveService.java | 13 +-- ...ceImpl.java => BpmOALeaveServiceImpl.java} | 26 ++---- .../oa/listener/BpmOALeaveResultListener.java | 4 +- .../impl/BpmProcessInstanceServiceImpl.java | 3 +- yudao-admin-ui/src/api/{oa => bpm}/leave.js | 8 -- yudao-admin-ui/src/api/oa/flow.js | 9 -- yudao-admin-ui/src/api/oa/todo.js | 91 ------------------- .../src/views/bpm/oa/leave/create.vue | 3 +- .../src/views/bpm/oa/leave/detail.vue | 2 +- .../src/views/bpm/oa/leave/index.vue | 33 +++++-- .../src/views/bpm/processInstance/index.vue | 2 +- 18 files changed, 74 insertions(+), 196 deletions(-) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/{OALeavePageReqVO.java => BpmOALeavePageReqVO.java} (95%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/{OALeaveRespVO.java => BpmOALeaveRespVO.java} (94%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/{OALeaveConvert.java => BpmOALeaveConvert.java} (55%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/{OALeaveDO.java => BpmOALeaveDO.java} (97%) delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/package-info.java rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/{OALeaveServiceImpl.java => BpmOALeaveServiceImpl.java} (76%) rename yudao-admin-ui/src/api/{oa => bpm}/leave.js (77%) delete mode 100644 yudao-admin-ui/src/api/oa/flow.js delete mode 100644 yudao-admin-ui/src/api/oa/todo.js diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/BpmOALeaveController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/BpmOALeaveController.java index e39a0747f..ed7b2f719 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/BpmOALeaveController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/BpmOALeaveController.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO; -import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO; import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -43,27 +43,19 @@ public class BpmOALeaveController { return success(leaveService.createLeave(getLoginUserId(), createReqVO)); } - @DeleteMapping("/cancel") - @ApiOperation("取消请假申请") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) - public CommonResult cancelLeave(@RequestParam("id") Long id) { - leaveService.cancelLeave(id); - return success(true); - } - @GetMapping("/get") @ApiOperation("获得请假申请") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) - public CommonResult getLeave(@RequestParam("id") Long id) { - OALeaveDO leave = leaveService.getLeave(id); - return success(OALeaveConvert.INSTANCE.convert(leave)); + public CommonResult getLeave(@RequestParam("id") Long id) { + BpmOALeaveDO leave = leaveService.getLeave(id); + return success(BpmOALeaveConvert.INSTANCE.convert(leave)); } @GetMapping("/page") @ApiOperation("获得请假申请分页") - public CommonResult> getLeavePage(@Valid OALeavePageReqVO pageVO) { - PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO); - return success(OALeaveConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getLeavePage(@Valid BpmOALeavePageReqVO pageVO) { + PageResult pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO); + return success(BpmOALeaveConvert.INSTANCE.convertPage(pageResult)); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeavePageReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeavePageReqVO.java similarity index 95% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeavePageReqVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeavePageReqVO.java index 7e83258e6..7b81455a2 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeavePageReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeavePageReqVO.java @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OALeavePageReqVO extends PageParam { +public class BpmOALeavePageReqVO extends PageParam { @ApiModelProperty(value = "状态", example = "1", notes = "参见 bpm_process_instance_result 枚举") private Integer result; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeaveRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveRespVO.java similarity index 94% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeaveRespVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveRespVO.java index 19292b7c9..2b386d8ce 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/OALeaveRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/oa/vo/BpmOALeaveRespVO.java @@ -13,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OALeaveRespVO extends BpmOALeaveBaseVO { +public class BpmOALeaveRespVO extends BpmOALeaveBaseVO { @ApiModelProperty(value = "请假表单主键", required = true, example = "1024") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/OALeaveConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/BpmOALeaveConvert.java similarity index 55% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/OALeaveConvert.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/BpmOALeaveConvert.java index 3c5ae82eb..8c7c1d8bf 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/OALeaveConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/oa/BpmOALeaveConvert.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -15,16 +15,16 @@ import java.util.List; * @author 芋艿 */ @Mapper -public interface OALeaveConvert { +public interface BpmOALeaveConvert { - OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class); + BpmOALeaveConvert INSTANCE = Mappers.getMapper(BpmOALeaveConvert.class); - OALeaveDO convert(BpmOALeaveCreateReqVO bean); + BpmOALeaveDO convert(BpmOALeaveCreateReqVO bean); - OALeaveRespVO convert(OALeaveDO bean); + BpmOALeaveRespVO convert(BpmOALeaveDO bean); - List convertList(List list); + List convertList(List list); - PageResult convertPage(PageResult page); + PageResult convertPage(PageResult page); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/OALeaveDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/BpmOALeaveDO.java similarity index 97% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/OALeaveDO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/BpmOALeaveDO.java index e8b0e94d2..53f8b7d75 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/OALeaveDO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/BpmOALeaveDO.java @@ -22,7 +22,7 @@ import org.activiti.engine.runtime.ProcessInstance; @Builder @NoArgsConstructor @AllArgsConstructor -public class OALeaveDO extends BaseDO { +public class BpmOALeaveDO extends BaseDO { /** * 请假表单主键 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/package-info.java deleted file mode 100644 index 23ebef9c5..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/dataobject/leave/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * TODO 芋艿:实现请假流程,接入工作流 - */ -package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/oa/BpmOALeaveMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/oa/BpmOALeaveMapper.java index f16bc6edf..1941744e6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/oa/BpmOALeaveMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/oa/BpmOALeaveMapper.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.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; @@ -14,16 +14,16 @@ import org.apache.ibatis.annotations.Mapper; * @author 芋道源码 */ @Mapper -public interface BpmOALeaveMapper extends BaseMapperX { +public interface BpmOALeaveMapper extends BaseMapperX { - default PageResult selectPage(Long userId, OALeavePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(OALeaveDO::getUserId, userId) - .eqIfPresent(OALeaveDO::getResult, reqVO.getResult()) - .eqIfPresent(OALeaveDO::getType, reqVO.getType()) - .likeIfPresent(OALeaveDO::getReason, reqVO.getReason()) - .betweenIfPresent(OALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(OALeaveDO::getId)); + 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-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java index 11d5d9fb7..62d991d84 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/BpmOALeaveService.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import javax.validation.Valid; @@ -32,20 +32,13 @@ public interface BpmOALeaveService { */ void updateLeaveResult(Long id, Integer result); - /** - * 删除请假申请 - * - * @param id 编号 - */ - void cancelLeave(Long id); - /** * 获得请假申请 * * @param id 编号 * @return 请假申请 */ - OALeaveDO getLeave(Long id); + BpmOALeaveDO getLeave(Long id); /** * 获得请假申请分页 @@ -54,6 +47,6 @@ public interface BpmOALeaveService { * @param pageReqVO 分页查询 * @return 请假申请分页 */ - PageResult getLeavePage(Long userId, OALeavePageReqVO pageReqVO); + PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/BpmOALeaveServiceImpl.java similarity index 76% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/BpmOALeaveServiceImpl.java index bde8ea620..f55836d6e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/OALeaveServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/impl/BpmOALeaveServiceImpl.java @@ -2,14 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl; import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*; -import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert; -import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.BpmOALeaveConvert; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO; import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper; import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,7 +28,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU */ @Service @Validated -public class OALeaveServiceImpl implements BpmOALeaveService { +public class BpmOALeaveServiceImpl implements BpmOALeaveService { /** * OA 请假对应的流程定义 KEY @@ -47,7 +46,7 @@ public class OALeaveServiceImpl implements BpmOALeaveService { public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) { // 插入 OA 请假单 long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false); - OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day) + BpmOALeaveDO leave = BpmOALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day) .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); leaveMapper.insert(leave); @@ -59,22 +58,13 @@ public class OALeaveServiceImpl implements BpmOALeaveService { .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId()))); // 将工作流的编号,更新到 OA 请假单中 - leaveMapper.updateById(new OALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); + leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId)); return leave.getId(); } @Override public void updateLeaveResult(Long id, Integer result) { - leaveMapper.updateById(new OALeaveDO().setId(id).setResult(result)); - } - - @Override - public void cancelLeave(Long id) { - // TODO 需要重新实现 - // 校验存在 - this.validateLeaveExists(id); - // 删除 - leaveMapper.deleteById(id); + leaveMapper.updateById(new BpmOALeaveDO().setId(id).setResult(result)); } private void validateLeaveExists(Long id) { @@ -84,12 +74,12 @@ public class OALeaveServiceImpl implements BpmOALeaveService { } @Override - public OALeaveDO getLeave(Long id) { + public BpmOALeaveDO getLeave(Long id) { return leaveMapper.selectById(id); } @Override - public PageResult getLeavePage(Long userId, OALeavePageReqVO pageReqVO) { + public PageResult getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) { return leaveMapper.selectPage(userId, pageReqVO); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java index 2450fee0a..fcc716db9 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/oa/listener/BpmOALeaveResultListener.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener; import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService; -import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.OALeaveServiceImpl; +import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.BpmOALeaveServiceImpl; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -21,7 +21,7 @@ public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListe @Override protected String getProcessDefinitionKey() { - return OALeaveServiceImpl.PROCESS_KEY; + return BpmOALeaveServiceImpl.PROCESS_KEY; } @Override diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index d43b6c9d4..7c87142d0 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -255,7 +255,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService } // 需要主动查询,因为 instance 只有 id 属性 - ProcessInstance processInstance = getProcessInstance(instance.getId()); + // 另外,此时如果去查询 ProcessInstance 的话,字段是不全的,所以去查询了 HistoricProcessInstance + HistoricProcessInstance processInstance = getHistoricProcessInstance(instance.getId()); // 更新拓展表 BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance) .setEndTime(new Date()) // 由于 ProcessInstance 里没有办法拿到 endTime,所以这里设置 diff --git a/yudao-admin-ui/src/api/oa/leave.js b/yudao-admin-ui/src/api/bpm/leave.js similarity index 77% rename from yudao-admin-ui/src/api/oa/leave.js rename to yudao-admin-ui/src/api/bpm/leave.js index 3ff4040b7..758389c88 100644 --- a/yudao-admin-ui/src/api/oa/leave.js +++ b/yudao-admin-ui/src/api/bpm/leave.js @@ -9,14 +9,6 @@ export function createLeave(data) { }) } -// 删除请假申请 -export function deleteLeave(id) { - return request({ - url: '/oa/leave/delete?id=' + id, - method: 'delete' - }) -} - // 获得请假申请 export function getLeave(id) { return request({ diff --git a/yudao-admin-ui/src/api/oa/flow.js b/yudao-admin-ui/src/api/oa/flow.js deleted file mode 100644 index 3c28cb418..000000000 --- a/yudao-admin-ui/src/api/oa/flow.js +++ /dev/null @@ -1,9 +0,0 @@ -import request from '@/utils/request' - - -export function getStartForm(processKey) { - return request({ - url: '/workflow/process/definition/getStartForm?processKey='+processKey, - method: 'get' - }) -} diff --git a/yudao-admin-ui/src/api/oa/todo.js b/yudao-admin-ui/src/api/oa/todo.js deleted file mode 100644 index 1a8bc26ab..000000000 --- a/yudao-admin-ui/src/api/oa/todo.js +++ /dev/null @@ -1,91 +0,0 @@ -import request from '@/utils/request' - -// 创建请假申请 -export function createLeave(data) { - return request({ - url: '/oa/leave/create', - method: 'post', - data: data - }) -} - -// 更新请假申请 -export function updateLeave(data) { - return request({ - url: '/oa/leave/update', - method: 'put', - data: data - }) -} - -// 删除请假申请 -export function deleteLeave(id) { - return request({ - url: '/oa/leave/delete?id=' + id, - method: 'delete' - }) -} - -// 获得请假申请 -export function getLeave(id) { - return request({ - url: '/oa/leave/get?id=' + id, - method: 'get' - }) -} - -// 获得待办任务分页 -export function getTodoTaskPage(query) { - return request({ - url: '/workflow/task/todo/page', - method: 'get', - params: query - }) -} - -// 签收任务 -export function claimTask(id) { - return request({ - url: '/workflow/task/claim?id=' + id, - method: 'get' - }) -} - -export function completeTask(data) { - return request({ - url: '/workflow/task/complete', - method: 'post', - data: data - }) -} - -export function taskSteps(data) { - return request({ - url: '/workflow/task/task-steps', - method: 'post', - data: data - }) -} - -export function getTaskFormKey(data) { - return request({ - url: '/workflow/task/formKey', - method: 'post', - data: data - }) -} - -export function processHistorySteps(id) { - return request({ - url: '/workflow/task/process/history-steps?id='+id, - method: 'get' - }) -} - - -export function getHighlightImg(id) { - return request({ - url: '/workflow/task/process/highlight-img?processInstanceId='+id, - method: 'get' - }) -} diff --git a/yudao-admin-ui/src/views/bpm/oa/leave/create.vue b/yudao-admin-ui/src/views/bpm/oa/leave/create.vue index 53a43ef21..4292fe22a 100644 --- a/yudao-admin-ui/src/views/bpm/oa/leave/create.vue +++ b/yudao-admin-ui/src/views/bpm/oa/leave/create.vue @@ -26,8 +26,9 @@