package com.ningdatech.pmapi.expert.assembler;

//import com.ningdatech.emapi.common.enumeration.BoolDisplayEnum;
//import com.ningdatech.emapi.common.helper.RegionCache;
//import com.ningdatech.emapi.common.utils.JSONObject;
//import com.ningdatech.emapi.expert.constants.DictExpertInfoTypeEnum;
//import com.ningdatech.emapi.expert.constants.ExpertApplyTypeEnum;
//import com.ningdatech.emapi.expert.constants.ExpertTagEnum;
//import com.ningdatech.emapi.expert.entity.*;
//import com.ningdatech.emapi.expert.entity.domain.*;
//import com.ningdatech.emapi.expert.entity.dto.*;
//import com.ningdatech.emapi.expert.entity.vo.ExpertFullInfoVO;
//import com.ningdatech.emapi.sys.file.entity.FileBasicInfo;
//import com.ningdatech.emapi.sys.file.entity.vo.result.AttachFileVo;
//import com.ningdatech.emapi.sys.meta.entity.RegionDtoMapKey;
//import com.ningdatech.emapi.sys.meta.entity.dto.DictionaryDTO;
//import com.ningdatech.emapi.sys.meta.entity.dto.TagDTO;
//import com.ningdatech.emapi.sys.meta.helper.DictionaryCache;
//import com.ningdatech.emapi.sys.meta.helper.TagCache;

import com.alibaba.fastjson.JSONObject;
import com.ningdatech.file.entity.vo.result.AttachFileVo;
import com.ningdatech.pmapi.common.enumeration.BoolDisplayEnum;
import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum;
import com.ningdatech.pmapi.expert.entity.ExpertAvoidCompany;
import com.ningdatech.pmapi.expert.entity.ExpertIntentionWorkRegion;
import com.ningdatech.pmapi.expert.entity.ExpertMetaApply;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.model.*;
import com.ningdatech.pmapi.expert.model.dto.*;
import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO;
import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum;
import com.ningdatech.pmapi.meta.constant.ExpertTagEnum;
import com.ningdatech.pmapi.meta.helper.DictionaryCache;
import com.ningdatech.pmapi.meta.helper.TagCache;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import com.ningdatech.pmapi.meta.model.dto.DictionaryDTO;
import com.ningdatech.pmapi.meta.model.dto.TagDTO;
import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary;
import com.ningdatech.pmapi.meta.model.entity.ExpertTag;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author liuxinxin
 * @date 2022/7/27 上午10:46
 */
@Component
@RequiredArgsConstructor
public class ExpertUserInfoAssembler {

    private final TagCache tagCache;
    private final DictionaryCache dictionaryCache;
//    private final RegionCache regionCache;

    public ExpertFullInfoVO buildExpertFullInfoVO(List<AttachFileVo> attachFiles
            , ExpertFullInfoAllDTO expertUserFullInfoAll) {
        ExpertUserFullInfoDTO expertUserInfoDTO = expertUserFullInfoAll.getExpertUserInfoDTO();
        // 字典字典段map
        Map<String, List<DictionaryFieldInfo>> dictionaryFieldInfoMap =
                buildDictionaryFieldInfoMap(expertUserFullInfoAll.getExpertDictionaryList());
        // 专家文件资料map
        Map<Long, FileBasicInfo> fileBasicInfoMap = buildFileBasicInfoMap(attachFiles);
        // 专家标签字段map
        Map<String, List<TagFieldInfo>> tagFieldInfoMap = buildTagFieldInfoMap(expertUserFullInfoAll.getExpertTagList());
        // 专家履职意向地
        List<ExpertRegionDTO> expertIntentionWorkRegionInfo =
                expertUserFullInfoAll.getExpertIntentionWorkRegionInfo();
        // 专家回避单位列表
        List<ExpertAvoidCompanyDTO> expertAvoidCompanyList = expertUserFullInfoAll.getExpertAvoidCompanyList();
        // 基本信息
        ExpertBasicInfo basicInfo = buildExpertBasicInfo(expertUserInfoDTO, dictionaryFieldInfoMap, tagFieldInfoMap, expertIntentionWorkRegionInfo, fileBasicInfoMap);
        // 学历信息
        ExpertEduInfo eduInfo = buildExpertEduInfo(expertUserInfoDTO, dictionaryFieldInfoMap, fileBasicInfoMap);
        // 职业信息
        ExpertJobInfo jobInfo = buildExpertJobInfo(expertUserInfoDTO, dictionaryFieldInfoMap);
        // 专业信息
        ExpertProfessionalInfo professionalInfo =
                buildExpertProfessionalInfo(expertUserInfoDTO, dictionaryFieldInfoMap, tagFieldInfoMap
                        , fileBasicInfoMap, expertAvoidCompanyList);
        // 推荐信息
        ExpertRecommendInfo recommendInfo = new ExpertRecommendInfo();
        recommendInfo.setRecommendedWay(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.RECOMMENDED_WAY.getKey()));
        recommendInfo.setRecommendationProofFile(
                getFileBasicInfoList(fileBasicInfoMap, expertUserInfoDTO.getRecommendationProofFileIdList()));
        // 其他信息
        ExpertOtherInfo otherInfo = new ExpertOtherInfo();
        otherInfo.setOther(tagFieldInfoMap.get(ExpertTagEnum.OTHER.getKey()));
        otherInfo.setRemark(expertUserInfoDTO.getRemark());

