houzhongjian
4 天以前 f4f9405f99cb35e2fd6cfeae4c54617304228fda
提交 | 用户 | 时间
bb2880 1 package com.iailab.module.bpm.framework.flowable.core.candidate.strategy.form;
H 2
3 import cn.hutool.core.convert.Convert;
4 import cn.hutool.core.lang.Assert;
5 import com.iailab.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
6 import com.iailab.module.bpm.framework.flowable.core.candidate.strategy.dept.AbstractBpmTaskCandidateDeptLeaderStrategy;
7 import com.iailab.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.Map;
13 import java.util.Set;
14
15 /**
16  * 表单内部门负责人 {@link BpmTaskCandidateStrategy} 实现类
17  *
18  * @author hou
19  */
20 @Component
21 public class BpmTaskCandidateFormSDeptLeaderStrategy extends AbstractBpmTaskCandidateDeptLeaderStrategy {
22
23     @Override
24     public BpmTaskCandidateStrategyEnum getStrategy() {
25         return BpmTaskCandidateStrategyEnum.FORM_DEPT_LEADER;
26     }
27
28     @Override
29     public void validateParam(String param) {
30         // 参数格式: | 分隔:1)左边为表单内部门字段。2)右边为部门层级
31         String[] params = param.split("\\|");
32         Assert.isTrue(params.length == 2, "参数格式不匹配");
33         Assert.notEmpty(param, "表单内部门字段不能为空");
34         int level = Integer.parseInt(params[1]);
35         Assert.isTrue(level > 0, "部门层级必须大于 0");
36     }
37
38     @Override
39     public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
40         String[] params = param.split("\\|");
41         Object result = execution.getVariable(params[0]);
42         int level = Integer.parseInt(params[1]);
43         return super.getMultiLevelDeptLeaderIds(Convert.toList(Long.class, result), level);
44     }
45
46     @Override
47     public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId,
48                                               String param, Long startUserId, String processDefinitionId,
49                                               Map<String, Object> processVariables) {
50         String[] params = param.split("\\|");
51         Object result = processVariables == null ? null : processVariables.get(params[0]);
52         int level = Integer.parseInt(params[1]);
53         return super.getMultiLevelDeptLeaderIds(Convert.toList(Long.class, result), level);
54     }
55
56 }