| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.DataSyncConfig; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | |
| | | |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private DataSyncConfig dataSyncConfig; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | |
| | | @Override |
| | | public List<CompanyDTO> findCompanyTreePage(Integer type) { |
| | | //配置组员人员类型来源方式 0自建 1ERP |
| | | String origin = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode(); |
| | | 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,origin); |
| | | return getCompanyTree( companies, null); |
| | | } |
| | | |
| | | |
| | | private List<CompanyDTO> getCompanyTree(List<Company> companies, String parentId,String origin){ |
| | | private List<CompanyDTO> getCompanyTree(List<Company> companies, String parentId){ |
| | | if (CollectionUtils.isEmpty(companies)){ |
| | | return null; |
| | | } |
| | | List<Company> collect = companies.stream() |
| | | .filter(s -> (StringUtils.equals(origin, Constants.ONE+"")?StringUtils.equals(s.getErpParentId(), parentId):StringUtils.equals(s.getParentId()+"", parentId))) |
| | | .collect(Collectors.toList()); |
| | | int origin =Constants.formatIntegerNum(dataSyncConfig.getOrgUserDataOrigin()); |
| | | List<Company> collect = null; |
| | | if(origin == DataSyncConfig.origin.erp){ |
| | | companies.stream().filter(s -> ( StringUtils.equals(s.getErpParentId()+"", parentId))).collect(Collectors.toList()); |
| | | }else if(origin == DataSyncConfig.origin.hk){ |
| | | companies.stream().filter(s -> ( StringUtils.equals(s.getHkParentId()+"", parentId))).collect(Collectors.toList()); |
| | | }else{ |
| | | companies.stream().filter(s -> ( StringUtils.equals(s.getParentId()+"", parentId))).collect(Collectors.toList()); |
| | | } |
| | | |
| | | if (CollectionUtils.isEmpty(companies)){ |
| | | return null; |
| | | } |
| | |
| | | Company company = collect.get(i); |
| | | CompanyDTO companyDTO = new CompanyDTO(); |
| | | BeanUtils.copyProperties(company,companyDTO); |
| | | companyDTO.setCompanyDTOList(getCompanyTree(companies,StringUtils.equals(origin, Constants.ONE+"")?company.getErpId(): company.getId()+"",origin)); |
| | | String pId = company.getId()+""; |
| | | if(origin == 1){ |
| | | pId = company.getErpId(); |
| | | }else if(origin == 2){ |
| | | pId = company.getHkParentId(); |
| | | } |
| | | companyDTO.setCompanyDTOList(getCompanyTree(companies,pId)); |
| | | companyDTOList.add(companyDTO); |
| | | } |
| | | return companyDTOList; |
| | |
| | | queryWrapper.eq(Company::getType,type); |
| | | List<Company> companyList = companyJoinMapper.selectJoinList(Company.class,queryWrapper); |
| | | //配置组员人员类型来源方式 0自建 1ERP |
| | | String origin = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ORG_USER_ORIGIN).getCode(); |
| | | CompanyTree treeBuild = new CompanyTree(companyList,Integer.valueOf(origin)); |
| | | CompanyTree treeBuild = new CompanyTree(companyList, dataSyncConfig.getOrgUserDataOrigin()); |
| | | companyList = treeBuild.buildTree(); |
| | | return companyList; |
| | | } |