Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk17
# Conflicts: # yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
This commit is contained in:
commit
5f993c6a9f
@ -54,11 +54,11 @@ public class BpmnVariableConstants {
|
|||||||
public static final String PROCESS_INSTANCE_VARIABLE_RETURN_FLAG = "RETURN_FLAG_%s";
|
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";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程实例的变量 - 是否跳过表达式
|
* 流程实例的变量 - 是否跳过表达式
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.bpm.service.task;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.*;
|
import cn.hutool.core.util.*;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
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.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode;
|
||||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
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.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 cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
@ -227,11 +226,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||||||
// 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量
|
// 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量
|
||||||
Set<String> needSimulateTaskDefKeysByReturn = new HashSet<>();
|
Set<String> needSimulateTaskDefKeysByReturn = new HashSet<>();
|
||||||
if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) {
|
if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) {
|
||||||
Map<String, Object> variables = runtimeService.getVariables(reqVO.getProcessInstanceId());
|
Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
|
||||||
Map<String, Object> simulateTaskVariables = MapUtil.filter(variables,
|
needSimulateTaskDefKeysByReturn.addAll(Convert.toSet(String.class, needSimulateTaskIds));
|
||||||
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)));
|
|
||||||
}
|
}
|
||||||
// 移除运行中的节点,运行中的节点无需预测
|
// 移除运行中的节点,运行中的节点无需预测
|
||||||
if (CollUtil.isNotEmpty(runActivityNodes)) {
|
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.framework.common.util.collection.CollectionUtils.*;
|
||||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
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.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.*;
|
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);
|
bpmnModel, reqVO.getNextAssignees(), instance);
|
||||||
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
runtimeService.setVariables(task.getProcessInstanceId(), variables);
|
||||||
|
|
||||||
// 5. 移除辅助预测的流程变量,这些变量在回退操作中设置
|
// 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置
|
||||||
// todo @jason:可以直接 + 拼接哈
|
Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
|
||||||
String simulateVariableName = StrUtil.concat(false,
|
Set<String> needSimulateTaskIdsByReturn = Convert.toSet(String.class, needSimulateTaskIds);
|
||||||
BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_PREFIX, task.getTaskDefinitionKey());
|
if (needSimulateTaskIdsByReturn.contains(task.getTaskDefinitionKey())) {
|
||||||
runtimeService.removeVariable(task.getProcessInstanceId(), simulateVariableName);
|
needSimulateTaskIdsByReturn.remove(task.getTaskDefinitionKey());
|
||||||
|
runtimeService.setVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn);
|
||||||
|
}
|
||||||
|
|
||||||
// 6. 调用 BPM complete 去完成任务
|
// 6. 调用 BPM complete 去完成任务
|
||||||
taskService.complete(task.getId(), variables, true);
|
taskService.complete(task.getId(), variables, true);
|
||||||
@ -937,11 +938,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 3. 构建需要预测的任务流程变量
|
// 3. 构建需要预测的任务流程变量
|
||||||
// TODO @jason:【驳回预测相关】是不是搞成一个变量,里面是 set 更简洁一点呀?
|
|
||||||
Set<String> needSimulateTaskDefinitionKeys = getNeedSimulateTaskDefinitionKeys(bpmnModel, currentTask, targetElement);
|
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. 执行驳回
|
// 4. 执行驳回
|
||||||
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
// 使用 moveExecutionsToSingleActivityId 替换 moveActivityIdsToSingleActivityId 原因:
|
||||||
@ -949,12 +946,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
runtimeService.createChangeActivityStateBuilder()
|
runtimeService.createChangeActivityStateBuilder()
|
||||||
.processInstanceId(currentTask.getProcessInstanceId())
|
.processInstanceId(currentTask.getProcessInstanceId())
|
||||||
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
.moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
|
||||||
// 设置需要预测的任务流程变量,用于辅助预测
|
// 设置需要预测的任务 ids 的流程变量,用于辅助预测
|
||||||
.processVariables(needSimulateVariables)
|
.processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
|
||||||
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
// 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
|
||||||
.localVariable(reqVO.getTargetTaskDefinitionKey(),
|
.localVariable(reqVO.getTargetTaskDefinitionKey(),
|
||||||
String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()),
|
String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE)
|
||||||
Boolean.TRUE)
|
|
||||||
.changeState();
|
.changeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user