Commit 3fce482716d475d9161c071e90ba6607135654f2

Authored by YunaiV
1 parent d40fa0f9

BPM:简化 task 接口的 VO,做一些合并。虽然字段上有冗余,但是读代码难度降低

Showing 15 changed files with 231 additions and 588 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceStatusOldEnum.java deleted
1 -package cn.iocoder.yudao.module.bpm.enums.task;  
2 -  
3 -import lombok.AllArgsConstructor;  
4 -import lombok.Getter;  
5 -  
6 -/**  
7 - * 流程实例的状态  
8 - *  
9 - * @author 芋道源码  
10 - */  
11 -@Deprecated  
12 -@Getter  
13 -@AllArgsConstructor  
14 -public enum BpmProcessInstanceStatusOldEnum {  
15 -  
16 - RUNNING(1, "进行中"),  
17 - FINISH(2, "已完成");  
18 -  
19 - /**  
20 - * 状态  
21 - */  
22 - private final Integer status;  
23 - /**  
24 - * 描述  
25 - */  
26 - private final String desc;  
27 -  
28 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
1 package cn.iocoder.yudao.module.bpm.controller.admin.task; 1 package cn.iocoder.yudao.module.bpm.controller.admin.task;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.util.StrUtil;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  7 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  8 +import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
  9 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  10 +import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO;
5 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; 11 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
  12 +import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
  13 +import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
6 import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; 14 import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
  15 +import cn.iocoder.yudao.module.system.api.dept.DeptApi;
  16 +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
  17 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  18 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
7 import io.swagger.v3.oas.annotations.Operation; 19 import io.swagger.v3.oas.annotations.Operation;
8 import io.swagger.v3.oas.annotations.Parameter; 20 import io.swagger.v3.oas.annotations.Parameter;
9 import io.swagger.v3.oas.annotations.tags.Tag; 21 import io.swagger.v3.oas.annotations.tags.Tag;
  22 +import jakarta.annotation.Resource;
  23 +import jakarta.validation.Valid;
  24 +import org.flowable.bpmn.model.UserTask;
  25 +import org.flowable.engine.history.HistoricProcessInstance;
  26 +import org.flowable.engine.runtime.ProcessInstance;
  27 +import org.flowable.task.api.Task;
  28 +import org.flowable.task.api.history.HistoricTaskInstance;
10 import org.springframework.security.access.prepost.PreAuthorize; 29 import org.springframework.security.access.prepost.PreAuthorize;
11 import org.springframework.validation.annotation.Validated; 30 import org.springframework.validation.annotation.Validated;
12 import org.springframework.web.bind.annotation.*; 31 import org.springframework.web.bind.annotation.*;
13 32
14 -import jakarta.annotation.Resource;  
15 -import jakarta.validation.Valid; 33 +import java.util.Collections;
16 import java.util.List; 34 import java.util.List;
  35 +import java.util.Map;
  36 +import java.util.Set;
  37 +import java.util.stream.Stream;
17 38
18 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 39 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  40 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
19 import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; 41 import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
20 42
21 @Tag(name = "管理后台 - 流程任务实例") 43 @Tag(name = "管理后台 - 流程任务实例")
@@ -26,28 +48,103 @@ public class BpmTaskController { @@ -26,28 +48,103 @@ public class BpmTaskController {
26 48
27 @Resource 49 @Resource
28 private BpmTaskService taskService; 50 private BpmTaskService taskService;
  51 + @Resource
  52 + private BpmProcessInstanceService processInstanceService;
  53 +
  54 + @Resource
  55 + private AdminUserApi adminUserApi;
  56 + @Resource
  57 + private DeptApi deptApi;
29 58
30 @GetMapping("todo-page") 59 @GetMapping("todo-page")
31 @Operation(summary = "获取 Todo 待办任务分页") 60 @Operation(summary = "获取 Todo 待办任务分页")
32 @PreAuthorize("@ss.hasPermission('bpm:task:query')") 61 @PreAuthorize("@ss.hasPermission('bpm:task:query')")
33 - public CommonResult<PageResult<BpmTaskTodoPageItemRespVO>> getTodoTaskPage(@Valid BpmTaskTodoPageReqVO pageVO) {  
34 - return success(taskService.getTodoTaskPage(getLoginUserId(), pageVO)); 62 + public CommonResult<PageResult<BpmTaskRespVO>> getTodoTaskPage(@Valid BpmTaskPageReqVO pageVO) {
  63 + PageResult<Task> pageResult = taskService.getTodoTaskPage(getLoginUserId(), pageVO);
  64 + // 拼接数据
  65 + Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
  66 + convertSet(pageResult.getList(), Task::getProcessInstanceId));
  67 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  68 + convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
  69 + return success(BeanUtils.toBean(pageResult, BpmTaskRespVO.class, taskVO -> {
  70 + ProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId());
  71 + if (processInstance == null) {
  72 + return;
  73 + }
  74 + AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
  75 + taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class,
  76 + processInstanceVO -> processInstanceVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class))));
  77 + }));
35 } 78 }
36 79
37 @GetMapping("done-page") 80 @GetMapping("done-page")
38 @Operation(summary = "获取 Done 已办任务分页") 81 @Operation(summary = "获取 Done 已办任务分页")
39 @PreAuthorize("@ss.hasPermission('bpm:task:query')") 82 @PreAuthorize("@ss.hasPermission('bpm:task:query')")
40 - public CommonResult<PageResult<BpmTaskDonePageItemRespVO>> getDoneTaskPage(@Valid BpmTaskDonePageReqVO pageVO) {  
41 - return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO)); 83 + public CommonResult<PageResult<BpmTaskRespVO>> getDoneTaskPage(@Valid BpmTaskPageReqVO pageVO) {
  84 + PageResult<HistoricTaskInstance> pageResult = taskService.getDoneTaskPage(getLoginUserId(), pageVO);
  85 + // 拼接数据
  86 + Map<String, HistoricProcessInstance> processInstanceMap = processInstanceService.getHistoricProcessInstanceMap(
  87 + convertSet(pageResult.getList(), HistoricTaskInstance::getProcessInstanceId));
  88 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  89 + convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
  90 + return success(BeanUtils.toBean(pageResult, BpmTaskRespVO.class, taskVO -> {
  91 + HistoricProcessInstance processInstance = processInstanceMap.get(taskVO.getProcessInstanceId());
  92 + if (processInstance == null) {
  93 + return;
  94 + }
  95 + AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
  96 + taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class,
  97 + processInstanceVO -> processInstanceVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class))));
  98 + }));
42 } 99 }
43 100
  101 + // TODO @芋艿:怎么优化下
