From d237b17280c43b67eb14e63821fc6e22475e6139 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Tue, 10 Dec 2024 13:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=BC=BA=E9=99=B7=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E3=80=91=20=E6=B5=81=E7=A8=8B=E9=A2=84=E6=B5=8B=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=83=BD=E8=AE=A1=E7=AE=97=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=97=B6=EF=BC=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=A9=BA=E5=88=97=E8=A1=A8=EF=BC=8C=E9=81=BF=E5=85=8D=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=97=A0=E6=B3=95=E8=BF=9B=E8=A1=8C=E4=B8=8B=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BpmTaskCandidateExpressionStrategy.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java index 5683edeef0..c008c1cb6f 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java @@ -4,10 +4,14 @@ import cn.hutool.core.convert.Convert; import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; +import com.google.common.collect.Sets; +import lombok.extern.slf4j.Slf4j; import org.flowable.bpmn.model.BpmnModel; +import org.flowable.common.engine.api.FlowableException; import org.flowable.engine.delegate.DelegateExecution; import org.springframework.stereotype.Component; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -17,6 +21,7 @@ import java.util.Set; * @author 芋道源码 */ @Component +@Slf4j public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy { @Override @@ -38,8 +43,16 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat @Override public Set calculateUsersByActivity(BpmnModel bpmnModel, String activityId, String param, Long startUserId, String processDefinitionId, Map processVariables) { - Object result = FlowableUtils.getExpressionValue(processVariables, param); - return Convert.toSet(Long.class, result); + Map variables = processVariables == null ? new HashMap<>() : processVariables; + try { + Object result = FlowableUtils.getExpressionValue(variables, param); + return Convert.toSet(Long.class, result); + } catch (FlowableException ex) { + // 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常, + log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex); + // 不能预测候选人,返回空列表, 避免流程无法进行 + return Sets.newHashSet(); + } } } \ No newline at end of file