From 30a14783481d100a6503a56c902b47182e542c93 Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期五, 08 十二月 2023 15:42:09 +0800
Subject: [PATCH] #组织树 和企业下的人员信息 人员卡信息

---
 server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
index 5958cf0..484823e 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/CompanyServiceImpl.java
@@ -1,5 +1,7 @@
 package com.doumee.service.business.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.doumee.core.annotation.excel.ExcelColumn;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.LoginUserInfo;
@@ -7,6 +9,7 @@
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
+import com.doumee.dao.admin.response.CompanyDTO;
 import com.doumee.dao.business.CompanyMapper;
 import com.doumee.dao.business.join.CompanyJoinMapper;
 import com.doumee.dao.business.model.Category;
@@ -18,13 +21,18 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 浼佷笟淇℃伅琛⊿ervice瀹炵幇
@@ -245,6 +253,41 @@
         return companyMapper.selectCount(wrapper);
     }
 
+
+    @Override
+    public List<CompanyDTO> findCompanyTreePage(Integer type) {
+
+        LambdaQueryWrapper<Company> wrapper = new LambdaQueryWrapper<>();
+
+        wrapper.eq(Company::getIsdeleted,Constants.ZERO)
+                .eq(Constants.equalsInteger(type,Constants.ONE),Company::getType,type);
+        List<Company> companies = companyMapper.selectList(wrapper);
+        return getCompanyTree( companies, null);
+    }
+
+
+    private List<CompanyDTO> getCompanyTree(List<Company> companies, Integer parentId){
+        if (CollectionUtils.isEmpty(companies)){
+            return null;
+        }
+        List<Company> collect = companies.stream()
+                                        .filter(s -> Constants.equalsInteger(s.getParentId(), parentId))
+                                        .collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(companies)){
+            return null;
+        }
+        List<CompanyDTO> companyDTOList = new ArrayList<>();
+        for (int i = 0; i < collect.size(); i++) {
+            Company company = collect.get(i);
+            CompanyDTO companyDTO = new CompanyDTO();
+            BeanUtils.copyProperties(company,companyDTO);
+            companyDTO.setCompanyDTOList(getCompanyTree(companies, company.getId()));
+            companyDTOList.add(companyDTO);
+        }
+        return companyDTOList;
+    }
+
+
     /**
      * 鍔冲姟鍏徃鍞竴鎬ф牎楠�
      * @param company

--
Gitblit v1.9.3