        // 专家申请履职意向展示列表
        List<ExpertRegionInfo> expertApplyIntentionWorkRegions = expertUserFullInfoAll.getExpertApplyIntentionWorkRegionInfo().stream().map(r -> {
            ExpertRegionInfo expertApplyIntentionWorkRegion = new ExpertRegionInfo();
            expertApplyIntentionWorkRegion.setRegionLevel(r.getRegionLevel());
            expertApplyIntentionWorkRegion.setRegionCode(r.getRegionCode());
//            expertApplyIntentionWorkRegion.setRegionName(regionCache.getUnionPathStr(r.getRegionCode(), r.getRegionLevel()));
            return expertApplyIntentionWorkRegion;
        }).collect(Collectors.toList());


        ExpertFullInfoVO expertFullInfoVO = new ExpertFullInfoVO();
        expertFullInfoVO.setUserId(expertUserInfoDTO.getUserId());
        expertFullInfoVO.setBasicInfo(basicInfo);
        expertFullInfoVO.setEduInfo(eduInfo);
        expertFullInfoVO.setJobInfo(jobInfo);
        expertFullInfoVO.setProfessionalInfo(professionalInfo);
        expertFullInfoVO.setRecommendInfo(recommendInfo);
        expertFullInfoVO.setExpertOtherInfo(otherInfo);
        expertFullInfoVO.setExpertApplyIntentionWorkRegions(expertApplyIntentionWorkRegions);

