@@ -15,7 +15,7 @@ import com.hz.pm.api.meta.constant.ExpertTagEnum; | |||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.helper.TagCache; | import com.hz.pm.api.meta.helper.TagCache; | ||||
import com.hz.pm.api.meta.model.ExpertRegionInfo; | import com.hz.pm.api.meta.model.ExpertRegionInfo; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.hz.pm.api.organization.model.entity.DingOrganization; | import com.hz.pm.api.organization.model.entity.DingOrganization; | ||||
import com.hz.pm.api.organization.service.IDingOrganizationService; | import com.hz.pm.api.organization.service.IDingOrganizationService; | ||||
@@ -62,7 +62,7 @@ public class ExpertRegisterUtil { | |||||
// 政治面貌 | // 政治面貌 | ||||
basic.setPolitical(new ArrayList<>()); | basic.setPolitical(new ArrayList<>()); | ||||
String political = MapUtil.getStr(w, "政治面貌"); | String political = MapUtil.getStr(w, "政治面貌"); | ||||
List<DictDTO> politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey()); | |||||
List<DictionaryDTO> politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey()); | |||||
if (!politicalDicts.isEmpty()) { | if (!politicalDicts.isEmpty()) { | ||||
politicalDicts.stream() | politicalDicts.stream() | ||||
.filter(dict -> dict.getName().equals(political)) | .filter(dict -> dict.getName().equals(political)) | ||||
@@ -82,7 +82,7 @@ public class ExpertRegisterUtil { | |||||
eduInfo.setDegree(new ArrayList<>()); | eduInfo.setDegree(new ArrayList<>()); | ||||
// 学历 | // 学历 | ||||
String eduStr = MapUtil.getStr(w, "学历"); | String eduStr = MapUtil.getStr(w, "学历"); | ||||
List<DictDTO> eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey()); | |||||
List<DictionaryDTO> eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey()); | |||||
if (!eduDicts.isEmpty()) { | if (!eduDicts.isEmpty()) { | ||||
eduDicts.stream() | eduDicts.stream() | ||||
.filter(dict -> dict.getName().equals(eduStr)) | .filter(dict -> dict.getName().equals(eduStr)) | ||||
@@ -96,7 +96,7 @@ public class ExpertRegisterUtil { | |||||
} | } | ||||
// 学位 | // 学位 | ||||
String degreeStr = MapUtil.getStr(w, "学位"); | String degreeStr = MapUtil.getStr(w, "学位"); | ||||
List<DictDTO> degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey()); | |||||
List<DictionaryDTO> degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey()); | |||||
if (!degreeDicts.isEmpty()) { | if (!degreeDicts.isEmpty()) { | ||||
degreeDicts.stream() | degreeDicts.stream() | ||||
.filter(dict -> dict.getName().equals(degreeStr)) | .filter(dict -> dict.getName().equals(degreeStr)) | ||||
@@ -139,7 +139,7 @@ public class ExpertRegisterUtil { | |||||
jobInfo.setAdministrativeDuties(MapUtil.getStr(w, "行政职务")); | jobInfo.setAdministrativeDuties(MapUtil.getStr(w, "行政职务")); | ||||
jobInfo.setAdministrativeRank(new ArrayList<>()); | jobInfo.setAdministrativeRank(new ArrayList<>()); | ||||
String administrativeRankStr = MapUtil.getStr(w, "行政职级"); | String administrativeRankStr = MapUtil.getStr(w, "行政职级"); | ||||
List<DictDTO> administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey()); | |||||
List<DictionaryDTO> administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey()); | |||||
if (!administrativeRankDicts.isEmpty()) { | if (!administrativeRankDicts.isEmpty()) { | ||||
administrativeRankDicts.stream() | administrativeRankDicts.stream() | ||||
.filter(dict -> dict.getName().equals(administrativeRankStr)) | .filter(dict -> dict.getName().equals(administrativeRankStr)) | ||||
@@ -153,7 +153,7 @@ public class ExpertRegisterUtil { | |||||
} | } | ||||
jobInfo.setCompanyAttribute(new ArrayList<>()); | jobInfo.setCompanyAttribute(new ArrayList<>()); | ||||
String companyTypeStr = MapUtil.getStr(w, "*单位类型"); | String companyTypeStr = MapUtil.getStr(w, "*单位类型"); | ||||
List<DictDTO> companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey()); | |||||
List<DictionaryDTO> companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey()); | |||||
if (!companyTypeDicts.isEmpty()) { | if (!companyTypeDicts.isEmpty()) { | ||||
companyTypeDicts.stream() | companyTypeDicts.stream() | ||||
.filter(dict -> dict.getName().equals(companyTypeStr)) | .filter(dict -> dict.getName().equals(companyTypeStr)) | ||||
@@ -170,7 +170,7 @@ public class ExpertRegisterUtil { | |||||
professionalInfo.setAwards("暂无"); | professionalInfo.setAwards("暂无"); | ||||
professionalInfo.setIndustrySector(new ArrayList<>()); | professionalInfo.setIndustrySector(new ArrayList<>()); | ||||
professionalInfo.setOther(new ArrayList<>()); | professionalInfo.setOther(new ArrayList<>()); | ||||
Map<String, TagDTO> tagMap = tagCache.getNameTagDtoMap(); | |||||
Map<String, TagDTO> tagMap = tagCache.getNameTagMap(); | |||||
String otherTagStr = MapUtil.getStr(w, "其他标签"); | String otherTagStr = MapUtil.getStr(w, "其他标签"); | ||||
if (StrUtils.isNotBlank(otherTagStr)) { | if (StrUtils.isNotBlank(otherTagStr)) { | ||||
for (String othTag : otherTagStr.split(SEPARATOR)) { | for (String othTag : otherTagStr.split(SEPARATOR)) { | ||||
@@ -240,7 +240,7 @@ public class ExpertRegisterUtil { | |||||
} | } | ||||
professionalInfo.setTitleLevel(new ArrayList<>()); | professionalInfo.setTitleLevel(new ArrayList<>()); | ||||
String titleLevel = MapUtil.getStr(w, "*职称级别"); | String titleLevel = MapUtil.getStr(w, "*职称级别"); | ||||
List<DictDTO> titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey()); | |||||
List<DictionaryDTO> titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey()); | |||||
if (!titleLevelDicts.isEmpty()) { | if (!titleLevelDicts.isEmpty()) { | ||||
titleLevelDicts.stream() | titleLevelDicts.stream() | ||||
.filter(dict -> dict.getName().equals(titleLevel)) | .filter(dict -> dict.getName().equals(titleLevel)) | ||||
@@ -11,7 +11,7 @@ import com.hz.pm.api.expert.model.vo.ExpertLibraryListItemVO; | |||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.helper.impl.TagsCacheImpl; | import com.hz.pm.api.meta.helper.impl.TagsCacheImpl; | ||||
import com.hz.pm.api.meta.model.ExpertRegionInfo; | import com.hz.pm.api.meta.model.ExpertRegionInfo; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.hz.pm.api.sys.model.dto.RegionDTO; | import com.hz.pm.api.sys.model.dto.RegionDTO; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -105,7 +105,7 @@ public class ExpertAdminExpertManageAssembler { | |||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
} | } | ||||
return collect.stream().peek(r -> { | return collect.stream().peek(r -> { | ||||
Optional<DictDTO> dict = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
Optional<DictionaryDTO> dict = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
dict.ifPresent(dictDTO -> r.setDictionaryName(dictDTO.getName())); | dict.ifPresent(dictDTO -> r.setDictionaryName(dictDTO.getName())); | ||||
}).collect(Collectors.toList()); | }).collect(Collectors.toList()); | ||||
} | } | ||||
@@ -17,7 +17,7 @@ import com.hz.pm.api.meta.constant.ExpertTagEnum; | |||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.helper.TagCache; | import com.hz.pm.api.meta.helper.TagCache; | ||||
import com.hz.pm.api.meta.model.ExpertRegionInfo; | import com.hz.pm.api.meta.model.ExpertRegionInfo; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.hz.pm.api.meta.model.entity.ExpertDictionary; | import com.hz.pm.api.meta.model.entity.ExpertDictionary; | ||||
import com.hz.pm.api.meta.model.entity.ExpertTag; | import com.hz.pm.api.meta.model.entity.ExpertTag; | ||||
@@ -123,7 +123,7 @@ public class ExpertUserInfoAssembler { | |||||
DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | ||||
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | ||||
dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | ||||
Optional<DictDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
Optional<DictionaryDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
dictionaryDTO.ifPresent(dictDTO -> dictionaryFieldInfo.setDictionaryName(dictDTO.getName())); | dictionaryDTO.ifPresent(dictDTO -> dictionaryFieldInfo.setDictionaryName(dictDTO.getName())); | ||||
return dictionaryFieldInfo; | return dictionaryFieldInfo; | ||||
}).collect(Collectors.groupingBy(DictionaryFieldInfo::getDictionaryFieldName)); | }).collect(Collectors.groupingBy(DictionaryFieldInfo::getDictionaryFieldName)); | ||||
@@ -4,8 +4,7 @@ import cn.hutool.core.collection.CollUtil; | |||||
import com.hz.pm.api.expert.model.*; | import com.hz.pm.api.expert.model.*; | ||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.helper.TagCache; | import com.hz.pm.api.meta.helper.TagCache; | ||||
import com.hz.pm.api.meta.model.ExpertRegionInfo; | |||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -82,7 +81,7 @@ public class ExpertManageHelper { | |||||
for (DictionaryFieldInfo dictField : dictFieldList) { | for (DictionaryFieldInfo dictField : dictFieldList) { | ||||
String dictCode = dictField.getDictionaryCode(); | String dictCode = dictField.getDictionaryCode(); | ||||
Optional<DictDTO> dict = dictionaryCache.getByCode(dictCode); | |||||
Optional<DictionaryDTO> dict = dictionaryCache.getByCode(dictCode); | |||||
if (!dict.isPresent()) { | if (!dict.isPresent()) { | ||||
String dictFieldName = dictField.getDictionaryFieldName(); | String dictFieldName = dictField.getDictionaryFieldName(); | ||||
throw BizException.wrap("字典数据无效:%s=%s", dictFieldName, dictCode); | throw BizException.wrap("字典数据无效:%s=%s", dictFieldName, dictCode); | ||||
@@ -26,7 +26,7 @@ import com.hz.pm.api.meeting.service.IMeetingExpertJudgeService; | |||||
import com.hz.pm.api.meeting.service.IMeetingExpertService; | import com.hz.pm.api.meeting.service.IMeetingExpertService; | ||||
import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | ||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.entity.ExpertDictionary; | import com.hz.pm.api.meta.model.entity.ExpertDictionary; | ||||
import com.hz.pm.api.meta.service.IExpertDictionaryService; | import com.hz.pm.api.meta.service.IExpertDictionaryService; | ||||
import com.hz.pm.api.sms.constant.VerificationCodeType; | import com.hz.pm.api.sms.constant.VerificationCodeType; | ||||
@@ -87,9 +87,9 @@ public class ExpertManage { | |||||
private Map<String, List<DictionaryVO>> listExpertDictionary(Long userId) { | private Map<String, List<DictionaryVO>> listExpertDictionary(Long userId) { | ||||
List<ExpertDictionary> dicts = expertDictionaryService.listByUserId(Collections.singleton(userId)); | List<ExpertDictionary> dicts = expertDictionaryService.listByUserId(Collections.singleton(userId)); | ||||
return dicts.stream().map(w -> { | return dicts.stream().map(w -> { | ||||
Optional<DictDTO> dict = dictionaryCache.getByCode(w.getDictionaryCode()); | |||||
Optional<DictionaryDTO> dict = dictionaryCache.getByCode(w.getDictionaryCode()); | |||||
if (dict.isPresent()) { | if (dict.isPresent()) { | ||||
DictDTO dto = dict.get(); | |||||
DictionaryDTO dto = dict.get(); | |||||
return new DictionaryVO(dto.getDictionaryCode(), dto.getName(), dto.getDictionaryType()); | return new DictionaryVO(dto.getDictionaryCode(), dto.getName(), dto.getDictionaryType()); | ||||
} else { | } else { | ||||
return null; | return null; | ||||
@@ -34,7 +34,7 @@ import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | |||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.model.ExpertRegionInfo; | import com.hz.pm.api.meta.model.ExpertRegionInfo; | ||||
import com.hz.pm.api.meta.model.bo.RegionContainsBO; | import com.hz.pm.api.meta.model.bo.RegionContainsBO; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.entity.ExpertDictionary; | import com.hz.pm.api.meta.model.entity.ExpertDictionary; | ||||
import com.hz.pm.api.meta.service.IExpertDictionaryService; | import com.hz.pm.api.meta.service.IExpertDictionaryService; | ||||
import com.hz.pm.api.sys.model.dto.RegionDTO; | import com.hz.pm.api.sys.model.dto.RegionDTO; | ||||
@@ -396,7 +396,7 @@ public class ExpertMetaApplyManage { | |||||
List<ExpertDictionary> titleLevelDictionaryList = titleLevelDictMap.get(userId); | List<ExpertDictionary> titleLevelDictionaryList = titleLevelDictMap.get(userId); | ||||
if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { | if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { | ||||
expertApplyMetaVO.setTitleLevel(titleLevelDictionaryList.stream().map(r -> { | expertApplyMetaVO.setTitleLevel(titleLevelDictionaryList.stream().map(r -> { | ||||
Optional<DictDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
Optional<DictionaryDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | ||||
dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | ||||
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | ||||
@@ -409,7 +409,7 @@ public class ExpertMetaApplyManage { | |||||
List<ExpertDictionary> expertTypeDictionaryList = expertTypeDictMap.get(userId); | List<ExpertDictionary> expertTypeDictionaryList = expertTypeDictMap.get(userId); | ||||
if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { | if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { | ||||
expertApplyMetaVO.setExpertType(expertTypeDictionaryList.stream().map(r -> { | expertApplyMetaVO.setExpertType(expertTypeDictionaryList.stream().map(r -> { | ||||
Optional<DictDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
Optional<DictionaryDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); | |||||
DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); | ||||
dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); | ||||
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); | ||||
@@ -2,6 +2,7 @@ package com.hz.pm.api.external.controller; | |||||
import com.hz.pm.api.external.MhUserOrgClient; | import com.hz.pm.api.external.MhUserOrgClient; | ||||
import com.hz.pm.api.user.manage.SyncMhUserOrgManage; | import com.hz.pm.api.user.manage.SyncMhUserOrgManage; | ||||
import io.swagger.annotations.Api; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||
import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
@@ -19,6 +20,7 @@ import java.time.LocalDateTime; | |||||
* @author WendyYang | * @author WendyYang | ||||
* @since 09:56 2023/12/22 | * @since 09:56 2023/12/22 | ||||
*/ | */ | ||||
@Api(hidden = true) | |||||
@RestController | @RestController | ||||
@RequiredArgsConstructor | @RequiredArgsConstructor | ||||
@RequestMapping("/api/v1/mh/sync") | @RequestMapping("/api/v1/mh/sync") | ||||
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.hz.pm.api.common.helper.RegionCacheHelper; | import com.hz.pm.api.common.helper.RegionCacheHelper; | ||||
import com.hz.pm.api.common.util.BizUtils; | import com.hz.pm.api.common.util.BizUtils; | ||||
import com.hz.pm.api.common.util.StrUtils; | import com.hz.pm.api.common.util.StrUtils; | ||||
import com.hz.pm.api.expert.constant.ExpertAccountStatusEnum; | |||||
import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | ||||
import com.hz.pm.api.expert.model.dto.ExpertDictionaryDTO; | import com.hz.pm.api.expert.model.dto.ExpertDictionaryDTO; | ||||
import com.hz.pm.api.expert.model.dto.ExpertFullInfoAllDTO; | import com.hz.pm.api.expert.model.dto.ExpertFullInfoAllDTO; | ||||
@@ -31,7 +30,7 @@ import com.hz.pm.api.meeting.service.IExpertInviteRuleService; | |||||
import com.hz.pm.api.meeting.service.IMeetingExpertService; | import com.hz.pm.api.meeting.service.IMeetingExpertService; | ||||
import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | ||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.sys.model.dto.RegionDTO; | import com.hz.pm.api.sys.model.dto.RegionDTO; | ||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
@@ -171,7 +170,7 @@ public class MeetingManageHelper { | |||||
.filter(dict -> dict.getExpertInfoField().equals(ExpertDictTypeEnum.TITLE_LEVEL.getKey())) | .filter(dict -> dict.getExpertInfoField().equals(ExpertDictTypeEnum.TITLE_LEVEL.getKey())) | ||||
.findFirst(); | .findFirst(); | ||||
if (first.isPresent()) { | if (first.isPresent()) { | ||||
Optional<DictDTO> dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode()); | |||||
Optional<DictionaryDTO> dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode()); | |||||
dictInfo.ifPresent(d -> basicInfoVo.setJobLevel(d.getName())); | dictInfo.ifPresent(d -> basicInfoVo.setJobLevel(d.getName())); | ||||
} else { | } else { | ||||
basicInfoVo.setJobLevel(""); | basicInfoVo.setJobLevel(""); | ||||
@@ -2,7 +2,7 @@ package com.hz.pm.api.meta.assembler; | |||||
import com.hz.pm.api.meta.model.entity.MetaDictionary; | import com.hz.pm.api.meta.model.entity.MetaDictionary; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.vo.ResDictionaryVO; | import com.hz.pm.api.meta.model.vo.ResDictionaryVO; | ||||
/** | /** | ||||
@@ -12,8 +12,8 @@ import com.hz.pm.api.meta.model.vo.ResDictionaryVO; | |||||
public class MetaDictionaryAssembler { | public class MetaDictionaryAssembler { | ||||
public static DictDTO toDictionaryDTO(MetaDictionary dictionaryManage) { | |||||
DictDTO dictionaryDTO = new DictDTO(); | |||||
public static DictionaryDTO toDictionaryDTO(MetaDictionary dictionaryManage) { | |||||
DictionaryDTO dictionaryDTO = new DictionaryDTO(); | |||||
dictionaryDTO.setDescribe(dictionaryManage.getDictionaryDescribe()); | dictionaryDTO.setDescribe(dictionaryManage.getDictionaryDescribe()); | ||||
dictionaryDTO.setDictionaryCode(dictionaryManage.getDictionaryCode()); | dictionaryDTO.setDictionaryCode(dictionaryManage.getDictionaryCode()); | ||||
dictionaryDTO.setDictionaryType(dictionaryManage.getDictionaryType()); | dictionaryDTO.setDictionaryType(dictionaryManage.getDictionaryType()); | ||||
@@ -23,7 +23,7 @@ public class MetaDictionaryAssembler { | |||||
return dictionaryDTO; | return dictionaryDTO; | ||||
} | } | ||||
public static ResDictionaryVO toDictionaryVO(DictDTO dictionaryDTO) { | |||||
public static ResDictionaryVO toDictionaryVO(DictionaryDTO dictionaryDTO) { | |||||
ResDictionaryVO resDictionaryVO = new ResDictionaryVO(); | ResDictionaryVO resDictionaryVO = new ResDictionaryVO(); | ||||
resDictionaryVO.setDescribe(dictionaryDTO.getDescribe()); | resDictionaryVO.setDescribe(dictionaryDTO.getDescribe()); | ||||
resDictionaryVO.setDictionaryCode(dictionaryDTO.getDictionaryCode()); | resDictionaryVO.setDictionaryCode(dictionaryDTO.getDictionaryCode()); | ||||
@@ -2,7 +2,7 @@ package com.hz.pm.api.meta.helper; | |||||
import com.hz.pm.api.meta.constant.DictTypeEnum; | import com.hz.pm.api.meta.constant.DictTypeEnum; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Optional; | import java.util.Optional; | ||||
@@ -20,7 +20,7 @@ public interface DictionaryCache { | |||||
* @param dictionaryType \ | * @param dictionaryType \ | ||||
* @return \ | * @return \ | ||||
*/ | */ | ||||
List<DictDTO> listDictByDictType(DictTypeEnum dictionaryType); | |||||
List<DictionaryDTO> listDictByDictType(DictTypeEnum dictionaryType); | |||||
/** | /** | ||||
* 根据字典类型 获取 字典列表 | * 根据字典类型 获取 字典列表 | ||||
@@ -28,7 +28,7 @@ public interface DictionaryCache { | |||||
* @param dictType \ | * @param dictType \ | ||||
* @return \ | * @return \ | ||||
*/ | */ | ||||
List<DictDTO> listDictByDictType(String dictType); | |||||
List<DictionaryDTO> listDictByDictType(String dictType); | |||||
/** | /** | ||||
* 根据字典类型、字典编码 获取 字典实体 | * 根据字典类型、字典编码 获取 字典实体 | ||||
@@ -37,7 +37,7 @@ public interface DictionaryCache { | |||||
* @param code \ | * @param code \ | ||||
* @return \ | * @return \ | ||||
*/ | */ | ||||
DictDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code); | |||||
DictionaryDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code); | |||||
/** | /** | ||||
* 根据字典编码 获取 字典实体 | * 根据字典编码 获取 字典实体 | ||||
@@ -45,8 +45,8 @@ public interface DictionaryCache { | |||||
* @param dictCode \ | * @param dictCode \ | ||||
* @return \ | * @return \ | ||||
*/ | */ | ||||
Optional<DictDTO> getByCode(String dictCode); | |||||
Optional<DictionaryDTO> getByCode(String dictCode); | |||||
Optional<DictDTO> getByDictTypeAndName(String dictType, String name); | |||||
Optional<DictionaryDTO> getByDictTypeAndName(String dictType, String name); | |||||
} | } |
@@ -34,7 +34,7 @@ public interface TagCache { | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
Map<String, TagDTO> getNameTagDtoMap(); | |||||
Map<String, TagDTO> getNameTagMap(); | |||||
/** | /** | ||||
* 获取所有子节点包含当前节点 | * 获取所有子节点包含当前节点 | ||||
@@ -1,55 +1,75 @@ | |||||
package com.hz.pm.api.meta.helper.basic; | package com.hz.pm.api.meta.helper.basic; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.collection.IterUtil; | |||||
import com.github.benmanes.caffeine.cache.CacheLoader; | |||||
import com.github.benmanes.caffeine.cache.Caffeine; | import com.github.benmanes.caffeine.cache.Caffeine; | ||||
import com.github.benmanes.caffeine.cache.LoadingCache; | import com.github.benmanes.caffeine.cache.LoadingCache; | ||||
import com.hz.pm.api.meta.constant.DictTypeEnum; | import com.hz.pm.api.meta.constant.DictTypeEnum; | ||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.service.IMetaDictionaryService; | import com.hz.pm.api.meta.service.IMetaDictionaryService; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.checkerframework.checker.nullness.qual.NonNull; | |||||
import org.springframework.beans.factory.InitializingBean; | import org.springframework.beans.factory.InitializingBean; | ||||
import java.util.Arrays; | |||||
import java.util.Collections; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @author liuxinxin | * @author liuxinxin | ||||
* @date 2022/12/22 上午11:03 | * @date 2022/12/22 上午11:03 | ||||
*/ | */ | ||||
@Slf4j | |||||
@RequiredArgsConstructor | @RequiredArgsConstructor | ||||
public abstract class AbstractDictionaryCache implements InitializingBean, DictionaryCache { | public abstract class AbstractDictionaryCache implements InitializingBean, DictionaryCache { | ||||
private final IMetaDictionaryService metaDictionaryService; | private final IMetaDictionaryService metaDictionaryService; | ||||
protected Map<String, DictDTO> dictionaryMap = new ConcurrentHashMap<>(); | |||||
protected LoadingCache<String, List<DictDTO>> dictCache; | |||||
protected Map<String, DictionaryDTO> dictionaryMap = new ConcurrentHashMap<>(); | |||||
protected LoadingCache<String, List<DictionaryDTO>> dictCache; | |||||
@Override | @Override | ||||
public void afterPropertiesSet() { | public void afterPropertiesSet() { | ||||
dictCache = Caffeine.newBuilder() | dictCache = Caffeine.newBuilder() | ||||
.refreshAfterWrite(30, TimeUnit.MINUTES) | |||||
.build(key -> { | |||||
List<DictDTO> dicts = metaDictionaryService.queryAll(); | |||||
dictionaryMap = buildCateMap(dicts); | |||||
Map<String, List<DictDTO>> dictMapByType = CollUtils.group(dicts, DictDTO::getDictionaryType); | |||||
return dictMapByType.get(key); | |||||
}); | |||||
warmUp(); | |||||
} | |||||
.refreshAfterWrite(7, TimeUnit.DAYS) | |||||
.build(new CacheLoader<String, List<DictionaryDTO>>() { | |||||
@Override | |||||
public List<DictionaryDTO> load(@NonNull String key) { | |||||
log.info("刷新字典数据:{}", key); | |||||
List<DictionaryDTO> dicts = metaDictionaryService.queryByDictType(key); | |||||
dicts.forEach(dict -> dictionaryMap.put(dict.getDictionaryCode(), dict)); | |||||
return dicts; | |||||
} | |||||
private Map<String, DictDTO> buildCateMap(List<DictDTO> dictionaryDTOList) { | |||||
Map<String, DictDTO> dictionaryDtoMap = new ConcurrentHashMap<>(128); | |||||
dictionaryDTOList.forEach(dictionaryDTO -> dictionaryDtoMap.put(dictionaryDTO.getDictionaryCode(), dictionaryDTO)); | |||||
return dictionaryDtoMap; | |||||
@Override | |||||
public @NonNull Map<String, List<DictionaryDTO>> loadAll(@NonNull Iterable<? extends String> keys) { | |||||
log.info("刷新字典数据[loadAll]:数量 -> {}", IterUtil.size(keys)); | |||||
if (CollUtil.isEmpty(keys)) { | |||||
return Collections.emptyMap(); | |||||
} | |||||
List<String> keysList = IterUtil.toList(keys).stream().map(String::toString).collect(Collectors.toList()); | |||||
List<DictionaryDTO> allDicts = metaDictionaryService.queryByDictTypes(keysList); | |||||
allDicts.forEach(dict -> dictionaryMap.put(dict.getDictionaryCode(), dict)); | |||||
return CollUtils.group(allDicts, DictionaryDTO::getDictionaryType); | |||||
} | |||||
}); | |||||
// 初始化所有字典信息 | |||||
initAllDicts(); | |||||
} | } | ||||
private void warmUp() { | |||||
for (DictTypeEnum typeEnum : DictTypeEnum.values()) { | |||||
dictCache.get(typeEnum.getKey()); | |||||
} | |||||
private void initAllDicts() { | |||||
List<String> dictTypes = Arrays.stream(DictTypeEnum.values()) | |||||
.map(DictTypeEnum::getKey) | |||||
.collect(Collectors.toList()); | |||||
dictCache.getAll(dictTypes); | |||||
} | } | ||||
} | } |
@@ -1,5 +1,9 @@ | |||||
package com.hz.pm.api.meta.helper.basic; | package com.hz.pm.api.meta.helper.basic; | ||||
import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.collection.IterUtil; | |||||
import cn.hutool.core.util.NumberUtil; | |||||
import com.github.benmanes.caffeine.cache.CacheLoader; | |||||
import com.github.benmanes.caffeine.cache.Caffeine; | import com.github.benmanes.caffeine.cache.Caffeine; | ||||
import com.github.benmanes.caffeine.cache.LoadingCache; | import com.github.benmanes.caffeine.cache.LoadingCache; | ||||
import com.hz.pm.api.meta.assembler.MetaTagAssembler; | import com.hz.pm.api.meta.assembler.MetaTagAssembler; | ||||
@@ -10,6 +14,7 @@ import com.hz.pm.api.meta.service.IMetaTagService; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.collections4.CollectionUtils; | import org.apache.commons.collections4.CollectionUtils; | ||||
import org.checkerframework.checker.nullness.qual.NonNull; | |||||
import org.springframework.beans.factory.InitializingBean; | import org.springframework.beans.factory.InitializingBean; | ||||
import java.util.*; | import java.util.*; | ||||
@@ -25,60 +30,82 @@ import java.util.stream.Collectors; | |||||
@RequiredArgsConstructor | @RequiredArgsConstructor | ||||
public abstract class AbstractTagsCache implements InitializingBean, TagCache { | public abstract class AbstractTagsCache implements InitializingBean, TagCache { | ||||
protected static final int MAX_LEVEL = 4; | protected static final int MAX_LEVEL = 4; | ||||
private final IMetaTagService metaTagService; | private final IMetaTagService metaTagService; | ||||
protected LoadingCache<String, List<TagTreeDTO>> tagsCache; | protected LoadingCache<String, List<TagTreeDTO>> tagsCache; | ||||
protected Map<String, TagDTO> tagDtoMap; | |||||
protected Map<String, TagDTO> tagCacheMap = new ConcurrentHashMap<>(); | |||||
@Override | @Override | ||||
public void afterPropertiesSet() { | public void afterPropertiesSet() { | ||||
tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) | |||||
.refreshAfterWrite(5, TimeUnit.MINUTES) | |||||
.build(key -> { | |||||
// 查询全部 | |||||
List<TagDTO> tagDTOList = metaTagService.queryAll(); | |||||
if (tagDTOList.isEmpty()) { | |||||
log.warn("当前层级对应树不存在:{}", key); | |||||
return Collections.emptyList(); | |||||
tagsCache = Caffeine.newBuilder() | |||||
.refreshAfterWrite(7, TimeUnit.DAYS) | |||||
.build(new CacheLoader<String, List<TagTreeDTO>>() { | |||||
@Override | |||||
public List<TagTreeDTO> load(@NonNull String key) { | |||||
log.info("刷新当前标签树:{}", key); | |||||
// 查询全部 | |||||
List<TagDTO> tags = metaTagService.queryLeLevel(Integer.parseInt(key)); | |||||
putToTagMap(tags); | |||||
return toTree(MetaTagAssembler.toTagTreeDTOList(tags)); | |||||
} | } | ||||
tagDtoMap = buildCateMap(tagDTOList); | |||||
List<TagDTO> tagInLevel = tagDTOList.stream().filter(tagDto -> { | |||||
// 只过滤出小于等于level的tag | |||||
if (Objects.isNull(tagDto.getTagLevel())) { | |||||
return false; | |||||
@Override | |||||
public @NonNull Map<String, List<TagTreeDTO>> loadAll(@NonNull Iterable<? extends @NonNull String> keys) { | |||||
if (CollUtil.isEmpty(keys)) { | |||||
return Collections.emptyMap(); | |||||
} | |||||
Optional<Integer> maxLevel = IterUtil.toList(keys).stream() | |||||
.map(Integer::parseInt) | |||||
.max(Comparator.comparingInt(Integer::intValue)); | |||||
if (!maxLevel.isPresent()) { | |||||
return Collections.emptyMap(); | |||||
} | } | ||||
return Integer.parseInt(key) >= tagDto.getTagLevel(); | |||||
}).collect(Collectors.toList()); | |||||
List<TagTreeDTO> treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); | |||||
return toTreeStructure(treeDtos); | |||||
Integer maxLevelVal = maxLevel.get(); | |||||
log.info("刷新当前标签树:最大层级为 -> {}", maxLevelVal); | |||||
List<TagDTO> allTags = metaTagService.queryLeLevel(maxLevelVal); | |||||
putToTagMap(allTags); | |||||
Map<String, List<TagTreeDTO>> mapByKeys = new HashMap<>(); | |||||
keys.forEach(key -> { | |||||
int currLevel = Integer.parseInt(key); | |||||
List<TagDTO> tagsByLevel = allTags.stream() | |||||
.filter(w -> w.getTagLevel() <= currLevel) | |||||
.collect(Collectors.toList()); | |||||
mapByKeys.put(String.valueOf(currLevel), toTree(MetaTagAssembler.toTagTreeDTOList(tagsByLevel))); | |||||
}); | |||||
return mapByKeys; | |||||
} | |||||
}); | }); | ||||
warmUp(); | |||||
// 初始化所有tag | |||||
initAllTags(); | |||||
} | } | ||||
private Map<String, TagDTO> buildCateMap(List<TagDTO> tagDTOList) { | |||||
Map<String, TagDTO> tagDtoMapTemp = new ConcurrentHashMap<>(1024); | |||||
tagDTOList.forEach(tagDTO -> tagDtoMapTemp.put(tagDTO.getTagCode(), tagDTO)); | |||||
return tagDtoMapTemp; | |||||
private void putToTagMap(List<TagDTO> tagDTOList) { | |||||
tagDTOList.forEach(tagDTO -> tagCacheMap.put(tagDTO.getTagCode(), tagDTO)); | |||||
} | } | ||||
private List<TagTreeDTO> toTreeStructure(List<TagTreeDTO> rootList) { | |||||
private List<TagTreeDTO> toTree(List<TagTreeDTO> tagTreeList) { | |||||
List<TagTreeDTO> nodeList = new ArrayList<>(); | List<TagTreeDTO> nodeList = new ArrayList<>(); | ||||
for (TagTreeDTO tagTreeDTO : rootList) { | |||||
if ("-1".equals(tagTreeDTO.getParentCode()) || Objects.isNull(tagTreeDTO.getParentCode())) { | |||||
nodeList.add(tagTreeDTO); | |||||
for (TagTreeDTO node : tagTreeList) { | |||||
String parentCode = node.getParentCode(); | |||||
if ("-1".equals(parentCode) || Objects.isNull(parentCode)) { | |||||
nodeList.add(node); | |||||
} | } | ||||
tagTreeDTO.setChildren(getChildren(tagTreeDTO.getTagCode(), rootList)); | |||||
node.setChildren(getChildren(node.getTagCode(), tagTreeList)); | |||||
} | } | ||||
return nodeList; | return nodeList; | ||||
} | } | ||||
public void warmUp() { | |||||
for (int level = 1; level <= MAX_LEVEL; level++) { | |||||
tagsCache.get(level + ""); | |||||
} | |||||
public void initAllTags() { | |||||
List<String> allLevels = Arrays.stream(NumberUtil.range(1, MAX_LEVEL)) | |||||
.mapToObj(String::valueOf) | |||||
.collect(Collectors.toList()); | |||||
tagsCache.getAll(allLevels); | |||||
} | } | ||||
protected List<TagTreeDTO> getChildren(String tagCode, List<TagTreeDTO> list) { | protected List<TagTreeDTO> getChildren(String tagCode, List<TagTreeDTO> list) { | ||||
@@ -2,7 +2,7 @@ package com.hz.pm.api.meta.helper.impl; | |||||
import com.hz.pm.api.meta.constant.DictTypeEnum; | import com.hz.pm.api.meta.constant.DictTypeEnum; | ||||
import com.hz.pm.api.meta.helper.basic.AbstractDictionaryCache; | import com.hz.pm.api.meta.helper.basic.AbstractDictionaryCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.service.IMetaDictionaryService; | import com.hz.pm.api.meta.service.IMetaDictionaryService; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
@@ -22,30 +22,30 @@ public class DictionaryCacheImpl extends AbstractDictionaryCache { | |||||
} | } | ||||
@Override | @Override | ||||
public List<DictDTO> listDictByDictType(DictTypeEnum dictionaryType) { | |||||
public List<DictionaryDTO> listDictByDictType(DictTypeEnum dictionaryType) { | |||||
return dictCache.get(dictionaryType.getKey()); | return dictCache.get(dictionaryType.getKey()); | ||||
} | } | ||||
@Override | @Override | ||||
public List<DictDTO> listDictByDictType(String dictType) { | |||||
public List<DictionaryDTO> listDictByDictType(String dictType) { | |||||
return dictCache.get(dictType); | return dictCache.get(dictType); | ||||
} | } | ||||
@Override | @Override | ||||
public DictDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code) { | |||||
public DictionaryDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code) { | |||||
return Objects.requireNonNull(dictCache.get(dictionaryType.getKey())) | return Objects.requireNonNull(dictCache.get(dictionaryType.getKey())) | ||||
.stream().filter(w -> w.getDictionaryCode().equals(code)) | .stream().filter(w -> w.getDictionaryCode().equals(code)) | ||||
.findFirst().orElse(null); | .findFirst().orElse(null); | ||||
} | } | ||||
@Override | @Override | ||||
public Optional<DictDTO> getByCode(String dictionaryCode) { | |||||
public Optional<DictionaryDTO> getByCode(String dictionaryCode) { | |||||
return Optional.ofNullable(dictionaryMap.get(dictionaryCode)); | return Optional.ofNullable(dictionaryMap.get(dictionaryCode)); | ||||
} | } | ||||
@Override | @Override | ||||
public Optional<DictDTO> getByDictTypeAndName(String dictType, String name) { | |||||
List<DictDTO> dicts = dictCache.get(dictType); | |||||
public Optional<DictionaryDTO> getByDictTypeAndName(String dictType, String name) { | |||||
List<DictionaryDTO> dicts = dictCache.get(dictType); | |||||
if (dicts == null || dicts.isEmpty()) { | if (dicts == null || dicts.isEmpty()) { | ||||
return Optional.empty(); | return Optional.empty(); | ||||
} | } | ||||
@@ -1,17 +1,20 @@ | |||||
package com.hz.pm.api.meta.helper.impl; | package com.hz.pm.api.meta.helper.impl; | ||||
import cn.hutool.core.bean.BeanUtil; | import cn.hutool.core.bean.BeanUtil; | ||||
import com.hz.pm.api.meta.service.IMetaTagService; | |||||
import com.ningdatech.basic.exception.BizException; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import com.hz.pm.api.meta.helper.basic.AbstractTagsCache; | import com.hz.pm.api.meta.helper.basic.AbstractTagsCache; | ||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.hz.pm.api.meta.model.dto.TagTreeDTO; | import com.hz.pm.api.meta.model.dto.TagTreeDTO; | ||||
import com.hz.pm.api.meta.service.IMetaTagService; | |||||
import com.ningdatech.basic.exception.BizException; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import io.micrometer.core.instrument.util.StringUtils; | import io.micrometer.core.instrument.util.StringUtils; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | /** | ||||
* @author liuxinxin | * @author liuxinxin | ||||
@@ -28,8 +31,8 @@ public class TagsCacheImpl extends AbstractTagsCache { | |||||
@Override | @Override | ||||
public TagTreeDTO getTagTreeDTO(int level, String rootTagCode) { | public TagTreeDTO getTagTreeDTO(int level, String rootTagCode) { | ||||
List<TagTreeDTO> tagTreeDtos = tagsCache.get(level + ""); | |||||
for (TagTreeDTO tagTreeDTO : tagTreeDtos) { | |||||
List<TagTreeDTO> tagTrees = tagsCache.get(level + ""); | |||||
for (TagTreeDTO tagTreeDTO : tagTrees) { | |||||
if (tagTreeDTO.getTagCode().equals(rootTagCode)) { | if (tagTreeDTO.getTagCode().equals(rootTagCode)) { | ||||
return tagTreeDTO; | return tagTreeDTO; | ||||
} | } | ||||
@@ -42,7 +45,7 @@ public class TagsCacheImpl extends AbstractTagsCache { | |||||
if (StringUtils.isBlank(tagCode)) { | if (StringUtils.isBlank(tagCode)) { | ||||
return null; | return null; | ||||
} | } | ||||
return tagDtoMap.get(tagCode); | |||||
return tagCacheMap.get(tagCode); | |||||
} | } | ||||
/** | /** | ||||
@@ -51,12 +54,12 @@ public class TagsCacheImpl extends AbstractTagsCache { | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public Map<String, TagDTO> getNameTagDtoMap() { | |||||
Map<String, TagDTO> nameTagDtoMap = new HashMap<>(1024); | |||||
for (String key : tagDtoMap.keySet()) { | |||||
nameTagDtoMap.put(tagDtoMap.get(key).getTagName(), tagDtoMap.get(key)); | |||||
public Map<String, TagDTO> getNameTagMap() { | |||||
Map<String, TagDTO> nameTagMap = new HashMap<>(1024); | |||||
for (String key : tagCacheMap.keySet()) { | |||||
nameTagMap.put(tagCacheMap.get(key).getTagName(), tagCacheMap.get(key)); | |||||
} | } | ||||
return nameTagDtoMap; | |||||
return nameTagMap; | |||||
} | } | ||||
@@ -72,7 +75,7 @@ public class TagsCacheImpl extends AbstractTagsCache { | |||||
List<TagTreeDTO> allTree = tagsCache.get(String.valueOf(MAX_LEVEL)); | List<TagTreeDTO> allTree = tagsCache.get(String.valueOf(MAX_LEVEL)); | ||||
assert allTree != null; | assert allTree != null; | ||||
List<TagTreeDTO> children = getChildren(code, allTree); | List<TagTreeDTO> children = getChildren(code, allTree); | ||||
TagDTO tagDTO = tagDtoMap.get(code); | |||||
TagDTO tagDTO = tagCacheMap.get(code); | |||||
TagTreeDTO rootNode = BeanUtil.copyProperties(tagDTO, TagTreeDTO.class); | TagTreeDTO rootNode = BeanUtil.copyProperties(tagDTO, TagTreeDTO.class); | ||||
rootNode.setChildren(children); | rootNode.setChildren(children); | ||||
return treeToList(rootNode); | return treeToList(rootNode); | ||||
@@ -18,7 +18,7 @@ import com.hz.pm.api.meta.constant.ExpertTagEnum; | |||||
import com.hz.pm.api.meta.constant.TagConst; | import com.hz.pm.api.meta.constant.TagConst; | ||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.helper.TagCache; | import com.hz.pm.api.meta.helper.TagCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.dto.TagTreeDTO; | import com.hz.pm.api.meta.model.dto.TagTreeDTO; | ||||
import com.hz.pm.api.meta.model.entity.ExpertDictionary; | import com.hz.pm.api.meta.model.entity.ExpertDictionary; | ||||
import com.hz.pm.api.meta.model.entity.ExpertTag; | import com.hz.pm.api.meta.model.entity.ExpertTag; | ||||
@@ -59,7 +59,7 @@ public class MetaManage { | |||||
for (String dictionaryType : dictionaryTypeList) { | for (String dictionaryType : dictionaryTypeList) { | ||||
ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); | ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); | ||||
resDictionaryListVO.setDictionaryName(dictionaryType); | resDictionaryListVO.setDictionaryName(dictionaryType); | ||||
List<DictDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); | |||||
List<DictionaryDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); | |||||
if (dictionaryList == null) { | if (dictionaryList == null) { | ||||
continue; | continue; | ||||
} | } | ||||
@@ -97,7 +97,7 @@ public class MetaManage { | |||||
for (String dictionaryType : dictionaryTypeList) { | for (String dictionaryType : dictionaryTypeList) { | ||||
ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); | ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); | ||||
resDictionaryListVO.setDictionaryName(dictionaryType); | resDictionaryListVO.setDictionaryName(dictionaryType); | ||||
List<DictDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); | |||||
List<DictionaryDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); | |||||
List<ResDictionaryVO> resDictionaryVOList = dictionaryList.stream() | List<ResDictionaryVO> resDictionaryVOList = dictionaryList.stream() | ||||
.map(MetaDictionaryAssembler::toDictionaryVO).collect(Collectors.toList()); | .map(MetaDictionaryAssembler::toDictionaryVO).collect(Collectors.toList()); | ||||
resDictionaryListVO.setDictionaryList(resDictionaryVOList); | resDictionaryListVO.setDictionaryList(resDictionaryVOList); | ||||
@@ -7,7 +7,7 @@ import lombok.Data; | |||||
* @date 2022/7/22 上午10:49 | * @date 2022/7/22 上午10:49 | ||||
*/ | */ | ||||
@Data | @Data | ||||
public class DictDTO { | |||||
public class DictionaryDTO { | |||||
private String dictionaryType; | private String dictionaryType; | ||||
@@ -2,8 +2,9 @@ package com.hz.pm.api.meta.service; | |||||
import com.hz.pm.api.meta.model.entity.MetaDictionary; | import com.hz.pm.api.meta.model.entity.MetaDictionary; | ||||
import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import java.util.Collection; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@@ -16,7 +17,10 @@ import java.util.List; | |||||
*/ | */ | ||||
public interface IMetaDictionaryService extends IService<MetaDictionary> { | public interface IMetaDictionaryService extends IService<MetaDictionary> { | ||||
List<DictDTO> queryAll(); | |||||
List<DictionaryDTO> queryAll(); | |||||
List<DictionaryDTO> queryByDictType(String dictType); | |||||
List<DictionaryDTO> queryByDictTypes(Collection<String> dictTypes); | |||||
} | } |
@@ -8,7 +8,7 @@ import java.util.List; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* 服务类 | |||||
* 服务类 | |||||
* </p> | * </p> | ||||
* | * | ||||
* @author Liuxinxin | * @author Liuxinxin | ||||
@@ -18,4 +18,6 @@ public interface IMetaTagService extends IService<MetaTag> { | |||||
List<TagDTO> queryAll(); | List<TagDTO> queryAll(); | ||||
List<TagDTO> queryLeLevel(int level); | |||||
} | } |
@@ -5,15 +5,17 @@ import com.hz.pm.api.meta.model.entity.MetaDictionary; | |||||
import com.hz.pm.api.meta.mapper.MetaDictionaryMapper; | import com.hz.pm.api.meta.mapper.MetaDictionaryMapper; | ||||
import com.hz.pm.api.meta.service.IMetaDictionaryService; | import com.hz.pm.api.meta.service.IMetaDictionaryService; | ||||
import com.hz.pm.api.meta.assembler.MetaDictionaryAssembler; | import com.hz.pm.api.meta.assembler.MetaDictionaryAssembler; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.Collection; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
/** | /** | ||||
* <p> | * <p> | ||||
* 服务实现类 | |||||
* 字典服务实现类 | |||||
* </p> | * </p> | ||||
* | * | ||||
* @author Liuxinxin | * @author Liuxinxin | ||||
@@ -23,10 +25,29 @@ import java.util.stream.Collectors; | |||||
public class MetaDictionaryServiceImpl extends ServiceImpl<MetaDictionaryMapper, MetaDictionary> implements IMetaDictionaryService { | public class MetaDictionaryServiceImpl extends ServiceImpl<MetaDictionaryMapper, MetaDictionary> implements IMetaDictionaryService { | ||||
@Override | @Override | ||||
public List<DictDTO> queryAll() { | |||||
List<MetaDictionary> dictionaryList = this.lambdaQuery().ne(MetaDictionary::getId, -1).list(); | |||||
List<DictDTO> dictionaryDTOList = dictionaryList.stream().map(MetaDictionaryAssembler::toDictionaryDTO).collect(Collectors.toList()); | |||||
return dictionaryDTOList; | |||||
public List<DictionaryDTO> queryAll() { | |||||
List<MetaDictionary> dicts = this.lambdaQuery() | |||||
.ne(MetaDictionary::getId, -1) | |||||
.list(); | |||||
return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); | |||||
} | |||||
@Override | |||||
public List<DictionaryDTO> queryByDictType(String dictType) { | |||||
List<MetaDictionary> dicts = this.lambdaQuery() | |||||
.ne(MetaDictionary::getId, -1) | |||||
.eq(MetaDictionary::getDictionaryType, dictType) | |||||
.list(); | |||||
return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); | |||||
} | |||||
@Override | |||||
public List<DictionaryDTO> queryByDictTypes(Collection<String> dictTypes) { | |||||
List<MetaDictionary> dicts = this.lambdaQuery() | |||||
.ne(MetaDictionary::getId, -1) | |||||
.in(MetaDictionary::getDictionaryType, dictTypes) | |||||
.list(); | |||||
return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); | |||||
} | } | ||||
} | } |
@@ -6,6 +6,7 @@ import com.hz.pm.api.meta.model.entity.MetaTag; | |||||
import com.hz.pm.api.meta.mapper.MetaTagMapper; | import com.hz.pm.api.meta.mapper.MetaTagMapper; | ||||
import com.hz.pm.api.meta.model.dto.TagDTO; | import com.hz.pm.api.meta.model.dto.TagDTO; | ||||
import com.hz.pm.api.meta.service.IMetaTagService; | import com.hz.pm.api.meta.service.IMetaTagService; | ||||
import com.ningdatech.basic.util.CollUtils; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -26,8 +27,17 @@ public class MetaTagServiceImpl extends ServiceImpl<MetaTagMapper, MetaTag> impl | |||||
@Override | @Override | ||||
public List<TagDTO> queryAll() { | public List<TagDTO> queryAll() { | ||||
List<MetaTag> allTags = this.lambdaQuery().ne(MetaTag::getId, -1).list(); | List<MetaTag> allTags = this.lambdaQuery().ne(MetaTag::getId, -1).list(); | ||||
List<TagDTO> allTagDTOList = allTags.stream().map(MetaTagAssembler::toTagDTO).collect(Collectors.toList()); | |||||
return allTagDTOList; | |||||
return CollUtils.convert(allTags, MetaTagAssembler::toTagDTO); | |||||
} | } | ||||
@Override | |||||
public List<TagDTO> queryLeLevel(int level) { | |||||
List<MetaTag> allTags = this.lambdaQuery() | |||||
.ne(MetaTag::getId, -1) | |||||
.le(MetaTag::getTagLevel, level) | |||||
.list(); | |||||
return CollUtils.convert(allTags, MetaTagAssembler::toTagDTO); | |||||
} | |||||
} | } |
@@ -13,9 +13,8 @@ import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | |||||
import com.hz.pm.api.expert.service.IExpertUserFullInfoService; | import com.hz.pm.api.expert.service.IExpertUserFullInfoService; | ||||
import com.hz.pm.api.external.MhUserOrgClient; | import com.hz.pm.api.external.MhUserOrgClient; | ||||
import com.hz.pm.api.external.model.dto.*; | import com.hz.pm.api.external.model.dto.*; | ||||
import com.hz.pm.api.meta.constant.ExpertDictTypeEnum; | |||||
import com.hz.pm.api.meta.helper.DictionaryCache; | import com.hz.pm.api.meta.helper.DictionaryCache; | ||||
import com.hz.pm.api.meta.model.dto.DictDTO; | |||||
import com.hz.pm.api.meta.model.dto.DictionaryDTO; | |||||
import com.hz.pm.api.meta.model.entity.ExpertDictionary; | import com.hz.pm.api.meta.model.entity.ExpertDictionary; | ||||
import com.hz.pm.api.meta.service.IExpertDictionaryService; | import com.hz.pm.api.meta.service.IExpertDictionaryService; | ||||
import com.hz.pm.api.user.constant.UserAvailableEnum; | import com.hz.pm.api.user.constant.UserAvailableEnum; | ||||
@@ -27,13 +26,10 @@ import com.hz.pm.api.user.task.SyncMhUserProperties; | |||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.collections4.SetUtils; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import java.time.LocalDate; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.time.format.DateTimeFormatter; | |||||
import java.util.*; | import java.util.*; | ||||
import static com.hz.pm.api.meta.constant.ExpertDictTypeEnum.*; | import static com.hz.pm.api.meta.constant.ExpertDictTypeEnum.*; | ||||
@@ -203,15 +199,15 @@ public class SyncMhUserOrgManage { | |||||
expertUserFullInfoService.saveOrUpdate(eui); | expertUserFullInfoService.saveOrUpdate(eui); | ||||
String expertLevel = expert.getExpertLevel(); | String expertLevel = expert.getExpertLevel(); | ||||
List<ExpertDictionary> dicts = new ArrayList<>(); | List<ExpertDictionary> dicts = new ArrayList<>(); | ||||
Optional<DictDTO> levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); | |||||
Optional<DictionaryDTO> levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); | |||||
levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | ||||
String grade = expert.getGrade(); | String grade = expert.getGrade(); | ||||
Optional<DictDTO> gradeDict = dictionaryCache.getByDictTypeAndName(EXPERT_LIBRARY.getKey(), grade); | |||||
Optional<DictionaryDTO> gradeDict = dictionaryCache.getByDictTypeAndName(EXPERT_LIBRARY.getKey(), grade); | |||||
gradeDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | gradeDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | ||||
String area = expert.getArea(); | String area = expert.getArea(); | ||||
Optional<DictDTO> areaDict = dictionaryCache.getByDictTypeAndName(EXPERT_AREA.getKey(), area); | |||||
Optional<DictionaryDTO> areaDict = dictionaryCache.getByDictTypeAndName(EXPERT_AREA.getKey(), area); | |||||
areaDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | areaDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | ||||
String skills = expert.getSkills(); | String skills = expert.getSkills(); | ||||
@@ -280,11 +276,11 @@ public class SyncMhUserOrgManage { | |||||
List<ExpertDictionary> dicts = new ArrayList<>(); | List<ExpertDictionary> dicts = new ArrayList<>(); | ||||
// 专家级别 | // 专家级别 | ||||
String expertLevel = expert.getExpertLevel(); | String expertLevel = expert.getExpertLevel(); | ||||
Optional<DictDTO> levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); | |||||
Optional<DictionaryDTO> levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); | |||||
levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | ||||
// 专家来源 | // 专家来源 | ||||
String expertCate = expert.getExpertCate(); | String expertCate = expert.getExpertCate(); | ||||
Optional<DictDTO> sourceDict = dictionaryCache.getByDictTypeAndName(EXPERT_SOURCE.getKey(), expertCate); | |||||
Optional<DictionaryDTO> sourceDict = dictionaryCache.getByDictTypeAndName(EXPERT_SOURCE.getKey(), expertCate); | |||||
sourceDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | sourceDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); | ||||
String skills = expert.getSkills(); | String skills = expert.getSkills(); | ||||
@@ -302,10 +298,10 @@ public class SyncMhUserOrgManage { | |||||
private List<ExpertDictionary> getSkillsDicts(String skills, Long userId) { | private List<ExpertDictionary> getSkillsDicts(String skills, Long userId) { | ||||
List<ExpertDictionary> dicts = new ArrayList<>(); | List<ExpertDictionary> dicts = new ArrayList<>(); | ||||
List<DictDTO> skillsDict = dictionaryCache.listDictByDictType(EXPERT_SPECIALTY.getKey()); | |||||
List<DictionaryDTO> skillsDict = dictionaryCache.listDictByDictType(EXPERT_SPECIALTY.getKey()); | |||||
if (StrUtil.isNotBlank(skills)) { | if (StrUtil.isNotBlank(skills)) { | ||||
for (String skill : CollUtil.newHashSet(skills.split("[,、,]"))) { | for (String skill : CollUtil.newHashSet(skills.split("[,、,]"))) { | ||||
Optional<DictDTO> first = skillsDict.stream() | |||||
Optional<DictionaryDTO> first = skillsDict.stream() | |||||
.filter(dict -> dict.getName().equals(skill.trim())) | .filter(dict -> dict.getName().equals(skill.trim())) | ||||
.findFirst(); | .findFirst(); | ||||
first.ifPresent(dict -> dicts.add(getExpertDictionary(userId, dict))); | first.ifPresent(dict -> dicts.add(getExpertDictionary(userId, dict))); | ||||
@@ -314,7 +310,7 @@ public class SyncMhUserOrgManage { | |||||
return dicts; | return dicts; | ||||
} | } | ||||
private ExpertDictionary getExpertDictionary(Long userId, DictDTO dict) { | |||||
private ExpertDictionary getExpertDictionary(Long userId, DictionaryDTO dict) { | |||||
ExpertDictionary dictionary = new ExpertDictionary(); | ExpertDictionary dictionary = new ExpertDictionary(); | ||||
dictionary.setUserId(userId); | dictionary.setUserId(userId); | ||||
dictionary.setDictionaryCode(dict.getDictionaryCode()); | dictionary.setDictionaryCode(dict.getDictionaryCode()); | ||||