|
@@ -7,10 +7,7 @@ import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
|
import com.fs.company.param.CompanyParam;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
-import com.fs.company.vo.CompanyCrmVO;
|
|
|
-import com.fs.company.vo.CompanyDataVO;
|
|
|
-import com.fs.company.vo.CompanyNameVO;
|
|
|
-import com.fs.company.vo.CompanyVO;
|
|
|
+import com.fs.company.vo.*;
|
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
import com.fs.store.config.StoreConfig;
|
|
@@ -18,6 +15,7 @@ import com.fs.store.domain.FsStoreOrder;
|
|
|
import com.fs.store.domain.FsStorePayment;
|
|
|
import com.fs.store.mapper.FsStoreOrderMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 企业Service业务层处理
|
|
@@ -37,7 +36,7 @@ import java.util.*;
|
|
|
@Service
|
|
|
public class CompanyServiceImpl implements ICompanyService
|
|
|
{
|
|
|
- Logger logger= LoggerFactory.getLogger(getClass());;
|
|
|
+ Logger logger= LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
|
private CompanyMapper companyMapper;
|
|
|
@Autowired
|
|
@@ -65,6 +64,9 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
@Autowired
|
|
|
private CompanyDeptMapper companyDeptMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<OptionsVO> selectAllCompanyList() {
|
|
@@ -484,5 +486,86 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<DeptDataVO> getDeptData(Long companyId) {
|
|
|
+ List<DeptDataVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ if (companyId != null) {
|
|
|
+ Company company = companyMapper.selectCompanyById(companyId);
|
|
|
+ if (company != null) {
|
|
|
+ DeptDataVO companyNode = buildCompanyNode(company);
|
|
|
+ result.add(companyNode);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Company> companies = companyMapper.selectCompanyAllList();
|
|
|
+
|
|
|
+ if (companies != null && !companies.isEmpty()) {
|
|
|
+ for (Company company : companies) {
|
|
|
+ DeptDataVO companyNode = buildCompanyNode(company);
|
|
|
+ result.add(companyNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result.stream().filter(e -> CollectionUtils.isNotEmpty(e.getChildren())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 构建公司节点,包含其下属部门和用户
|
|
|
+ * @param company 公司对象
|
|
|
+ * @return 公司节点
|
|
|
+ */
|
|
|
+ private DeptDataVO buildCompanyNode(Company company) {
|
|
|
+ DeptDataVO companyNode = new DeptDataVO();
|
|
|
+ companyNode.setLabel(company.getCompanyName());
|
|
|
+ companyNode.setId(company.getCompanyId());
|
|
|
+
|
|
|
+ List<DeptDataVO> deptDataList = getCompanyDeptUserData(company.getCompanyId());
|
|
|
+
|
|
|
+ companyNode.setChildren(deptDataList.isEmpty() ? null : deptDataList);
|
|
|
+
|
|
|
+ return companyNode;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取公司,以及公司部门、部门下面的销售数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<DeptDataVO> getCompanyDeptUserData(Long companyId){
|
|
|
+ List<CompanyDept> companyDepts = companyDeptMapper.selectDeptDataByCompanyId(companyId);
|
|
|
+
|
|
|
+ if (companyDepts == null || companyDepts.isEmpty()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<DeptDataVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ for (CompanyDept companyDept : companyDepts) {
|
|
|
+ DeptDataVO deptNode = new DeptDataVO();
|
|
|
+ deptNode.setLabel(companyDept.getDeptName());
|
|
|
+ deptNode.setId(companyDept.getDeptId());
|
|
|
+
|
|
|
+ List<CompanyUser> companyUsers =
|
|
|
+ companyUserMapper.selectCompanyUserByDeptId(companyDept.getDeptId());
|
|
|
+
|
|
|
+ List<DeptDataVO> userNodes = new ArrayList<>();
|
|
|
+
|
|
|
+ if (companyUsers != null && !companyUsers.isEmpty()) {
|
|
|
+ for (CompanyUser companyUser : companyUsers) {
|
|
|
+ DeptDataVO userNode = new DeptDataVO();
|
|
|
+ userNode.setLabel(companyUser.getUserName());
|
|
|
+ userNode.setId(companyUser.getUserId());
|
|
|
+ userNode.setChildren(null);
|
|
|
+
|
|
|
+ userNodes.add(userNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ deptNode.setChildren(userNodes.isEmpty() ? null : userNodes);
|
|
|
+
|
|
|
+ result.add(deptNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|