From 1ab15dd1f9e7a0f0f906c060993cd1c4442812c9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 8 Jan 2022 09:56:56 +0800 Subject: [PATCH] =?UTF-8?q?bpm=20=E6=88=91=E7=9A=84=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=20task=20=E7=9A=84=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/BpmProcessInstanceController.http | 2 +- .../{workflow => task}/TaskController.java | 4 +- .../BpmProcessInstancePageItemRespVO.java | 18 +++- .../vo => task/vo/task}/FileResp.java | 2 +- .../vo => task/vo/task}/TaskHandleVO.java | 2 +- .../vo => task/vo/task}/TaskQueryReqVO.java | 2 +- .../vo => task/vo/task}/TaskReqVO.java | 2 +- .../vo => task/vo/task}/TaskStepVO.java | 2 +- .../vo/task}/TodoTaskPageReqVO.java | 2 +- .../vo => task/vo/task}/TodoTaskRespVO.java | 2 +- .../task/BpmProcessInstanceConvert.java | 12 ++- .../modules/bpm/convert/task/TaskConvert.java | 4 +- .../bpm/service/task/BpmTaskService.java | 30 ++++++- .../impl/BpmProcessInstanceServiceImpl.java | 49 +++++------ .../service/task/impl/BpmTaskServiceImpl.java | 87 ++++++++++--------- .../src/views/bpm/process/index.vue | 8 +- 16 files changed, 139 insertions(+), 89 deletions(-) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow => task}/TaskController.java (94%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/FileResp.java (82%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TaskHandleVO.java (75%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TaskQueryReqVO.java (71%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TaskReqVO.java (74%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TaskStepVO.java (79%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TodoTaskPageReqVO.java (83%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/{workflow/vo => task/vo/task}/TodoTaskRespVO.java (87%) 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 95958cc8e..6cc99c5f2 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 @@ -5,7 +5,7 @@ tenant-id: 1 Authorization: Bearer {{token}} { - "processDefinitionId": "leave:7:20ada39c-6c95-11ec-88b1-cacd34981f8e", + "processDefinitionId": "gateway_test:2:00e52d8e-701b-11ec-aca9-a2380e71991a", "variables": { "a": 1, "b": "2" diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/TaskController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/TaskController.java similarity index 94% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/TaskController.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/TaskController.java index 32260bd56..877ee7fac 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/TaskController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/TaskController.java @@ -1,6 +1,6 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstancePageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstancePageItemRespVO.java index ea89d62ac..14a262570 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstancePageItemRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/instance/BpmProcessInstancePageItemRespVO.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; +import java.util.List; @ApiModel("流程实例的分页 Item Response VO") @Data @@ -34,6 +35,21 @@ public class BpmProcessInstancePageItemRespVO { @ApiModelProperty(value = "结束时间", required = true) private Date endTime; - // TODO 芋艿:tasks + /** + * 当前任务 + */ + private List tasks; + + @ApiModel("流程任务") + @Data + public static class Task { + + @ApiModelProperty(value = "流程任务的编号", required = true, example = "1024") + private String id; + + @ApiModelProperty(value = "任务名称", required = true, example = "芋道") + private String name; + + } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/FileResp.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/FileResp.java similarity index 82% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/FileResp.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/FileResp.java index f3fdedb1a..fb9cbca2c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/FileResp.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/FileResp.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import lombok.Data; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskHandleVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java similarity index 75% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskHandleVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java index fff775a73..2f28f4961 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskHandleVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskHandleVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import lombok.Data; import lombok.ToString; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskQueryReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java similarity index 71% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskQueryReqVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java index d67fad001..97135bb66 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskQueryReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskQueryReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import lombok.Data; import lombok.ToString; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskReqVO.java similarity index 74% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskReqVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskReqVO.java index 0657ae79d..4c038dd34 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import lombok.Data; import lombok.ToString; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskStepVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java similarity index 79% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskStepVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java index 5d8433e80..ad148a85d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TaskStepVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TaskStepVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import lombok.Data; import lombok.ToString; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskPageReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskPageReqVO.java similarity index 83% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskPageReqVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskPageReqVO.java index 411b23d52..78691d2fa 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskPageReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskPageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.annotations.ApiModel; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskRespVO.java similarity index 87% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskRespVO.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskRespVO.java index 93184a2fb..8ffd3d56f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/workflow/vo/TodoTaskRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/TodoTaskRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo; +package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task; import io.swagger.annotations.ApiModel; import lombok.Data; 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 1b7a2e1a0..c1263e5d8 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,12 +5,15 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessIn import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; +import java.util.Map; +import java.util.function.Consumer; /** * 流程实例 Convert @@ -32,10 +35,17 @@ public interface BpmProcessInstanceConvert { }) BpmProcessInstanceExtDO convert(ProcessInstance instance, ProcessDefinition definition); - PageResult convertPage(PageResult page); + default PageResult convertPage(PageResult page, + Map> taskMap) { + List list = convertList(page.getList()); + list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId())))); + return new PageResult<>(list, page.getTotal()); + } List convertList(List list); + List convertList2(List tasks); + @Mapping(source = "processInstanceId", target = "id") BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/TaskConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/TaskConvert.java index 7d8b3dd0c..c300df396 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/TaskConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/TaskConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.convert.task; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TaskStepVO; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TodoTaskRespVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStepVO; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TodoTaskRespVO; import org.activiti.api.task.model.Task; import org.activiti.engine.history.HistoricActivityInstance; import org.activiti.engine.repository.ProcessDefinition; 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 dceba6ff6..30f257628 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 @@ -1,15 +1,41 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import org.activiti.engine.task.Task; import java.util.List; +import java.util.Map; +import java.util.Set; /** - * 工作流用户任务服务接口 + * 工作任务 Service 接口 + * + * @author jason + * @author 芋道源码 */ public interface BpmTaskService { + /** + * 获得流程任务列表 + * + * @param processInstanceIds 流程实例的编号数组 + * @return 流程任务列表 + */ + List getTasksByProcessInstanceIds(List processInstanceIds); + + /** + * 获得流程任务 Map + * + * @param processInstanceIds 流程实例的编号数组 + * @return 流程任务 Map + */ + default Map> getTaskMapByProcessInstanceIds(List processInstanceIds) { + return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), + Task::getProcessInstanceId); + } /** * 获取当前用户的待办任务, 分页 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 f06db74cf..0c3696a8d 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,9 +12,11 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceRes import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum; 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.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 lombok.extern.slf4j.Slf4j; import org.activiti.engine.HistoryService; import org.activiti.engine.RuntimeService; @@ -34,6 +36,7 @@ import java.util.Map; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_IS_SUSPENDED; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_NOT_EXISTS; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; /** * 流程实例 Service 实现类 @@ -55,7 +58,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService @Resource private RuntimeService runtimeService; @Resource - private TaskService taskService; + private BpmTaskService taskService; @Resource private HistoryService historyService; @@ -88,17 +91,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService createProcessInstanceExt(instance, definition); // 添加初始的评论 TODO 芋艿:在思考下 - Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); - if (task != null) { - SysUserDO user = userService.getUser(userId); - Assert.notNull(user, "用户({})不存在", userId); - String type = "normal"; - taskService.addComment(task.getId(), instance.getProcessInstanceId(), type, - String.format("%s 发起流程申请", user.getNickname())); - // TODO 芋艿:应该不用下面两个步骤 -// taskService.setAssignee(task.getId(), String.valueOf(userId)); -// taskService.complete(task.getId(), variables); - } +// Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult(); +// if (task != null) { +// SysUserDO user = userService.getUser(userId); +// Assert.notNull(user, "用户({})不存在", userId); +// String type = "normal"; +// taskService.addComment(task.getId(), instance.getProcessInstanceId(), type, +// String.format("%s 发起流程申请", user.getNickname())); +// // TODO 芋艿:应该不用下面两个步骤 +//// taskService.setAssignee(task.getId(), String.valueOf(userId)); +//// taskService.complete(task.getId(), variables); +// } return instance.getId(); } @@ -123,24 +126,12 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService if (CollUtil.isEmpty(pageResult.getList())) { return new PageResult<>(pageResult.getTotal()); } - // TODO 芋艿:tasks + + // 获得流程 Task Map + List processInstanceIds = convertList(pageResult.getList(), BpmProcessInstanceExtDO::getProcessInstanceId); + Map> taskMap = taskService.getTaskMapByProcessInstanceIds(processInstanceIds); // 转换返回 - return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult); - } - - public void getMyProcessInstancePage(Long userId) { - // id title 所属流程 当前审批环节 状态 结果 创建时间 提交申请时间 【标题、状态】「ActBusiness」 - // id title 流程类别 流程版本 提交时间 流程状态 耗时 当前节点 办理 【标题、提交时间】「HistoricProcessInstanceQuery」 - - // id name 所属流程 流程类别 创建时间 状态 当前审批环节 【标题、流程、时间、状态、结果】 - - runtimeService.createProcessInstanceQuery().list(); - HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery() - .startedBy(String.valueOf(userId)) // 发起人是自己 - .orderByProcessInstanceStartTime().desc(); // 按照发起时间倒序 - List list = historicProcessInstanceQuery.list(); - System.out.println("test"); - + return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap); } /** 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 3652dc548..28f4d1ece 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,16 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; -import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*; +import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.TaskConvert; import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import lombok.extern.slf4j.Slf4j; -import org.activiti.api.runtime.shared.query.Page; -import org.activiti.api.runtime.shared.query.Pageable; -import org.activiti.api.task.model.Task; import org.activiti.api.task.model.builders.ClaimTaskPayloadBuilder; import org.activiti.api.task.model.builders.TaskPayloadBuilder; import org.activiti.api.task.runtime.TaskRuntime; @@ -22,11 +19,13 @@ import org.activiti.bpmn.model.SequenceFlow; import org.activiti.engine.HistoryService; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; import org.activiti.engine.history.HistoricActivityInstance; import org.activiti.engine.history.HistoricProcessInstance; 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.image.ProcessDiagramGenerator; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,11 +34,7 @@ import org.springframework.util.ObjectUtils; import javax.annotation.Resource; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; +import java.util.*; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.HIGHLIGHT_IMG_ERROR; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS; @@ -51,34 +46,39 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Resource private TaskRuntime taskRuntime; - @Resource - private org.activiti.engine.TaskService activitiTaskService; - - @Resource - private HistoryService historyService; - - @Resource - private RepositoryService repositoryService; - + private TaskService taskService; @Resource private RuntimeService runtimeService; + @Resource + private HistoryService historyService; + @Resource + private RepositoryService repositoryService; @Resource private ProcessDiagramGenerator processDiagramGenerator; + @Override + public List getTasksByProcessInstanceIds(List processInstanceIds) { + if (CollUtil.isEmpty(processInstanceIds)) { + return Collections.emptyList(); + } + return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list(); + } + @Override public PageResult getTodoTaskPage(TodoTaskPageReqVO pageReqVO) { // TODO @jason:封装一个方法,用于转换成 activiti 的分页对象 - final Pageable pageable = Pageable.of((pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize(), pageReqVO.getPageSize()); - Page pageTasks = taskRuntime.tasks(pageable); - int totalItems = pageTasks.getTotalItems(); - List tasks = pageTasks.getContent(); - final List respVOList = tasks.stream().map(task -> { - ProcessDefinition definition = repositoryService.getProcessDefinition(task.getProcessDefinitionId()); - return TaskConvert.INSTANCE.convert(task, definition); - }).collect(Collectors.toList()); - return new PageResult<>(respVOList, (long)totalItems); +// final Pageable pageable = Pageable.of((pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize(), pageReqVO.getPageSize()); +// Page pageTasks = taskRuntime.tasks(pageable); +// int totalItems = pageTasks.getTotalItems(); +// List tasks = pageTasks.getContent(); +// final List respVOList = tasks.stream().map(task -> { +// ProcessDefinition definition = repositoryService.getProcessDefinition(task.getProcessDefinitionId()); +// return TaskConvert.INSTANCE.convert(task, definition); +// }).collect(Collectors.toList()); +// return new PageResult<>(respVOList, (long)totalItems); + return null; } @@ -95,27 +95,27 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Override @Transactional public void completeTask(TaskReqVO taskReq) { - final Task task = taskRuntime.task(taskReq.getTaskId()); - - activitiTaskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment()); - - taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId()) - .withVariables(taskReq.getVariables()) - .build()); +// final Task task = taskRuntime.task(taskReq.getTaskId()); +// +// taskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment()); +// +// taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId()) +// .withVariables(taskReq.getVariables()) +// .build()); } @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; +// 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() @@ -129,7 +129,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { TaskStepVO stepVO = TaskConvert.INSTANCE.convert(instance); stepVO.setStatus(1); // TODO @jason:1 这个 magic number 要枚举起来。 // TODO @jason:可以考虑把 comments 读取后,在统一调用 convert 拼接。另外 Comment 是废弃的类,有没其它可以使用的哈? - List comments = activitiTaskService.getTaskComments(instance.getTaskId()); + List comments = taskService.getTaskComments(instance.getTaskId()); if (!CollUtil.isEmpty(comments)) { stepVO.setComment(Optional.ofNullable(comments.get(0)).map(Comment::getFullMessage).orElse("")); } @@ -160,8 +160,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { @Override public TodoTaskRespVO getTaskFormKey(TaskQueryReqVO taskQuery) { - final Task task = taskRuntime.task(taskQuery.getTaskId()); - return TaskConvert.INSTANCE.convert(task); +// final Task task = taskRuntime.task(taskQuery.getTaskId()); +// return TaskConvert.INSTANCE.convert(task); + return null; } @Override diff --git a/yudao-admin-ui/src/views/bpm/process/index.vue b/yudao-admin-ui/src/views/bpm/process/index.vue index f6d486721..12994c635 100644 --- a/yudao-admin-ui/src/views/bpm/process/index.vue +++ b/yudao-admin-ui/src/views/bpm/process/index.vue @@ -54,7 +54,13 @@ {{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }} - + + +