Browse Source

撤回任务

lamphua 1 year ago
parent
commit
e3d1040592

+ 20
- 12
oa-back/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java View File

99
         if (Objects.isNull(task)) {
99
         if (Objects.isNull(task)) {
100
             return AjaxResult.error("任务不存在");
100
             return AjaxResult.error("任务不存在");
101
         }
101
         }
102
-        //如果pass变量是通过,存入流程任务变量表
103
-        if (Objects.nonNull(taskVo.getVariables().get("pass")) && taskVo.getVariables().get("pass").equals("通过"))
104
-            runtimeService.setVariable(task.getExecutionId(), "pass", taskVo.getVariables().get("pass"));
105
-        else {
106
-            if (DelegationState.PENDING.equals(task.getDelegationState())) {
107
-                taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
108
-                taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables());
109
-            } else {
102
+
103
+        if (DelegationState.PENDING.equals(task.getDelegationState())) {
104
+            taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
105
+            taskService.resolveTask(taskVo.getTaskId(), taskVo.getVariables());
106
+        } else {
107
+            //如果pass变量是通过,存入流程任务变量表
108
+            if (Objects.nonNull(taskVo.getVariables().get("pass")) && taskVo.getVariables().get("pass").equals("通过")) {
109
+                runtimeService.setVariable(task.getExecutionId(), "pass", taskVo.getVariables().get("pass"));
110
                 taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getRemark(), taskVo.getComment());
110
                 taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getRemark(), taskVo.getComment());
111
+            }
112
+            else {
113
+                taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.REJECT.getRemark(), taskVo.getComment());
111
                 Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
114
                 Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
112
                 taskService.setAssignee(taskVo.getTaskId(), userId.toString());
115
                 taskService.setAssignee(taskVo.getTaskId(), userId.toString());
113
                 taskService.complete(taskVo.getTaskId(), taskVo.getVariables());
116
                 taskService.complete(taskVo.getTaskId(), taskVo.getVariables());
114
             }
117
             }
115
         }
118
         }
119
+
116
         return AjaxResult.success();
120
         return AjaxResult.success();
117
     }
121
     }
118
 
122
 
675
             }
679
             }
676
         }
680
         }
677
 
681
 
678
-        List<UserTask> parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null);
679
         //仅考虑撤回到其中一个用户任务节点,在没有会签、并行等情况下可以用
682
         //仅考虑撤回到其中一个用户任务节点,在没有会签、并行等情况下可以用
680
-        String targetTaskDefinitionId = parentUserTaskList.get(0).getId();
683
+        List<HistoricTaskInstance> historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricTaskInstanceStartTime().asc().list();
684
+        String lastHistoricTaskDefinitionKey = "";
685
+        for (HistoricTaskInstance historicTaskInstance : historicTaskInstanceList) {
686
+            if (historicTaskInstance.getId().equals(flowTaskVo.getTaskId()))
687
+                lastHistoricTaskDefinitionKey = historicTaskInstance.getTaskDefinitionKey();
688
+        }
681
         if (allElements != null) {
689
         if (allElements != null) {
682
             for (FlowElement flowElement : allElements) {
690
             for (FlowElement flowElement : allElements) {
683
                 // 跳转的节点元素
691
                 // 跳转的节点元素
684
-                if (flowElement.getId().equals(targetTaskDefinitionId)) {
692
+                if (flowElement.getId().equals(lastHistoricTaskDefinitionKey)) {
685
                     target = flowElement;
693
                     target = flowElement;
686
                 }
694
                 }
687
             }
695
             }
701
             // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
709
             // 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
702
             runtimeService.createChangeActivityStateBuilder()
710
             runtimeService.createChangeActivityStateBuilder()
703
                     .processInstanceId(task.getProcessInstanceId())
711
                     .processInstanceId(task.getProcessInstanceId())
704
-                    .moveActivityIdsToSingleActivityId(currentIds, targetTaskDefinitionId).changeState();
712
+                    .moveActivityIdsToSingleActivityId(currentIds, lastHistoricTaskDefinitionKey).changeState();
705
         } catch (FlowableObjectNotFoundException e) {
713
         } catch (FlowableObjectNotFoundException e) {
706
             throw new CustomException("未找到流程实例,流程可能已发生变化");
714
             throw new CustomException("未找到流程实例,流程可能已发生变化");
707
         } catch (FlowableException e) {
715
         } catch (FlowableException e) {

+ 2
- 1
oa-ui/src/views/flowable/task/finished/index.vue View File

191
     /** 撤回任务 */
191
     /** 撤回任务 */
192
     handleRevoke(row) {
192
     handleRevoke(row) {
193
       const params = {
193
       const params = {
194
-        instanceId: row.procInsId
194
+        instanceId: row.procInsId,
195
+        taskId: row.taskId
195
       }
196
       }
196
       revokeProcess(params).then(res => {
197
       revokeProcess(params).then(res => {
197
         this.$modal.msgSuccess(res.msg);
198
         this.$modal.msgSuccess(res.msg);

Loading…
Cancel
Save