|
@@ -3,7 +3,7 @@
|
|
*/
|
|
*/
|
|
package com.jeeplus.sys.service;
|
|
package com.jeeplus.sys.service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.jeeplus.core.service.TreeService;
|
|
import com.jeeplus.core.service.TreeService;
|
|
@@ -12,15 +12,18 @@ import com.jeeplus.sys.constant.enums.OfficeTypeEnum;
|
|
import com.jeeplus.sys.domain.Office;
|
|
import com.jeeplus.sys.domain.Office;
|
|
import com.jeeplus.sys.mapper.OfficeMapper;
|
|
import com.jeeplus.sys.mapper.OfficeMapper;
|
|
import com.jeeplus.sys.service.dto.OfficeDTO;
|
|
import com.jeeplus.sys.service.dto.OfficeDTO;
|
|
|
|
+import com.jeeplus.sys.service.dto.UserDTO;
|
|
import com.jeeplus.sys.service.mapstruct.OfficeWrapper;
|
|
import com.jeeplus.sys.service.mapstruct.OfficeWrapper;
|
|
|
|
+import com.jeeplus.sys.utils.UserUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
-import org.checkerframework.checker.units.qual.A;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 机构Service
|
|
* 机构Service
|
|
@@ -37,7 +40,7 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
@Autowired
|
|
@Autowired
|
|
private OfficeMapper officeMapper;
|
|
private OfficeMapper officeMapper;
|
|
|
|
|
|
- public List <OfficeDTO> getRootTree(List<OfficeDTO> list, String extId, String type, String showAll) {
|
|
|
|
|
|
+ public List <OfficeDTO> getRootTree(List<OfficeDTO> list, String extId, String type, String showAll, String showMyOffice) {
|
|
List<OfficeDTO> offices = Lists.newArrayList ();
|
|
List<OfficeDTO> offices = Lists.newArrayList ();
|
|
List<OfficeDTO> rootTrees = officeWrapper.toDTO (super.getChildren (new Office (OfficeDTO.getRootId ())));
|
|
List<OfficeDTO> rootTrees = officeWrapper.toDTO (super.getChildren (new Office (OfficeDTO.getRootId ())));
|
|
for (OfficeDTO root : rootTrees) {
|
|
for (OfficeDTO root : rootTrees) {
|
|
@@ -47,9 +50,48 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
|
|
offices.addAll (officeList);
|
|
offices.addAll (officeList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (com.jeeplus.sys.utils.StringUtils.isNotBlank(showMyOffice)) {
|
|
|
|
+ // 排除管理员
|
|
|
|
+ if (!UserUtils.getCurrentUserDTO().isAdmin()){
|
|
|
|
+ offices = this.getCompanyFromTree(offices);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return offices;
|
|
return offices;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 在tree数据中找到当前登录人的“集团”以及“公司”
|
|
|
|
+ */
|
|
|
|
+ public List<OfficeDTO> getCompanyFromTree(List<OfficeDTO> rootTrees){
|
|
|
|
+ // 当前登录人的集团id
|
|
|
|
+ String corporationId = UserUtils.getCurrentUserDTO().getCompanyDTO().getId();
|
|
|
|
+ // 公司id
|
|
|
|
+ String parentIds = officeMapper.selectById(UserUtils.getCurrentUserDTO().getOfficeDTO().getId()).getParentIds();
|
|
|
|
+ String[] split = parentIds.split(",");
|
|
|
|
+ String companyId = split[2];
|
|
|
|
+
|
|
|
|
+ AtomicReference<OfficeDTO> officeDTO = new AtomicReference<>(new OfficeDTO());
|
|
|
|
+ if (CollectionUtil.isNotEmpty(rootTrees)) {
|
|
|
|
+ rootTrees.stream().forEach(item->{
|
|
|
|
+ if(item.getId().equals(corporationId)){ // 找到登录人的集团
|
|
|
|
+ officeDTO.set(item);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(item.getChildren())&&!"".equals(companyId)){
|
|
|
|
+ List<OfficeDTO> companys = new ArrayList<>();
|
|
|
|
+ item.getChildren().stream().forEach(child->{
|
|
|
|
+ if(child.getId().equals(companyId)){ // 找到登录人的公司
|
|
|
|
+ companys.add(child);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ officeDTO.get().setChildren(companys);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ List<OfficeDTO> trees = new ArrayList<>();
|
|
|
|
+ trees.add(officeDTO.get());
|
|
|
|
+ return trees;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
public List<OfficeDTO> formatListToTree(OfficeDTO root, List<OfficeDTO> allList, String extId, String type, String showAll) {
|
|
public List<OfficeDTO> formatListToTree(OfficeDTO root, List<OfficeDTO> allList, String extId, String type, String showAll) {
|
|
String rootId = root.getId ();
|
|
String rootId = root.getId ();
|