Commit d237b17280c43b67eb14e63821fc6e22475e6139

Authored by jason
1 parent de9dc245

【缺陷修复】 流程预测时,不能计算流程表达式时,返回空列表,避免流程无法进行下去

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;
4 4 import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
5 5 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
6 6 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
  7 +import com.google.common.collect.Sets;
  8 +import lombok.extern.slf4j.Slf4j;
7 9 import org.flowable.bpmn.model.BpmnModel;
  10 +import org.flowable.common.engine.api.FlowableException;
8 11 import org.flowable.engine.delegate.DelegateExecution;
9 12 import org.springframework.stereotype.Component;
10 13  
  14 +import java.util.HashMap;
11 15 import java.util.Map;
12 16 import java.util.Set;
13 17  
... ... @@ -17,6 +21,7 @@ import java.util.Set;
17 21 * @author 芋道源码
18 22 */
19 23 @Component
  24 +@Slf4j
20 25 public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy {
21 26  
22 27 @Override
... ... @@ -38,8 +43,16 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
38 43 @Override
39 44 public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId, String param,
40 45 Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
41   - Object result = FlowableUtils.getExpressionValue(processVariables, param);
42   - return Convert.toSet(Long.class, result);
  46 + Map<String, Object> variables = processVariables == null ? new HashMap<>() : processVariables;
  47 + try {
  48 + Object result = FlowableUtils.getExpressionValue(variables, param);
  49 + return Convert.toSet(Long.class, result);
  50 + } catch (FlowableException ex) {
  51 + // 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常,
  52 + log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex);
  53 + // 不能预测候选人,返回空列表, 避免流程无法进行
  54 + return Sets.newHashSet();
  55 + }
43 56 }
44 57  
45 58 }
46 59 \ No newline at end of file
... ...