From 1397e09913013bac568a4bbe7cf9f4ee3eada5a3 Mon Sep 17 00:00:00 2001 From: wangli <274027703@qq.com> Date: Wed, 11 Feb 2026 15:01:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(REQ-7380)=20-=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=A2=84=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=E4=B8=AD=E6=9C=AA?= =?UTF-8?q?=E9=80=82=E9=85=8Dcategory=20=E7=89=88=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NextActivityConfigCheckJobHandler.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/job/NextActivityConfigCheckJobHandler.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/job/NextActivityConfigCheckJobHandler.java index 9ad5586c7..f64a12bf0 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/job/NextActivityConfigCheckJobHandler.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/job/NextActivityConfigCheckJobHandler.java @@ -13,6 +13,7 @@ import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.ListUtils; import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.Process; import org.flowable.bpmn.model.ReceiveTask; import org.flowable.bpmn.model.ServiceTask; import org.flowable.bpmn.model.UserTask; @@ -22,6 +23,7 @@ import org.flowable.engine.RuntimeService; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.util.CommandContextUtil; +import org.flowable.engine.impl.util.ProcessDefinitionUtil; import org.flowable.engine.runtime.Execution; import org.flowable.engine.runtime.ProcessInstance; import org.flowable.job.service.JobHandler; @@ -38,6 +40,7 @@ import java.util.concurrent.atomic.AtomicReference; import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApprovalMethod; import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApproverEmptyHandleType; import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getApproverSpecify; +import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion; /** * 检查节点配置是否合法 @@ -71,7 +74,9 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem return; } try { - doCheck(job, flowElements, processEngineConfiguration); + Process mainProcess = ProcessDefinitionUtil.getBpmnModel(processInstance.getProcessDefinitionId()).getMainProcess(); + Optional categoryVersion = getCategoryVersion(mainProcess); + doCheck(job, flowElements, processEngineConfiguration, categoryVersion.get()); } catch (Exception e) { // 有任何异常,则通过钉钉告警 log.warn("NextActivityConfigCheckJobHandler msg: {}", e.getMessage(), e); @@ -89,7 +94,7 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem } } - private void doCheck(JobEntity job, List flowElements, ProcessEngineConfigurationImpl processEngineConfiguration) { + private void doCheck(JobEntity job, List flowElements, ProcessEngineConfigurationImpl processEngineConfiguration, Integer categoryVersion) { AtomicReference checkActivityId = new AtomicReference<>(""); ListUtils.emptyIfNull(flowElements).stream() .filter(i -> i instanceof UserTask || i instanceof ReceiveTask || i instanceof ServiceTask) @@ -115,8 +120,9 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem assigners.addAll(approverSelect(specify.getType(), flowElement, (DelegateExecution) executions.get(0), true)); }); + // 审批候选人为空时的兜底 - emptyAssigneeHandle(assigners, flowElement, (DelegateExecution) executions.get(0)); + emptyAssigneeHandle(assigners, flowElement, (DelegateExecution) executions.get(0), categoryVersion); break; } }); @@ -144,12 +150,13 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem /** * 计算节点的待审批人为空时, 执行模型配置中的审批人为空时的处理方式 * - * @param assigners 节点计算的待审批人集合, 可能为空 - * @param flowElement 当前节点 - * @param execution 当前执行实例 + * @param assigners 节点计算的待审批人集合, 可能为空 + * @param flowElement 当前节点 + * @param execution 当前执行实例 + * @param categoryVersion */ private void emptyAssigneeHandle(List assigners, FlowElement flowElement, - DelegateExecution execution) { + DelegateExecution execution, Integer categoryVersion) { // 审批人为空并且当前节点设置了自动跳过条件 if (!CollectionUtils.isEmpty(assigners)) { return; @@ -163,10 +170,12 @@ public class NextActivityConfigCheckJobHandler extends AbstractJobHandler implem break; case transferToAdmin: try { - assigners.addAll(approverSelect(ApproverEmptyHandleTypeEnum.transferToAdmin.getType(), flowElement, - execution, true)); - if (CollectionUtils.isEmpty(assigners)) { - throw new IllegalArgumentException("审批人为空后转交管理员仍然为空"); + if (categoryVersion < 2) { + assigners.addAll(approverSelect(ApproverEmptyHandleTypeEnum.transferToAdmin.getType(), flowElement, + execution, true)); + if (CollectionUtils.isEmpty(assigners)) { + throw new IllegalArgumentException("审批人为空后转交管理员仍然为空"); + } } } catch (Exception e) { if (e instanceof IllegalArgumentException) {