diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java index 52b16297d2..d3318c9633 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java @@ -76,4 +76,13 @@ public class BpmTaskController { taskService.updateTaskAssignee(getLoginUserId(), reqVO); return success(true); } + @PutMapping("/back") + @ApiOperation(value = "回退") +// @PreAuthorize("@ss.hasPermission('bpm:task:back')") + public CommonResult backTask(@Valid @RequestBody BpmTaskUpdateAssigneeReqVO reqVO) { + //先硬编码到 回退到第一个审批节点 + String destinationTaskDefKey = "task01"; + taskService.backTask(reqVO.getId(),destinationTaskDefKey); + return success(true); + } } diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java index e8aab6aa8e..00a0a86620 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java @@ -76,6 +76,12 @@ public interface BpmTaskService { * @param reqVO 不通过请求 */ void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); + /** + * 回退任务 + * + * @param taskId 任务编号 + */ + void backTask(String taskId,String destinationTaskDefKey); /** * 将流程任务分配给指定用户 diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index 5c004977ca..0660576f0e 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import lombok.extern.slf4j.Slf4j; import org.flowable.engine.HistoryService; +import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.runtime.ProcessInstance; @@ -51,6 +52,8 @@ public class BpmTaskServiceImpl implements BpmTaskService{ @Resource private TaskService taskService; @Resource + private RuntimeService runtimeService; + @Resource private HistoryService historyService; @Resource @@ -203,6 +206,16 @@ public class BpmTaskServiceImpl implements BpmTaskService{ .setResult(BpmProcessInstanceResultEnum.REJECT.getResult()).setComment(reqVO.getComment())); } + @Override + public void backTask(String taskId,String destinationTaskDefKey) { + Task currentTask = taskService.createTaskQuery().taskId(taskId).singleResult(); + + runtimeService.createChangeActivityStateBuilder() + .processInstanceId(currentTask.getProcessInstanceId()) + .moveActivityIdTo(currentTask.getTaskDefinitionKey(), destinationTaskDefKey) + .changeState(); + } + @Override public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { // 校验任务存在 diff --git a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/LeaveFormKeyTest.java b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/LeaveFormKeyTest.java index 90105af2ea..da99fec3d8 100644 --- a/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/LeaveFormKeyTest.java +++ b/yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/LeaveFormKeyTest.java @@ -87,6 +87,23 @@ public class LeaveFormKeyTest extends AbstractOATest { } + /** + * 任意流程的跳转 + */ + @Test + public void taskJump(){ + // 当前任务 + String taskId="ddd"; + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + String assignee = "下一个自由跳转人"; + taskService.setAssignee(taskId,assignee); + // 自由跳转 + String taskDefKey="目标-任务名称"; + //moveActivityIdTo的两个参数,源任务key,目标任务key + runtimeService.createChangeActivityStateBuilder().processInstanceId(task.getProcessInstanceId()).moveActivityIdTo(task.getTaskDefinitionKey(), taskDefKey).changeState(); + + } + /** * 领导驳回后申请人取消申请 */ diff --git a/yudao-ui-admin/src/api/bpm/task.js b/yudao-ui-admin/src/api/bpm/task.js index 177a7dfc9a..aa32263f3c 100644 --- a/yudao-ui-admin/src/api/bpm/task.js +++ b/yudao-ui-admin/src/api/bpm/task.js @@ -39,6 +39,13 @@ export function rejectTask(data) { data: data }) } +export function backTask(data) { + return request({ + url: '/bpm/task/back', + method: 'PUT', + data: data + }) +} export function updateTaskAssignee(data) { return request({ diff --git a/yudao-ui-admin/src/views/bpm/processInstance/detail.vue b/yudao-ui-admin/src/views/bpm/processInstance/detail.vue index f5d4992c2a..6311ae0a53 100644 --- a/yudao-ui-admin/src/views/bpm/processInstance/detail.vue +++ b/yudao-ui-admin/src/views/bpm/processInstance/detail.vue @@ -109,7 +109,7 @@ import store from "@/store"; import {decodeFields} from "@/utils/formGenerator"; import Parser from '@/components/parser/Parser' import {createProcessInstance, getProcessInstance} from "@/api/bpm/processInstance"; -import {approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee} from "@/api/bpm/task"; +import {approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee,backTask} from "@/api/bpm/task"; import {getDate} from "@/utils/dateUtils"; import {listSimpleUsers} from "@/api/system/user"; import {getActivityList} from "@/api/bpm/activity"; @@ -406,7 +406,15 @@ export default { }, /** 处理审批退回的操作 */ handleBack(task) { - this.$modal.msgError("暂不支持【退回】功能!"); + const data = { + id: task.id, + assigneeUserId: 1 + } + // this.$modal.msgError("暂不支持【--退回】功能!"); + backTask(data).then(response => { + this.$modal.msgSuccess("回退成功!"); + this.getDetail(); // 获得最新详情 + }); } } };