|
@@ -5,6 +5,7 @@ package com.jeeplus.sys.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -48,6 +49,7 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
|
|
|
|
public List <OfficeDTO> getRootTree(List<OfficeDTO> list, String extId, String type, String showAll, String showMyOffice) {
|
|
|
List<OfficeDTO> offices = Lists.newArrayList ();
|
|
|
+ // 获取到所有parent_id为‘0’的部门数据
|
|
|
List<OfficeDTO> rootTrees = officeWrapper.toDTO (super.getChildren (new Office (OfficeDTO.getRootId ())));
|
|
|
for (OfficeDTO root : rootTrees) {
|
|
|
if (this.isUseAble ( extId, type,root, showAll )){
|
|
@@ -60,8 +62,11 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
|
OfficeDTO officeDTO = UserUtils.getCurrentUserDTO().getOfficeDTO();
|
|
|
// 排除管理员
|
|
|
if (!UserUtils.getCurrentUserDTO().isAdmin()){
|
|
|
- if(null != officeDTO && StringUtils.isNotBlank(officeDTO.getParentIds()) && !officeDTO.getParentIds().contains("1602911406782988290")){
|
|
|
- offices = this.getCompanyFromTree(offices);
|
|
|
+ // isPublic为“0”,当前用户的部门为私有部门,查询的部门包含自己所属部门和公有部门
|
|
|
+ if ("0".equals(officeDTO.getIsPublic())) {
|
|
|
+ if(null != officeDTO && StringUtils.isNotBlank(officeDTO.getParentIds())){
|
|
|
+ offices = this.getCompanyFromTree(offices);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -74,7 +79,6 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
|
public List<OfficeDTO> getCompanyFromTree(List<OfficeDTO> rootTrees){
|
|
|
// 当前登录人的集团id
|
|
|
String corporationId = UserUtils.getCurrentUserDTO().getCompanyDTO().getId();
|
|
|
- OfficeDTO officeDTO1 = UserUtils.getCurrentUserDTO().getOfficeDTO();
|
|
|
// 公司id
|
|
|
String parentIds = officeMapper.selectById(UserUtils.getCurrentUserDTO().getOfficeDTO().getId()).getParentIds();
|
|
|
String companyId = null;
|
|
@@ -82,30 +86,36 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
|
if(split.length>2){
|
|
|
companyId = split[2];
|
|
|
}else{
|
|
|
- companyId = officeDTO1.getId();
|
|
|
+ companyId = UserUtils.getCurrentUserDTO().getOfficeDTO().getId();
|
|
|
}
|
|
|
-
|
|
|
- AtomicReference<OfficeDTO> officeDTO = new AtomicReference<>(new OfficeDTO());
|
|
|
+ List<OfficeDTO> os = new ArrayList<>();
|
|
|
if (CollectionUtil.isNotEmpty(rootTrees)) {
|
|
|
String finalCompanyId = companyId;
|
|
|
rootTrees.stream().forEach(item->{
|
|
|
- if(item.getId().equals(corporationId)){ // 找到登录人的集团
|
|
|
- officeDTO.set(item);
|
|
|
- if (CollectionUtil.isNotEmpty(item.getChildren())&&!"".equals(finalCompanyId)){
|
|
|
- List<OfficeDTO> companys = new ArrayList<>();
|
|
|
- item.getChildren().stream().forEach(child->{
|
|
|
- if(child.getId().equals(finalCompanyId)){ // 找到登录人的公司
|
|
|
- companys.add(child);
|
|
|
- }
|
|
|
- });
|
|
|
- officeDTO.get().setChildren(companys);
|
|
|
+ if ("1".equals(item.getIsPublic())) { // 找到公有的集团
|
|
|
+ OfficeDTO officeDTO = item;
|
|
|
+ if (CollectionUtil.isNotEmpty(item.getChildren())){
|
|
|
+ officeDTO.setChildren(item.getChildren());
|
|
|
+ }
|
|
|
+ os.add(officeDTO);
|
|
|
+ }else{
|
|
|
+ if(item.getId().equals(corporationId)){ // 找到登录人的集团
|
|
|
+ OfficeDTO officeDTO = item;
|
|
|
+ if (CollectionUtil.isNotEmpty(item.getChildren())&&!"".equals(finalCompanyId)){
|
|
|
+ List<OfficeDTO> companys = new ArrayList<>();
|
|
|
+ item.getChildren().stream().forEach(child->{
|
|
|
+ if(child.getId().equals(finalCompanyId) || "1".equals(child.getIsPublic())){ // 登录人的公司 或者 公有公司
|
|
|
+ companys.add(child);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ officeDTO.setChildren(companys);
|
|
|
+ }
|
|
|
+ os.add(officeDTO);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- List<OfficeDTO> trees = new ArrayList<>();
|
|
|
- trees.add(officeDTO.get());
|
|
|
- return trees;
|
|
|
+ return os;
|
|
|
}
|
|
|
|
|
|
|