Browse Source

优化专家信息封装

master
WendyYang 1 year ago
parent
commit
ee8c814e5a
2 changed files with 42 additions and 41 deletions
  1. +4
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/expert/assembler/DictionaryAssembler.java
  2. +38
    -37
      pmapi/src/main/java/com/ningdatech/pmapi/expert/assembler/ExpertUserInfoAssembler.java

+ 4
- 4
pmapi/src/main/java/com/ningdatech/pmapi/expert/assembler/DictionaryAssembler.java View File

@@ -1,6 +1,6 @@
package com.ningdatech.pmapi.expert.assembler;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.CollUtil;
import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo;
import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary;

@@ -15,11 +15,11 @@ import java.util.stream.Collectors;

public class DictionaryAssembler {

public static List<DictionaryFieldInfo> toDictionaryFieldInfoList(List<ExpertDictionary> expertDictionaryList) {
if (CollectionUtil.isEmpty(expertDictionaryList)) {
public static List<DictionaryFieldInfo> toDictFieldInfoList(List<ExpertDictionary> expertDictList) {
if (CollUtil.isEmpty(expertDictList)) {
return new ArrayList<>();
}
return expertDictionaryList.stream().map(r -> {
return expertDictList.stream().map(r -> {
DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo();
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField());
dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode());


+ 38
- 37
pmapi/src/main/java/com/ningdatech/pmapi/expert/assembler/ExpertUserInfoAssembler.java View File

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.expert.assembler;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.file.entity.vo.result.AttachFileVo;
import com.ningdatech.pmapi.common.enumeration.BoolDisplayEnum;
@@ -404,56 +405,56 @@ public class ExpertUserInfoAssembler {
return expertUserFullInfoDTO;
}

public static ExpertAdminExpertManageListDTO buildExpertAdminExpertManageListDTO(ExpertUserFullInfo expertUserFullInfo
, Map<Long, List<ExpertDictionary>> expertDictionaryMap, Map<Long, List<ExpertTag>> expertTagMap) {
public static ExpertAdminExpertManageListDTO buildExpertAdminExpertManageListDTO(ExpertUserFullInfo expertUserFullInfo,
Map<Long, List<ExpertDictionary>> expertDictMap,
Map<Long, List<ExpertTag>> expertTagMap) {
Long userId = expertUserFullInfo.getUserId();
ExpertAdminExpertManageListDTO expertAdminExpertManageListDTO = new ExpertAdminExpertManageListDTO();
expertAdminExpertManageListDTO.setUserId(expertUserFullInfo.getUserId());
expertAdminExpertManageListDTO.setExpertName(expertUserFullInfo.getExpertName());
expertAdminExpertManageListDTO.setPhoneNo(expertUserFullInfo.getPhoneNo());
expertAdminExpertManageListDTO.setIsDingUser(BoolDisplayEnum.judgeBoolean(expertUserFullInfo.getIsDingUser()));
expertAdminExpertManageListDTO.setCompany(expertUserFullInfo.getCompany());
expertAdminExpertManageListDTO.setLegalEntityCode(expertUserFullInfo.getLegalEntityCode());
expertAdminExpertManageListDTO.setExpertAccountStatus(expertUserFullInfo.getExpertAccountStatus());
ExpertAdminExpertManageListDTO adminManageExpertListItem = new ExpertAdminExpertManageListDTO();
adminManageExpertListItem.setUserId(expertUserFullInfo.getUserId());
adminManageExpertListItem.setExpertName(expertUserFullInfo.getExpertName());
adminManageExpertListItem.setPhoneNo(expertUserFullInfo.getPhoneNo());
adminManageExpertListItem.setIsDingUser(BoolDisplayEnum.judgeBoolean(expertUserFullInfo.getIsDingUser()));
adminManageExpertListItem.setCompany(expertUserFullInfo.getCompany());
adminManageExpertListItem.setLegalEntityCode(expertUserFullInfo.getLegalEntityCode());
adminManageExpertListItem.setExpertAccountStatus(expertUserFullInfo.getExpertAccountStatus());

// 装配字典数据
List<ExpertDictionary> userExpertDictionaryList = Objects.isNull(expertDictionaryMap.get(userId)) ? new ArrayList<>() : expertDictionaryMap.get(userId);
Map<String, List<ExpertDictionary>> fieldExpertDictionaryMap = userExpertDictionaryList.stream().collect(Collectors.groupingBy(ExpertDictionary::getExpertInfoField));
expertAdminExpertManageListDTO.setExpertType(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.EXPERT_TYPE.getKey())));
expertAdminExpertManageListDTO.setCompanyAttribute(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.COMPANY_ATTRIBUTE.getKey())));
expertAdminExpertManageListDTO.setTitleLevel(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.TITLE_LEVEL.getKey())));
List<ExpertDictionary> userExpertDictList = expertDictMap.getOrDefault(userId, Collections.emptyList());
Map<String, List<ExpertDictionary>> fieldExpertDictMap = userExpertDictList.stream().collect(Collectors.groupingBy(ExpertDictionary::getExpertInfoField));
adminManageExpertListItem.setExpertType(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.EXPERT_TYPE.getKey())));
adminManageExpertListItem.setCompanyAttribute(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.COMPANY_ATTRIBUTE.getKey())));
adminManageExpertListItem.setTitleLevel(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.TITLE_LEVEL.getKey())));
// 装配标签数据
List<ExpertTag> expertTagList = Objects.isNull(expertTagMap.get(userId)) ? new ArrayList<>() : expertTagMap.get(userId);
Map<String, List<ExpertTag>> fieldExpertTagMap = expertTagList.stream().collect(Collectors.groupingBy(ExpertTag::getExpertInfoField));
expertAdminExpertManageListDTO.setExpertSource(
TagAssembler.toTagFieldInfoList(fieldExpertTagMap.get(ExpertTagEnum.EXPERT_SOURCE.getKey())));
adminManageExpertListItem.setExpertSource(TagAssembler.toTagFieldInfoList(fieldExpertTagMap.get(ExpertTagEnum.EXPERT_SOURCE.getKey())));