        return expertFullInfoVO;
    }

    public static Map<Long, FileBasicInfo> buildFileBasicInfoMap(List<AttachFileVo> attachFiles) {
        return attachFiles.stream().map(r -> {
            FileBasicInfo fileBasicInfo = new FileBasicInfo();
            fileBasicInfo.setFileId(r.getFileId());
            fileBasicInfo.setFileName(r.getOriginalFileName());
            return fileBasicInfo;
        }).collect(Collectors.toMap(FileBasicInfo::getFileId, Function.identity()));
    }

    public Map<String, List<TagFieldInfo>> buildTagFieldInfoMap(List<ExpertTagDTO> expertTagList) {
        return expertTagList.stream().map(r -> {
            TagFieldInfo tagFieldInfo = new TagFieldInfo();
            tagFieldInfo.setTagCode(r.getTagCode());
            tagFieldInfo.setTagFieldName(r.getExpertInfoField());
            TagDTO tagDTO = tagCache.getByTagCode(r.getTagCode());
            if (Objects.nonNull(tagDTO)) {
                tagFieldInfo.setTagName(tagDTO.getTagName());
            }
            return tagFieldInfo;
        }).collect(Collectors.groupingBy(TagFieldInfo::getTagFieldName));
    }

    public Map<String, List<DictionaryFieldInfo>> buildDictionaryFieldInfoMap(List<ExpertDictionaryDTO> expertDictionaryList) {
        return expertDictionaryList.stream().map(r -> {
            DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo();
            dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField());
            dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode());
            DictionaryDTO dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode());
            if (Objects.nonNull(dictionaryDTO)) {
                dictionaryFieldInfo.setDictionaryName(dictionaryDTO.getName());
            }
            return dictionaryFieldInfo;
        }).collect(Collectors.groupingBy(DictionaryFieldInfo::getDictionaryFieldName));
    }

    public static ExpertProfessionalInfo buildExpertProfessionalInfo(ExpertUserFullInfoDTO expertUserInfoDTO
            , Map<String, List<DictionaryFieldInfo>> dictionaryFieldInfoMap, Map<String, List<TagFieldInfo>> tagFieldInfoMap
            , Map<Long, FileBasicInfo> fileBasicInfoMap, List<ExpertAvoidCompanyDTO> expertAvoidCompanyList) {
        ExpertProfessionalInfo professionalInfo = new ExpertProfessionalInfo();
        professionalInfo.setTechnicalTitles(expertUserInfoDTO.getTechnicalTitles());
        professionalInfo.setTitleLevel(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.TITLE_LEVEL.getKey()));
        professionalInfo.setTitleCertificateFile(getFileBasicInfoList(fileBasicInfoMap, expertUserInfoDTO.getTitleCertificateFileIdList()));
        professionalInfo.setGoodAt(tagFieldInfoMap.get(ExpertTagEnum.GOOD_AT.getKey()));
        professionalInfo.setTechnicalExpertise(tagFieldInfoMap.get(ExpertTagEnum.TECHNICAL_EXPERTISE.getKey()));
        professionalInfo.setAwards(expertUserInfoDTO.getAwards());
        professionalInfo.setIndustrySector(tagFieldInfoMap.get(ExpertTagEnum.INDUSTRY_SECTOR.getKey()));
        professionalInfo.setRecognitionReward(expertUserInfoDTO.getRecognitionReward());
        professionalInfo.setAvoidCompanyList(expertAvoidCompanyList.stream().map(r -> {
            ExpertAvoidCompanyInfo expertAvoidCompanyInfo = new ExpertAvoidCompanyInfo();
            expertAvoidCompanyInfo.setCompanyName(r.getCompanyName());
            expertAvoidCompanyInfo.setCompanyUniqCode(r.getCompanyUniqCode());
            return expertAvoidCompanyInfo;
        }).collect(Collectors.toList()));
        return professionalInfo;
    }

    public static ExpertJobInfo buildExpertJobInfo(ExpertUserFullInfoDTO expertUserInfoDTO
            , Map<String, List<DictionaryFieldInfo>> dictionaryFieldInfoMap) {
        ExpertJobInfo jobInfo = new ExpertJobInfo();
        jobInfo.setJobStatus(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.JOB_STATUS.getKey()));
        jobInfo.setRetiredAt(expertUserInfoDTO.getRetiredAt());
        jobInfo.setCompany(expertUserInfoDTO.getCompany());
        jobInfo.setCompanyUniqCode(expertUserInfoDTO.getCompanyUniqCode());
        jobInfo.setLegalEntityCode(expertUserInfoDTO.getLegalEntityCode());
        jobInfo.setAdministrativeDuties(expertUserInfoDTO.getAdministrativeDuties());
        jobInfo.setStartWorkAt(expertUserInfoDTO.getStartWorkAt());
        jobInfo.setAdministrativeRank(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.ADMINISTRATIVE_RANK.getKey()));
        jobInfo.setCompanyAttribute(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.COMPANY_ATTRIBUTE.getKey()));
        jobInfo.setAddress(expertUserInfoDTO.getAddress());
        jobInfo.setExperience(expertUserInfoDTO.getExperience());
        return jobInfo;
    }

    public static ExpertEduInfo buildExpertEduInfo(ExpertUserFullInfoDTO expertUserInfoDTO
            , Map<String, List<DictionaryFieldInfo>> dictionaryFieldInfoMap, Map<Long, FileBasicInfo> fileBasicInfoMap) {
        // 学历信息
        ExpertEduInfo eduInfo = new ExpertEduInfo();
        eduInfo.setSchool(expertUserInfoDTO.getSchool());
        eduInfo.setGraduatedAt(expertUserInfoDTO.getGraduatedAt());
        eduInfo.setAcademicTitle(expertUserInfoDTO.getAcademicTitle());
        eduInfo.setEdu(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.EDU.getKey()));
        eduInfo.setGraduationCertificateFile(getFileBasicInfoList(fileBasicInfoMap
                , expertUserInfoDTO.getGraduationCertificateFileIdList()));
        eduInfo.setDegree(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.DEGREE.getKey()));
        eduInfo.setDegreeCertificateFile(getFileBasicInfoList(fileBasicInfoMap, expertUserInfoDTO.getDegreeCertificateFileIdList()));
        return eduInfo;
    }

    public static List<FileBasicInfo> getFileBasicInfoList(Map<Long, FileBasicInfo> fileBasicInfoMap, List<Long> fileIdList) {
        if (CollectionUtils.isEmpty(fileIdList)) {
            return new ArrayList<>();
        }
        List<FileBasicInfo> fileBasicInfoList = new ArrayList<>();
        for (Long fileId : fileIdList) {
            FileBasicInfo fileBasicInfo = fileBasicInfoMap.get(fileId);
            if (Objects.nonNull(fileBasicInfo)) {
                fileBasicInfoList.add(fileBasicInfo);
            }
        }
        return fileBasicInfoList;
    }

    public static FileBasicInfo getFileBasicInfo(Map<Long, FileBasicInfo> fileBasicInfoMap, Long fileId) {
        if (Objects.isNull(fileId)) {
            return null;
        }
        FileBasicInfo fileBasicInfo = fileBasicInfoMap.get(fileId);
        return fileBasicInfo;
    }

    public ExpertBasicInfo buildExpertBasicInfo(ExpertUserFullInfoDTO expertUserInfoDTO
            , Map<String, List<DictionaryFieldInfo>> dictionaryFieldInfoMap
            , Map<String, List<TagFieldInfo>> tagFieldInfoMap
            , List<ExpertRegionDTO> expertIntentionWorkRegionInfo
            , Map<Long, FileBasicInfo> fileBasicInfoMap) {
        //专家层级
        ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
        expertRegionInfo.setRegionLevel(expertUserInfoDTO.getRegionLevel());
        expertRegionInfo.setRegionCode(expertUserInfoDTO.getRegionCode());

        // 基本信息
        ExpertBasicInfo basicInfo = new ExpertBasicInfo();
        basicInfo.setIsDingUser(expertUserInfoDTO.getIsDingUser());
        basicInfo.setPhoneNo(expertUserInfoDTO.getPhoneNo());
        basicInfo.setName(expertUserInfoDTO.getName());
        basicInfo.setAvatarFile(getFileBasicInfo(fileBasicInfoMap, expertUserInfoDTO.getAvatarFileId()));
        basicInfo.setGender(expertUserInfoDTO.getGender());
        basicInfo.setPolitical(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.POLITICAL.getKey()));
        basicInfo.setIdCard(expertUserInfoDTO.getIdCard());
        basicInfo.setOfficePhone(expertUserInfoDTO.getPhoneNo());
        basicInfo.setBirth(expertUserInfoDTO.getBirth());
        basicInfo.setBank(expertUserInfoDTO.getBank());
        basicInfo.setBankNo(expertUserInfoDTO.getBankNo());
        basicInfo.setEmail(expertUserInfoDTO.getEmail());
        basicInfo.setHometown(expertUserInfoDTO.getHometown());
        basicInfo.setNationality(expertUserInfoDTO.getNationality());
        basicInfo.setExpertSource(tagFieldInfoMap.get(ExpertTagEnum.EXPERT_SOURCE.getKey()));
        if (Objects.nonNull(expertRegionInfo)) {
//            expertRegionInfo.setRegionName(regionCache.getUnionPathStr(expertRegionInfo.getRegionCode(), expertRegionInfo.getRegionLevel()));
            basicInfo.setExpertRegionInfo(expertRegionInfo);
        }

        basicInfo.setExpertIntentionWorkRegions(expertIntentionWorkRegionInfo.stream().map(r -> {
            ExpertRegionInfo expertIntentionWorkRegion = new ExpertRegionInfo();
            expertIntentionWorkRegion.setRegionCode(r.getRegionCode());
            expertIntentionWorkRegion.setRegionLevel(r.getRegionLevel());
//            expertIntentionWorkRegion.setRegionName(regionCache.getUnionPathStr(r.getRegionCode(), r.getRegionLevel()));
            return expertIntentionWorkRegion;
        }).collect(Collectors.toList()));
        basicInfo.setExpertType(dictionaryFieldInfoMap.get(DictExpertInfoTypeEnum.EXPERT_TYPE.getKey()));
        return basicInfo;
    }

    public static ExpertFullInfoAllDTO buildExpertFullInfoAllDTO(ExpertUserFullInfo expertUserFullInfo
            , List<ExpertTag> expertTagList
            , List<ExpertDictionary> expertDictionaryList
            , List<ExpertIntentionWorkRegion> expertIntentionWorkRegionList
            , List<ExpertMetaApply> expertMetaApplyList
            , List<ExpertAvoidCompany> expertAvoidCompanyList) {
        ExpertUserFullInfoDTO expertUserFullInfoDTO = buildExpertUserFullInfoDTO(expertUserFullInfo);
        List<ExpertDictionaryDTO> expertDictionaryDTOList = buildExpertDictionaryDTOList(expertDictionaryList);
        List<ExpertTagDTO> expertTagDTOList = buildExpertTagDTOList(expertTagList);
        List<ExpertRegionDTO> expertIntentionWorkRegionInfo = buildExpertIntentionWorkRegionInfo(expertIntentionWorkRegionList);

        // 专家申请履职意向展示列表
        List<ExpertRegionDTO> expertApplyIntentionWorkRegionInfo = buildExpertApplyIntentionWorkRegionInfo(expertIntentionWorkRegionList, expertMetaApplyList);
        List<ExpertAvoidCompanyDTO> expertAvoidCompanyDTOList = buildExpertAvoidCompanyDTOList(expertAvoidCompanyList);
        ExpertFullInfoAllDTO expertFullInfoAllDTO = new ExpertFullInfoAllDTO();
        expertFullInfoAllDTO.setUserId(expertUserFullInfo.getUserId());
        expertFullInfoAllDTO.setExpertUserInfoDTO(expertUserFullInfoDTO);
        expertFullInfoAllDTO.setExpertDictionaryList(expertDictionaryDTOList);
        expertFullInfoAllDTO.setExpertTagList(expertTagDTOList);
        expertFullInfoAllDTO.setExpertIntentionWorkRegionInfo(expertIntentionWorkRegionInfo);
        expertFullInfoAllDTO.setExpertApplyIntentionWorkRegionInfo(expertApplyIntentionWorkRegionInfo);
        expertFullInfoAllDTO.setExpertAvoidCompanyList(expertAvoidCompanyDTOList);
        return expertFullInfoAllDTO;
    }

    private static List<ExpertRegionDTO> buildExpertApplyIntentionWorkRegionInfo(List<ExpertIntentionWorkRegion> expertIntentionWorkRegionList
            , List<ExpertMetaApply> expertMetaApplyList) {
        HashSet<RegionDtoMapKey> set = new HashSet();
        for (ExpertIntentionWorkRegion expertIntentionWorkRegion : expertIntentionWorkRegionList) {
            RegionDtoMapKey regionDtoMapKey = new RegionDtoMapKey();
            regionDtoMapKey.setRegionCode(expertIntentionWorkRegion.getRegionCode());
            regionDtoMapKey.setRegionLevel(expertIntentionWorkRegion.getRegionLevel());
            set.add(regionDtoMapKey);
        }

        for (ExpertMetaApply expertMetaApply : expertMetaApplyList) {
            String applyType = expertMetaApply.getApplyType();
            RegionDtoMapKey regionDtoMapKey = new RegionDtoMapKey();
            regionDtoMapKey.setRegionCode(expertMetaApply.getRegionCode());
            regionDtoMapKey.setRegionLevel(expertMetaApply.getRegionLevel());
            ExpertApplyTypeEnum typeEnum = ExpertApplyTypeEnum.of(applyType);
            switch (typeEnum) {
                case EXPERT_INTENTION_LEAVE: {
                    set.remove(regionDtoMapKey);
                }
                break;
                case EXPERT_INTENTION_JOIN: {
                    set.add(regionDtoMapKey);
                }
                break;
                default:
                    break;
            }
        }
        return set.stream().map(r -> {
            ExpertRegionDTO expertRegionDTO = new ExpertRegionDTO();
            expertRegionDTO.setRegionCode(r.getRegionCode());
            expertRegionDTO.setRegionLevel(r.getRegionLevel());
            return expertRegionDTO;
        }).collect(Collectors.toList());
    }

    private static List<ExpertAvoidCompanyDTO> buildExpertAvoidCompanyDTOList(List<ExpertAvoidCompany> expertAvoidCompanyList) {
        return expertAvoidCompanyList.stream().map(r -> {
            ExpertAvoidCompanyDTO expertAvoidCompanyDTO = new ExpertAvoidCompanyDTO();
            expertAvoidCompanyDTO.setCompanyUniqCode(r.getCompanyUniqCode());
            expertAvoidCompanyDTO.setCompanyName(r.getCompanyName());
            return expertAvoidCompanyDTO;
        }).collect(Collectors.toList());
    }

    private static List<ExpertRegionDTO> buildExpertIntentionWorkRegionInfo(List<ExpertIntentionWorkRegion> expertIntentionWorkRegionList) {
        return expertIntentionWorkRegionList.stream().map(r -> {
            ExpertRegionDTO expertRegionDTO = new ExpertRegionDTO();
            expertRegionDTO.setRegionLevel(r.getRegionLevel());
            expertRegionDTO.setRegionCode(r.getRegionCode());
            return expertRegionDTO;
        }).collect(Collectors.toList());
    }

    private static List<ExpertTagDTO> buildExpertTagDTOList(List<ExpertTag> expertTagList) {
        return expertTagList.stream().map(r -> {
            ExpertTagDTO expertTagDTO = new ExpertTagDTO();
            expertTagDTO.setExpertInfoField(r.getExpertInfoField());
            expertTagDTO.setTagCode(r.getTagCode());
            return expertTagDTO;
        }).collect(Collectors.toList());
    }

    private static List<ExpertDictionaryDTO> buildExpertDictionaryDTOList(List<ExpertDictionary> expertDictionaryList) {
        return expertDictionaryList.stream().map(r -> {
            ExpertDictionaryDTO expertDictionaryDTO = new ExpertDictionaryDTO();
            expertDictionaryDTO.setExpertInfoField(r.getExpertInfoField());
            expertDictionaryDTO.setDictionaryCode(r.getDictionaryCode());
            return expertDictionaryDTO;
        }).collect(Collectors.toList());
    }

    public static ExpertUserFullInfoDTO buildExpertUserFullInfoDTO(ExpertUserFullInfo expertUserFullInfo) {
        ExpertUserFullInfoDTO expertUserFullInfoDTO = new ExpertUserFullInfoDTO();
        expertUserFullInfoDTO.setIsDingUser(BoolDisplayEnum.judgeBoolean(expertUserFullInfo.getIsDingUser()));
        expertUserFullInfoDTO.setPhoneNo(expertUserFullInfo.getPhoneNo());
        expertUserFullInfoDTO.setGender(expertUserFullInfo.getGender());
        expertUserFullInfoDTO.setName(expertUserFullInfo.getExpertName());
        expertUserFullInfoDTO.setAvatarFileId(expertUserFullInfo.getAvatarFileId());
        expertUserFullInfoDTO.setIdCard(expertUserFullInfo.getIdCard());
        expertUserFullInfoDTO.setOfficePhone(expertUserFullInfo.getOfficePhone());
        expertUserFullInfoDTO.setBirth(expertUserFullInfo.getBirth());
        expertUserFullInfoDTO.setBankNo(expertUserFullInfo.getBankNo());
        expertUserFullInfoDTO.setBank(expertUserFullInfo.getBank());
        expertUserFullInfoDTO.setEmail(expertUserFullInfo.getEmail());
        expertUserFullInfoDTO.setHometown(expertUserFullInfo.getHometown());
        expertUserFullInfoDTO.setNationality(expertUserFullInfo.getNationality());

        expertUserFullInfoDTO.setSchool(expertUserFullInfo.getSchool());
        expertUserFullInfoDTO.setGraduatedAt(expertUserFullInfo.getGraduatedAt());
        expertUserFullInfoDTO.setAcademicTitle(expertUserFullInfo.getAcademicTitle());
        if (StringUtils.isNotBlank(expertUserFullInfo.getGraduationCertificateFileIdList())) {
            expertUserFullInfoDTO.setGraduationCertificateFileIdList(JSONObject.parseArray(expertUserFullInfo.getGraduationCertificateFileIdList(), Long.class));
        }
        if (StringUtils.isNotBlank(expertUserFullInfo.getDegreeCertificateFileIdList())) {
            expertUserFullInfoDTO.setDegreeCertificateFileIdList(JSONObject.parseArray(expertUserFullInfo.getDegreeCertificateFileIdList(), Long.class));
        }
        expertUserFullInfoDTO.setRetiredAt(expertUserFullInfo.getRetiredAt());
        expertUserFullInfoDTO.setCompany(expertUserFullInfo.getCompany());
//        expertUserFullInfoDTO.setCompanyUniqCode(expertUserFullInfo.getCompanyUniqCode());
        expertUserFullInfoDTO.setLegalEntityCode(expertUserFullInfo.getLegalEntityCode());
        expertUserFullInfoDTO.setAdministrativeDuties(expertUserFullInfo.getAdministrativeDuties());
        expertUserFullInfoDTO.setStartWorkAt(expertUserFullInfo.getStartWorkAt());
        expertUserFullInfoDTO.setAddress(expertUserFullInfo.getAddress());
        expertUserFullInfoDTO.setExperience(expertUserFullInfo.getExperience());

        expertUserFullInfoDTO.setTechnicalTitles(expertUserFullInfo.getTechnicalTitles());
        if (StringUtils.isNotBlank(expertUserFullInfo.getTitleCertificateFileIdList())) {
            expertUserFullInfoDTO.setTitleCertificateFileIdList(JSONObject.parseArray(expertUserFullInfo.getTitleCertificateFileIdList(), Long.class));
        }
        expertUserFullInfoDTO.setAwards(expertUserFullInfo.getAwards());
        expertUserFullInfoDTO.setRecognitionReward(expertUserFullInfo.getRecognitionReward());

        expertUserFullInfoDTO.setRegionCode(expertUserFullInfo.getRegionCode());
        expertUserFullInfoDTO.setRegionLevel(expertUserFullInfo.getRegionLevel());

        if (StringUtils.isNotBlank(expertUserFullInfo.getRecommendationProofFileIdList())) {
            expertUserFullInfoDTO.setRecommendationProofFileIdList(JSONObject.parseArray(expertUserFullInfo.getRecommendationProofFileIdList(), Long.class));
        }
        expertUserFullInfoDTO.setRemark(expertUserFullInfo.getRemark());

        return expertUserFullInfoDTO;
    }

