Commit 56eedfd14761762bd6b2386d0f79e04dc099cdc1
1 parent
c5a9f5d0
回退-任务
Showing
6 changed files
with
62 additions
and
2 deletions
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 { | @@ -76,4 +76,13 @@ public class BpmTaskController { | ||
| 76 | taskService.updateTaskAssignee(getLoginUserId(), reqVO); | 76 | taskService.updateTaskAssignee(getLoginUserId(), reqVO); |
| 77 | return success(true); | 77 | return success(true); |
| 78 | } | 78 | } |
| 79 | + @PutMapping("/back") | ||
| 80 | + @ApiOperation(value = "回退") | ||
| 81 | +// @PreAuthorize("@ss.hasPermission('bpm:task:back')") | ||
| 82 | + public CommonResult<Boolean> backTask(@Valid @RequestBody BpmTaskUpdateAssigneeReqVO reqVO) { | ||
| 83 | + //先硬编码到 回退到第一个审批节点 | ||
| 84 | + String destinationTaskDefKey = "task01"; | ||
| 85 | + taskService.backTask(reqVO.getId(),destinationTaskDefKey); | ||
| 86 | + return success(true); | ||
| 87 | + } | ||
| 79 | } | 88 | } |
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 { | @@ -76,6 +76,12 @@ public interface BpmTaskService { | ||
| 76 | * @param reqVO 不通过请求 | 76 | * @param reqVO 不通过请求 |
| 77 | */ | 77 | */ |
| 78 | void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); | 78 | void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO); |
| 79 | + /** | ||
| 80 | + * 回退任务 | ||
| 81 | + * | ||
| 82 | + * @param taskId 任务编号 | ||
| 83 | + */ | ||
| 84 | + void backTask(String taskId,String destinationTaskDefKey); | ||
| 79 | 85 | ||
| 80 | /** | 86 | /** |
| 81 | * 将流程任务分配给指定用户 | 87 | * 将流程任务分配给指定用户 |
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; | @@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 17 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 17 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 18 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| 19 | import org.flowable.engine.HistoryService; | 19 | import org.flowable.engine.HistoryService; |
| 20 | +import org.flowable.engine.RuntimeService; | ||
| 20 | import org.flowable.engine.TaskService; | 21 | import org.flowable.engine.TaskService; |
| 21 | import org.flowable.engine.history.HistoricProcessInstance; | 22 | import org.flowable.engine.history.HistoricProcessInstance; |
| 22 | import org.flowable.engine.runtime.ProcessInstance; | 23 | import org.flowable.engine.runtime.ProcessInstance; |
| @@ -51,6 +52,8 @@ public class BpmTaskServiceImpl implements BpmTaskService{ | @@ -51,6 +52,8 @@ public class BpmTaskServiceImpl implements BpmTaskService{ | ||
| 51 | @Resource | 52 | @Resource |
| 52 | private TaskService taskService; | 53 | private TaskService taskService; |
| 53 | @Resource | 54 | @Resource |
| 55 | + private RuntimeService runtimeService; | ||
| 56 | + @Resource | ||
| 54 | private HistoryService historyService; | 57 | private HistoryService historyService; |
| 55 | 58 | ||
| 56 | @Resource | 59 | @Resource |
| @@ -204,6 +207,16 @@ public class BpmTaskServiceImpl implements BpmTaskService{ | @@ -204,6 +207,16 @@ public class BpmTaskServiceImpl implements BpmTaskService{ | ||
| 204 | } | 207 | } |
| 205 | 208 | ||
| 206 | @Override | 209 | @Override |
| 210 | + public void backTask(String taskId,String destinationTaskDefKey) { | ||
| 211 | + Task currentTask = taskService.createTaskQuery().taskId(taskId).singleResult(); | ||
| 212 | + | ||
| 213 | + runtimeService.createChangeActivityStateBuilder() | ||
| 214 | + .processInstanceId(currentTask.getProcessInstanceId()) | ||
| 215 | + .moveActivityIdTo(currentTask.getTaskDefinitionKey(), destinationTaskDefKey) | ||
| 216 | + .changeState(); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + @Override | ||
| 207 | public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { | 220 | public void updateTaskAssignee(Long userId, BpmTaskUpdateAssigneeReqVO reqVO) { |
| 208 | // 校验任务存在 | 221 | // 校验任务存在 |
| 209 | Task task = checkTask(userId, reqVO.getId()); | 222 | Task task = checkTask(userId, reqVO.getId()); |
yudao-module-bpm/yudao-module-bpm-impl-flowable/src/test/java/cn/iocoder/yudao/module/bpm/LeaveFormKeyTest.java
| @@ -88,6 +88,23 @@ public class LeaveFormKeyTest extends AbstractOATest { | @@ -88,6 +88,23 @@ public class LeaveFormKeyTest extends AbstractOATest { | ||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | /** | 90 | /** |
| 91 | + * 任意流程的跳转 | ||
| 92 | + */ | ||
| 93 | + @Test | ||
| 94 | + public void taskJump(){ | ||
| 95 | + // 当前任务 | ||
| 96 | + String taskId="ddd"; | ||
| 97 | + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); | ||
| 98 | + String assignee = "下一个自由跳转人"; | ||
| 99 | + taskService.setAssignee(taskId,assignee); | ||
| 100 | + // 自由跳转 | ||
| 101 | + String taskDefKey="目标-任务名称"; | ||
| 102 | + //moveActivityIdTo的两个参数,源任务key,目标任务key | ||
| 103 | + runtimeService.createChangeActivityStateBuilder().processInstanceId(task.getProcessInstanceId()).moveActivityIdTo(task.getTaskDefinitionKey(), taskDefKey).changeState(); | ||
| 104 | + | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 91 | * 领导驳回后申请人取消申请 | 108 | * 领导驳回后申请人取消申请 |
| 92 | */ | 109 | */ |
| 93 | @Test | 110 | @Test |
yudao-ui-admin/src/api/bpm/task.js
| @@ -39,6 +39,13 @@ export function rejectTask(data) { | @@ -39,6 +39,13 @@ export function rejectTask(data) { | ||
| 39 | data: data | 39 | data: data |
| 40 | }) | 40 | }) |
| 41 | } | 41 | } |
| 42 | +export function backTask(data) { | ||
| 43 | + return request({ | ||
| 44 | + url: '/bpm/task/back', | ||
| 45 | + method: 'PUT', | ||
| 46 | + data: data | ||
| 47 | + }) | ||
| 48 | +} | ||
| 42 | 49 | ||
| 43 | export function updateTaskAssignee(data) { | 50 | export function updateTaskAssignee(data) { |
| 44 | return request({ | 51 | return request({ |
yudao-ui-admin/src/views/bpm/processInstance/detail.vue
| @@ -109,7 +109,7 @@ import store from "@/store"; | @@ -109,7 +109,7 @@ import store from "@/store"; | ||
| 109 | import {decodeFields} from "@/utils/formGenerator"; | 109 | import {decodeFields} from "@/utils/formGenerator"; |
| 110 | import Parser from '@/components/parser/Parser' | 110 | import Parser from '@/components/parser/Parser' |
| 111 | import {createProcessInstance, getProcessInstance} from "@/api/bpm/processInstance"; | 111 | import {createProcessInstance, getProcessInstance} from "@/api/bpm/processInstance"; |
| 112 | -import {approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee} from "@/api/bpm/task"; | 112 | +import {approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee,backTask} from "@/api/bpm/task"; |
| 113 | import {getDate} from "@/utils/dateUtils"; | 113 | import {getDate} from "@/utils/dateUtils"; |
| 114 | import {listSimpleUsers} from "@/api/system/user"; | 114 | import {listSimpleUsers} from "@/api/system/user"; |
| 115 | import {getActivityList} from "@/api/bpm/activity"; | 115 | import {getActivityList} from "@/api/bpm/activity"; |
| @@ -406,7 +406,15 @@ export default { | @@ -406,7 +406,15 @@ export default { | ||
| 406 | }, | 406 | }, |
| 407 | /** 处理审批退回的操作 */ | 407 | /** 处理审批退回的操作 */ |
| 408 | handleBack(task) { | 408 | handleBack(task) { |
| 409 | - this.$modal.msgError("暂不支持【退回】功能!"); | 409 | + const data = { |
| 410 | + id: task.id, | ||
| 411 | + assigneeUserId: 1 | ||
| 412 | + } | ||
| 413 | + // this.$modal.msgError("暂不支持【--退回】功能!"); | ||
| 414 | + backTask(data).then(response => { | ||
| 415 | + this.$modal.msgSuccess("回退成功!"); | ||
| 416 | + this.getDetail(); // 获得最新详情 | ||
| 417 | + }); | ||
| 410 | } | 418 | } |
| 411 | } | 419 | } |
| 412 | }; | 420 | }; |