Commit 921f99d39d8aa41771d9785174eb71b313a1c97c
1 parent
b13f7142
fix: 方法,变量名词,注释规范
Showing
7 changed files
with
46 additions
and
52 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
| @@ -46,10 +46,10 @@ public interface ErrorCodeConstants { | @@ -46,10 +46,10 @@ public interface ErrorCodeConstants { | ||
| 46 | ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1_009_005_000, "审批任务失败,原因:该任务不处于未审批"); | 46 | ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1_009_005_000, "审批任务失败,原因:该任务不处于未审批"); |
| 47 | ErrorCode TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "审批任务失败,原因:该任务的审批人不是你"); | 47 | ErrorCode TASK_COMPLETE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "审批任务失败,原因:该任务的审批人不是你"); |
| 48 | ErrorCode TASK_NOT_EXISTS = new ErrorCode(1_009_005_002, "流程任务不存在"); | 48 | ErrorCode TASK_NOT_EXISTS = new ErrorCode(1_009_005_002, "流程任务不存在"); |
| 49 | - ErrorCode TASK_IS_NOT_ACTIVITY = new ErrorCode(1_009_005_003, "当前任务不属于活动状态,不能操作"); | ||
| 50 | - ErrorCode TASK_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_004, " 当前节点相对于目标节点,不属于串行关系,无法回退"); | 49 | + ErrorCode TASK_IS_PENDING = new ErrorCode(1_009_005_003, "当前任务处于挂起状态,不能操作"); |
| 50 | + ErrorCode TASK_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_004, "目标节点是在并行网关上或非同一路线上,不可跳转"); | ||
| 51 | ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_005, " 目标节点不存在"); | 51 | ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_005, " 目标节点不存在"); |
| 52 | - ErrorCode TASK_ROLLBACK_FAIL = new ErrorCode(1_009_005_006, "回退任务失败,选择回退的节点没有需要回滚的任务!请重新选择其他任务节点"); | 52 | + ErrorCode TASK_RETURN_FAIL = new ErrorCode(1_009_005_006, "回退任务失败,选择回退的节点没有需要回滚的任务!请重新选择其他任务节点"); |
| 53 | // ========== 流程任务分配规则 1-009-006-000 ========== | 53 | // ========== 流程任务分配规则 1-009-006-000 ========== |
| 54 | ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1_009_006_000, "流程({}) 的任务({}) 已经存在分配规则"); | 54 | ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1_009_006_000, "流程({}) 的任务({}) 已经存在分配规则"); |
| 55 | ErrorCode TASK_ASSIGN_RULE_NOT_EXISTS = new ErrorCode(1_009_006_001, "流程任务分配规则不存在"); | 55 | ErrorCode TASK_ASSIGN_RULE_NOT_EXISTS = new ErrorCode(1_009_006_001, "流程任务分配规则不存在"); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
| @@ -77,16 +77,17 @@ public class BpmTaskController { | @@ -77,16 +77,17 @@ public class BpmTaskController { | ||
| 77 | 77 | ||
| 78 | @GetMapping("/get-return-list") | 78 | @GetMapping("/get-return-list") |
| 79 | @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") | 79 | @Operation(summary = "获取所有可回退的节点", description = "用于【流程详情】的【回退】按钮") |
| 80 | - @PreAuthorize("@ss.hasPermission('bpm:task:rollback')") | ||
| 81 | - public CommonResult<List<BpmTaskRollbackRespVO>> getReturnList(String taskId) { | ||
| 82 | - return success(taskService.findReturnTaskList(taskId)); | 80 | + @Parameter(name = "taskId", description = "当前任务ID", required = true) |
| 81 | + @PreAuthorize("@ss.hasPermission('bpm:task:return')") | ||
| 82 | + public CommonResult<List<BpmTaskSimpleRespVO>> getReturnList(@RequestParam("taskId") String taskId) { | ||
| 83 | + return success(taskService.getReturnTaskList(taskId)); | ||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | - @PutMapping("/rollback") | 86 | + @PutMapping("/return") |
| 86 | @Operation(summary = "回退任务", description = "用于【流程详情】的【回退】按钮") | 87 | @Operation(summary = "回退任务", description = "用于【流程详情】的【回退】按钮") |
| 87 | - @PreAuthorize("@ss.hasPermission('bpm:task:rollback')") | ||
| 88 | - public CommonResult<Boolean> getReturnList(@Valid @RequestBody BpmTaskRollbackReqVO reqVO) { | ||
| 89 | - taskService.taskReturn(reqVO); | 88 | + @PreAuthorize("@ss.hasPermission('bpm:task:return')") |
| 89 | + public CommonResult<Boolean> returnTask(@Valid @RequestBody BpmTaskReturnReqVO reqVO) { | ||
| 90 | + taskService.returnTask(reqVO); | ||
| 90 | return success(true); | 91 | return success(true); |
| 91 | } | 92 | } |
| 92 | 93 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRollbackReqVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskReturnReqVO.java
| @@ -7,17 +7,17 @@ import javax.validation.constraints.NotEmpty; | @@ -7,17 +7,17 @@ import javax.validation.constraints.NotEmpty; | ||
| 7 | 7 | ||
| 8 | @Schema(description = "管理后台 - 回退流程任务的 Request VO") | 8 | @Schema(description = "管理后台 - 回退流程任务的 Request VO") |
| 9 | @Data | 9 | @Data |
| 10 | -public class BpmTaskRollbackReqVO { | 10 | +public class BpmTaskReturnReqVO { |
| 11 | 11 | ||
| 12 | @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 12 | @Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | @NotEmpty(message = "任务编号不能为空") | 13 | @NotEmpty(message = "任务编号不能为空") |
| 14 | private String id; | 14 | private String id; |
| 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 targetDefinitionKey; |
| 19 | 19 | ||
| 20 | - @Schema(description = "回退意见") | 20 | + @Schema(description = "回退意见", example = "") |
| 21 | private String reason; | 21 | private String reason; |
| 22 | 22 | ||
| 23 | } | 23 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRollbackRespVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskSimpleRespVO.java
| @@ -8,10 +8,10 @@ import lombok.Data; | @@ -8,10 +8,10 @@ import lombok.Data; | ||
| 8 | */ | 8 | */ |
| 9 | @Schema(description = "管理后台 - 流程任务的 可回退的节点 Response VO") | 9 | @Schema(description = "管理后台 - 流程任务的 可回退的节点 Response VO") |
| 10 | @Data | 10 | @Data |
| 11 | -public class BpmTaskRollbackRespVO { | 11 | +public class BpmTaskSimpleRespVO { |
| 12 | 12 | ||
| 13 | @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one") | 13 | @Schema(description = "任务定义的标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "Activity_one") |
| 14 | - private String taskDefinitionKey; | 14 | + private String definitionKey; |
| 15 | 15 | ||
| 16 | @Schema(description = "任务名词", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批") | 16 | @Schema(description = "任务名词", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批") |
| 17 | private String name; | 17 | private String name; |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
| @@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils; | @@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | 6 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 7 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskDonePageItemRespVO; | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskDonePageItemRespVO; |
| 8 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; | 8 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO; |
| 9 | -import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRollbackRespVO; | 9 | +import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskSimpleRespVO; |
| 10 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskTodoPageItemRespVO; | 10 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskTodoPageItemRespVO; |
| 11 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; | 11 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; |
| 12 | import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; | 12 | import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; |
| @@ -141,9 +141,9 @@ public interface BpmTaskConvert { | @@ -141,9 +141,9 @@ public interface BpmTaskConvert { | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | @Mapping(source = "taskDefinitionKey", target = "id") | 143 | @Mapping(source = "taskDefinitionKey", target = "id") |
| 144 | - default List<BpmTaskRollbackRespVO> convertList(List<FlowElement> elementList) { | ||
| 145 | - return CollectionUtils.convertList(elementList, element -> new BpmTaskRollbackRespVO() | 144 | + default List<BpmTaskSimpleRespVO> convertList(List<FlowElement> elementList) { |
| 145 | + return CollectionUtils.convertList(elementList, element -> new BpmTaskSimpleRespVO() | ||
| 146 | .setName(element.getName()) | 146 | .setName(element.getName()) |
| 147 | - .setTaskDefinitionKey(element.getId())); | 147 | + .setDefinitionKey(element.getId())); |
| 148 | } | 148 | } |
| 149 | } | 149 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java
| @@ -22,7 +22,6 @@ public interface BpmTaskService { | @@ -22,7 +22,6 @@ public interface BpmTaskService { | ||
| 22 | * | 22 | * |
| 23 | * @param userId 用户编号 | 23 | * @param userId 用户编号 |
| 24 | * @param pageReqVO 分页请求 | 24 | * @param pageReqVO 分页请求 |
| 25 | - * | ||
| 26 | * @return 流程任务分页 | 25 | * @return 流程任务分页 |
| 27 | */ | 26 | */ |
| 28 | PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); | 27 | PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO); |
| @@ -32,7 +31,6 @@ public interface BpmTaskService { | @@ -32,7 +31,6 @@ public interface BpmTaskService { | ||
| 32 | * | 31 | * |
| 33 | * @param userId 用户编号 | 32 | * @param userId 用户编号 |
| 34 | * @param pageReqVO 分页请求 | 33 | * @param pageReqVO 分页请求 |
| 35 | - * | ||
| 36 | * @return 流程任务分页 | 34 | * @return 流程任务分页 |
| 37 | */ | 35 | */ |
| 38 | PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); | 36 | PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO); |
| @@ -41,19 +39,17 @@ public interface BpmTaskService { | @@ -41,19 +39,17 @@ public interface BpmTaskService { | ||
| 41 | * 获得流程任务 Map | 39 | * 获得流程任务 Map |
| 42 | * | 40 | * |
| 43 | * @param processInstanceIds 流程实例的编号数组 | 41 | * @param processInstanceIds 流程实例的编号数组 |
| 44 | - * | ||
| 45 | * @return 流程任务 Map | 42 | * @return 流程任务 Map |
| 46 | */ | 43 | */ |
| 47 | default Map<String, List<Task>> getTaskMapByProcessInstanceIds(List<String> processInstanceIds) { | 44 | default Map<String, List<Task>> getTaskMapByProcessInstanceIds(List<String> processInstanceIds) { |
| 48 | return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), | 45 | return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds), |
| 49 | - Task::getProcessInstanceId); | 46 | + Task::getProcessInstanceId); |
| 50 | } | 47 | } |
| 51 | 48 | ||
| 52 | /** | 49 | /** |
| 53 | * 获得流程任务列表 | 50 | * 获得流程任务列表 |
| 54 | * | 51 | * |
| 55 | * @param processInstanceIds 流程实例的编号数组 | 52 | * @param processInstanceIds 流程实例的编号数组 |
| 56 | - * | ||
| 57 | * @return 流程任务列表 | 53 | * @return 流程任务列表 |
| 58 | */ | 54 | */ |
| 59 | List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds); | 55 | List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds); |
| @@ -62,7 +58,6 @@ public interface BpmTaskService { | @@ -62,7 +58,6 @@ public interface BpmTaskService { | ||
| 62 | * 获得指令流程实例的流程任务列表,包括所有状态的 | 58 | * 获得指令流程实例的流程任务列表,包括所有状态的 |
| 63 | * | 59 | * |
| 64 | * @param processInstanceId 流程实例的编号 | 60 | * @param processInstanceId 流程实例的编号 |
| 65 | - * | ||
| 66 | * @return 流程任务列表 | 61 | * @return 流程任务列表 |
| 67 | */ | 62 | */ |
| 68 | List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId); | 63 | List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId); |
| @@ -128,16 +123,18 @@ public interface BpmTaskService { | @@ -128,16 +123,18 @@ public interface BpmTaskService { | ||
| 128 | void updateTaskExtAssign(Task task); | 123 | void updateTaskExtAssign(Task task); |
| 129 | 124 | ||
| 130 | /** | 125 | /** |
| 131 | - * 获取当前人物的可回退的流程集合 | 126 | + * 获取当前任务的可回退的流程集合 |
| 127 | + * | ||
| 132 | * @param taskId 当前的任务ID | 128 | * @param taskId 当前的任务ID |
| 133 | * @return 可以回退的节点列表 | 129 | * @return 可以回退的节点列表 |
| 134 | */ | 130 | */ |
| 135 | - List<BpmTaskRollbackRespVO> findReturnTaskList(String taskId); | 131 | + List<BpmTaskSimpleRespVO> getReturnTaskList(String taskId); |
| 136 | 132 | ||
| 137 | /** | 133 | /** |
| 138 | * 将任务回退到指定的 targetDefinitionKey 位置 | 134 | * 将任务回退到指定的 targetDefinitionKey 位置 |
| 135 | + * | ||
| 139 | * @param reqVO 回退的任务key和当前所在的任务ID | 136 | * @param reqVO 回退的任务key和当前所在的任务ID |
| 140 | */ | 137 | */ |
| 141 | - void taskReturn(BpmTaskRollbackReqVO reqVO); | 138 | + void returnTask(BpmTaskReturnReqVO reqVO); |
| 142 | 139 | ||
| 143 | } | 140 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| 1 | package cn.iocoder.yudao.module.bpm.service.task; | 1 | package cn.iocoder.yudao.module.bpm.service.task; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.collection.ListUtil; | ||
| 5 | import cn.hutool.core.util.ArrayUtil; | 4 | import cn.hutool.core.util.ArrayUtil; |
| 6 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| @@ -22,19 +21,13 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | @@ -22,19 +21,13 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||
| 22 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 23 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 22 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 24 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
| 25 | -import org.flowable.bpmn.constants.BpmnXMLConstants; | ||
| 26 | import org.flowable.bpmn.model.BpmnModel; | 24 | import org.flowable.bpmn.model.BpmnModel; |
| 27 | import org.flowable.bpmn.model.FlowElement; | 25 | import org.flowable.bpmn.model.FlowElement; |
| 28 | import org.flowable.bpmn.model.UserTask; | 26 | import org.flowable.bpmn.model.UserTask; |
| 29 | -import org.flowable.common.engine.api.FlowableException; | ||
| 30 | -import org.flowable.common.engine.api.FlowableObjectNotFoundException; | ||
| 31 | import org.flowable.engine.HistoryService; | 27 | import org.flowable.engine.HistoryService; |
| 32 | -import org.flowable.engine.RepositoryService; | ||
| 33 | import org.flowable.engine.RuntimeService; | 28 | import org.flowable.engine.RuntimeService; |
| 34 | import org.flowable.engine.TaskService; | 29 | import org.flowable.engine.TaskService; |
| 35 | -import org.flowable.engine.history.HistoricActivityInstance; | ||
| 36 | import org.flowable.engine.history.HistoricProcessInstance; | 30 | import org.flowable.engine.history.HistoricProcessInstance; |
| 37 | -import org.flowable.engine.repository.ProcessDefinition; | ||
| 38 | import org.flowable.engine.runtime.ProcessInstance; | 31 | import org.flowable.engine.runtime.ProcessInstance; |
| 39 | import org.flowable.task.api.Task; | 32 | import org.flowable.task.api.Task; |
| 40 | import org.flowable.task.api.TaskQuery; | 33 | import org.flowable.task.api.TaskQuery; |
| @@ -333,9 +326,12 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -333,9 +326,12 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 333 | } | 326 | } |
| 334 | 327 | ||
| 335 | @Override | 328 | @Override |
| 336 | - public List<BpmTaskRollbackRespVO> findReturnTaskList(String taskId) { | 329 | + public List<BpmTaskSimpleRespVO> getReturnTaskList(String taskId) { |
| 337 | // 当前任务 task | 330 | // 当前任务 task |
| 338 | - Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); | 331 | + Task task = getTask(taskId); |
| 332 | + if (null == task) { | ||
| 333 | + throw exception(TASK_NOT_EXISTS); | ||
| 334 | + } | ||
| 339 | // 根据流程定义获取流程模型信息 | 335 | // 根据流程定义获取流程模型信息 |
| 340 | BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); | 336 | BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); |
| 341 | // 查询该任务的前置任务节点的key集合 | 337 | // 查询该任务的前置任务节点的key集合 |
| @@ -348,7 +344,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -348,7 +344,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 348 | List<FlowElement> elementList = new ArrayList<>(); | 344 | List<FlowElement> elementList = new ArrayList<>(); |
| 349 | for (String activityId : historyTaksDefinitionKeySet) { | 345 | for (String activityId : historyTaksDefinitionKeySet) { |
| 350 | FlowElement target = ModelUtils.getFlowElementById(bpmnModel, activityId); | 346 | FlowElement target = ModelUtils.getFlowElementById(bpmnModel, activityId); |
| 351 | - //不支持串行和子流程 | 347 | + //非 串行和子流程则加入返回节点 elementList |
| 352 | boolean isSequential = ModelUtils.isSequentialReachable(source, target, new HashSet<>()); | 348 | boolean isSequential = ModelUtils.isSequentialReachable(source, target, new HashSet<>()); |
| 353 | if (isSequential) { | 349 | if (isSequential) { |
| 354 | elementList.add(target); | 350 | elementList.add(target); |
| @@ -378,13 +374,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -378,13 +374,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 378 | 374 | ||
| 379 | @Transactional(rollbackFor = Exception.class) | 375 | @Transactional(rollbackFor = Exception.class) |
| 380 | @Override | 376 | @Override |
| 381 | - public void taskReturn(BpmTaskRollbackReqVO reqVO) { | 377 | + public void returnTask(BpmTaskReturnReqVO reqVO) { |
| 382 | // 当前任务 task | 378 | // 当前任务 task |
| 383 | - Task task = validateRollback(reqVO.getId()); | 379 | + Task task = validateReturnTask(reqVO.getId()); |
| 384 | // 校验源头和目标节点的关系,并返回目标元素 | 380 | // 校验源头和目标节点的关系,并返回目标元素 |
| 385 | - FlowElement targetElement = validateRollbackProcessDefinition(task.getTaskDefinitionKey(), reqVO.getTargetDefinitionKey(), task.getProcessDefinitionId()); | 381 | + FlowElement targetElement = validateReturnProcessDefinition(task.getTaskDefinitionKey(), reqVO.getTargetDefinitionKey(), task.getProcessDefinitionId()); |
| 386 | //调用flowable框架的回退逻辑 | 382 | //调用flowable框架的回退逻辑 |
| 387 | - this.handlerRollback(task, targetElement, reqVO); | 383 | + this.handlerReturn(task, targetElement, reqVO); |
| 388 | // 更新任务扩展表 | 384 | // 更新任务扩展表 |
| 389 | taskExtMapper.updateByTaskId( | 385 | taskExtMapper.updateByTaskId( |
| 390 | new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult()) | 386 | new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult()) |
| @@ -397,14 +393,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -397,14 +393,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 397 | * @param taskId 当前任务ID | 393 | * @param taskId 当前任务ID |
| 398 | * @return | 394 | * @return |
| 399 | */ | 395 | */ |
| 400 | - private Task validateRollback(String taskId) { | 396 | + private Task validateReturnTask(String taskId) { |
| 401 | // 当前任务 task | 397 | // 当前任务 task |
| 402 | - Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); | 398 | + Task task = getTask(taskId); |
| 403 | if (null == task) { | 399 | if (null == task) { |
| 404 | throw exception(TASK_NOT_EXISTS); | 400 | throw exception(TASK_NOT_EXISTS); |
| 405 | } | 401 | } |
| 406 | if (task.isSuspended()) { | 402 | if (task.isSuspended()) { |
| 407 | - throw exception(TASK_IS_NOT_ACTIVITY); | 403 | + throw exception(TASK_IS_PENDING); |
| 408 | } | 404 | } |
| 409 | return task; | 405 | return task; |
| 410 | } | 406 | } |
| @@ -417,7 +413,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -417,7 +413,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 417 | * @param processDefinitionId 当前流程定义ID | 413 | * @param processDefinitionId 当前流程定义ID |
| 418 | * @return 目标元素 | 414 | * @return 目标元素 |
| 419 | */ | 415 | */ |
| 420 | - private FlowElement validateRollbackProcessDefinition(String sourceKey, String targetKey, String processDefinitionId) { | 416 | + private FlowElement validateReturnProcessDefinition(String sourceKey, String targetKey, String processDefinitionId) { |
| 421 | // 获取流程模型信息 | 417 | // 获取流程模型信息 |
| 422 | BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); | 418 | BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); |
| 423 | // 获取当前任务节点元素 | 419 | // 获取当前任务节点元素 |
| @@ -442,24 +438,24 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -442,24 +438,24 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 442 | * @param targetElement 需要回退到的目标任务 | 438 | * @param targetElement 需要回退到的目标任务 |
| 443 | * @param reqVO 前端参数封装 | 439 | * @param reqVO 前端参数封装 |
| 444 | */ | 440 | */ |
| 445 | - public void handlerRollback(Task task, FlowElement targetElement, BpmTaskRollbackReqVO reqVO) { | 441 | + public void handlerReturn(Task task, FlowElement targetElement, BpmTaskReturnReqVO reqVO) { |
| 446 | // 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务 | 442 | // 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务 |
| 447 | List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list(); | 443 | List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list(); |
| 448 | List<String> runTaskKeyList = convertList(runTaskList, Task::getTaskDefinitionKey); | 444 | List<String> runTaskKeyList = convertList(runTaskList, Task::getTaskDefinitionKey); |
| 449 | // 通过 targetElement 的出口连线,结合 runTaskList 比对,获取需要撤回的任务 key | 445 | // 通过 targetElement 的出口连线,结合 runTaskList 比对,获取需要撤回的任务 key |
| 450 | - List<UserTask> rollbackUserTaskList = ModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); | 446 | + List<UserTask> returnUserTaskList = ModelUtils.iteratorFindChildUserTasks(targetElement, runTaskKeyList, null, null); |
| 451 | // 需退回任务 key | 447 | // 需退回任务 key |
| 452 | - List<String> rollbackTaskDefinitionKeyList = convertList(rollbackUserTaskList, UserTask::getId); | 448 | + List<String> returnTaskDefinitionKeyList = convertList(returnUserTaskList, UserTask::getId); |
| 453 | 449 | ||
| 454 | // 通过 key 和 runTaskList 中的key对比,拿到任务ID,设置设置回退意见 | 450 | // 通过 key 和 runTaskList 中的key对比,拿到任务ID,设置设置回退意见 |
| 455 | List<String> currentTaskIds = new ArrayList<>(); | 451 | List<String> currentTaskIds = new ArrayList<>(); |
| 456 | - rollbackTaskDefinitionKeyList.forEach(currentId -> runTaskList.forEach(runTask -> { | 452 | + returnTaskDefinitionKeyList.forEach(currentId -> runTaskList.forEach(runTask -> { |
| 457 | if (currentId.equals(runTask.getTaskDefinitionKey())) { | 453 | if (currentId.equals(runTask.getTaskDefinitionKey())) { |
| 458 | currentTaskIds.add(runTask.getId()); | 454 | currentTaskIds.add(runTask.getId()); |
| 459 | } | 455 | } |
| 460 | })); | 456 | })); |
| 461 | if (CollUtil.isEmpty(currentTaskIds)) { | 457 | if (CollUtil.isEmpty(currentTaskIds)) { |
| 462 | - throw exception(TASK_ROLLBACK_FAIL); | 458 | + throw exception(TASK_RETURN_FAIL); |
| 463 | } | 459 | } |
| 464 | // 设置回退意见 | 460 | // 设置回退意见 |
| 465 | for (String currentTaskId : currentTaskIds) { | 461 | for (String currentTaskId : currentTaskIds) { |
| @@ -468,7 +464,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -468,7 +464,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 468 | // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1) | 464 | // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1) |
| 469 | runtimeService.createChangeActivityStateBuilder() | 465 | runtimeService.createChangeActivityStateBuilder() |
| 470 | .processInstanceId(task.getProcessInstanceId()) | 466 | .processInstanceId(task.getProcessInstanceId()) |
| 471 | - .moveActivityIdsToSingleActivityId(rollbackTaskDefinitionKeyList, reqVO.getTargetDefinitionKey()) | 467 | + .moveActivityIdsToSingleActivityId(returnTaskDefinitionKeyList, reqVO.getTargetDefinitionKey()) |
| 472 | .changeState(); | 468 | .changeState(); |
| 473 | } | 469 | } |
| 474 | 470 |