【同步】BOOT 和 CLOUD 的功能
This commit is contained in:
@@ -54,11 +54,11 @@ public class BpmnVariableConstants {
|
||||
public static final String PROCESS_INSTANCE_VARIABLE_RETURN_FLAG = "RETURN_FLAG_%s";
|
||||
|
||||
/**
|
||||
* 流程实例的变量前缀 - 用于退回操作,记录需要预测的节点:格式 NEED_SIMULATE_TASK_{节点定义 id}
|
||||
* 流程实例的变量 - 用于退回操作,记录需要预测的节点 ids, 变量值类型为 Set
|
||||
*
|
||||
* 目的是:退回操作,预测节点会不准,在流程变量中记录需要预测的节点,来辅助预测
|
||||
*/
|
||||
public static final String PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX = "NEED_SIMULATE_TASK_";
|
||||
public static final String PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS = "NEED_SIMULATE_TASK_IDS";
|
||||
|
||||
/**
|
||||
* 流程实例的变量 - 是否跳过表达式
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy
|
||||
}
|
||||
// 执行抄送
|
||||
createProcessInstanceCopy(userIds, reason,
|
||||
task.getProcessInstanceId(), task.getTaskDefinitionKey(), task.getId(), task.getName());
|
||||
task.getProcessInstanceId(), task.getTaskDefinitionKey(), task.getName(), task.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.bpm.service.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
@@ -72,7 +72,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
@@ -227,11 +226,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
// 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量
|
||||
Set<String> needSimulateTaskDefKeysByReturn = new HashSet<>();
|
||||
if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) {
|
||||
Map<String, Object> variables = runtimeService.getVariables(reqVO.getProcessInstanceId());
|
||||
Map<String, Object> simulateTaskVariables = MapUtil.filter(variables,
|
||||
item -> item.getKey().startsWith(PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX));
|
||||
simulateTaskVariables.forEach((key, value) ->
|
||||
needSimulateTaskDefKeysByReturn.add(StrUtil.removePrefix(key, PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX)));
|
||||
Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
|
||||
needSimulateTaskDefKeysByReturn.addAll(Convert.toSet(String.class, needSimulateTaskIds));
|
||||
}
|
||||
// 移除运行中的节点,运行中的节点无需预测
|
||||
if (CollUtil.isNotEmpty(runActivityNodes)) {
|
||||
|
||||
@@ -69,7 +69,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
|
||||
//import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.*;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.*;
|
||||
|
||||
/**
|
||||
@@ -604,11 +603,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
bpmnModel, reqVO.getNextAssignees(), instance);
|
||||
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
||||
|
||||
// 5. 移除辅助预测的流程变量,这些变量在回退操作中设置
|
||||
// todo @jason:可以直接 + 拼接哈
|
||||
String simulateVariableName = StrUtil.concat(false,
|
||||
BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, task.getTaskDefinitionKey());
|
||||
runtimeService.removeVariable(task.getProcessInstanceId(), simulateVariableName);
|
||||
// 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置
|
||||
Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), BpmnVariableConstants.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(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn);
|
||||
}
|
||||
|
||||
// 6. 调用 BPM complete 去完成任务
|
||||
taskService.complete(task.getId(), variables, true);
|
||||
@@ -937,11 +938,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, BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, key), item -> Boolean.TRUE);
|
||||
|
||||
|
||||
// 4. 执行驳回
|
||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
||||
@@ -949,12 +946,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(currentTask.getProcessInstanceId())
|
||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||
// 设置需要预测的任务流程变量,用于辅助预测
|
||||
.processVariables(needSimulateVariables)
|
||||
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
||||
// 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
||||
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
||||
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
||||
.localVariable(reqVO.getTargetTaskDefinitionKey(),
|
||||
String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()),
|
||||
Boolean.TRUE)
|
||||
String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE)
|
||||
.changeState();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user