潘志宝
9 天以前 6b13839488edcd06046e26a41fe897358176689c
提交 | 用户 | 时间
bb2880 1 package com.iailab.module.bpm.framework.flowable.core.candidate.strategy.user;
e7c126 2
H 3 import com.iailab.framework.common.util.string.StrUtils;
4 import com.iailab.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
5 import com.iailab.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
6 import com.iailab.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
7 import com.iailab.module.bpm.service.definition.BpmUserGroupService;
8 import org.springframework.stereotype.Component;
9
10 import javax.annotation.Resource;
11 import java.util.Collection;
12 import java.util.List;
13 import java.util.Set;
14
15 import static com.iailab.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
16
bb2880 17
e7c126 18 /**
H 19  * 用户组 {@link BpmTaskCandidateStrategy} 实现类
20  *
bb2880 21  * @author hou
e7c126 22  */
H 23 @Component
24 public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy {
25
26     @Resource
27     private BpmUserGroupService userGroupService;
28
29     @Override
30     public BpmTaskCandidateStrategyEnum getStrategy() {
31         return BpmTaskCandidateStrategyEnum.USER_GROUP;
32     }
33
34     @Override
35     public void validateParam(String param) {
36         Set<Long> groupIds = StrUtils.splitToLongSet(param);
bb2880 37         userGroupService.validUserGroups(groupIds);
e7c126 38     }
H 39
40     @Override
bb2880 41     public Set<Long> calculateUsers(String param) {
e7c126 42         Set<Long> groupIds = StrUtils.splitToLongSet(param);
H 43         List<BpmUserGroupDO> groups = userGroupService.getUserGroupList(groupIds);
44         return convertSetByFlatMap(groups, BpmUserGroupDO::getUserIds, Collection::stream);
45     }
46
47 }