44 @GetMapping("/list-by-process-instance-id") 102 @GetMapping("/list-by-process-instance-id")
45 @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的") 103 @Operation(summary = "获得指定流程实例的任务列表", description = "包括完成的、未完成的")
46 @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true) 104 @Parameter(name = "processInstanceId", description = "流程实例的编号", required = true)
47 @PreAuthorize("@ss.hasPermission('bpm:task:query')") 105 @PreAuthorize("@ss.hasPermission('bpm:task:query')")
48 public CommonResult<List<BpmTaskRespVO>> getTaskListByProcessInstanceId( 106 public CommonResult<List<BpmTaskRespVO>> getTaskListByProcessInstanceId(
49 @RequestParam("processInstanceId") String processInstanceId) { 107 @RequestParam("processInstanceId") String processInstanceId) {
50 - return success(taskService.getTaskListByProcessInstanceId(processInstanceId)); 108 + List<HistoricTaskInstance> taskList = taskService.getTaskListByProcessInstanceId(processInstanceId);
  109 + if (CollUtil.isEmpty(taskList)) {
  110 + return success(Collections.emptyList());
  111 + }
  112 +
  113 + // 拼接数据
  114 + HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId);
  115 + // 获得 User 和 Dept Map
  116 + Set<Long> userIds = convertSet(taskList, task -> NumberUtils.parseLong(task.getAssignee()));
  117 + userIds.add(NumberUtils.parseLong(processInstance.getStartUserId()));
  118 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
  119 + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
  120 + convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
  121 + List<BpmTaskRespVO> taskVOList = CollectionUtils.convertList(taskList, task -> {
  122 + BpmTaskRespVO taskVO = BeanUtils.toBean(task, BpmTaskRespVO.class);
  123 + taskVO.setStatus((Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS));
  124 + // 流程实例
  125 + AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));
  126 + taskVO.setProcessInstance(BeanUtils.toBean(processInstance, BpmTaskRespVO.ProcessInstance.class,
  127 + processInstanceVO -> processInstanceVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class))));
  128 + // 用户信息
  129 + AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee()));
  130 + if (assignUser != null) {
  131 + taskVO.setAssigneeUser(BeanUtils.toBean(assignUser, BpmProcessInstanceRespVO.User.class));
  132 + DeptRespDTO dept = deptMap.get(assignUser.getDeptId());
  133 + if (dept != null) {
  134 + taskVO.getAssigneeUser().setDeptName(dept.getName());
  135 + }
  136 + }
  137 + return taskVO;
  138 + });
  139 +
  140 + // 拼接父子关系
  141 + Map<String, List<BpmTaskRespVO>> childrenTaskMap = convertMultiMap(
  142 + filterList(taskVOList, r -> StrUtil.isNotEmpty(r.getParentTaskId())),
  143 + BpmTaskRespVO::getParentTaskId);
  144 + for (BpmTaskRespVO taskVO : taskVOList) {
  145 + taskVO.setChildren(childrenTaskMap.get(taskVO.getId()));
  146 + }
  147 + return success(filterList(taskVOList, r -> StrUtil.isEmpty(r.getParentTaskId())));
