Commit 0c06a1596eb6363c8a58353aaf5560a5c04dc9b1
1 parent
4cf82ba2
【功能新增】 增加审批人分配策略:选择表单内成员
Showing
2 changed files
with
51 additions
and
0 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/user/BpmTaskCandidateUserFieldOnFormStrategy.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.user; | |
| 2 | + | |
| 3 | +import cn.hutool.core.convert.Convert; | |
| 4 | +import cn.hutool.core.lang.Assert; | |
| 5 | +import cn.hutool.core.map.MapUtil; | |
| 6 | +import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy; | |
| 7 | +import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; | |
| 8 | +import org.flowable.bpmn.model.BpmnModel; | |
| 9 | +import org.flowable.engine.delegate.DelegateExecution; | |
| 10 | +import org.springframework.stereotype.Component; | |
| 11 | + | |
| 12 | +import java.util.HashSet; | |
| 13 | +import java.util.Map; | |
| 14 | +import java.util.Set; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 表单内用户字段 {@link BpmTaskCandidateUserStrategy} 实现类 | |
| 20 | + * | |
| 21 | + * @author jason | |
| 22 | + */ | |
| 23 | +@Component | |
| 24 | +public class BpmTaskCandidateUserFieldOnFormStrategy implements BpmTaskCandidateStrategy { | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public BpmTaskCandidateStrategyEnum getStrategy() { | |
| 28 | + return BpmTaskCandidateStrategyEnum.USER_FIELD_ON_FORM; | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public void validateParam(String param) { | |
| 33 | + Assert.notEmpty(param, "表单内用户字段不能为空"); | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) { | |
| 38 | + Object result = execution.getVariable(param); | |
| 39 | + return Convert.toSet(Long.class, result); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId, | |
| 44 | + String param, Long startUserId, String processDefinitionId, | |
| 45 | + Map<String, Object> processVariables) { | |
| 46 | + Long result = MapUtil.getLong(processVariables, param); | |
| 47 | + return result != null ? asSet(result) : new HashSet<>(); | |
| 48 | + } | |
| 49 | + | |
| 50 | +} | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmTaskCandidateStrategyEnum.java
| ... | ... | @@ -29,6 +29,7 @@ public enum BpmTaskCandidateStrategyEnum implements IntArrayValuable { |
| 29 | 29 | START_USER_DEPT_LEADER(37, "发起人部门负责人"), |
| 30 | 30 | START_USER_DEPT_LEADER_MULTI(38, "发起人连续多级部门的负责人"), |
| 31 | 31 | USER_GROUP(40, "用户组"), |
| 32 | + USER_FIELD_ON_FORM(50, "表单内用户字段"), | |
| 32 | 33 | EXPRESSION(60, "流程表达式"), // 表达式 ExpressionManager |
| 33 | 34 | ASSIGN_EMPTY(1, "审批人为空"), |
| 34 | 35 | ; | ... | ... |