Commit a6e5b2880b0548f35f300e47f558da57f440fc74
1 parent
87c5c068
【功能优化】工作流:会签、或签分配人的时候,如果已经分配过,则不重复计算
Showing
2 changed files
with
15 additions
and
6 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmParallelMultiInstanceBehavior.java
| ... | ... | @@ -48,8 +48,13 @@ public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehav |
| 48 | 48 | super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); |
| 49 | 49 | |
| 50 | 50 | // 第二步,获取任务的所有处理人 |
| 51 | - Set<Long> assigneeUserIds = taskCandidateInvoker.calculateUsers(execution); | |
| 52 | - execution.setVariable(super.collectionVariable, assigneeUserIds); | |
| 51 | + // 由于每次审批(会签、或签等情况)后都会执行一次,所以 variable 已经有结果,不重复计算 | |
| 52 | + @SuppressWarnings("unchecked") | |
| 53 | + Set<Long> assigneeUserIds = (Set<Long>) execution.getVariable(super.collectionVariable, Set.class); | |
| 54 | + if (assigneeUserIds == null) { | |
| 55 | + assigneeUserIds = taskCandidateInvoker.calculateUsers(execution); | |
| 56 | + execution.setVariable(super.collectionVariable, assigneeUserIds); | |
| 57 | + } | |
| 53 | 58 | return assigneeUserIds.size(); |
| 54 | 59 | } |
| 55 | 60 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/behavior/BpmSequentialMultiInstanceBehavior.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; | |
| 4 | 3 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; |
| 4 | +import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; | |
| 5 | 5 | import lombok.Setter; |
| 6 | 6 | import org.flowable.bpmn.model.Activity; |
| 7 | 7 | import org.flowable.engine.delegate.DelegateExecution; |
| 8 | 8 | import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior; |
| 9 | 9 | import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior; |
| 10 | 10 | |
| 11 | -import java.util.LinkedHashSet; | |
| 12 | 11 | import java.util.Set; |
| 13 | 12 | |
| 14 | 13 | /** |
| ... | ... | @@ -42,8 +41,13 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB |
| 42 | 41 | super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId()); |
| 43 | 42 | |
| 44 | 43 | // 第二步,获取任务的所有处理人 |
| 45 | - Set<Long> assigneeUserIds = new LinkedHashSet<>(taskCandidateInvoker.calculateUsers(execution)); // 保证有序!!! | |
| 46 | - execution.setVariable(super.collectionVariable, assigneeUserIds); | |
| 44 | + // 由于每次审批(会签、或签等情况)后都会执行一次,所以 variable 已经有结果,不重复计算 | |
| 45 | + @SuppressWarnings("unchecked") | |
| 46 | + Set<Long> assigneeUserIds = (Set<Long>) execution.getVariable(super.collectionVariable, Set.class); | |
| 47 | + if (assigneeUserIds == null) { | |
| 48 | + assigneeUserIds = taskCandidateInvoker.calculateUsers(execution); | |
| 49 | + execution.setVariable(super.collectionVariable, assigneeUserIds); | |
| 50 | + } | |
| 47 | 51 | return assigneeUserIds.size(); |
| 48 | 52 | } |
| 49 | 53 | ... | ... |