|
|
@@ -601,9 +601,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|
|
bpmnModel, reqVO.getNextAssignees(), instance);
|
|
|
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
|
|
|
|
|
- // 5. 移除辅助预测的流程变量,这些变量在回退操作中设置
|
|
|
- String simulateVariableName = StrUtil.concat(false, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, task.getTaskDefinitionKey());
|
|
|
- runtimeService.removeVariable(task.getProcessInstanceId(), simulateVariableName);
|
|
|
+ // 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置
|
|
|
+ Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
|
|
|
+ Set<String> needSimulateTaskIdsByReturn = Convert.toSet(String.class, needSimulateTaskIds);
|
|
|
+ if (needSimulateTaskIdsByReturn.contains(task.getTaskDefinitionKey())) {
|
|
|
+ needSimulateTaskIdsByReturn.remove(task.getTaskDefinitionKey());
|
|
|
+ runtimeService.setVariable(task.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn);
|
|
|
+ }
|
|
|
|
|
|
// 6. 调用 BPM complete 去完成任务
|
|
|
taskService.complete(task.getId(), variables, true);
|
|
|
@@ -932,11 +936,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|
|
});
|
|
|
|
|
|
// 3. 构建需要预测的任务流程变量
|
|
|
- // TODO @jason:【驳回预测相关】是不是搞成一个变量,里面是 set 更简洁一点呀?
|
|
|
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
|
|
|
- Map<String, Object> needSimulateVariables = convertMap(needSimulateTaskDefinitionKeys,
|
|
|
- key -> StrUtil.concat(false, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, key), item -> Boolean.TRUE);
|
|
|
-
|
|
|
|
|
|
// 4. 执行驳回
|
|
|
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
|
|
@@ -944,9 +944,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|
|
runtimeService.createChangeActivityStateBuilder()
|
|
|
.processInstanceId(currentTask.getProcessInstanceId())
|
|
|
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
|
|
- // 设置需要预测的任务流程变量,用于辅助预测
|
|
|
- .processVariables(needSimulateVariables)
|
|
|
- // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
|
|
+ // 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
|
|
+ .processVariable(PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
|
|
+ // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
|
|
.localVariable(reqVO.getTargetTaskDefinitionKey(),
|
|
|
String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE)
|
|
|
.changeState();
|