|
@@ -1,20 +1,16 @@
|
|
|
package cn.iocoder.yudao.module.bpm.service.definition;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
+import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
|
|
+import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
|
|
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
|
|
+import cn.iocoder.yudao.framework.flowable.core.enums.BpmnModelConstants;
|
|
|
import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils;
|
|
|
-import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleCreateReqVO;
|
|
|
-import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleRespVO;
|
|
|
-import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleUpdateReqVO;
|
|
|
-import cn.iocoder.yudao.module.bpm.convert.definition.BpmTaskAssignRuleConvert;
|
|
|
-import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
|
|
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
|
|
-import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmTaskAssignRuleMapper;
|
|
|
import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants;
|
|
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
|
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
|
|
@@ -28,17 +24,16 @@ import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.flowable.bpmn.model.BpmnModel;
|
|
|
+import org.flowable.bpmn.model.FlowElement;
|
|
|
import org.flowable.bpmn.model.UserTask;
|
|
|
-import org.flowable.common.engine.api.FlowableException;
|
|
|
import org.flowable.engine.delegate.DelegateExecution;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import jakarta.annotation.Resource;
|
|
|
-import jakarta.validation.Valid;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
|
|
@@ -46,7 +41,6 @@ import static cn.hutool.core.text.CharSequenceUtil.format;
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
-import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
|
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -58,15 +52,11 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
|
|
public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
|
|
|
|
|
@Resource
|
|
|
- private BpmTaskAssignRuleMapper taskRuleMapper;
|
|
|
- @Resource
|
|
|
- @Lazy // 解决循环依赖
|
|
|
- private BpmModelService modelService;
|
|
|
+ private BpmUserGroupService userGroupService;
|
|
|
@Resource
|
|
|
@Lazy // 解决循环依赖
|
|
|
- private BpmProcessDefinitionService processDefinitionService;
|
|
|
- @Resource
|
|
|
- private BpmUserGroupService userGroupService;
|
|
|
+ private BpmProcessInstanceService processInstanceService;
|
|
|
+
|
|
|
@Resource
|
|
|
private RoleApi roleApi;
|
|
|
@Resource
|
|
@@ -79,9 +69,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
|
|
private DictDataApi dictDataApi;
|
|
|
@Resource
|
|
|
private PermissionApi permissionApi;
|
|
|
- @Resource
|
|
|
- @Lazy // 解决循环依赖
|
|
|
- private BpmProcessInstanceService processInstanceService;
|
|
|
+
|
|
|
/**
|
|
|
* 任务分配脚本
|
|
|
*/
|
|
@@ -93,130 +81,23 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
|
|
|
- String taskDefinitionKey) {
|
|
|
- return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByModelId(String modelId) {
|
|
|
- return taskRuleMapper.selectListByModelId(modelId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<BpmTaskAssignRuleRespVO> getTaskAssignRuleList(String modelId, String processDefinitionId) {
|
|
|
- // 获得规则
|
|
|
- List<BpmTaskAssignRuleDO> rules = Collections.emptyList();
|
|
|
- BpmnModel model = null;
|
|
|
- if (StrUtil.isNotEmpty(modelId)) {
|
|
|
- rules = getTaskAssignRuleListByModelId(modelId);
|
|
|
- model = modelService.getBpmnModel(modelId);
|
|
|
- } else if (StrUtil.isNotEmpty(processDefinitionId)) {
|
|
|
- rules = getTaskAssignRuleListByProcessDefinitionId(processDefinitionId, null);
|
|
|
- model = processDefinitionService.getBpmnModel(processDefinitionId);
|
|
|
- }
|
|
|
- if (model == null) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
- // 获得用户任务,只有用户任务才可以设置分配规则
|
|
|
- List<UserTask> userTasks = BpmnModelUtils.getBpmnModelElements(model, UserTask.class);
|
|
|
- if (CollUtil.isEmpty(userTasks)) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
- // 转换数据
|
|
|
- return BpmTaskAssignRuleConvert.INSTANCE.convertList(userTasks, rules);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Long createTaskAssignRule(@Valid BpmTaskAssignRuleCreateReqVO reqVO) {
|
|
|
- // 校验参数
|
|
|
- validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
|
|
|
- // 校验是否已经配置
|
|
|
- BpmTaskAssignRuleDO existRule =
|
|
|
- taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(reqVO.getModelId(), reqVO.getTaskDefinitionKey());
|
|
|
- if (existRule != null) {
|
|
|
- throw exception(TASK_ASSIGN_RULE_EXISTS, reqVO.getModelId(), reqVO.getTaskDefinitionKey());
|
|
|
- }
|
|
|
-
|
|
|
- // 存储
|
|
|
- BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO)
|
|
|
- .setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型,才允许新建
|
|
|
- taskRuleMapper.insert(rule);
|
|
|
- return rule.getId();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateTaskAssignRule(@Valid BpmTaskAssignRuleUpdateReqVO reqVO) {
|
|
|
- // 校验参数
|
|
|
- validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
|
|
|
- // 校验是否存在
|
|
|
- BpmTaskAssignRuleDO existRule = taskRuleMapper.selectById(reqVO.getId());
|
|
|
- if (existRule == null) {
|
|
|
- throw exception(TASK_ASSIGN_RULE_NOT_EXISTS);
|
|
|
- }
|
|
|
- // 只允许修改流程模型的规则
|
|
|
- if (!Objects.equals(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL, existRule.getProcessDefinitionId())) {
|
|
|
- throw exception(TASK_UPDATE_FAIL_NOT_MODEL);
|
|
|
- }
|
|
|
-
|
|
|
- // 执行更新
|
|
|
- taskRuleMapper.updateById(BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean isTaskAssignRulesEquals(String modelId, String processDefinitionId) {
|
|
|
- // 调用 VO 接口的原因是,过滤掉流程模型不需要的规则,保持和 copyTaskAssignRules 方法的一致性
|
|
|
- List<BpmTaskAssignRuleRespVO> modelRules = getTaskAssignRuleList(modelId, null);
|
|
|
- List<BpmTaskAssignRuleRespVO> processInstanceRules = getTaskAssignRuleList(null, processDefinitionId);
|
|
|
- if (modelRules.size() != processInstanceRules.size()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 遍历,匹配对应的规则
|
|
|
- Map<String, BpmTaskAssignRuleRespVO> processInstanceRuleMap =
|
|
|
- CollectionUtils.convertMap(processInstanceRules, BpmTaskAssignRuleRespVO::getTaskDefinitionKey);
|
|
|
- for (BpmTaskAssignRuleRespVO modelRule : modelRules) {
|
|
|
- BpmTaskAssignRuleRespVO processInstanceRule = processInstanceRuleMap.get(modelRule.getTaskDefinitionKey());
|
|
|
- if (processInstanceRule == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (!ObjectUtil.equals(modelRule.getType(), processInstanceRule.getType()) || !ObjectUtil.equal(
|
|
|
- modelRule.getOptions(), processInstanceRule.getOptions())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void copyTaskAssignRules(String fromModelId, String toProcessDefinitionId) {
|
|
|
- List<BpmTaskAssignRuleRespVO> rules = getTaskAssignRuleList(fromModelId, null);
|
|
|
- if (CollUtil.isEmpty(rules)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 开始复制
|
|
|
- List<BpmTaskAssignRuleDO> newRules = BpmTaskAssignRuleConvert.INSTANCE.convertList2(rules);
|
|
|
- newRules.forEach(rule -> rule.setProcessDefinitionId(toProcessDefinitionId).setId(null).setCreateTime(null)
|
|
|
- .setUpdateTime(null));
|
|
|
- taskRuleMapper.insertBatch(newRules);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void checkTaskAssignRuleAllConfig(String id) {
|
|
|
- // 一个用户任务都没配置,所以无需配置规则
|
|
|
- List<BpmTaskAssignRuleRespVO> taskAssignRules = getTaskAssignRuleList(id, null);
|
|
|
- if (CollUtil.isEmpty(taskAssignRules)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- // 校验未配置规则的任务
|
|
|
- taskAssignRules.forEach(rule -> {
|
|
|
- if (CollUtil.isEmpty(rule.getOptions())) {
|
|
|
- throw exception(MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG, rule.getTaskDefinitionName());
|
|
|
+ public void checkTaskAssignRuleAllConfig(byte[] bpmnBytes) {
|
|
|
+ BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes);
|
|
|
+ assert bpmnModel != null;
|
|
|
+ List<UserTask> userTaskList = BpmnModelUtils.getBpmnModelElements(bpmnModel, UserTask.class);
|
|
|
+ // 遍历所有的 UserTask,校验审批人配置
|
|
|
+ userTaskList.forEach(userTask -> {
|
|
|
+ // TODO 芋艿:assignType/assignOptions/, 枚举
|
|
|
+ Integer type = NumberUtils.parseInt(userTask.getAttributeValue(BpmnModelConstants.NAMESPACE, "assignType"));
|
|
|
+ String options = userTask.getAttributeValue(BpmnModelConstants.NAMESPACE, "assignOptions");
|
|
|
+ if (type == null || StrUtil.isBlank(options)) {
|
|
|
+ throw exception(MODEL_DEPLOY_FAIL_TASK_ASSIGN_RULE_NOT_CONFIG, userTask.getName());
|
|
|
}
|
|
|
+ validTaskAssignRuleOptions(type, StrUtils.splitToLong(options, ","));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void validTaskAssignRuleOptions(Integer type, Set<Long> options) {
|
|
|
+ private void validTaskAssignRuleOptions(Integer type, Collection<Long> options) {
|
|
|
if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) {
|
|
|
roleApi.validRoleList(options);
|
|
|
} else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
|
|
@@ -247,92 +128,83 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
|
|
|
return convertSet(assignee, Function.identity());
|
|
|
}
|
|
|
// 2. 通过分配规则,计算审批人
|
|
|
- BpmTaskAssignRuleDO rule = getTaskRule(execution);
|
|
|
- return calculateTaskCandidateUsers(execution, rule);
|
|
|
+ return calculateTaskCandidateUsers0(execution);
|
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|
|
|
- BpmTaskAssignRuleDO getTaskRule(DelegateExecution execution) {
|
|
|
- List<BpmTaskAssignRuleDO> taskRules = getTaskAssignRuleListByProcessDefinitionId(
|
|
|
- execution.getProcessDefinitionId(), execution.getCurrentActivityId());
|
|
|
- if (CollUtil.isEmpty(taskRules)) {
|
|
|
- throw new FlowableException(format("流程任务({}/{}/{}) 找不到符合的任务规则",
|
|
|
- execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId()));
|
|
|
- }
|
|
|
- if (taskRules.size() > 1) {
|
|
|
- throw new FlowableException(format("流程任务({}/{}/{}) 找到过多任务规则({})",
|
|
|
- execution.getId(), execution.getProcessDefinitionId(), execution.getCurrentActivityId()));
|
|
|
- }
|
|
|
- return taskRules.get(0);
|
|
|
- }
|
|
|
-
|
|
|
- @VisibleForTesting
|
|
|
- Set<Long> calculateTaskCandidateUsers(DelegateExecution execution, BpmTaskAssignRuleDO rule) {
|
|
|
+ Set<Long> calculateTaskCandidateUsers0(DelegateExecution execution) {
|
|
|
+ // 获得审批人配置
|
|
|
+ // TODO 芋艿:assignType/assignOptions/, 枚举
|
|
|
+ FlowElement flowElement = execution.getCurrentFlowElement();
|
|
|
+ Integer type = NumberUtils.parseInt(flowElement.getAttributeValue(BpmnModelConstants.NAMESPACE, "assignType"));
|
|
|
+ Set<Long> options = StrUtils.splitToLongSet(flowElement.getAttributeValue(BpmnModelConstants.NAMESPACE, "assignOptions"), ",");
|
|
|
+
|
|
|
+ // 计算审批人
|
|
|
Set<Long> assigneeUserIds = null;
|
|
|
- if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByRole(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByDeptMember(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByPost(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByUser(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByUserGroup(rule);
|
|
|
- } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), rule.getType())) {
|
|
|
- assigneeUserIds = calculateTaskCandidateUsersByScript(execution, rule);
|
|
|
+ if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByRole(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByDeptMember(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByPost(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByUser(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByUserGroup(options);
|
|
|
+ } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.SCRIPT.getType(), type)) {
|
|
|
+ assigneeUserIds = calculateTaskCandidateUsersByScript(execution, options);
|
|
|
}
|
|
|
|
|
|
// 移除被禁用的用户
|
|
|
removeDisableUsers(assigneeUserIds);
|
|
|
// 如果候选人为空,抛出异常
|
|
|
if (CollUtil.isEmpty(assigneeUserIds)) {
|
|
|
- log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", execution.getId(),
|
|
|
- execution.getProcessDefinitionId(), execution.getCurrentActivityId(), toJsonString(rule));
|
|
|
+ log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}/{}) 找不到候选人]", execution.getId(),
|
|
|
+ execution.getProcessDefinitionId(), execution.getCurrentActivityId(), type, options);
|
|
|
throw exception(TASK_CREATE_FAIL_NO_CANDIDATE_USER);
|
|
|
}
|
|
|
return assigneeUserIds;
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByRole(BpmTaskAssignRuleDO rule) {
|
|
|
- return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions());
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByRole(Set<Long> roleIds) {
|
|
|
+ return permissionApi.getUserRoleIdListByRoleIds(roleIds);
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByDeptMember(BpmTaskAssignRuleDO rule) {
|
|
|
- List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(rule.getOptions());
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByDeptMember(Set<Long> deptIds) {
|
|
|
+ List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(deptIds);
|
|
|
return convertSet(users, AdminUserRespDTO::getId);
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByDeptLeader(BpmTaskAssignRuleDO rule) {
|
|
|
- List<DeptRespDTO> depts = deptApi.getDeptList(rule.getOptions());
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByDeptLeader(Set<Long> deptIds) {
|
|
|
+ List<DeptRespDTO> depts = deptApi.getDeptList(deptIds);
|
|
|
return convertSet(depts, DeptRespDTO::getLeaderUserId);
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByPost(BpmTaskAssignRuleDO rule) {
|
|
|
- List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(rule.getOptions());
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByPost(Set<Long> postIds) {
|
|
|
+ List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(postIds);
|
|
|
return convertSet(users, AdminUserRespDTO::getId);
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByUser(BpmTaskAssignRuleDO rule) {
|
|
|
- return rule.getOptions();
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByUser(Set<Long> userIds) {
|
|
|
+ return userIds;
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByUserGroup(BpmTaskAssignRuleDO rule) {
|
|
|
- List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions());
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByUserGroup(Set<Long> groupIds) {
|
|
|
+ List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(groupIds);
|
|
|
Set<Long> userIds = new HashSet<>();
|
|
|
userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds()));
|
|
|
return userIds;
|
|
|
}
|
|
|
|
|
|
- private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, BpmTaskAssignRuleDO rule) {
|
|
|
+ private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, Set<Long> scriptIds) {
|
|
|
// 获得对应的脚本
|
|
|
- List<BpmTaskAssignScript> scripts = new ArrayList<>(rule.getOptions().size());
|
|
|
- rule.getOptions().forEach(id -> {
|
|
|
- BpmTaskAssignScript script = scriptMap.get(id);
|
|
|
+ List<BpmTaskAssignScript> scripts = new ArrayList<>(scriptIds.size());
|
|
|
+ scriptIds.forEach(scriptId -> {
|
|
|
+ BpmTaskAssignScript script = scriptMap.get(scriptId);
|
|
|
if (script == null) {
|
|
|
- throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id);
|
|
|
+ throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, scriptId);
|
|
|
}
|
|
|
scripts.add(script);
|
|
|
});
|