瀏覽代碼

报销人员筛选功能修改

user5 2 年之前
父節點
當前提交
4aabd5970a

+ 59 - 7
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/reimbursement/reimbursementInfo/service/ReimbursementInfoService.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.StringUtils;
 import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.manytomany.domain.Student;
 import com.jeeplus.test.mould.service.SerialnumTplService;
 import com.jeeplus.test.oss.domain.WorkAttachment;
 import com.jeeplus.test.oss.mapper.OssServiceMapper;
@@ -29,10 +31,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ReimbursementInfoService {
@@ -292,18 +292,70 @@ public class ReimbursementInfoService {
         List<TreeUserDto> list = new ArrayList<>();
         // 查询部门
         List<TreeUserDto> officeList = infoMapper.findOfficeList();
-        if (CollectionUtils.isNotEmpty(officeList)) {
+        /*if (CollectionUtils.isNotEmpty(officeList)) {
             list.addAll(officeList);
-        }
+        }*/
+
         // 查询用户
         List<TreeUserDto> userList = infoMapper.findUserList(name);
-        if (CollectionUtils.isNotEmpty(userList)) {
+        /*if (CollectionUtils.isNotEmpty(userList)) {
             list.addAll(userList);
+        }*/
+        list = disposeUserTree(userList, officeList);
+        for (TreeUserDto officeDto : officeList) {
+            if("0".equals(officeDto.getParentId())){
+                list.add(officeDto);
+            }
+        }
+        //去重
+        List<TreeUserDto> newList = list.stream().collect(Collectors.collectingAndThen(
+                Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TreeUserDto::getId))), ArrayList::new)
+        );
+        return newList;
+    }
+
+    /**
+     * 用户树形数据处理
+     * @param userList
+     * @param officeList
+     * @return
+     */
+    public List<TreeUserDto> disposeUserTree(List<TreeUserDto> userList, List<TreeUserDto> officeList){
+        List<TreeUserDto> list = new ArrayList<>();
+        for (TreeUserDto userDto : userList) {
+
+            for (TreeUserDto officeDto : officeList) {
+                if(userDto.getParentId().equals(officeDto.getId())){
+                    list.add(officeDto);
+                    list.add(userDto);
+                    List<TreeUserDto> treeUserDtos = disposeOfficeTree(officeDto, officeList);
+                    if(null!= treeUserDtos && treeUserDtos.size()>0){
+                        list.addAll(treeUserDtos);
+                    }
+                }
+            }
         }
         return list;
     }
 
     /**
+     * 用户树形数据处理
+     * @param officeInfo
+     * @param officeList
+     * @return
+     */
+    public List<TreeUserDto> disposeOfficeTree(TreeUserDto officeInfo, List<TreeUserDto> officeList){
+        List<TreeUserDto> listAll = Lists.newArrayList();
+            for (TreeUserDto officeDto : officeList) {
+                if(officeInfo.getParentId().equals(officeDto.getId())){
+                    listAll.add(officeDto);
+                    disposeOfficeTree(officeDto,officeList);
+                }
+            }
+        return listAll;
+    }
+
+    /**
      * 下载列表查询
      */
     public List<RetureListDto> exportList(QueryListDto dto) throws Exception{