|
|
@ -20,10 +20,7 @@ import org.dromara.system.api.domain.vo.RemoteDeptVo; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@ -33,7 +30,7 @@ public class BusinessLayerServiceImpl implements IBusinessLayerService { |
|
|
|
|
|
|
|
private final BusinessLayerMapper baseMapper; |
|
|
|
|
|
|
|
@DubboReference |
|
|
|
@DubboReference(timeout = 30000) |
|
|
|
RemoteDeptService remoteDeptService; |
|
|
|
|
|
|
|
@Override |
|
|
@ -41,10 +38,16 @@ public class BusinessLayerServiceImpl implements IBusinessLayerService { |
|
|
|
Page<BusinessLayerVo> result = baseMapper.queryPageList(pageQuery.build(), bo); |
|
|
|
|
|
|
|
result.getRecords().forEach(businessLayerVo -> { |
|
|
|
List<RemoteDeptVo> deptList = remoteDeptService.listTreeDeptByChild(businessLayerVo.getDeptId()); |
|
|
|
LinkedList<Long> deptIdList = new LinkedList<>(); |
|
|
|
deptList.forEach(deptVo -> { |
|
|
|
deptIdList.add(deptVo.getDeptId()); |
|
|
|
}); |
|
|
|
|
|
|
|
List<BusinessLayerVo> layerVoList = baseMapper.selectInfoByParent(businessLayerVo.getId()); |
|
|
|
|
|
|
|
businessLayerVo.setChildren(buildTree(layerVoList,businessLayerVo.getId())); |
|
|
|
|
|
|
|
businessLayerVo.setDeptIdList(deptIdList); |
|
|
|
}); |
|
|
|
|
|
|
|
return TableDataInfo.build(result); |
|
|
@ -101,7 +104,7 @@ public class BusinessLayerServiceImpl implements IBusinessLayerService { |
|
|
|
* @param allNodes |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<BusinessLayerVo> buildTree(List<BusinessLayerVo> allNodes, Long parentId) { |
|
|
|
public List<BusinessLayerVo> buildTree(List<BusinessLayerVo> allNodes, Long parentId) { |
|
|
|
// 创建一个Map来存储所有节点,键为ID,值为节点
|
|
|
|
Map<Long, BusinessLayerVo> nodeMap = new HashMap<>(); |
|
|
|
for (BusinessLayerVo node : allNodes) { |
|
|
@ -113,6 +116,14 @@ public class BusinessLayerServiceImpl implements IBusinessLayerService { |
|
|
|
|
|
|
|
// 遍历所有节点,将子节点添加到父节点的 children 列表中
|
|
|
|
for (BusinessLayerVo node : allNodes) { |
|
|
|
List<RemoteDeptVo> deptList = remoteDeptService.listTreeDeptByChild(node.getDeptId()); |
|
|
|
LinkedList<Long> deptIdList = new LinkedList<>(); |
|
|
|
deptList.forEach(deptVo -> { |
|
|
|
deptIdList.add(deptVo.getDeptId()); |
|
|
|
}); |
|
|
|
|
|
|
|
node.setDeptIdList(deptIdList); |
|
|
|
|
|
|
|
if (node.getParentId().equals(parentId)) { |
|
|
|
rootNodes.add(node); // 当前节点的 parentId 与传入的 parentId 匹配,作为根节点
|
|
|
|
} else { |
|
|
|