ソースを参照

修改项目结算退回之后重新提交到退回人

余思翰 3ヶ月前
コミット
bf7c6d7715

+ 8
- 1
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java ファイルの表示

@@ -108,6 +108,13 @@ public class FlowTaskController {
108 108
         return AjaxResult.success();
109 109
     }
110 110
 
111
+    @ApiOperation(value = "重新提交任务")
112
+    @PostMapping(value = "/reCommit")
113
+    public AjaxResult taskRecommit(@RequestBody FlowTaskVo flowTaskVo) {
114
+        flowTaskService.taskRecommit(flowTaskVo);
115
+        return AjaxResult.success();
116
+    }
117
+
111 118
     @ApiOperation(value = "获取所有可回退的节点")
112 119
     @PostMapping(value = "/returnList")
113 120
     public AjaxResult findReturnTaskList(@RequestBody FlowTaskVo flowTaskVo) {
@@ -116,7 +123,7 @@ public class FlowTaskController {
116 123
 
117 124
     @ApiOperation(value = "获取重新提交的节点")
118 125
     @PostMapping(value = "/reCommitTask")
119
-    public AjaxResult findReCommitTask(FlowTaskVo flowTaskVo) {
126
+    public AjaxResult findReCommitTask(@RequestBody FlowTaskVo flowTaskVo) {
120 127
         return flowTaskService.findReCommitTask(flowTaskVo);
121 128
     }
122 129
 

+ 7
- 0
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java ファイルの表示

@@ -36,6 +36,13 @@ public interface IFlowTaskService {
36 36
      */
37 37
     void taskReturn(FlowTaskVo flowTaskVo);
38 38
 
39
+    /**
40
+     * 重新提交任务
41
+     *
42
+     * @param flowTaskVo 请求实体参数
43
+     */
44
+    void taskRecommit(FlowTaskVo flowTaskVo);
45
+
39 46
     /**
40 47
      * 获取所有可回退的节点
41 48
      *

+ 90
- 0
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java ファイルの表示

@@ -384,6 +384,96 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
384 384
     }
385 385
 
386 386
 
387
+    /**
388
+     * 重新提交任务
389
+     *
390
+     * @param flowTaskVo 请求实体参数
391
+     */
392
+    @Transactional(rollbackFor = Exception.class)
393
+    @Override
394
+    public void taskRecommit(FlowTaskVo flowTaskVo) {
395
+        if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
396
+            throw new CustomException("任务处于挂起状态");
397
+        }
398
+        // 当前任务 task
399
+        Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
400
+        // 获取流程定义信息
401
+        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
402
+        // 获取所有节点信息
403
+        Process process = repositoryService.getBpmnModel(processDefinition.getId()).getProcesses().get(0);
404
+        // 获取全部节点列表,包含子节点
405
+        Collection<FlowElement> allElements = FlowableUtils.getAllElements(process.getFlowElements(), null);
406
+        // 获取当前任务节点元素
407
+        FlowElement source = null;
408
+        // 获取跳转的节点元素
409
+        FlowElement target = null;
410
+        if (allElements != null) {
411
+            for (FlowElement flowElement : allElements) {
412
+                // 当前任务节点元素
413
+                if (flowElement.getId().equals(task.getTaskDefinitionKey())) {
414
+                    source = flowElement;
415
+                }
416
+                // 跳转的节点元素
417
+                if (flowElement.getId().equals(flowTaskVo.getTargetKey())) {
418
+                    target = flowElement;
419
+                }
420
+            }
421
+        }
422
+
423
+        // 从当前节点向前扫描
424
+        // 如果存在路线上不存在目标节点,说明目标节点是在网关上或非同一路线上,不可跳转
425
+        // 否则目标节点相对于当前节点,属于串行
426
+//        Boolean isSequential = FlowableUtils.iteratorCheckSequentialReferTarget(source, flowTaskVo.getTargetKey(), null, null);
427
+//        if (!isSequential) {
428
+//            throw new CustomException("当前节点相对于目标节点,不属于串行关系,无法回退");
429
+//        }
430
+
431
+
432
+        // 获取所有正常进行的任务节点 Key,这些任务不能直接使用,需要找出其中需要撤回的任务
433
+        List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
434
+        List<String> runTaskKeyList = new ArrayList<>();
435
+        runTaskList.forEach(item -> runTaskKeyList.add(item.getTaskDefinitionKey()));
436
+        // 需退回任务列表
437
+        List<String> currentIds = new ArrayList<>();
438
+        currentIds.add(source.getId());
439
+        // 通过父级网关的出口连线,结合 runTaskList 比对,获取需要撤回的任务
440
+//        List<UserTask> currentUserTaskList = FlowableUtils.iteratorFindChildUserTasks(target, runTaskKeyList, null, null);
441
+//        currentUserTaskList.forEach(item -> currentIds.add(item.getId()));
442
+
443
+        // 循环获取那些需要被撤回的节点的ID,用来设置驳回原因
444
+        List<String> currentTaskIds = new ArrayList<>();
445
+        currentIds.forEach(currentId -> runTaskList.forEach(runTask -> {
446
+            if (currentId.equals(runTask.getTaskDefinitionKey())) {
447
+                currentTaskIds.add(runTask.getId());
448
+            }
449
+        }));
450
+        // 设置回退意见
451
+        currentTaskIds.forEach(currentTaskId -> taskService.addComment(currentTaskId, task.getProcessInstanceId(), FlowComment.NORMAL.getRemark(), flowTaskVo.getComment()));
452
+
453
+        try {
454
+            // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
455
+            runtimeService.createChangeActivityStateBuilder()
456
+                    .processInstanceId(task.getProcessInstanceId())
457
+                    .moveActivityIdsToSingleActivityId(currentIds, flowTaskVo.getTargetKey()).changeState();
458
+            String currentTaskId = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).singleResult().getId();
459
+            List<HistoricTaskInstance> htiList = historyService.createHistoricTaskInstanceQuery()
460
+                    .processInstanceId(task.getProcessInstanceId()).taskDefinitionKey(flowTaskVo.getTargetKey())
461
+                    .list();
462
+            String taskAssignee = "";
463
+            for (HistoricTaskInstance hti: htiList) {
464
+                if (!hti.getId().equals(currentTaskId)) {
465
+                    taskAssignee = hti.getAssignee();
466
+                    break;
467
+                }
468
+            }
469
+            taskService.setAssignee(currentTaskId, taskAssignee);
470
+        } catch (FlowableObjectNotFoundException e) {
471
+            throw new CustomException("未找到流程实例,流程可能已发生变化");
472
+        } catch (FlowableException e) {
473
+            throw new CustomException("无法取消或开始活动");
474
+        }
475
+    }
476
+
387 477
     /**
388 478
      * 获取所有可回退的节点
389 479
      *

+ 18
- 0
oa-ui/src/api/flowable/todo.js ファイルの表示

@@ -46,6 +46,15 @@ export function returnTask(data) {
46 46
   })
47 47
 }
48 48
 
49
+// 重新提交任务
50
+export function taskRecommit(data) {
51
+  return request({
52
+    url: '/flowable/task/reCommit',
53
+    method: 'post',
54
+    data: data
55
+  })
56
+}
57
+
49 58
 // 驳回任务
50 59
 export function rejectTask(data) {
51 60
   return request({
@@ -140,3 +149,12 @@ export function flowTaskForm(query) {
140 149
     params: query
141 150
   })
142 151
 }
152
+
153
+// 重新提交到退回人
154
+export function findReCommitTask(data){
155
+  return request({
156
+    url: '/flowable/task/reCommitTask',
157
+    method: 'post',
158
+    data: data
159
+  })
160
+}

+ 6
- 0
oa-ui/src/views/flowable/form/components/flowBtn/returnComment.vue ファイルの表示

@@ -1,3 +1,9 @@
1
+<!--
2
+ * @Author: ysh
3
+ * @Date: 2024-09-27 16:33:10
4
+ * @LastEditors: 
5
+ * @LastEditTime: 2024-12-30 09:50:09
6
+-->
1 7
 <template>
2 8
   <div>
3 9
     <div>退回意见:{{ reBackDescription }}</div>

+ 21
- 10
oa-ui/src/views/flowable/form/settleForm.vue ファイルの表示

@@ -1,8 +1,8 @@
1 1
 <!--
2 2
  * @Author: ysh
3 3
  * @Date: 2024-04-30 09:03:14
4
- * @LastEditors: wrh
5
- * @LastEditTime: 2024-12-27 11:37:41
4
+ * @LastEditors: Please set LastEditors
5
+ * @LastEditTime: 2024-12-30 10:46:54
6 6
 -->
7 7
 <template>
8 8
   <div class="app-container" v-loading="loading">
@@ -477,10 +477,8 @@
477 477
         <el-button type="success" icon="el-icon-printer" @click="printOpen = true">打印</el-button>
478 478
         <div style="text-align: center" v-if="!disabled">
479 479
           <el-button type="warning" @click="preserve">保存</el-button>
480
-          <el-button type="danger"
481
-            v-if="taskName != '结算发起'"
482
-            @click="returnOpen = true">退 回</el-button>
483
-          <el-button type="primary" @click="submitNextFlow" v-if="taskName != '董事长批准'">提交下一个流程</el-button>
480
+          <el-button type="danger" v-if="taskName != '结算发起'" @click="returnOpen = true">退 回</el-button>
481
+          <el-button type="primary" @click="submitNextFlow" v-if="taskName != '董事长批准'">提 交</el-button>
484 482
           <el-button type="primary" @click="submitNextFlow" v-else>结算批准</el-button>
485 483
         </div>
486 484
       </el-col>
@@ -527,7 +525,7 @@ import ChoosePrice from "./components/choosePrice.vue";
527 525
 import { getUser } from "@/api/system/user";
528 526
 import { getUserByRole } from "@/api/system/role";
529 527
 import { getUserByPost } from "@/api/system/post";
530
-import { complete, getNextFlowNode } from "@/api/flowable/todo";
528
+import { complete, getNextFlowNode, returnTask, findReCommitTask, taskRecommit } from "@/api/flowable/todo";
531 529
 import { getUsersDeptLeader, getUsersDeptLeaderByDept, getUsersManageLeaderByDept, } from "@/api/system/post.js";
532 530
 import { listBudget } from "@/api/oa/budget/budget";
533 531
 import { listBudgetSettle } from "@/api/oa/budget/budgetSettle";
@@ -851,9 +849,22 @@ export default {
851 849
               confirmButtonText: '确定',
852 850
               type: 'warning'
853 851
             }).then(() => {
854
-              getUserByRole({ roleId: 4 }).then((res) => {
855
-                this.getNextFlowNodeFn(res.data[0]);
856
-              });
852
+              if (this.showAlter) {
853
+                const taskId = this.taskForm.taskId
854
+                findReCommitTask(this.taskForm).then(res => {
855
+                  taskRecommit({ taskId, targetKey: res.data[0].id, comment: '' }).then(res1 => {
856
+                    if (res1.code == 200) {
857
+                      this.$message.success('操作成功')
858
+                      this.$emit('goBack');
859
+                    }
860
+                  })
861
+                })
862
+              } else {
863
+                getUserByRole({ roleId: 4 }).then((res) => {
864
+                  this.getNextFlowNodeFn(res.data[0]);
865
+                });
866
+              }
867
+
857 868
             })
858 869
           } else if (this.taskName == "综合事务部处理") {
859 870
             getUserByRole({ roleId: 5 }).then((res) => {

読み込み中…
キャンセル
保存