From dace9cfed56fe01db443d787e605ac4026c20235 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sun, 12 Oct 2025 16:28:49 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20[BPM=20=E5=B7=A5=E4=BD=9C=E6=B5=81]=20?= =?UTF-8?q?=E9=A9=B3=E5=9B=9E=E9=A2=84=E6=B5=8B=20review=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/task/BpmProcessInstanceServiceImpl.java | 3 +-- .../module/bpm/service/task/BpmTaskServiceImpl.java | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java b/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java index aaef5df875..af388fbd04 100644 --- a/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java +++ b/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java @@ -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_TASK_IDS; 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; @@ -223,7 +222,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService // 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量 Set needSimulateTaskDefKeysByReturn = new HashSet<>(); if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) { - Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); + Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); needSimulateTaskDefKeysByReturn.addAll(Convert.toSet(String.class, needSimulateTaskIds)); } // 移除运行中的节点,运行中的节点无需预测 diff --git a/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java b/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java index a41cee6202..36cdcf31eb 100644 --- a/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java +++ b/yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java @@ -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.*; /** @@ -602,11 +601,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { runtimeService.setVariables(task.getProcessInstanceId(), variables); // 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置 - Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); + Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); Set 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); + runtimeService.setVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn); } // 6. 调用 BPM complete 去完成任务 @@ -945,10 +944,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { .processInstanceId(currentTask.getProcessInstanceId()) .moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey()) // 设置需要预测的任务 ids 的流程变量,用于辅助预测 - .processVariable(PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys) + .processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys) // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过 .localVariable(reqVO.getTargetTaskDefinitionKey(), - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE) + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE) .changeState(); } @@ -1492,9 +1491,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略(使用 local variable) Boolean returnTaskFlag = runtimeService.getVariableLocal(task.getExecutionId(), - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class); + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class); Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(), - PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); + BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); if (userTaskElement.getId().equals(START_USER_NODE_ID) && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核 || BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核