Commit dace9cfed56fe01db443d787e605ac4026c20235

Authored by jason
1 parent 27235016

perf: [BPM 工作流] 驳回预测 review 修改

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. @@ -72,7 +72,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
72 import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode; 72 import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode;
73 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; 73 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
74 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID; 74 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
75 -import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS;  
76 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType; 75 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType;
77 import static java.util.Arrays.asList; 76 import static java.util.Arrays.asList;
78 import static java.util.Collections.singletonList; 77 import static java.util.Collections.singletonList;
@@ -223,7 +222,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService @@ -223,7 +222,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
223 // 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量 222 // 3.2 获取由于退回操作,需要预测的节点。从流程变量中获取,回退操作会设置这些变量
224 Set<String> needSimulateTaskDefKeysByReturn = new HashSet<>(); 223 Set<String> needSimulateTaskDefKeysByReturn = new HashSet<>();
225 if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) { 224 if (StrUtil.isNotEmpty(reqVO.getProcessInstanceId())) {
226 - Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); 225 + Object needSimulateTaskIds = runtimeService.getVariable(reqVO.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
227 needSimulateTaskDefKeysByReturn.addAll(Convert.toSet(String.class, needSimulateTaskIds)); 226 needSimulateTaskDefKeysByReturn.addAll(Convert.toSet(String.class, needSimulateTaskIds));
228 } 227 }
229 // 移除运行中的节点,运行中的节点无需预测 228 // 移除运行中的节点,运行中的节点无需预测
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 @@ -69,7 +69,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
69 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; 69 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
70 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; 70 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
71 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID; 71 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
72 -import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.*;  
73 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.*; 72 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.*;
74 73
75 /** 74 /**
@@ -602,11 +601,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -602,11 +601,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
602 runtimeService.setVariables(task.getProcessInstanceId(), variables); 601 runtimeService.setVariables(task.getProcessInstanceId(), variables);
603 602
604 // 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置 603 // 5. 如果当前节点 Id 存在于需要预测的流程节点中,从中移除。 流程变量在回退操作中设置
605 - Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS); 604 + Object needSimulateTaskIds = runtimeService.getVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS);
606 Set<String> needSimulateTaskIdsByReturn = Convert.toSet(String.class, needSimulateTaskIds); 605 Set<String> needSimulateTaskIdsByReturn = Convert.toSet(String.class, needSimulateTaskIds);
607 if (needSimulateTaskIdsByReturn.contains(task.getTaskDefinitionKey())) { 606 if (needSimulateTaskIdsByReturn.contains(task.getTaskDefinitionKey())) {
608 needSimulateTaskIdsByReturn.remove(task.getTaskDefinitionKey()); 607 needSimulateTaskIdsByReturn.remove(task.getTaskDefinitionKey());
609 - runtimeService.setVariable(task.getProcessInstanceId(), PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn); 608 + runtimeService.setVariable(task.getProcessInstanceId(), BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskIdsByReturn);
610 } 609 }
611 610
612 // 6. 调用 BPM complete 去完成任务 611 // 6. 调用 BPM complete 去完成任务
@@ -945,10 +944,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -945,10 +944,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
945 .processInstanceId(currentTask.getProcessInstanceId()) 944 .processInstanceId(currentTask.getProcessInstanceId())
946 .moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey()) 945 .moveExecutionsToSingleActivityId(runExecutionIds, reqVO.getTargetTaskDefinitionKey())
947 // 设置需要预测的任务 ids 的流程变量,用于辅助预测 946 // 设置需要预测的任务 ids 的流程变量,用于辅助预测
948 - .processVariable(PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys) 947 + .processVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_NEED_SIMULATE_TASK_IDS, needSimulateTaskDefinitionKeys)
949 // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过 948 // 设置流程变量(local)节点退回标记, 用于退回到节点,不执行 BpmUserTaskAssignStartUserHandlerTypeEnum 策略,导致自动通过
950 .localVariable(reqVO.getTargetTaskDefinitionKey(), 949 .localVariable(reqVO.getTargetTaskDefinitionKey(),
951 - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE) 950 + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, reqVO.getTargetTaskDefinitionKey()), Boolean.TRUE)
952 .changeState(); 951 .changeState();
953 } 952 }
954 953
@@ -1492,9 +1491,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -1492,9 +1491,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
1492 FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); 1491 FlowElement userTaskElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
1493 // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略(使用 local variable) 1492 // 判断是否为退回或者驳回:如果是退回或者驳回不走这个策略(使用 local variable)
1494 Boolean returnTaskFlag = runtimeService.getVariableLocal(task.getExecutionId(), 1493 Boolean returnTaskFlag = runtimeService.getVariableLocal(task.getExecutionId(),
1495 - String.format(PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class); 1494 + String.format(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG, task.getTaskDefinitionKey()), Boolean.class);
1496 Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(), 1495 Boolean skipStartUserNodeFlag = Convert.toBool(runtimeService.getVariable(processInstance.getProcessInstanceId(),
1497 - PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); 1496 + BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
1498 if (userTaskElement.getId().equals(START_USER_NODE_ID) 1497 if (userTaskElement.getId().equals(START_USER_NODE_ID)
1499 && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核 1498 && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
1500 || BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核 1499 || BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核