51 } 148 }
52 149
53 @PutMapping("/approve") 150 @PutMapping("/approve")
@@ -74,12 +171,14 @@ public class BpmTaskController { @@ -74,12 +171,14 @@ public class BpmTaskController {
74 return success(true); 171 return success(true);
75 } 172 }
76 173
77 - @GetMapping("/return-list") 174 + @GetMapping("/list-by-return")
78 @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") 175 @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮")
79 @Parameter(name = "taskId", description = "当前任务ID", required = true) 176 @Parameter(name = "taskId", description = "当前任务ID", required = true)
80 @PreAuthorize("@ss.hasPermission('bpm:task:update')") 177 @PreAuthorize("@ss.hasPermission('bpm:task:update')")
81 - public CommonResult<List<BpmTaskSimpleRespVO>> getReturnList(@RequestParam("taskId") String taskId) {  
82 - return success(taskService.getReturnTaskList(taskId)); 178 + public CommonResult<List<BpmTaskRespVO>> getTaskListByReturn(@RequestParam("id") String id) {
  179 + List<UserTask> userTaskList = taskService.getUserTaskListByReturn(id);
  180 + return success(convertList(userTaskList, userTask -> // 只返回 id 和 name
  181 + new BpmTaskRespVO().setName(userTask.getName()).setTaskDefinitionKey(userTask.getId())));
83 } 182 }
84 183
85 @PutMapping("/return") 184 @PutMapping("/return")
@@ -114,12 +213,23 @@ public class BpmTaskController { @@ -114,12 +213,23 @@ public class BpmTaskController {
114 return success(true); 213 return success(true);
115 } 214 }
116 215
117 - @GetMapping("children-list")  
118 - @Operation(summary = "获取能被减签的任务")  
119 - @Parameter(name = "parentId", description = "父级任务 ID", required = true)  
120 - @PreAuthorize("@ss.hasPermission('bpm:task:update')")  
121 - public CommonResult<List<BpmTaskSubSignRespVO>> getChildrenTaskList(@RequestParam("parentId") String parentId) {  
122 - return success(taskService.getChildrenTaskList(parentId)); 216 + // TODO 芋艿:待测试
  217 + @GetMapping("list-by-parent-task-id")
  218 + @Operation(summary = "获得指定父级任务的子任务列表") // 目前用于,减签的时候,获得子任务列表
  219 + @Parameter(name = "parentTaskId", description = "父级任务编号", required = true)
  220 + @PreAuthorize("@ss.hasPermission('bpm:task:query')")
  221 + public CommonResult<List<BpmTaskRespVO>> getTaskListByParentTaskId(@RequestParam("parentTaskId") String parentTaskId) {
  222 + List<Task> taskList = taskService.getTaskListByParentTaskId(parentTaskId);
  223 + if (CollUtil.isEmpty(taskList)) {
  224 + return success(Collections.emptyList());
  225 + }
  226 + // 拼接数据
  227 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  228 + convertSetByFlatMap(taskList, user -> Stream.of(Long.valueOf(user.getAssignee()), Long.valueOf(user.getOwner()))));
  229 + return success(convertList(taskList, task -> BeanUtils.toBean(task, BpmTaskRespVO.class, taskVO -> {
  230 + taskVO.setAssigneeUser(BeanUtils.toBean(userMap.get(NumberUtils.parseLong(task.getAssignee())), BpmProcessInstanceRespVO.User.class));
  231 + taskVO.setOwnerUser(BeanUtils.toBean(userMap.get(NumberUtils.parseLong(task.getOwner())), BpmProcessInstanceRespVO.User.class));
  232 + })));
123 } 233 }
124 234
125 } 235 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageItemRespVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 -import java.time.LocalDateTime;  
9 -  
10 -@Schema(description = "管理后台 - 流程任务的 Done 已完成的分页项 Response VO")  
11 -@Data  
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class BpmTaskDonePageItemRespVO extends BpmTaskTodoPageItemRespVO {  
15 -  
16 - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)  
17 - private LocalDateTime endTime;  
18 - @Schema(description = "持续时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")  
19 - private Long durationInMillis;  
20 -  
21 - @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")  
22 - private Integer status; // 参见 BpmProcessInstanceResultEnum 枚举  
23 -  
24 - @Schema(description = "审批建议", requiredMode = Schema.RequiredMode.REQUIRED, example = "不请假了!")  
25 - private String reason;  
26 -  
27 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskDonePageReqVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageParam;  
4 -import io.swagger.v3.oas.annotations.media.Schema;  
5 -import lombok.Data;  
6 -import lombok.EqualsAndHashCode;  
7 -import lombok.ToString;  
8 -import org.springframework.format.annotation.DateTimeFormat;  
9 -  
10 -import java.time.LocalDateTime;  
11 -  
12 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
13 -  
14 -@Schema(description = "管理后台 - 流程任务的 Done 已办的分页 Request VO")  
15 -@Data  
16 -@EqualsAndHashCode(callSuper = true)  
17 -@ToString(callSuper = true)  
18 -public class BpmTaskDonePageReqVO extends PageParam {  
19 -  
20 - @Schema(description = "流程任务名", example = "芋道")  
21 - private String name;  
22 -  
23 - @Schema(description = "开始的创建收间")  
24 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
25 - private LocalDateTime beginCreateTime;  
26 -  
27 - @Schema(description = "结束的创建时间")  
28 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
29 - private LocalDateTime endCreateTime;  
30 -  
31 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageReqVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskPageReqVO.java
@@ -10,13 +10,11 @@ import org.springframework.format.annotation.DateTimeFormat; @@ -10,13 +10,11 @@ import org.springframework.format.annotation.DateTimeFormat;
10 10
11 import java.time.LocalDateTime; 11 import java.time.LocalDateTime;
12 12
13 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
14 -  
15 -@Schema(description = "管理后台 - 流程任务的 TODO 待办的分页 Request VO") 13 +@Schema(description = "管理后台 - 流程任务的的分页 Request VO") // 待办、已办,都使用该分页
16 @Data 14 @Data
17 @EqualsAndHashCode(callSuper = true) 15 @EqualsAndHashCode(callSuper = true)
18 @ToString(callSuper = true) 16 @ToString(callSuper = true)
19 -public class BpmTaskTodoPageReqVO extends PageParam { 17 +public class BpmTaskPageReqVO extends PageParam {
20 18
21 @Schema(description = "流程任务名", example = "芋道") 19 @Schema(description = "流程任务名", example = "芋道")
22 private String name; 20 private String name;
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java
1 package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; 1 package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
2 2
  3 +import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceRespVO;
3 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 5 import lombok.Data;
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 6
  7 +import java.time.LocalDateTime;
8 import java.util.List; 8 import java.util.List;
9 9
10 -@Schema(description = "管理后台 - 流程任务的 Response VO") 10 +@Schema(description = "管理后台 - 流程任务 Response VO")
11 @Data 11 @Data
12 -@EqualsAndHashCode(callSuper = true)  
13 -@ToString(callSuper = true)  
14 -public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO { 12 +public class BpmTaskRespVO {
15 13
16 - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "user-001")  
17 - private String definitionKey; 14 + @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  15 + private String id;
  16 +
  17 + @Schema(description = "任务名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
  18 + private String name;
  19 +
  20 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  21 + private LocalDateTime createTime;
  22 +
  23 + @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
  24 + private LocalDateTime endTime;
18 25
  26 + @Schema(description = "持续时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
  27 + private Long durationInMillis;
  28 +
  29 + @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  30 + private Integer status; // 参见 BpmProcessInstanceResultEnum 枚举
  31 +
  32 + /**
  33 + * 负责人的用户信息
  34 + */
  35 + private BpmProcessInstanceRespVO.User ownerUser;
19 /** 36 /**
20 * 审核的用户信息 37 * 审核的用户信息
21 */ 38 */
22 - private User assigneeUser; 39 + private BpmProcessInstanceRespVO.User assigneeUser;
  40 +
  41 + // TODO @芋艿:这个 key 有点问题,应该是 taskDefinitionId
  42 + @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "user-001")
  43 + private String definitionKey;
  44 + @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one")
  45 + private String taskDefinitionKey;
  46 +
  47 + @Schema(description = "所属流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8888")
  48 + private String processInstanceId;
23 49
24 /** 50 /**
25 - * 父任务ID 51 + * 所属流程实例
26 */ 52 */
  53 + private ProcessInstance processInstance;
  54 +
  55 + @Schema(description = "父任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
27 private String parentTaskId; 56 private String parentTaskId;
28 57
29 - @Schema(description = "子任务(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask") 58 + @Schema(description = "子任务列表(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask")
30 private List<BpmTaskRespVO> children; 59 private List<BpmTaskRespVO> children;
31 60
32 - @Schema(description = "用户信息")  
33 @Data 61 @Data
34 - public static class User { 62 + @Schema(description = "流程实例")
  63 + public static class ProcessInstance {
35 64
36 - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
37 - private Long id;  
38 - @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")  
39 - private String nickname; 65 + @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  66 + private String id;
40 67
41 - @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
42 - private Long deptId;  
43 - @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "研发部")  
44 - private String deptName; 68 + @Schema(description = "流程实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
  69 + private String name;
  70 +
  71 + @Schema(description = "提交时间", requiredMode = Schema.RequiredMode.REQUIRED)
  72 + private LocalDateTime createTime;
  73 +
  74 + @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
  75 + private String processDefinitionId;
  76 +
  77 + /**
  78 + * 发起人的用户信息
  79 + */
  80 + private BpmProcessInstanceRespVO.User startUser;
45 81
46 } 82 }
  83 +
47 } 84 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java
@@ -15,7 +15,7 @@ public class BpmTaskReturnReqVO { @@ -15,7 +15,7 @@ public class BpmTaskReturnReqVO {
15 15
16 @Schema(description = "回退到的任务 Key", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 16 @Schema(description = "回退到的任务 Key", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
17 @NotEmpty(message = "回退到的任务 Key 不能为空") 17 @NotEmpty(message = "回退到的任务 Key 不能为空")
18 - private String targetDefinitionKey; 18 + private String targetTaskDefinitionKey;
19 19
20 @Schema(description = "回退意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "我就是想驳回") 20 @Schema(description = "回退意见", requiredMode = Schema.RequiredMode.REQUIRED, example = "我就是想驳回")
21 @NotEmpty(message = "回退意见不能为空") 21 @NotEmpty(message = "回退意见不能为空")
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSimpleRespVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -@Schema(description = "管理后台 - 流程任务的精简 Response VO")  
7 -@Data  
8 -public class BpmTaskSimpleRespVO {  
9 -  
10 - @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one")  
11 - private String definitionKey;  
12 -  
13 - @Schema(description = "任务名词", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批")  
14 - private String name;  
15 -  
16 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSubSignRespVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -@Schema(description = "管理后台 - 减签流程任务的 Response VO")  
7 -@Data  
8 -public class BpmTaskSubSignRespVO {  
9 -  
10 - @Schema(description = "审核的用户信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "小李")  
11 - private BpmTaskRespVO.User assigneeUser;  
12 -  
13 - @Schema(description = "任务 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12312")  
14 - private String id;  
15 -  
16 - @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批")  
17 - private String name;  
18 -  
19 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskTodoPageItemRespVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -  
6 -import java.time.LocalDateTime;  
7 -  
8 -@Schema(description = "管理后台 - 流程任务的 Running 进行中的分页项 Response VO")  
9 -@Data  
10 -public class BpmTaskTodoPageItemRespVO {  
11 -  
12 - @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
13 - private String id;  
14 -  
15 - @Schema(description = "任务名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")  
16 - private String name;  
17 -  
18 - @Schema(description = "接收时间", requiredMode = Schema.RequiredMode.REQUIRED)  
19 - private LocalDateTime claimTime;  
20 -  
21 - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)  
22 - private LocalDateTime createTime;  
23 -  
24 - @Schema(description = "激活状态-参见 SuspensionState 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")  
25 - private Integer suspensionState;  
26 -  
27 - /**  
28 - * 所属流程实例  
29 - */  
30 - private ProcessInstance processInstance;  
31 -  
32 - @Data  
33 - @Schema(description = "流程实例")  
34 - public static class ProcessInstance {  
35 -  
36 - @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
37 - private String id;  
38 -  
39 - @Schema(description = "流程实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")  
40 - private String name;  
41 -  
42 - @Schema(description = "发起人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
43 - private Long startUserId;  
44 -  
45 - @Schema(description = "发起人的用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")  
46 - private String startUserNickname;  
47 -  
48 - @Schema(description = "流程定义的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")  
49 - private String processDefinitionId;  
50 -  
51 - }  
52 -  
53 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
1 package cn.iocoder.yudao.module.bpm.convert.task; 1 package cn.iocoder.yudao.module.bpm.convert.task;
2 2
3 -import cn.hutool.core.util.ObjectUtil;  
4 -import cn.hutool.core.util.StrUtil;  
5 -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;  
6 -import cn.iocoder.yudao.framework.common.util.collection.MapUtils;  
7 import cn.iocoder.yudao.framework.common.util.date.DateUtils; 3 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
8 import cn.iocoder.yudao.framework.common.util.number.NumberUtils; 4 import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
9 -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;  
10 -import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;  
11 import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; 5 import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
12 -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;  
13 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 6 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
14 -import org.flowable.bpmn.model.FlowElement;  
15 -import org.flowable.common.engine.impl.db.SuspensionState;  
16 -import org.flowable.engine.history.HistoricProcessInstance;  
17 import org.flowable.engine.runtime.ProcessInstance; 7 import org.flowable.engine.runtime.ProcessInstance;
18 import org.flowable.task.api.Task; 8 import org.flowable.task.api.Task;
19 -import org.flowable.task.api.history.HistoricTaskInstance;  
20 import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; 9 import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
21 import org.mapstruct.Mapper; 10 import org.mapstruct.Mapper;
22 -import org.mapstruct.Mapping;  
23 -import org.mapstruct.Mappings;  
24 -import org.mapstruct.Named;  
25 import org.mapstruct.factory.Mappers; 11 import org.mapstruct.factory.Mappers;
26 12
27 import java.util.Date; 13 import java.util.Date;
28 -import java.util.List;  
29 -import java.util.Map;  
30 -  
31 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap;  
32 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;  
33 14
34 /** 15 /**
35 * Bpm 任务 Convert 16 * Bpm 任务 Convert
@@ -41,91 +22,6 @@ public interface BpmTaskConvert { @@ -41,91 +22,6 @@ public interface BpmTaskConvert {
41 22
42 BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); 23 BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class);
43 24
44 - default List<BpmTaskTodoPageItemRespVO> convertList1(List<Task> tasks,  
45 - Map<String, ProcessInstance> processInstanceMap,  
46 - Map<Long, AdminUserRespDTO> userMap) {  
47 - return CollectionUtils.convertList(tasks, task -> {  
48 - BpmTaskTodoPageItemRespVO respVO = convert1(task);  
49 - ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId());  
50 - if (processInstance != null) {  
51 - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));  
52 - respVO.setProcessInstance(convert(processInstance, startUser));  
53 - }  
54 - return respVO;  
55 - });  
56 - }  
57 -  
58 - @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState")  
59 - BpmTaskTodoPageItemRespVO convert1(Task bean);  
60 -  
61 - @Named("convertSuspendedToSuspensionState")  
62 - default Integer convertSuspendedToSuspensionState(boolean suspended) {  
63 - return suspended ? SuspensionState.SUSPENDED.getStateCode() : SuspensionState.ACTIVE.getStateCode();  
64 - }  
65 -  
66 - default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks,  
67 - Map<String, HistoricProcessInstance> historicProcessInstanceMap,  
68 - Map<Long, AdminUserRespDTO> userMap) {  
69 - return CollectionUtils.convertList(tasks, task -> {  
70 - BpmTaskDonePageItemRespVO respVO = convert2(task);  
71 - respVO.setStatus((Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS));  
72 - // 流程实例  
73 - HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId());  
74 - if (processInstance != null) {  
75 - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));  
76 - respVO.setProcessInstance(convert(processInstance, startUser));  
77 - }  
78 - return respVO;  
79 - });  
80 - }  
81 -  
82 - BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean);  
83 -  
84 - @Mappings({  
85 - @Mapping(source = "processInstance.id", target = "id"),  
86 - @Mapping(source = "processInstance.name", target = "name"),  
87 - @Mapping(source = "processInstance.startUserId", target = "startUserId"),  
88 - @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),  
89 - @Mapping(source = "startUser.nickname", target = "startUserNickname")  
90 - })  
91 - BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser);  
92 -  
93 - default List<BpmTaskRespVO> convertList3(List<HistoricTaskInstance> tasks,  
94 - HistoricProcessInstance processInstance,  
95 - Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {  
96 - return CollectionUtils.convertList(tasks, task -> {  
97 - BpmTaskRespVO respVO = convert3(task);  
98 - respVO.setStatus((Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS));  
99 - // 流程实例  
100 - if (processInstance != null) {  
101 - AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId()));  
102 - respVO.setProcessInstance(convert(processInstance, startUser));  
103 - }  
104 - AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(task.getAssignee()));  
105 - if (assignUser != null) {  
106 - respVO.setAssigneeUser(convert3(assignUser));  
107 - DeptRespDTO dept = deptMap.get(assignUser.getDeptId());  
108 - if (dept != null) {  
109 - respVO.getAssigneeUser().setDeptName(dept.getName());  
110 - }  
111 - }  
112 - return respVO;  
113 - });  
114 - }  
115 -  
116 - @Mapping(source = "taskDefinitionKey", target = "definitionKey")  
117 - BpmTaskRespVO convert3(HistoricTaskInstance bean);  
118 -  
119 - BpmTaskRespVO.User convert3(AdminUserRespDTO bean);  
120 -  
121 - @Mappings({@Mapping(source = "processInstance.id", target = "id"),  
122 - @Mapping(source = "processInstance.name", target = "name"),  
123 - @Mapping(source = "processInstance.startUserId", target = "startUserId"),  
124 - @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),  
125 - @Mapping(source = "startUser.nickname", target = "startUserNickname")})  
126 - BpmTaskTodoPageItemRespVO.ProcessInstance convert(HistoricProcessInstance processInstance,  
127 - AdminUserRespDTO startUser);  
128 -  
129 default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser, 25 default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, AdminUserRespDTO startUser,
130 Task task) { 26 Task task) {
131 BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO(); 27 BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO();
@@ -136,12 +32,6 @@ public interface BpmTaskConvert { @@ -136,12 +32,6 @@ public interface BpmTaskConvert {
136 return reqDTO; 32 return reqDTO;
137 } 33 }
138 34
139 - default List<BpmTaskSimpleRespVO> convertList(List<? extends FlowElement> elementList) {  
140 - return CollectionUtils.convertList(elementList, element -> new BpmTaskSimpleRespVO()  
141 - .setName(element.getName())  
142 - .setDefinitionKey(element.getId()));  
143 - }  
144 -  
145 //此处不用 mapstruct 映射,因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的 35 //此处不用 mapstruct 映射,因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的
146 //使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题 36 //使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题
147 default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){ 37 default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){
@@ -160,33 +50,4 @@ public interface BpmTaskConvert { @@ -160,33 +50,4 @@ public interface BpmTaskConvert {
160 return task; 50 return task;
161 } 51 }
162 52
163 - default List<BpmTaskSubSignRespVO> convertList(List<Task> bpmTaskExtDOList,  
164 - Map<Long, AdminUserRespDTO> userMap){  
165 - return CollectionUtils.convertList(bpmTaskExtDOList, task -> {  
166 - BpmTaskSubSignRespVO bpmTaskSubSignRespVO = new BpmTaskSubSignRespVO()  
167 - .setId(task.getId()).setName(task.getName());  
168 - // 后加签任务不会直接设置 assignee ,所以不存在 assignee 的情况,则去取 owner  
169 -// Task sourceTask = idTaskMap.get(task.getTaskId());  
170 - String assignee = ObjectUtil.defaultIfBlank(task.getOwner(), task.getAssignee());  
171 - MapUtils.findAndThen(userMap,NumberUtils.parseLong(assignee),  
172 - assignUser-> bpmTaskSubSignRespVO.setAssigneeUser(convert3(assignUser)));  
173 - return bpmTaskSubSignRespVO;  
174 - });  
175 - }  
176 -  
177 - /**  
178 - * 转换任务为父子级  
179 - *  
180 - * @param sourceList 原始数据  
181 - * @return 转换后的父子级数组  
182 - */  
183 - default List<BpmTaskRespVO> convertChildrenList(List<BpmTaskRespVO> sourceList) {  
184 - List<BpmTaskRespVO> childrenTaskList = filterList(sourceList, r -> StrUtil.isNotEmpty(r.getParentTaskId()));  
185 - Map<String, List<BpmTaskRespVO>> parentChildrenTaskListMap = convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId);  
186 - for (BpmTaskRespVO bpmTaskRespVO : sourceList) {  
187 - bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId()));  
188 - }  
189 - return filterList(sourceList, r -> StrUtil.isEmpty(r.getParentTaskId()));  
190 - }  
191 -  
192 } 53 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmTaskExtDO.java deleted
1 -package cn.iocoder.yudao.module.bpm.dal.dataobject.task;  
2 -  
3 -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;  
4 -import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;  
5 -import com.baomidou.mybatisplus.annotation.TableId;  
6 -import com.baomidou.mybatisplus.annotation.TableName;  
7 -import lombok.Data;  
8 -import lombok.EqualsAndHashCode;  
9 -import lombok.ToString;  
10 -  
11 -import java.time.LocalDateTime;  
12 -  
13 -/**  
14 - * Bpm 流程任务的拓展表  
15 - * 主要解决 Flowable Task 和 HistoricTaskInstance 不支持拓展字段,所以新建拓展表  
16 - *  
17 - * @author 芋道源码  
18 - */  
19 -@TableName(value = "bpm_task_ext", autoResultMap = true)  
20 -@Data  
21 -@EqualsAndHashCode(callSuper = true)  
22 -@ToString(callSuper = true)  
23 -@Deprecated  
24 -public class BpmTaskExtDO extends BaseDO {  
25 -  
26 - /**  
27 - * 编号,自增  
28 - */  
29 - @TableId  
30 - private Long id;  
31 -  
32 - /**  
33 - * 任务的审批人  
34 - *  
35 - * 冗余 Task 的 assignee 属性  
36 - */  
37 - private Long assigneeUserId;  
38 - /**  
39 - * 任务的名字  
40 - *  
41 - * 冗余 Task 的 name 属性,为了筛选  
42 - */  
43 - private String name;  
44 - /**  
45 - * 任务的编号  
46 - *  
47 - * 关联 Task 的 id 属性  
48 - */  
49 - private String taskId;  
50 -// /**  
51 -// * 任务的标识  
52 -// *  
53 -// * 关联 {@link Task#getTaskDefinitionKey()}  
54 -// */  
55 -// private String definitionKey;  
56 - /**  
57 - * 任务的结果  
58 - *  
59 - * 枚举 {@link BpmProcessInstanceResultEnum}  
60 - */  
61 - private Integer result;  
62 - /**  
63 - * 审批建议  
64 - */  
65 - @Deprecated  
66 - private String reason;  
67 - /**  
68 - * 任务的结束时间  
69 - *  
70 - * 冗余 HistoricTaskInstance 的 endTime 属性  
71 - */  
72 - private LocalDateTime endTime;  
73 -  
74 - /**  
75 - * 流程实例的编号  
76 - *  
77 - * 关联 ProcessInstance 的 id 属性  
78 - */  
79 - private String processInstanceId;  
80 - /**  
81 - * 流程定义的编号  
82 - *  
83 - * 关联 ProcessDefinition 的 id 属性  
84 - */  
85 - private String processDefinitionId;  
86 -  
87 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java deleted
1 -package cn.iocoder.yudao.module.bpm.dal.mysql.task;  
2 -  
3 -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;  
4 -import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;  
5 -import org.apache.ibatis.annotations.Mapper;  
6 -  
7 -@Mapper  
8 -public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {  
9 -  
10 -// default void updateByTaskId(BpmTaskExtDO entity) {  
11 -// update(entity, new LambdaQueryWrapper<BpmTaskExtDO>().eq(BpmTaskExtDO::getTaskId, entity.getTaskId()));  
12 -// }  
13 -  
14 -// default List<BpmTaskExtDO> selectListByTaskIds(Collection<String> taskIds) {  
15 -// return selectList(BpmTaskExtDO::getTaskId, taskIds);  
16 -// }  
17 -  
18 - // TODO @海:BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST) 应该作为条件,mapper 不要有业务  
19 -// default List<BpmTaskExtDO> selectProcessListByTaskIds(Collection<String> taskIds) {  
20 -// return selectList(new LambdaQueryWrapperX<BpmTaskExtDO>()  
21 -// .in(BpmTaskExtDO::getTaskId, taskIds)  
22 -// .in(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST));  
23 -// }  
24 -  
25 -// default BpmTaskExtDO selectByTaskId(String taskId) {  
26 -// return selectOne(BpmTaskExtDO::getTaskId, taskId);  
27 -// }  
28 -  
29 -// default void updateBatchByTaskIdList(List<String> taskIdList, BpmTaskExtDO updateObj) {  
30 -// update(updateObj, new LambdaQueryWrapper<BpmTaskExtDO>().in(BpmTaskExtDO::getTaskId, taskIdList));  
31 -// }  
32 -  
33 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java
@@ -4,7 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -4,7 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; 4 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
5 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; 5 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
6 import jakarta.validation.Valid; 6 import jakarta.validation.Valid;
  7 +import org.flowable.bpmn.model.UserTask;
7 import org.flowable.task.api.Task; 8 import org.flowable.task.api.Task;
  9 +import org.flowable.task.api.history.HistoricTaskInstance;
8 10
9 import java.util.Collection; 11 import java.util.Collection;
10 import java.util.List; 12 import java.util.List;
@@ -25,7 +27,7 @@ public interface BpmTaskService { @@ -25,7 +27,7 @@ public interface BpmTaskService {
25 * @param pageReqVO 分页请求 27 * @param pageReqVO 分页请求
26 * @return 流程任务分页 28 * @return 流程任务分页
27 */ 29 */
28 - PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); 30 + PageResult<Task> getTodoTaskPage(Long userId, BpmTaskPageReqVO pageReqVO);
29 31
30 /** 32 /**
31 * 获得已办的流程任务分页 33 * 获得已办的流程任务分页
@@ -34,7 +36,7 @@ public interface BpmTaskService { @@ -34,7 +36,7 @@ public interface BpmTaskService {
34 * @param pageReqVO 分页请求 36 * @param pageReqVO 分页请求
35 * @return 流程任务分页 37 * @return 流程任务分页
36 */ 38 */
37 - PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); 39 + PageResult<HistoricTaskInstance> getDoneTaskPage(Long userId, BpmTaskPageReqVO pageReqVO);
38 40
39 /** 41 /**
40 * 获得流程任务 Map 42 * 获得流程任务 Map
@@ -56,12 +58,12 @@ public interface BpmTaskService { @@ -56,12 +58,12 @@ public interface BpmTaskService {
56 List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds); 58 List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds);
57 59
58 /** 60 /**
59 - * 获得指令流程实例的流程任务列表,包括所有状态的 61 + * 获得指定流程实例的流程任务列表,包括所有状态的
60 * 62 *
61 * @param processInstanceId 流程实例的编号 63 * @param processInstanceId 流程实例的编号
62 * @return 流程任务列表 64 * @return 流程任务列表
63 */ 65 */
64 - List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId); 66 + List<HistoricTaskInstance> getTaskListByProcessInstanceId(String processInstanceId);
65 67
66 /** 68 /**
67 * 通过任务 69 * 通过任务
@@ -126,12 +128,12 @@ public interface BpmTaskService { @@ -126,12 +128,12 @@ public interface BpmTaskService {
126 Task getTask(String id); 128 Task getTask(String id);
127 129
128 /** 130 /**
129 - * 获取当前任务的可回退的流程集合 131 + * 获取当前任务的可回退的 UserTask 集合
130 * 132 *
131 - * @param taskId 当前的任务 ID 133 + * @param id 当前的任务 ID
132 * @return 可以回退的节点列表 134 * @return 可以回退的节点列表
133 */ 135 */
134 - List<BpmTaskSimpleRespVO> getReturnTaskList(String taskId); 136 + List<UserTask> getUserTaskListByReturn(String id);
135 137
136 /** 138 /**
137 * 将任务回退到指定的 targetDefinitionKey 位置 139 * 将任务回退到指定的 targetDefinitionKey 位置
@@ -158,7 +160,7 @@ public interface BpmTaskService { @@ -158,7 +160,7 @@ public interface BpmTaskService {
158 void createSignTask(Long userId, BpmTaskAddSignReqVO reqVO); 160 void createSignTask(Long userId, BpmTaskAddSignReqVO reqVO);
159 161
160 /** 162 /**
161 - * 任务减签名 163 + * 任务减签
162 * 164 *
163 * @param userId 当前用户ID 165 * @param userId 当前用户ID
164 * @param reqVO 被减签的任务 ID,理由 166 * @param reqVO 被减签的任务 ID,理由
@@ -166,12 +168,12 @@ public interface BpmTaskService { @@ -166,12 +168,12 @@ public interface BpmTaskService {
166 void deleteSignTask(Long userId, BpmTaskSubSignReqVO reqVO); 168 void deleteSignTask(Long userId, BpmTaskSubSignReqVO reqVO);
167 169
168 /** 170 /**
169 - * 获取指定任务的子任务和审批人信息 171 + * 获取指定任务的子任务列表
170 * 172 *
171 - * @param parentId 指定任务ID 173 + * @param parentTaskId 父任务ID
172 * @return 子任务列表 174 * @return 子任务列表
173 */ 175 */
174 - List<BpmTaskSubSignRespVO> getChildrenTaskList(String parentId); 176 + List<Task> getTaskListByParentTaskId(String parentTaskId);
175 177
176 /** 178 /**
177 * 通过任务 ID,查询任务名 Map 179 * 通过任务 ID,查询任务名 Map
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
@@ -13,15 +13,12 @@ import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; @@ -13,15 +13,12 @@ import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils;
13 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; 13 import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
14 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; 14 import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
15 import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; 15 import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
16 -import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper;  
17 import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; 16 import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum;
18 import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; 17 import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
19 import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum; 18 import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum;
20 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants; 19 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
21 import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; 20 import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
22 import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; 21 import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
23 -import cn.iocoder.yudao.module.system.api.dept.DeptApi;  
24 -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;  
25 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 22 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
26 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 23 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
27 import jakarta.annotation.Resource; 24 import jakarta.annotation.Resource;
@@ -34,7 +31,6 @@ import org.flowable.engine.HistoryService; @@ -34,7 +31,6 @@ import org.flowable.engine.HistoryService;
34 import org.flowable.engine.ManagementService; 31 import org.flowable.engine.ManagementService;
35 import org.flowable.engine.RuntimeService; 32 import org.flowable.engine.RuntimeService;
36 import org.flowable.engine.TaskService; 33 import org.flowable.engine.TaskService;
37 -import org.flowable.engine.history.HistoricProcessInstance;  
38 import org.flowable.engine.runtime.ProcessInstance; 34 import org.flowable.engine.runtime.ProcessInstance;
39 import org.flowable.task.api.DelegationState; 35 import org.flowable.task.api.DelegationState;
40 import org.flowable.task.api.Task; 36 import org.flowable.task.api.Task;
@@ -50,10 +46,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager @@ -50,10 +46,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
50 import org.springframework.util.Assert; 46 import org.springframework.util.Assert;
51 47
52 import java.util.*; 48 import java.util.*;
53 -import java.util.stream.Stream;  
54 49
55 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 50 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
56 -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; 51 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
  52 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
57 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; 53 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
58 54
59 /** 55 /**
@@ -82,49 +78,31 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -82,49 +78,31 @@ public class BpmTaskServiceImpl implements BpmTaskService {
82 78
83 @Resource 79 @Resource
84 private AdminUserApi adminUserApi; 80 private AdminUserApi adminUserApi;
85 - @Resource  
86 - private DeptApi deptApi;  
87 -  
88 - @Resource  
89 - private BpmTaskExtMapper taskExtMapper;  
90 81
91 @Resource 82 @Resource
92 private ManagementService managementService; 83 private ManagementService managementService;
93 84
94 @Override 85 @Override
95 - public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {  
96 - // 查询待办任务 86 + public PageResult<Task> getTodoTaskPage(Long userId, BpmTaskPageReqVO pageVO) {
97 TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(String.valueOf(userId)) // 分配给自己 87 TaskQuery taskQuery = taskService.createTaskQuery().taskAssignee(String.valueOf(userId)) // 分配给自己
98 .orderByTaskCreateTime().desc(); // 创建时间倒序 88 .orderByTaskCreateTime().desc(); // 创建时间倒序
99 if (StrUtil.isNotBlank(pageVO.getName())) { 89 if (StrUtil.isNotBlank(pageVO.getName())) {
100 taskQuery.taskNameLike("%" + pageVO.getName() + "%"); 90 taskQuery.taskNameLike("%" + pageVO.getName() + "%");
101 } 91 }
102 - if (ArrayUtil.get(pageVO.getCreateTime(), 0) != null) { 92 + if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
103 taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); 93 taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
  94 + taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1]));
104 } 95 }
105 - if (ArrayUtil.get(pageVO.getCreateTime(), 1) != null) {  
106 - taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1])); 96 + long count = taskQuery.count();
  97 + if (count == 0) {
  98 + return PageResult.empty();
107 } 99 }
108 - // 执行查询  
109 List<Task> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize()); 100 List<Task> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
110 - if (CollUtil.isEmpty(tasks)) {  
111 - return PageResult.empty(taskQuery.count());  
112 - }  
113 -  
114 - // 获得 ProcessInstance Map  
115 - Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(  
116 - convertSet(tasks, Task::getProcessInstanceId));  
117 - // 获得 User Map  
118 - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(  
119 - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));  
120 - // 拼接结果  
121 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap),  
122 - taskQuery.count()); 101 + return new PageResult<>(tasks, count);
123 } 102 }
124 103
125 @Override 104 @Override
126 - public PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) {  
127 - // 查询已办任务 105 + public PageResult<HistoricTaskInstance> getDoneTaskPage(Long userId, BpmTaskPageReqVO pageVO) {
128 HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().finished() // 已完成 106 HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().finished() // 已完成
129 .includeTaskLocalVariables() 107 .includeTaskLocalVariables()
130 .taskAssignee(String.valueOf(userId)) // 分配给自己 108 .taskAssignee(String.valueOf(userId)) // 分配给自己
@@ -132,29 +110,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -132,29 +110,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
132 if (StrUtil.isNotBlank(pageVO.getName())) { 110 if (StrUtil.isNotBlank(pageVO.getName())) {
133 taskQuery.taskNameLike("%" + pageVO.getName() + "%"); 111 taskQuery.taskNameLike("%" + pageVO.getName() + "%");
134 } 112 }
135 - // TODO @芋艿:传参风格,统一  
136 - if (pageVO.getBeginCreateTime() != null) {  
137 - taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getBeginCreateTime()));  
138 - }  
139 - if (pageVO.getEndCreateTime() != null) {  
140 - taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getEndCreateTime())); 113 + if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
  114 + taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
  115 + taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1]));
141 } 116 }
142 // 执行查询 117 // 执行查询
143 - List<HistoricTaskInstance> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());  
144 - if (CollUtil.isEmpty(tasks)) {  
145 - return PageResult.empty(taskQuery.count()); 118 + long count = taskQuery.count();
  119 + if (count == 0) {
  120 + return PageResult.empty();
146 } 121 }
147 -  
148 - // 获得 ProcessInstance Map  
149 - Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap(  
150 - convertSet(tasks, HistoricTaskInstance::getProcessInstanceId));  
151 - // 获得 User Map  
152 - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(  
153 - convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));  
154 - // 拼接结果  
155 - return new PageResult<>(  
156 - BpmTaskConvert.INSTANCE.convertList2(tasks, historicProcessInstanceMap, userMap),  
157 - taskQuery.count()); 122 + List<HistoricTaskInstance> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
  123 + return new PageResult<>(tasks, count);
158 } 124 }
159 125
160 @Override 126 @Override
@@ -166,8 +132,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -166,8 +132,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
166 } 132 }
167 133
168 @Override 134 @Override
169 - public List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId) {  
170 - // 获得任务列表 135 + public List<HistoricTaskInstance> getTaskListByProcessInstanceId(String processInstanceId) {
171 List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery() 136 List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery()
172 .includeTaskLocalVariables() 137 .includeTaskLocalVariables()
173 .processInstanceId(processInstanceId) 138 .processInstanceId(processInstanceId)
@@ -176,19 +141,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -176,19 +141,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
176 if (CollUtil.isEmpty(tasks)) { 141 if (CollUtil.isEmpty(tasks)) {
177 return Collections.emptyList(); 142 return Collections.emptyList();
178 } 143 }
179 -  
180 - // 获得 ProcessInstance Map  
181 - HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(processInstanceId);  
182 - // 获得 User Map  
183 - Set<Long> userIds = convertSet(tasks, task -> NumberUtils.parseLong(task.getAssignee()));  
184 - userIds.add(NumberUtils.parseLong(processInstance.getStartUserId()));  
185 - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);  
186 - // 获得 Dept Map  
187 - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));  
188 -  
189 - // 拼接数据  
190 - List<BpmTaskRespVO> result = BpmTaskConvert.INSTANCE.convertList3(tasks, processInstance, userMap, deptMap);  
191 - return BpmTaskConvert.INSTANCE.convertChildrenList(result); 144 + return tasks;
192 } 145 }
193 146
194 @Override 147 @Override
@@ -531,10 +484,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -531,10 +484,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
531 } 484 }
532 485
533 @Override 486 @Override
534 - public List<BpmTaskSimpleRespVO> getReturnTaskList(String taskId) {  
535 - // 1. 校验当前任务 task 存在  
536 - Task task = validateTaskExist(taskId);  
537 - // 根据流程定义获取流程模型信息 487 + public List<UserTask> getUserTaskListByReturn(String id) {
  488 + // 1.1 校验当前任务 task 存在
  489 + Task task = validateTaskExist(id);
  490 + // 1.2 根据流程定义获取流程模型信息
538 BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); 491 BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId());
539 FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); 492 FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
540 if (source == null) { 493 if (source == null) {
@@ -548,7 +501,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -548,7 +501,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
548 } 501 }
549 // 2.2 过滤:只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回 502 // 2.2 过滤:只有串行可到达的节点,才可以回退。类似非串行、子流程无法退回
550 previousUserList.removeIf(userTask -> !BpmnModelUtils.isSequentialReachable(source, userTask, null)); 503 previousUserList.removeIf(userTask -> !BpmnModelUtils.isSequentialReachable(source, userTask, null));
551 - return BpmTaskConvert.INSTANCE.convertList(previousUserList); 504 + return previousUserList;
552 } 505 }
553 506
554 @Override 507 @Override
@@ -560,7 +513,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -560,7 +513,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
560 throw exception(TASK_IS_PENDING); 513 throw exception(TASK_IS_PENDING);
561 } 514 }
562 // 1.2 校验源头和目标节点的关系,并返回目标元素 515 // 1.2 校验源头和目标节点的关系,并返回目标元素
563 - FlowElement targetElement = validateTargetTaskCanReturn(task.getTaskDefinitionKey(), reqVO.getTargetDefinitionKey(), task.getProcessDefinitionId()); 516 + FlowElement targetElement = validateTargetTaskCanReturn(task.getTaskDefinitionKey(), reqVO.getTargetTaskDefinitionKey(), task.getProcessDefinitionId());
564 517
565 // 3. 更新任务扩展表 TODO 芋艿:需要提前搞 518 // 3. 更新任务扩展表 TODO 芋艿:需要提前搞
566 updateTaskStatus(task.getId(), BpmProcessInstanceResultEnum.BACK.getResult()); 519 updateTaskStatus(task.getId(), BpmProcessInstanceResultEnum.BACK.getResult());
@@ -635,7 +588,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -635,7 +588,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
635 runtimeService.createChangeActivityStateBuilder() 588 runtimeService.createChangeActivityStateBuilder()
636 .processInstanceId(currentTask.getProcessInstanceId()) 589 .processInstanceId(currentTask.getProcessInstanceId())
637 .moveActivityIdsToSingleActivityId(returnTaskKeyList, // 当前要跳转的节点列表( 1 或多) 590 .moveActivityIdsToSingleActivityId(returnTaskKeyList, // 当前要跳转的节点列表( 1 或多)
638 - reqVO.getTargetDefinitionKey()) // targetKey 跳转到的节点(1) 591 + reqVO.getTargetTaskDefinitionKey()) // targetKey 跳转到的节点(1)
639 .changeState(); 592 .changeState();
640 } 593 }
641 594
@@ -877,6 +830,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -877,6 +830,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
877 return StrUtil.equalsAny(scopeType,BpmTaskAddSignTypeEnum.BEFORE.getType(),scopeType, BpmTaskAddSignTypeEnum.AFTER.getType()); 830 return StrUtil.equalsAny(scopeType,BpmTaskAddSignTypeEnum.BEFORE.getType(),scopeType, BpmTaskAddSignTypeEnum.AFTER.getType());
878 } 831 }
879 832
  833 +// TODO @海:BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST) 应该作为条件,mapper 不要有业务
880 /** 834 /**
881 * 获取所有要被取消的删除的任务 ID 集合 835 * 获取所有要被取消的删除的任务 ID 集合
882 * 836 *
@@ -918,42 +872,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -918,42 +872,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
918 * @return 所有子任务的 ID 集合 872 * @return 所有子任务的 ID 集合
919 */ 873 */
920 private List<String> getChildrenTaskIdList(String parentTaskId) { 874 private List<String> getChildrenTaskIdList(String parentTaskId) {
921 - return convertList(getChildrenTaskList0(parentTaskId), Task::getId); 875 + return convertList(getTaskListByParentTaskId(parentTaskId), Task::getId);
922 } 876 }
923 877
924 - /**  
925 - * 获取指定父级任务的所有子任务 ID 集合  
926 - *  
927 - * @param parentTaskId 父任务 ID  
928 - * @return 所有子任务的 ID 集合  
929 - */  
930 - private List<Task> getChildrenTaskList0(String parentTaskId) { 878 + @Override
  879 + public List<Task> getTaskListByParentTaskId(String parentTaskId) {
931 String tableName = managementService.getTableName(TaskEntity.class); 880 String tableName = managementService.getTableName(TaskEntity.class);
932 // taskService.createTaskQuery() 没有 parentId 参数,所以写 sql 查询 881 // taskService.createTaskQuery() 没有 parentId 参数,所以写 sql 查询
933 String sql = "select ID_,OWNER_,ASSIGNEE_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; 882 String sql = "select ID_,OWNER_,ASSIGNEE_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}";
934 return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); 883 return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list();
935 } 884 }
936 885
937 -  
938 - @Override  
939 - public List<BpmTaskSubSignRespVO> getChildrenTaskList(String parentId) {  
940 - // 1. 只查询进行中的任务 后加签的任务,可能不存在 assignee,所以还需要查询 owner  
941 - List<Task> taskList = getChildrenTaskList0(parentId);  
942 - if (CollUtil.isEmpty(taskList)) {  
943 - return Collections.emptyList();  
944 - }  
945 -  
946 - // 2.1 将 owner 和 assignee 统一到一个集合中  
947 - List<Long> userIds = convertListByFlatMap(taskList, control ->  
948 - Stream.of(NumberUtils.parseLong(control.getAssignee()), NumberUtils.parseLong(control.getOwner()))  
949 - .filter(Objects::nonNull)); // TODO 芋艿:这里可能可以优化下  
950 - // 2.2 组装数据  
951 - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);  
952 -// List<BpmTaskExtDO> taskExtList = taskExtMapper.selectProcessListByTaskIds(childrenTaskIdList);  
953 -// Map<String, Task> idTaskMap = convertMap(taskList, TaskInfo::getId);  
954 - return BpmTaskConvert.INSTANCE.convertList(taskList, userMap);  
955 - }  
956 -  
957 @Override 886 @Override
958 public Map<String, String> getTaskNameByTaskIds(Collection<String> taskIds) { 887 public Map<String, String> getTaskNameByTaskIds(Collection<String> taskIds) {
959 if (CollUtil.isEmpty(taskIds)) { 888 if (CollUtil.isEmpty(taskIds)) {