潘志宝
4 天以前 b8a0affd03b5fa9fa33cd6f870e90394c2df86c7
提交 | 用户 | 时间
bb2880 1 package com.iailab.module.bpm.framework.flowable.core.candidate.strategy.user;
H 2
3 import com.iailab.framework.common.util.collection.SetUtils;
4 import com.iailab.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
5 import com.iailab.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
6 import com.iailab.module.bpm.service.task.BpmProcessInstanceService;
7 import org.flowable.bpmn.model.BpmnModel;
8 import org.flowable.engine.delegate.DelegateExecution;
9 import org.flowable.engine.runtime.ProcessInstance;
10 import org.springframework.context.annotation.Lazy;
11 import org.springframework.stereotype.Component;
12
13 import javax.annotation.Resource;
14 import java.util.Map;
15 import java.util.Set;
16
17 /**
18  * 发起人自己 {@link BpmTaskCandidateUserStrategy} 实现类
19  * <p>
20  * 适合场景:用于需要发起人信息复核等场景
21  *
22  * @author hou
23  */
24 @Component
25 public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrategy {
26
27     @Resource
28     @Lazy // 延迟加载,避免循环依赖
29     private BpmProcessInstanceService processInstanceService;
30
31     @Override
32     public BpmTaskCandidateStrategyEnum getStrategy() {
33         return BpmTaskCandidateStrategyEnum.START_USER;
34     }
35
36     @Override
37     public void validateParam(String param) {
38     }
39
40     @Override
41     public boolean isParamRequired() {
42         return false;
43     }
44
45     @Override
46     public Set<Long> calculateUsersByTask(DelegateExecution execution, String param) {
47         ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
48         return SetUtils.asSet(Long.valueOf(processInstance.getStartUserId()));
49     }
50
51     @Override
52     public Set<Long> calculateUsersByActivity(BpmnModel bpmnModel, String activityId, String param,
53                                               Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
54         return SetUtils.asSet(startUserId);
55     }
56
57 }