【功能修改】任务的候选人的策略, 增加移除被禁用的用户接口
This commit is contained in:
parent
7f6d214ea9
commit
d42c63e8fd
|
@ -111,7 +111,7 @@ public class BpmTaskCandidateInvoker {
|
|||
removeStartUserIfSkip(execution, userIds);
|
||||
|
||||
// 2. 移除被禁用的用户 TODO @芋艿 移除禁用的用户是否应该放在 1.1 之后
|
||||
removeDisableUsers(userIds);
|
||||
// removeDisableUsers(userIds); @芋艿 把这个移到了 BpmTaskCandidateStrategy 下面。 看一下是否可以
|
||||
return userIds;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ public interface BpmTaskCandidateStrategy {
|
|||
* @return 用户编号集合
|
||||
*/
|
||||
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 用户编号集合
|
||||
*/
|
||||
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 @芋艿 加了, 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.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -13,11 +14,12 @@ import java.util.*;
|
|||
*
|
||||
* @author jason
|
||||
*/
|
||||
public abstract class BpmTaskCandidateAbstractDeptLeaderStrategy implements BpmTaskCandidateStrategy {
|
||||
public abstract class BpmTaskCandidateAbstractDeptLeaderStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
protected DeptApi deptApi;
|
||||
|
||||
public BpmTaskCandidateAbstractDeptLeaderStrategy(DeptApi deptApi) {
|
||||
public BpmTaskCandidateAbstractDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi);
|
||||
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.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -19,10 +18,11 @@ import java.util.Set;
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateAssignEmptyStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateAssignEmptyStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
public BpmTaskCandidateAssignEmptyStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
|
@ -38,7 +38,9 @@ public class BpmTaskCandidateAssignEmptyStrategy implements BpmTaskCandidateStra
|
|||
// 情况一:指定人员审批
|
||||
Integer assignEmptyHandlerType = BpmnModelUtils.parseAssignEmptyHandlerType(execution.getCurrentFlowElement());
|
||||
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.enums.BpmTaskCandidateStrategyEnum;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -17,8 +18,8 @@ import java.util.Set;
|
|||
@Component
|
||||
public class BpmTaskCandidateDeptLeaderMultiStrategy extends BpmTaskCandidateAbstractDeptLeaderStrategy {
|
||||
|
||||
public BpmTaskCandidateDeptLeaderMultiStrategy(DeptApi deptApi) {
|
||||
super(deptApi);
|
||||
public BpmTaskCandidateDeptLeaderMultiStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi, deptApi);
|
||||
}
|
||||
|
||||
@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.system.api.dept.DeptApi;
|
||||
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 java.util.List;
|
||||
|
@ -19,10 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateDeptLeaderStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateDeptLeaderStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
private final DeptApi deptApi;
|
||||
|
||||
public BpmTaskCandidateDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi);
|
||||
this.deptApi = deptApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -20,12 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateDeptMemberStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateDeptMemberStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
private final DeptApi deptApi;
|
||||
|
||||
public BpmTaskCandidateDeptMemberStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi);
|
||||
this.deptApi = deptApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.enums.BpmTaskCandidateStrategyEnum;
|
||||
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.springframework.stereotype.Component;
|
||||
|
||||
|
@ -15,7 +16,11 @@ import java.util.Set;
|
|||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateExpressionStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
public BpmTaskCandidateExpressionStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
|
@ -30,7 +35,9 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
|
|||
@Override
|
||||
public Set<Long> calculateUsers(DelegateExecution execution, String 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.enums.BpmTaskCandidateStrategyEnum;
|
||||
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 java.util.Collection;
|
||||
|
@ -20,10 +20,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateGroupStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateGroupStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private BpmUserGroupService userGroupService;
|
||||
private final BpmUserGroupService userGroupService;
|
||||
|
||||
public BpmTaskCandidateGroupStrategy(AdminUserApi adminUserApi, BpmUserGroupService userGroupService) {
|
||||
super(adminUserApi);
|
||||
this.userGroupService = userGroupService;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -20,12 +19,14 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidatePostStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidatePostStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private PostApi postApi;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
private final PostApi postApi;
|
||||
|
||||
public BpmTaskCandidatePostStrategy(AdminUserApi adminUserApi, PostApi postApi) {
|
||||
super(adminUserApi);
|
||||
this.postApi = postApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
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.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -16,13 +17,17 @@ import java.util.Set;
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateRoleStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateRoleStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private RoleApi roleApi;
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
public BpmTaskCandidateRoleStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
return BpmTaskCandidateStrategyEnum.ROLE;
|
||||
|
|
|
@ -32,11 +32,8 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
|||
@Lazy
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
public BpmTaskCandidateStartUserDeptLeaderMultiStrategy(DeptApi deptApi) {
|
||||
super(deptApi);
|
||||
public BpmTaskCandidateStartUserDeptLeaderMultiStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi, deptApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +57,9 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
|||
if (dept == null) {
|
||||
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
|
||||
|
@ -69,7 +68,9 @@ public class BpmTaskCandidateStartUserDeptLeaderMultiStrategy extends BpmTaskCan
|
|||
if (dept == null) {
|
||||
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 // 避免循环依赖
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
return BpmTaskCandidateStrategyEnum.START_USER_DEPT_LEADER;
|
||||
}
|
||||
|
||||
public BpmTaskCandidateStartUserDeptLeaderStrategy(DeptApi deptApi) {
|
||||
super(deptApi);
|
||||
public BpmTaskCandidateStartUserDeptLeaderStrategy(AdminUserApi adminUserApi, DeptApi deptApi) {
|
||||
super(adminUserApi, deptApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,13 +53,17 @@ public class BpmTaskCandidateStartUserDeptLeaderStrategy extends BpmTaskCandidat
|
|||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||
Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
|
||||
// 获取发起人的部门负责人
|
||||
return getStartUserDeptLeader(startUserId, param);
|
||||
Set<Long> users = getStartUserDeptLeader(startUserId, param);
|
||||
removeDisableUsers(users);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
|
|
|
@ -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.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.util.BpmnModelUtils;
|
||||
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.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.UserTask;
|
||||
|
@ -23,12 +23,16 @@ import java.util.*;
|
|||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateStartUserSelectStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
@Lazy // 延迟加载,避免循环依赖
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
public BpmTaskCandidateStartUserSelectStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
return BpmTaskCandidateStrategyEnum.START_USER_SELECT;
|
||||
|
@ -46,7 +50,9 @@ public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidate
|
|||
execution.getProcessInstanceId());
|
||||
// 获得审批人
|
||||
List<Long> assignees = startUserSelectAssignees.get(execution.getCurrentActivityId());
|
||||
return new LinkedHashSet<>(assignees);
|
||||
Set<Long> users = new LinkedHashSet<>(assignees);
|
||||
removeDisableUsers(users);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +64,9 @@ public class BpmTaskCandidateStartUserSelectStrategy implements BpmTaskCandidate
|
|||
Assert.notNull(startUserSelectAssignees, "流程实例({}) 的发起人自选审批人不能为空", processInstance.getId());
|
||||
// 获得审批人
|
||||
List<Long> assignees = startUserSelectAssignees.get(activityId);
|
||||
return new LinkedHashSet<>(assignees);
|
||||
Set<Long> users = new LinkedHashSet<>(assignees);
|
||||
removeDisableUsers(users);
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy;
|
||||
|
||||
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.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
|
@ -20,12 +20,16 @@ import java.util.Set;
|
|||
* @author jason
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateStartUserStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
@Lazy // 延迟加载,避免循环依赖
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
public BpmTaskCandidateStartUserStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskCandidateStrategyEnum getStrategy() {
|
||||
return BpmTaskCandidateStrategyEnum.START_USER;
|
||||
|
@ -43,12 +47,16 @@ public class BpmTaskCandidateStartUserStrategy implements BpmTaskCandidateStrate
|
|||
@Override
|
||||
public Set<Long> calculateUsers(DelegateExecution execution, String param) {
|
||||
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
|
||||
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.enums.BpmTaskCandidateStrategyEnum;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -17,10 +16,11 @@ import java.util.Set;
|
|||
* @author kyle
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskCandidateUserStrategy implements BpmTaskCandidateStrategy {
|
||||
public class BpmTaskCandidateUserStrategy extends BpmTaskCandidateAbstractStrategy {
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
public BpmTaskCandidateUserStrategy(AdminUserApi adminUserApi) {
|
||||
super(adminUserApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 org.flowable.bpmn.model.UserTask;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
|
||||
|
@ -34,15 +34,23 @@ import static org.mockito.Mockito.when;
|
|||
*/
|
||||
public class BpmTaskCandidateInvokerTest extends BaseMockitoUnitTest {
|
||||
|
||||
@InjectMocks
|
||||
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
||||
|
||||
@Mock
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Spy
|
||||
private BpmTaskCandidateStrategy strategy = new BpmTaskCandidateUserStrategy();
|
||||
private BpmTaskCandidateStrategy strategy ;
|
||||
|
||||
@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
|
||||
public void testCalculateUsers() {
|
||||
|
|
Loading…
Reference in New Issue