【功能修改】任务的候选人的策略, 增加移除被禁用的用户接口
This commit is contained in:
parent
7f6d214ea9
commit
d42c63e8fd
|
@ -111,7 +111,7 @@ public class BpmTaskCandidateInvoker {
|
||||||
removeStartUserIfSkip(execution, userIds);
|
removeStartUserIfSkip(execution, userIds);
|
||||||
|
|
||||||
// 2. 移除被禁用的用户 TODO @芋艿 移除禁用的用户是否应该放在 1.1 之后
|
// 2. 移除被禁用的用户 TODO @芋艿 移除禁用的用户是否应该放在 1.1 之后
|
||||||
removeDisableUsers(userIds);
|
// removeDisableUsers(userIds); @芋艿 把这个移到了 BpmTaskCandidateStrategy 下面。 看一下是否可以
|
||||||
return userIds;
|
return userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,9 @@ public interface BpmTaskCandidateStrategy {
|
||||||
* @return 用户编号集合
|
* @return 用户编号集合
|
||||||
*/
|
*/
|
||||||
default Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
default Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
||||||
return calculateUsers(param);
|
Set<Long> users = calculateUsers(param);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,9 +74,19 @@ public interface BpmTaskCandidateStrategy {
|
||||||
* @return 用户编号集合
|
* @return 用户编号集合
|
||||||
*/
|
*/
|
||||||
default Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
default Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
||||||
return calculateUsers(param);
|
Set<Long> users = calculateUsers(param);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除被禁用的用户
|
||||||
|
*
|
||||||
|
* @param users 用户 Ids
|
||||||
|
*/
|
||||||
|
void removeDisableUsers(Set<Long> users);
|
||||||
|
|
||||||
// TODO @芋艿:后续可以抽象一个 calculateUsers(String param),默认 calculateUsers 和 calculateUsers 调用它
|
// TODO @芋艿:后续可以抽象一个 calculateUsers(String param),默认 calculateUsers 和 calculateUsers 调用它
|
||||||
// TODO @芋艿 加了, review 一下
|
// TODO @芋艿 加了, review 一下
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -13,11 +14,12 @@ import java.util.*;
|
||||||
*
|
*
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
public abstract class BpmTaskCandidateAbstractDeptLeaderStrategy implements BpmTaskCandidateStrategy {
|
public abstract class BpmTaskCandidateAbstractDeptLeaderStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
protected DeptApi deptApi;
|
protected DeptApi deptApi;
|
||||||
|
|
||||||
public BpmTaskCandidateAbstractDeptLeaderStrategy(DeptApi deptApi) {
|
public BpmTaskCandidateAbstractDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
|
super(adminUserApi);
|
||||||
this.deptApi = deptApi;
|
this.deptApi = deptApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BpmTaskCandidateStrategy} 抽象类
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
public abstract class BpmTaskCandidateAbstractStrategy implements BpmTaskCandidateStrategy {
|
||||||
|
|
||||||
|
protected AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
public BpmTaskCandidateAbstractStrategy(AdminUserApi adminUserApi) {
|
||||||
|
this.adminUserApi = adminUserApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDisableUsers(Set<Long> users) {
|
||||||
|
if (CollUtil.isEmpty(users)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(users);
|
||||||
|
users.removeIf(id -> {
|
||||||
|
AdminUserRespDTO user = userMap.get(id);
|
||||||
|
return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -19,10 +18,11 @@ import java.util.Set;
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateAssignEmptyStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateAssignEmptyStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
public BpmTaskCandidateAssignEmptyStrategy(AdminUserApi adminUserApi) {
|
||||||
private AdminUserApi adminUserApi;
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
@ -38,7 +38,9 @@ public class BpmTaskCandidateAssignEmptyStrategy implements BpmTaskCandidateStra
|
||||||
// 情况一:指定人员审批
|
// 情况一:指定人员审批
|
||||||
Integer assignEmptyHandlerType = BpmnModelUtils.parseAssignEmptyHandlerType(execution.getCurrentFlowElement());
|
Integer assignEmptyHandlerType = BpmnModelUtils.parseAssignEmptyHandlerType(execution.getCurrentFlowElement());
|
||||||
if (Objects.equals(assignEmptyHandlerType, BpmUserTaskAssignEmptyHandlerTypeEnum.ASSIGN_USER.getType())) {
|
if (Objects.equals(assignEmptyHandlerType, BpmUserTaskAssignEmptyHandlerTypeEnum.ASSIGN_USER.getType())) {
|
||||||
return new HashSet<>(BpmnModelUtils.parseAssignEmptyHandlerUserIds(execution.getCurrentFlowElement()));
|
HashSet<Long> users = new HashSet<>(BpmnModelUtils.parseAssignEmptyHandlerUserIds(execution.getCurrentFlowElement()));
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 情况二:流程管理员
|
// 情况二:流程管理员
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -17,8 +18,8 @@ import java.util.Set;
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateDeptLeaderMultiStrategy extends BpmTaskCandidateAbstractDeptLeaderStrategy {
|
public class BpmTaskCandidateDeptLeaderMultiStrategy extends BpmTaskCandidateAbstractDeptLeaderStrategy {
|
||||||
|
|
||||||
public BpmTaskCandidateDeptLeaderMultiStrategy(DeptApi deptApi) {
|
public BpmTaskCandidateDeptLeaderMultiStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
super(deptApi);
|
super(adminUserApi, deptApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
import jakarta.annotation.Resource;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,10 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateDeptLeaderStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
private final DeptApi deptApi;
|
||||||
private DeptApi deptApi;
|
|
||||||
|
public BpmTaskCandidateDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
|
super(adminUserApi);
|
||||||
|
this.deptApi = deptApi;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidat
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,12 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateDeptMemberStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
private final DeptApi deptApi;
|
||||||
private DeptApi deptApi;
|
|
||||||
@Resource
|
public BpmTaskCandidateDeptMemberStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
private AdminUserApi adminUserApi;
|
super(adminUserApi);
|
||||||
|
this.deptApi = deptApi;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -15,7 +16,11 @@ import java.util.Set;
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateExpressionStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
|
public BpmTaskCandidateExpressionStrategy(AdminUserApi adminUserApi) {
|
||||||
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
@ -30,7 +35,9 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
public Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
||||||
Object result = FlowableUtils.getExpressionValue(execution, param);
|
Object result = FlowableUtils.getExpressionValue(execution, param);
|
||||||
return Convert.toSet(Long.class, result);
|
Set<Long> users = Convert.toSet(Long.class, result);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
|
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
|
||||||
import jakarta.annotation.Resource;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -20,10 +20,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateGroupStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
private final BpmUserGroupService userGroupService;
|
||||||
private BpmUserGroupService userGroupService;
|
|
||||||
|
public BpmTaskCandidateGroupStrategy(AdminUserApi adminUserApi, BpmUserGroupService userGroupService) {
|
||||||
|
super(adminUserApi);
|
||||||
|
this.userGroupService = userGroupService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidat
|
||||||
import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,12 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidatePostStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
private final PostApi postApi;
|
||||||
private PostApi postApi;
|
|
||||||
@Resource
|
public BpmTaskCandidatePostStrategy(AdminUserApi adminUserApi, PostApi postApi) {
|
||||||
private AdminUserApi adminUserApi;
|
super(adminUserApi);
|
||||||
|
this.postApi = postApi;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -16,13 +17,17 @@ import java.util.Set;
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateRoleStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateRoleStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RoleApi roleApi;
|
private RoleApi roleApi;
|
||||||
@Resource
|
@Resource
|
||||||
private PermissionApi permissionApi;
|
private PermissionApi permissionApi;
|
||||||
|
|
||||||
|
public BpmTaskCandidateRoleStrategy(AdminUserApi adminUserApi) {
|
||||||
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
return BpmTaskCandidateStrategyEnum.ROLE;
|
return BpmTaskCandidateStrategyEnum.ROLE;
|
||||||
|
|
|
@ -32,11 +32,8 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
||||||
@Lazy
|
@Lazy
|
||||||
private BpmProcessInstanceService processInstanceService;
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
@Resource
|
public BpmTaskCandidateStartUserDeptLeaderMultiStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
private AdminUserApi adminUserApi;
|
super(adminUserApi, deptApi);
|
||||||
|
|
||||||
public BpmTaskCandidateStartUserDeptLeaderMultiStrategy(DeptApi deptApi) {
|
|
||||||
super(deptApi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,7 +57,9 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
||||||
if (dept == null) {
|
if (dept == null) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
return getMultiLevelDeptLeaderIds(toList(dept.getId()), Integer.valueOf(param)); // 参数是部门的层级
|
Set<Long> users = getMultiLevelDeptLeaderIds(toList(dept.getId()), Integer.valueOf(param)); // 参数是部门的层级
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +68,9 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
||||||
if (dept == null) {
|
if (dept == null) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
return getMultiLevelDeptLeaderIds(toList(dept.getId()), Integer.valueOf(param)); // 参数是部门的层级
|
Set<Long> users = getMultiLevelDeptLeaderIds(toList(dept.getId()), Integer.valueOf(param)); // 参数是部门的层级
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,16 +32,13 @@ public class BpmTaskCandidateStartUserDeptLeaderStrategy extends BpmTaskCandidat
|
||||||
@Lazy // 避免循环依赖
|
@Lazy // 避免循环依赖
|
||||||
private BpmProcessInstanceService processInstanceService;
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AdminUserApi adminUserApi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
return BpmTaskCandidateStrategyEnum.START_USER_DEPT_LEADER;
|
return BpmTaskCandidateStrategyEnum.START_USER_DEPT_LEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BpmTaskCandidateStartUserDeptLeaderStrategy(DeptApi deptApi) {
|
public BpmTaskCandidateStartUserDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||||
super(deptApi);
|
super(adminUserApi, deptApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,13 +53,17 @@ public class BpmTaskCandidateStartUserDeptLeaderStrategy extends BpmTaskCandidat
|
||||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||||
Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
|
Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
|
||||||
// 获取发起人的部门负责人
|
// 获取发起人的部门负责人
|
||||||
return getStartUserDeptLeader(startUserId, param);
|
Set<Long> users = getStartUserDeptLeader(startUserId, param);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
public Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
||||||
// 获取发起人的部门负责人
|
// 获取发起人的部门负责人
|
||||||
return getStartUserDeptLeader(startUserId, param);
|
Set<Long> users = getStartUserDeptLeader(startUserId, param);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Long> getStartUserDeptLeader(Long startUserId, String param) {
|
private Set<Long> getStartUserDeptLeader(Long startUserId, String param) {
|
||||||
|
|
|
@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.flowable.bpmn.model.BpmnModel;
|
import org.flowable.bpmn.model.BpmnModel;
|
||||||
import org.flowable.bpmn.model.UserTask;
|
import org.flowable.bpmn.model.UserTask;
|
||||||
|
@ -23,12 +23,16 @@ import java.util.*;
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateStartUserSelectStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy // 延迟加载,避免循环依赖
|
@Lazy // 延迟加载,避免循环依赖
|
||||||
private BpmProcessInstanceService processInstanceService;
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
|
public BpmTaskCandidateStartUserSelectStrategy(AdminUserApi adminUserApi) {
|
||||||
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
return BpmTaskCandidateStrategyEnum.START_USER_SELECT;
|
return BpmTaskCandidateStrategyEnum.START_USER_SELECT;
|
||||||
|
@ -46,7 +50,9 @@ public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidate
|
||||||
execution.getProcessInstanceId());
|
execution.getProcessInstanceId());
|
||||||
// 获得审批人
|
// 获得审批人
|
||||||
List<Long> assignees = startUserSelectAssignees.get(execution.getCurrentActivityId());
|
List<Long> assignees = startUserSelectAssignees.get(execution.getCurrentActivityId());
|
||||||
return new LinkedHashSet<>(assignees);
|
Set<Long> users = new LinkedHashSet<>(assignees);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +64,9 @@ public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidate
|
||||||
Assert.notNull(startUserSelectAssignees, "流程实例({}) 的发起人自选审批人不能为空", processInstance.getId());
|
Assert.notNull(startUserSelectAssignees, "流程实例({}) 的发起人自选审批人不能为空", processInstance.getId());
|
||||||
// 获得审批人
|
// 获得审批人
|
||||||
List<Long> assignees = startUserSelectAssignees.get(activityId);
|
List<Long> assignees = startUserSelectAssignees.get(activityId);
|
||||||
return new LinkedHashSet<>(assignees);
|
Set<Long> users = new LinkedHashSet<>(assignees);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
|
@ -20,12 +20,16 @@ import java.util.Set;
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateStartUserStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy // 延迟加载,避免循环依赖
|
@Lazy // 延迟加载,避免循环依赖
|
||||||
private BpmProcessInstanceService processInstanceService;
|
private BpmProcessInstanceService processInstanceService;
|
||||||
|
|
||||||
|
public BpmTaskCandidateStartUserStrategy(AdminUserApi adminUserApi) {
|
||||||
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
return BpmTaskCandidateStrategyEnum.START_USER;
|
return BpmTaskCandidateStrategyEnum.START_USER;
|
||||||
|
@ -43,12 +47,16 @@ public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrate
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
public Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
||||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||||
return SetUtils.asSet(Long.valueOf(processInstance.getStartUserId()));
|
Set<Long> users = SetUtils.asSet(Long.valueOf(processInstance.getStartUserId()));
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
public Set<Long> calculateUsers(Long startUserId, ProcessInstance processInstance, String activityId, String param) {
|
||||||
return SetUtils.asSet(startUserId);
|
Set<Long> users = SetUtils.asSet(startUserId);
|
||||||
|
removeDisableUsers(users);
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateStrategy;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -17,10 +16,11 @@ import java.util.Set;
|
||||||
* @author kyle
|
* @author kyle
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy {
|
public class BpmTaskCandidateUserStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||||
|
|
||||||
@Resource
|
public BpmTaskCandidateUserStrategy(AdminUserApi adminUserApi) {
|
||||||
private AdminUserApi adminUserApi;
|
super(adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import org.flowable.bpmn.model.UserTask;
|
import org.flowable.bpmn.model.UserTask;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Spy;
|
import org.mockito.Spy;
|
||||||
|
|
||||||
|
@ -34,15 +34,23 @@ import static org.mockito.Mockito.when;
|
||||||
*/
|
*/
|
||||||
public class BpmTaskCandidateInvokerTest extends BaseMockitoUnitTest {
|
public class BpmTaskCandidateInvokerTest extends BaseMockitoUnitTest {
|
||||||
|
|
||||||
@InjectMocks
|
|
||||||
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
private BpmTaskCandidateStrategy strategy = new BpmTaskCandidateUserStrategy();
|
private BpmTaskCandidateStrategy strategy ;
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
private List<BpmTaskCandidateStrategy> strategyList = Collections.singletonList(strategy);
|
private List<BpmTaskCandidateStrategy> strategyList ;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
strategy = new BpmTaskCandidateUserStrategy(adminUserApi); // 创建strategy实例
|
||||||
|
strategyList = Collections.singletonList(strategy); // 创建strategyList
|
||||||
|
taskCandidateInvoker = new BpmTaskCandidateInvoker(strategyList, adminUserApi);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCalculateUsers() {
|
public void testCalculateUsers() {
|
||||||
|
|
Loading…
Reference in New Issue