//    public static ExpertAdminExpertManageListDTO buildExpertAdminExpertManageListDTO(ExpertUserFullInfo expertUserFullInfo
//            , Map<Long, List<ExpertDictionary>> expertDictionaryMap, Map<Long, List<ExpertTag>> expertTagMap) {
//        Long userId = expertUserFullInfo.getUserId();
//        ExpertAdminExpertManageListDTO expertAdminExpertManageListDTO = new ExpertAdminExpertManageListDTO();
//        expertAdminExpertManageListDTO.setUserId(expertUserFullInfo.getUserId());
//        expertAdminExpertManageListDTO.setExpertName(expertUserFullInfo.getName());
//        expertAdminExpertManageListDTO.setPhoneNo(expertUserFullInfo.getPhoneNo());
//        expertAdminExpertManageListDTO.setIsDingUser(BoolDisplayEnum.judgeBoolean(expertUserFullInfo.getIsDingUser()));
//        expertAdminExpertManageListDTO.setCompany(expertUserFullInfo.getCompany());
//        expertAdminExpertManageListDTO.setLegalEntityCode(expertUserFullInfo.getLegalEntityCode());
//        expertAdminExpertManageListDTO.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<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())));
//
//        if (StringUtils.isNotBlank(expertUserFullInfo.getRegionCode()) && Objects.nonNull(expertUserFullInfo.getRegionLevel())) {
//            ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
//            expertRegionInfo.setRegionLevel(expertUserFullInfo.getRegionLevel());
//            expertRegionInfo.setRegionCode(expertUserFullInfo.getRegionCode());
//            expertAdminExpertManageListDTO.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())));
//        return expertAdminExpertManageListDTO;
//
//    }


}
