|
@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
import com.ningdatech.pmapi.common.config.DingOrganizationProperties; |
|
|
import com.ningdatech.pmapi.common.config.DingOrganizationProperties; |
|
|
|
|
|
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; |
|
|
import com.ningdatech.pmapi.common.util.StrUtils; |
|
|
import com.ningdatech.pmapi.common.util.StrUtils; |
|
|
|
|
|
import com.ningdatech.pmapi.fiscal.service.ICompanyFiscalCodeService; |
|
|
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; |
|
|
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; |
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO; |
|
|
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO; |
|
@@ -17,6 +19,7 @@ import com.ningdatech.pmapi.organization.model.vo.OrganizationTreeVO; |
|
|
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO; |
|
|
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO; |
|
|
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; |
|
|
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; |
|
|
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; |
|
|
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; |
|
|
|
|
|
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
@@ -24,6 +27,7 @@ import org.springframework.stereotype.Component; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Comparator; |
|
|
import java.util.Comparator; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -40,24 +44,43 @@ public class OrganizationManage { |
|
|
|
|
|
|
|
|
private final IDingEmployeeInfoService iDingEmployeeInfoService; |
|
|
private final IDingEmployeeInfoService iDingEmployeeInfoService; |
|
|
|
|
|
|
|
|
|
|
|
private final RegionCacheHelper regionCacheHelper; |
|
|
|
|
|
|
|
|
|
|
|
private final ICompanyFiscalCodeService iCompanyFiscalCodeService; |
|
|
|
|
|
|
|
|
public PageVo<ResOrganizationListVO> organizationList(ReqOrganizationListPO reqOrganizationListPO) { |
|
|
public PageVo<ResOrganizationListVO> organizationList(ReqOrganizationListPO reqOrganizationListPO) { |
|
|
String orgName = reqOrganizationListPO.getOrgName(); |
|
|
String orgName = reqOrganizationListPO.getOrgName(); |
|
|
|
|
|
String regionId = reqOrganizationListPO.getRegionId(); |
|
|
|
|
|
|
|
|
Page<DingOrganization> page = iDingOrganizationService |
|
|
Page<DingOrganization> page = iDingOrganizationService |
|
|
.page(new Page<>(reqOrganizationListPO.getPageNumber(), reqOrganizationListPO.getPageSize()) |
|
|
.page(new Page<>(reqOrganizationListPO.getPageNumber(), reqOrganizationListPO.getPageSize()) |
|
|
, Wrappers.lambdaQuery(DingOrganization.class) |
|
|
, Wrappers.lambdaQuery(DingOrganization.class) |
|
|
.like(StringUtils.isNotBlank(orgName), DingOrganization::getOrganizationName, orgName)); |
|
|
|
|
|
|
|
|
.like(StringUtils.isNotBlank(orgName), DingOrganization::getOrganizationName, orgName) |
|
|
|
|
|
.eq(StringUtils.isNotBlank(regionId), DingOrganization::getDivisionCode, regionId) |
|
|
|
|
|
.orderByAsc(DingOrganization::getId) |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
long total = page.getTotal(); |
|
|
long total = page.getTotal(); |
|
|
List<DingOrganization> records = page.getRecords(); |
|
|
List<DingOrganization> records = page.getRecords(); |
|
|
|
|
|
|
|
|
List<ResOrganizationListVO> resVOList = new ArrayList<>(); |
|
|
List<ResOrganizationListVO> resVOList = new ArrayList<>(); |
|
|
if (CollUtil.isNotEmpty(records)) { |
|
|
if (CollUtil.isNotEmpty(records)) { |
|
|
|
|
|
List<String> organizationCodeList = records.stream().map(DingOrganization::getOrganizationCode) |
|
|
|
|
|
.distinct().collect(Collectors.toList()); |
|
|
|
|
|
Map<String, String> orgFiscalCodeMap = iCompanyFiscalCodeService.getByOrgFiscalCodeMap(organizationCodeList); |
|
|
|
|
|
|
|
|
resVOList = records.stream().map(r -> { |
|
|
resVOList = records.stream().map(r -> { |
|
|
ResOrganizationListVO resOrganizationListVO = new ResOrganizationListVO(); |
|
|
ResOrganizationListVO resOrganizationListVO = new ResOrganizationListVO(); |
|
|
resOrganizationListVO.setOrgCode(r.getOrganizationCode()); |
|
|
resOrganizationListVO.setOrgCode(r.getOrganizationCode()); |
|
|
resOrganizationListVO.setOrgName(r.getOrganizationName()); |
|
|
resOrganizationListVO.setOrgName(r.getOrganizationName()); |
|
|
// TODO 补充其他字段 |
|
|
|
|
|
|
|
|
String divisionCode = r.getDivisionCode(); |
|
|
|
|
|
if (StringUtils.isNotBlank(divisionCode)) { |
|
|
|
|
|
RegionDTO regionDTO = regionCacheHelper.getByCodeAndLevel(divisionCode, 3); |
|
|
|
|
|
resOrganizationListVO.setRegionId(regionDTO.getRegionCode()); |
|
|
|
|
|
resOrganizationListVO.setRegionName(regionDTO.getRegionName()); |
|
|
|
|
|
} |
|
|
|
|
|
String fiscalCode = orgFiscalCodeMap.get(r.getOrganizationCode()); |
|
|
|
|
|
resOrganizationListVO.setFiscalCode(fiscalCode); |
|
|
return resOrganizationListVO; |
|
|
return resOrganizationListVO; |
|
|
}).collect(Collectors.toList()); |
|
|
}).collect(Collectors.toList()); |
|
|
} |
|
|
} |
|
@@ -110,6 +133,12 @@ public class OrganizationManage { |
|
|
public List<KeyTreeVO> treeRubbishVOList(ReqSynthesizePO request) { |
|
|
public List<KeyTreeVO> treeRubbishVOList(ReqSynthesizePO request) { |
|
|
String organizationCode = request.getOrganizationCode(); |
|
|
String organizationCode = request.getOrganizationCode(); |
|
|
String organizationName = request.getOrganizationName(); |
|
|
String organizationName = request.getOrganizationName(); |
|
|
|
|
|
String employeeName = request.getEmployeeName(); |
|
|
|
|
|
|
|
|
|
|
|
// 用户搜索为特殊逻辑 |
|
|
|
|
|
if (StringUtils.isNotBlank(employeeName)) { |
|
|
|
|
|
return treeEmployeeQuery(employeeName, organizationCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
List<DingOrganization> dingOrganizationList = new ArrayList<>(); |
|
|
List<DingOrganization> dingOrganizationList = new ArrayList<>(); |
|
|
List<String> organizationCodeList = new ArrayList<>(); |
|
|
List<String> organizationCodeList = new ArrayList<>(); |
|
@@ -141,6 +170,61 @@ public class OrganizationManage { |
|
|
return orgKeyTreeVOList; |
|
|
return orgKeyTreeVOList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<KeyTreeVO> treeEmployeeQuery(String employeeName, String organizationCode) { |
|
|
|
|
|
List<String> organizationCodeList = CollUtil.toList(organizationCode).stream() |
|
|
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService |
|
|
|
|
|
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) |
|
|
|
|
|
.like(DingEmployeeInfo::getEmployeeName, employeeName) |
|
|
|
|
|
.eq(DingEmployeeInfo::getMainJob, "true") |
|
|
|
|
|
.in(CollUtil.isNotEmpty(organizationCodeList), DingEmployeeInfo::getOrganizationCode, organizationCodeList) |
|
|
|
|
|
); |
|
|
|
|
|
List<String> resultOrganizationCodeList = dingEmployeeInfoList.stream() |
|
|
|
|
|
.filter(r -> StringUtils.isNotBlank(r.getOrganizationCode())) |
|
|
|
|
|
.map(DingEmployeeInfo::getOrganizationCode) |
|
|
|
|
|
.distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(resultOrganizationCodeList)) { |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<DingOrganization> dingOrganizationList = iDingOrganizationService.list(Wrappers.lambdaQuery(DingOrganization.class) |
|
|
|
|
|
.in(DingOrganization::getOrganizationCode, resultOrganizationCodeList)); |
|
|
|
|
|
|
|
|
|
|
|
List<KeyTreeVO> orgKeyTreeVOList = dingOrganizationList.stream().map(r -> { |
|
|
|
|
|
KeyTreeVO keyTreeVO = new KeyTreeVO(); |
|
|
|
|
|
keyTreeVO.setTitle(r.getOrganizationName()); |
|
|
|
|
|
keyTreeVO.setKey(r.getOrganizationCode()); |
|
|
|
|
|
keyTreeVO.setType("ORGANIZATION"); |
|
|
|
|
|
return keyTreeVO; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
employeeNameSearcheTreeVOList(orgKeyTreeVOList, dingEmployeeInfoList); |
|
|
|
|
|
return orgKeyTreeVOList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void employeeNameSearcheTreeVOList(List<KeyTreeVO> basicOrgKeyTreeVOList, List<DingEmployeeInfo> allDingEmployeeInfoList) { |
|
|
|
|
|
Map<String, List<DingEmployeeInfo>> orgCodeEmployeeMap = allDingEmployeeInfoList.stream() |
|
|
|
|
|
.filter(r -> StringUtils.isNotBlank(r.getOrganizationCode())) |
|
|
|
|
|
.collect(Collectors.groupingBy(DingEmployeeInfo::getOrganizationCode)); |
|
|
|
|
|
|
|
|
|
|
|
for (KeyTreeVO basicOrgKeyTreeVO : basicOrgKeyTreeVOList) { |
|
|
|
|
|
String parentCode = basicOrgKeyTreeVO.getKey(); |
|
|
|
|
|
|
|
|
|
|
|
List<DingEmployeeInfo> dingEmployeeInfoList = orgCodeEmployeeMap.get(parentCode); |
|
|
|
|
|
List<KeyTreeVO> memberChildren = dingEmployeeInfoList.stream().map(r -> { |
|
|
|
|
|
KeyTreeVO child = new KeyTreeVO(); |
|
|
|
|
|
child.setKey(r.getEmployeeCode()); |
|
|
|
|
|
child.setTitle(r.getEmployeeName()); |
|
|
|
|
|
child.setType("MEMBER"); |
|
|
|
|
|
return child; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
basicOrgKeyTreeVO.setChildren(memberChildren); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void treeVOList(Boolean needMember, List<KeyTreeVO> basicOrgKeyTreeVOList) { |
|
|
public void treeVOList(Boolean needMember, List<KeyTreeVO> basicOrgKeyTreeVOList) { |
|
|
for (KeyTreeVO basicOrgKeyTreeVO : basicOrgKeyTreeVOList) { |
|
|
for (KeyTreeVO basicOrgKeyTreeVO : basicOrgKeyTreeVOList) { |
|
|
String parentCode = basicOrgKeyTreeVO.getKey(); |
|
|
String parentCode = basicOrgKeyTreeVO.getKey(); |
|
|