|
@@ -99,20 +99,24 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
99
|
99
|
if (Objects.isNull(task)) {
|
100
|
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
|
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
|
114
|
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
112
|
115
|
taskService.setAssignee(taskVo.getTaskId(), userId.toString());
|
113
|
116
|
taskService.complete(taskVo.getTaskId(), taskVo.getVariables());
|
114
|
117
|
}
|
115
|
118
|
}
|
|
119
|
+
|
116
|
120
|
return AjaxResult.success();
|
117
|
121
|
}
|
118
|
122
|
|
|
@@ -675,13 +679,17 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
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
|
689
|
if (allElements != null) {
|
682
|
690
|
for (FlowElement flowElement : allElements) {
|
683
|
691
|
// 跳转的节点元素
|
684
|
|
- if (flowElement.getId().equals(targetTaskDefinitionId)) {
|
|
692
|
+ if (flowElement.getId().equals(lastHistoricTaskDefinitionKey)) {
|
685
|
693
|
target = flowElement;
|
686
|
694
|
}
|
687
|
695
|
}
|
|
@@ -701,7 +709,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
701
|
709
|
// 1 对 1 或 多 对 1 情况,currentIds 当前要跳转的节点列表(1或多),targetKey 跳转到的节点(1)
|
702
|
710
|
runtimeService.createChangeActivityStateBuilder()
|
703
|
711
|
.processInstanceId(task.getProcessInstanceId())
|
704
|
|
- .moveActivityIdsToSingleActivityId(currentIds, targetTaskDefinitionId).changeState();
|
|
712
|
+ .moveActivityIdsToSingleActivityId(currentIds, lastHistoricTaskDefinitionKey).changeState();
|
705
|
713
|
} catch (FlowableObjectNotFoundException e) {
|
706
|
714
|
throw new CustomException("未找到流程实例,流程可能已发生变化");
|
707
|
715
|
} catch (FlowableException e) {
|