|
|
@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
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.fiscal.service.ICompanyFiscalCodeService; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; |
|
|
|
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; |
|
|
|
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.service.IDingEmployeeInfoService; |
|
|
|
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; |
|
|
|
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@@ -24,6 +27,7 @@ import org.springframework.stereotype.Component; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@@ -40,24 +44,43 @@ public class OrganizationManage { |
|
|
|
|
|
|
|
private final IDingEmployeeInfoService iDingEmployeeInfoService; |
|
|
|
|
|
|
|
private final RegionCacheHelper regionCacheHelper; |
|
|
|
|
|
|
|
private final ICompanyFiscalCodeService iCompanyFiscalCodeService; |
|
|
|
|
|
|
|
public PageVo<ResOrganizationListVO> organizationList(ReqOrganizationListPO reqOrganizationListPO) { |
|
|
|
String orgName = reqOrganizationListPO.getOrgName(); |
|
|
|
String regionId = reqOrganizationListPO.getRegionId(); |
|
|
|
|
|
|
|
Page<DingOrganization> page = iDingOrganizationService |
|
|
|
.page(new Page<>(reqOrganizationListPO.getPageNumber(), reqOrganizationListPO.getPageSize()) |
|
|
|
, 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(); |
|
|
|
List<DingOrganization> records = page.getRecords(); |
|
|
|
|
|
|
|
List<ResOrganizationListVO> resVOList = new ArrayList<>(); |
|
|
|
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 -> { |
|
|
|
ResOrganizationListVO resOrganizationListVO = new ResOrganizationListVO(); |
|
|
|
resOrganizationListVO.setOrgCode(r.getOrganizationCode()); |
|
|
|
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; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|