Commit 45399687b4849064ac0daba9550d51898a9a44e2
1 parent
dea5e07e
fix: 修复退回到多实例任务时候,会自动跳过问题。 https://github.com/YunaiV/ruoyi-vue-pro/issues/1128
Showing
1 changed file
with
8 additions
and
6 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -618,7 +618,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -618,7 +618,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 618 | runtimeService.setVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn); | 618 | runtimeService.setVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn); |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | - // 6. 调用 BPM complete 去完成任务 | 621 | + // 6. 清理退回设置的不自动通过的变量。 |
| 622 | + runtimeService.removeVariable(task.getProcessInstanceId(), String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey())); | ||
| 623 | + | ||
| 624 | + // 7. 调用 BPM complete 去完成任务 | ||
| 622 | taskService.complete(task.getId(), variables, true); | 625 | taskService.complete(task.getId(), variables, true); |
| 623 | 626 | ||
| 624 | // 【加签专属】处理加签任务 | 627 | // 【加签专属】处理加签任务 |
| @@ -955,9 +958,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -955,9 +958,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 955 | .moveActivityIdsToSingleActivityId(returnTaskKeyList, reqVO.getTargetTaskDefinitionKey()) | 958 | .moveActivityIdsToSingleActivityId(returnTaskKeyList, reqVO.getTargetTaskDefinitionKey()) |
| 956 | // 设置需要预测的任务 ids 的流程变量,用于辅助预测 | 959 | // 设置需要预测的任务 ids 的流程变量,用于辅助预测 |
| 957 | .processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys) | 960 | .processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys) |
| 958 | - // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过 | ||
| 959 | - .localVariable(reqVO.getTargetTaskDefinitionKey(), | ||
| 960 | - String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE) | 961 | + // 设置流程变量节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过 |
| 962 | + .processVariable(String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE) | ||
| 961 | .changeState(); | 963 | .changeState(); |
| 962 | } | 964 | } |
| 963 | 965 | ||
| @@ -1506,8 +1508,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -1506,8 +1508,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 1506 | return; | 1508 | return; |
| 1507 | } | 1509 | } |
| 1508 | FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); | 1510 | FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| 1509 | - // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略(使用 local variable) | ||
| 1510 | - Boolean returnTaskFlag = runtimeService.getVariableLocal(task.getExecutionId(), | 1511 | + // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略 |
| 1512 | + Boolean returnTaskFlag = runtimeService.getVariable(processInstance.getProcessInstanceId(), | ||
| 1511 | String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class); | 1513 | String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class); |
| 1512 | Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(), | 1514 | Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(), |
| 1513 | BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); | 1515 | BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); |