✨ #5779 【需求】审批部门负责人,自动根据发起人关联,不需要手动选择
(cherry picked from commit cc9e157f387cf183ecd6ca2d11a7d901a20f8bed)
This commit is contained in:
1 parent
f8630da5af
commit
4b2d55f339
1 file changed
+20
-11
+20
-11
@@ -1,7 +1,9 @@
|
||||
package com.pig4cloud.pigx.flow.engine.node.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteDeptService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.flow.engine.node.AssignUserStrategy;
|
||||
import com.pig4cloud.pigx.flow.task.constant.ProcessInstanceConstant;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
@@ -9,6 +11,7 @@ import com.pig4cloud.pigx.flow.task.dto.NodeUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
@@ -26,17 +29,23 @@ import java.util.stream.Stream;
|
||||
@Component(ProcessInstanceConstant.AssignedTypeClass.LEADER + "AssignUserStrategy")
|
||||
public class AssignUserLeaderStrategyImpl implements AssignUserStrategy {
|
||||
|
||||
private final RemoteDeptService deptService;
|
||||
private final RemoteDeptService deptService;
|
||||
|
||||
@Override
|
||||
public List<Long> handle(Node node, NodeUser rootUser, Map<String, Object> variables) {
|
||||
// 获取部门ID
|
||||
return node.getNodeUserList()
|
||||
.stream()
|
||||
.map(nodeUser -> deptService.getAllDeptLeader(nodeUser.getId()))
|
||||
.flatMap((Function<R<List<Long>>, Stream<Long>>) listR -> listR.getData() == null ? null
|
||||
: listR.getData().stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<Long> handle(Node node, NodeUser rootUser, Map<String, Object> variables) {
|
||||
// 如果节点没有设置部门主管,则默认为当前用户的部门主管
|
||||
if (CollUtil.isEmpty(node.getNodeUserList())) {
|
||||
List<NodeUser> nodeUserList = new ArrayList<>();
|
||||
nodeUserList.add(NodeUser.builder().id(SecurityUtils.getUser().getDeptId()).build());
|
||||
node.setNodeUserList(nodeUserList);
|
||||
}
|
||||
|
||||
return node.getNodeUserList()
|
||||
.stream()
|
||||
.map(nodeUser -> deptService.getAllDeptLeader(nodeUser.getId()))
|
||||
.flatMap((Function<R<List<Long>>, Stream<Long>>) listR -> listR.getData() == null ? null
|
||||
: listR.getData().stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user