Ver código fonte

Merge remote-tracking branch 'origin/master'

tags/24080901
PoffyZhang 1 ano atrás
pai
commit
0d89e4f33e
5 arquivos alterados com 121 adições e 4 exclusões
  1. +11
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/fiscal/service/ICompanyFiscalCodeService.java
  2. +19
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/fiscal/service/impl/CompanyFiscalCodeServiceImpl.java
  3. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java
  4. +87
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java
  5. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/organization/model/po/ReqSynthesizePO.java

+ 11
- 0
pmapi/src/main/java/com/ningdatech/pmapi/fiscal/service/ICompanyFiscalCodeService.java Ver arquivo

@@ -3,6 +3,9 @@ package com.ningdatech.pmapi.fiscal.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.fiscal.entity.CompanyFiscalCode;

import java.util.List;
import java.util.Map;

/**
* <p>
* 服务类
@@ -14,4 +17,12 @@ import com.ningdatech.pmapi.fiscal.entity.CompanyFiscalCode;
public interface ICompanyFiscalCodeService extends IService<CompanyFiscalCode> {

CompanyFiscalCode getByOrganizationCode(String orgCode);

/**
* 获取 key orgCode fiscalCode
*
* @param orgCodeList
* @return
*/
Map<String, String> getByOrgFiscalCodeMap(List<String> orgCodeList);
}

+ 19
- 0
pmapi/src/main/java/com/ningdatech/pmapi/fiscal/service/impl/CompanyFiscalCodeServiceImpl.java Ver arquivo

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.fiscal.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -8,6 +9,11 @@ import com.ningdatech.pmapi.fiscal.mapper.NdCompanyFiscalCodeMapper;
import com.ningdatech.pmapi.fiscal.service.ICompanyFiscalCodeService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* <p>
* 服务实现类
@@ -30,4 +36,17 @@ public class CompanyFiscalCodeServiceImpl extends ServiceImpl<NdCompanyFiscalCod
.eq(CompanyFiscalCode::getOrganizationCode, orgCode));

}

@Override
public Map<String, String> getByOrgFiscalCodeMap(List<String> orgCodeList) {
if (CollUtil.isNotEmpty(orgCodeList)) {
return new HashMap<String, String>();
}
List<CompanyFiscalCode> companyFiscalCodeList = this.list(Wrappers.lambdaQuery(CompanyFiscalCode.class)
.in(CompanyFiscalCode::getOrganizationCode, orgCodeList));

Map<String, String> orgCodeAndFiscalCodeMap = companyFiscalCodeList.stream()
.collect(Collectors.toMap(CompanyFiscalCode::getOrganizationCode, CompanyFiscalCode::getFiscalCode));
return orgCodeAndFiscalCodeMap;
}
}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/basic/AbstractDictionaryCache.java Ver arquivo

@@ -2,10 +2,10 @@ package com.ningdatech.pmapi.meta.helper.basic;

import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.ningdatech.pmapi.meta.service.IMetaDictionaryService;
import com.ningdatech.pmapi.meta.constant.DictAllTypeEnum;
import com.ningdatech.pmapi.meta.helper.DictionaryCache;
import com.ningdatech.pmapi.meta.model.dto.DictionaryDTO;
import com.ningdatech.pmapi.meta.service.IMetaDictionaryService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;



+ 87
- 3
pmapi/src/main/java/com/ningdatech/pmapi/organization/manage/OrganizationManage.java Ver arquivo

@@ -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());
}
@@ -110,6 +133,12 @@ public class OrganizationManage {
public List<KeyTreeVO> treeRubbishVOList(ReqSynthesizePO request) {
String organizationCode = request.getOrganizationCode();
String organizationName = request.getOrganizationName();
String employeeName = request.getEmployeeName();

// 用户搜索为特殊逻辑
if (StringUtils.isNotBlank(employeeName)) {
return treeEmployeeQuery(employeeName, organizationCode);
}

List<DingOrganization> dingOrganizationList = new ArrayList<>();
List<String> organizationCodeList = new ArrayList<>();
@@ -141,6 +170,61 @@ public class OrganizationManage {
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) {
for (KeyTreeVO basicOrgKeyTreeVO : basicOrgKeyTreeVOList) {
String parentCode = basicOrgKeyTreeVO.getKey();


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/organization/model/po/ReqSynthesizePO.java Ver arquivo

@@ -21,4 +21,7 @@ public class ReqSynthesizePO {

@ApiModelProperty("单位名称")
private String organizationName;

@ApiModelProperty("筛选人员姓名")
private String employeeName;
}

Carregando…
Cancelar
Salvar