if (StringUtils.isNotBlank(expertUserFullInfo.getRegionCode()) && Objects.nonNull(expertUserFullInfo.getRegionLevel())) {
if (StrUtil.isNotBlank(expertUserFullInfo.getRegionCode()) && Objects.nonNull(expertUserFullInfo.getRegionLevel())) {
ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
expertRegionInfo.setRegionLevel(expertUserFullInfo.getRegionLevel());
expertRegionInfo.setRegionCode(expertUserFullInfo.getRegionCode());
expertAdminExpertManageListDTO.setExpertRegionInfo(expertRegionInfo);
adminManageExpertListItem.setExpertRegionInfo(expertRegionInfo);
}

// 以下数据为专家excel导出使用
expertAdminExpertManageListDTO.setGender(expertUserFullInfo.getGender());
expertAdminExpertManageListDTO.setBirth(expertUserFullInfo.getBirth());
expertAdminExpertManageListDTO.setHometown(expertUserFullInfo.getHometown());
expertAdminExpertManageListDTO.setNationality(expertUserFullInfo.getNationality());
expertAdminExpertManageListDTO.setPolitical(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.POLITICAL.getKey())));
expertAdminExpertManageListDTO.setIdCard(expertUserFullInfo.getIdCard());
expertAdminExpertManageListDTO.setBankNo(expertUserFullInfo.getBankNo());
expertAdminExpertManageListDTO.setEdu(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.EDU.getKey())));
expertAdminExpertManageListDTO.setRecommendedWay(
DictionaryAssembler.toDictionaryFieldInfoList(fieldExpertDictionaryMap.get(DictExpertInfoTypeEnum.RECOMMENDED_WAY.getKey())));
expertAdminExpertManageListDTO.setCreateTime(expertUserFullInfo.getCreateOn());
return expertAdminExpertManageListDTO;
adminManageExpertListItem.setGender(expertUserFullInfo.getGender());
adminManageExpertListItem.setBirth(expertUserFullInfo.getBirth());
adminManageExpertListItem.setHometown(expertUserFullInfo.getHometown());
adminManageExpertListItem.setNationality(expertUserFullInfo.getNationality());
adminManageExpertListItem.setPolitical(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.POLITICAL.getKey())));
adminManageExpertListItem.setIdCard(expertUserFullInfo.getIdCard());
adminManageExpertListItem.setBankNo(expertUserFullInfo.getBankNo());
adminManageExpertListItem.setEdu(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.EDU.getKey())));
adminManageExpertListItem.setRecommendedWay(
DictionaryAssembler.toDictFieldInfoList(fieldExpertDictMap.get(DictExpertInfoTypeEnum.RECOMMENDED_WAY.getKey())));
adminManageExpertListItem.setCreateTime(expertUserFullInfo.getCreateOn());
return adminManageExpertListItem;
}




Loading…
Cancel
Save