From c3e9520ee317c3984d3d525f8cdd1a755f9379d3 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 26 Dec 2023 20:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E3=80=81=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hz/pm/api/common/util/ExpertRegisterUtil.java | 16 ++-- .../ExpertAdminExpertManageAssembler.java | 4 +- .../expert/assembler/ExpertUserInfoAssembler.java | 4 +- .../pm/api/expert/helper/ExpertManageHelper.java | 5 +- .../com/hz/pm/api/expert/manage/ExpertManage.java | 6 +- .../api/expert/manage/ExpertMetaApplyManage.java | 6 +- .../api/external/controller/MhSyncController.java | 2 + .../pm/api/meeting/helper/MeetingManageHelper.java | 5 +- .../meta/assembler/MetaDictionaryAssembler.java | 8 +- .../com/hz/pm/api/meta/helper/DictionaryCache.java | 12 +-- .../java/com/hz/pm/api/meta/helper/TagCache.java | 2 +- .../meta/helper/basic/AbstractDictionaryCache.java | 60 +++++++++----- .../api/meta/helper/basic/AbstractTagsCache.java | 91 ++++++++++++++-------- .../api/meta/helper/impl/DictionaryCacheImpl.java | 14 ++-- .../hz/pm/api/meta/helper/impl/TagsCacheImpl.java | 29 +++---- .../java/com/hz/pm/api/meta/manage/MetaManage.java | 6 +- .../java/com/hz/pm/api/meta/model/dto/DictDTO.java | 40 ---------- .../hz/pm/api/meta/model/dto/DictionaryDTO.java | 40 ++++++++++ .../api/meta/service/IMetaDictionaryService.java | 8 +- .../hz/pm/api/meta/service/IMetaTagService.java | 4 +- .../service/impl/MetaDictionaryServiceImpl.java | 33 ++++++-- .../api/meta/service/impl/MetaTagServiceImpl.java | 14 +++- .../hz/pm/api/user/manage/SyncMhUserOrgManage.java | 22 +++--- 23 files changed, 257 insertions(+), 174 deletions(-) delete mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictDTO.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java index c609bc4..3f113b1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java @@ -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.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.organization.model.entity.DingOrganization; import com.hz.pm.api.organization.service.IDingOrganizationService; @@ -62,7 +62,7 @@ public class ExpertRegisterUtil { // 政治面貌 basic.setPolitical(new ArrayList<>()); String political = MapUtil.getStr(w, "政治面貌"); - List politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey()); + List politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey()); if (!politicalDicts.isEmpty()) { politicalDicts.stream() .filter(dict -> dict.getName().equals(political)) @@ -82,7 +82,7 @@ public class ExpertRegisterUtil { eduInfo.setDegree(new ArrayList<>()); // 学历 String eduStr = MapUtil.getStr(w, "学历"); - List eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey()); + List eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey()); if (!eduDicts.isEmpty()) { eduDicts.stream() .filter(dict -> dict.getName().equals(eduStr)) @@ -96,7 +96,7 @@ public class ExpertRegisterUtil { } // 学位 String degreeStr = MapUtil.getStr(w, "学位"); - List degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey()); + List degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey()); if (!degreeDicts.isEmpty()) { degreeDicts.stream() .filter(dict -> dict.getName().equals(degreeStr)) @@ -139,7 +139,7 @@ public class ExpertRegisterUtil { jobInfo.setAdministrativeDuties(MapUtil.getStr(w, "行政职务")); jobInfo.setAdministrativeRank(new ArrayList<>()); String administrativeRankStr = MapUtil.getStr(w, "行政职级"); - List administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey()); + List administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey()); if (!administrativeRankDicts.isEmpty()) { administrativeRankDicts.stream() .filter(dict -> dict.getName().equals(administrativeRankStr)) @@ -153,7 +153,7 @@ public class ExpertRegisterUtil { } jobInfo.setCompanyAttribute(new ArrayList<>()); String companyTypeStr = MapUtil.getStr(w, "*单位类型"); - List companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey()); + List companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey()); if (!companyTypeDicts.isEmpty()) { companyTypeDicts.stream() .filter(dict -> dict.getName().equals(companyTypeStr)) @@ -170,7 +170,7 @@ public class ExpertRegisterUtil { professionalInfo.setAwards("暂无"); professionalInfo.setIndustrySector(new ArrayList<>()); professionalInfo.setOther(new ArrayList<>()); - Map tagMap = tagCache.getNameTagDtoMap(); + Map tagMap = tagCache.getNameTagMap(); String otherTagStr = MapUtil.getStr(w, "其他标签"); if (StrUtils.isNotBlank(otherTagStr)) { for (String othTag : otherTagStr.split(SEPARATOR)) { @@ -240,7 +240,7 @@ public class ExpertRegisterUtil { } professionalInfo.setTitleLevel(new ArrayList<>()); String titleLevel = MapUtil.getStr(w, "*职称级别"); - List titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey()); + List titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey()); if (!titleLevelDicts.isEmpty()) { titleLevelDicts.stream() .filter(dict -> dict.getName().equals(titleLevel)) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java index 872ea48..3ce707b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java @@ -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.impl.TagsCacheImpl; 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.sys.model.dto.RegionDTO; import lombok.RequiredArgsConstructor; @@ -105,7 +105,7 @@ public class ExpertAdminExpertManageAssembler { return Collections.emptyList(); } return collect.stream().peek(r -> { - Optional dict = dictionaryCache.getByCode(r.getDictionaryCode()); + Optional dict = dictionaryCache.getByCode(r.getDictionaryCode()); dict.ifPresent(dictDTO -> r.setDictionaryName(dictDTO.getName())); }).collect(Collectors.toList()); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java index 646b2a4..546ccc1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java @@ -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.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.entity.ExpertDictionary; import com.hz.pm.api.meta.model.entity.ExpertTag; @@ -123,7 +123,7 @@ public class ExpertUserInfoAssembler { DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); - Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); + Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); dictionaryDTO.ifPresent(dictDTO -> dictionaryFieldInfo.setDictionaryName(dictDTO.getName())); return dictionaryFieldInfo; }).collect(Collectors.groupingBy(DictionaryFieldInfo::getDictionaryFieldName)); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java index 4b68048..d6a7118 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java @@ -4,8 +4,7 @@ import cn.hutool.core.collection.CollUtil; import com.hz.pm.api.expert.model.*; import com.hz.pm.api.meta.helper.DictionaryCache; 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.ningdatech.basic.exception.BizException; import lombok.RequiredArgsConstructor; @@ -82,7 +81,7 @@ public class ExpertManageHelper { for (DictionaryFieldInfo dictField : dictFieldList) { String dictCode = dictField.getDictionaryCode(); - Optional dict = dictionaryCache.getByCode(dictCode); + Optional dict = dictionaryCache.getByCode(dictCode); if (!dict.isPresent()) { String dictFieldName = dictField.getDictionaryFieldName(); throw BizException.wrap("字典数据无效:%s=%s", dictFieldName, dictCode); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java index aee709b..bdcfb75 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java @@ -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.meta.constant.ExpertDictTypeEnum; 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.service.IExpertDictionaryService; import com.hz.pm.api.sms.constant.VerificationCodeType; @@ -87,9 +87,9 @@ public class ExpertManage { private Map> listExpertDictionary(Long userId) { List dicts = expertDictionaryService.listByUserId(Collections.singleton(userId)); return dicts.stream().map(w -> { - Optional dict = dictionaryCache.getByCode(w.getDictionaryCode()); + Optional dict = dictionaryCache.getByCode(w.getDictionaryCode()); if (dict.isPresent()) { - DictDTO dto = dict.get(); + DictionaryDTO dto = dict.get(); return new DictionaryVO(dto.getDictionaryCode(), dto.getName(), dto.getDictionaryType()); } else { return null; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java index 31c7e41..cb06e94 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java @@ -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.model.ExpertRegionInfo; 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.service.IExpertDictionaryService; import com.hz.pm.api.sys.model.dto.RegionDTO; @@ -396,7 +396,7 @@ public class ExpertMetaApplyManage { List titleLevelDictionaryList = titleLevelDictMap.get(userId); if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { expertApplyMetaVO.setTitleLevel(titleLevelDictionaryList.stream().map(r -> { - Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); + Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); @@ -409,7 +409,7 @@ public class ExpertMetaApplyManage { List expertTypeDictionaryList = expertTypeDictMap.get(userId); if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) { expertApplyMetaVO.setExpertType(expertTypeDictionaryList.stream().map(r -> { - Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); + Optional dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode()); DictionaryFieldInfo dictionaryFieldInfo = new DictionaryFieldInfo(); dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode()); dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java index cdec6f6..07eb735 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java @@ -2,6 +2,7 @@ package com.hz.pm.api.external.controller; import com.hz.pm.api.external.MhUserOrgClient; import com.hz.pm.api.user.manage.SyncMhUserOrgManage; +import io.swagger.annotations.Api; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; @@ -19,6 +20,7 @@ import java.time.LocalDateTime; * @author WendyYang * @since 09:56 2023/12/22 */ +@Api(hidden = true) @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/mh/sync") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java index e2ce9fe..242bcf0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java @@ -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.util.BizUtils; 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.model.dto.ExpertDictionaryDTO; 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.meta.constant.ExpertDictTypeEnum; 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.ningdatech.basic.exception.BizException; import com.ningdatech.basic.util.CollUtils; @@ -171,7 +170,7 @@ public class MeetingManageHelper { .filter(dict -> dict.getExpertInfoField().equals(ExpertDictTypeEnum.TITLE_LEVEL.getKey())) .findFirst(); if (first.isPresent()) { - Optional dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode()); + Optional dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode()); dictInfo.ifPresent(d -> basicInfoVo.setJobLevel(d.getName())); } else { basicInfoVo.setJobLevel(""); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java index 5fb9554..6243da7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java @@ -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.dto.DictDTO; +import com.hz.pm.api.meta.model.dto.DictionaryDTO; 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 static DictDTO toDictionaryDTO(MetaDictionary dictionaryManage) { - DictDTO dictionaryDTO = new DictDTO(); + public static DictionaryDTO toDictionaryDTO(MetaDictionary dictionaryManage) { + DictionaryDTO dictionaryDTO = new DictionaryDTO(); dictionaryDTO.setDescribe(dictionaryManage.getDictionaryDescribe()); dictionaryDTO.setDictionaryCode(dictionaryManage.getDictionaryCode()); dictionaryDTO.setDictionaryType(dictionaryManage.getDictionaryType()); @@ -23,7 +23,7 @@ public class MetaDictionaryAssembler { return dictionaryDTO; } - public static ResDictionaryVO toDictionaryVO(DictDTO dictionaryDTO) { + public static ResDictionaryVO toDictionaryVO(DictionaryDTO dictionaryDTO) { ResDictionaryVO resDictionaryVO = new ResDictionaryVO(); resDictionaryVO.setDescribe(dictionaryDTO.getDescribe()); resDictionaryVO.setDictionaryCode(dictionaryDTO.getDictionaryCode()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java index 0ae6557..4907295 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java @@ -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.model.dto.DictDTO; +import com.hz.pm.api.meta.model.dto.DictionaryDTO; import java.util.List; import java.util.Optional; @@ -20,7 +20,7 @@ public interface DictionaryCache { * @param dictionaryType \ * @return \ */ - List listDictByDictType(DictTypeEnum dictionaryType); + List listDictByDictType(DictTypeEnum dictionaryType); /** * 根据字典类型 获取 字典列表 @@ -28,7 +28,7 @@ public interface DictionaryCache { * @param dictType \ * @return \ */ - List listDictByDictType(String dictType); + List listDictByDictType(String dictType); /** * 根据字典类型、字典编码 获取 字典实体 @@ -37,7 +37,7 @@ public interface DictionaryCache { * @param code \ * @return \ */ - DictDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code); + DictionaryDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code); /** * 根据字典编码 获取 字典实体 @@ -45,8 +45,8 @@ public interface DictionaryCache { * @param dictCode \ * @return \ */ - Optional getByCode(String dictCode); + Optional getByCode(String dictCode); - Optional getByDictTypeAndName(String dictType, String name); + Optional getByDictTypeAndName(String dictType, String name); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java index 7512ec2..daa0779 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java @@ -34,7 +34,7 @@ public interface TagCache { * * @return */ - Map getNameTagDtoMap(); + Map getNameTagMap(); /** * 获取所有子节点包含当前节点 diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java index 26ff827..b982854 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java @@ -1,55 +1,75 @@ 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.LoadingCache; import com.hz.pm.api.meta.constant.DictTypeEnum; 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.ningdatech.basic.util.CollUtils; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.checkerframework.checker.nullness.qual.NonNull; import org.springframework.beans.factory.InitializingBean; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * @author liuxinxin * @date 2022/12/22 上午11:03 */ +@Slf4j @RequiredArgsConstructor public abstract class AbstractDictionaryCache implements InitializingBean, DictionaryCache { private final IMetaDictionaryService metaDictionaryService; - protected Map dictionaryMap = new ConcurrentHashMap<>(); - protected LoadingCache> dictCache; + protected Map dictionaryMap = new ConcurrentHashMap<>(); + protected LoadingCache> dictCache; @Override public void afterPropertiesSet() { dictCache = Caffeine.newBuilder() - .refreshAfterWrite(30, TimeUnit.MINUTES) - .build(key -> { - List dicts = metaDictionaryService.queryAll(); - dictionaryMap = buildCateMap(dicts); - Map> dictMapByType = CollUtils.group(dicts, DictDTO::getDictionaryType); - return dictMapByType.get(key); - }); - warmUp(); - } + .refreshAfterWrite(7, TimeUnit.DAYS) + .build(new CacheLoader>() { + @Override + public List load(@NonNull String key) { + log.info("刷新字典数据:{}", key); + List dicts = metaDictionaryService.queryByDictType(key); + dicts.forEach(dict -> dictionaryMap.put(dict.getDictionaryCode(), dict)); + return dicts; + } - private Map buildCateMap(List dictionaryDTOList) { - Map dictionaryDtoMap = new ConcurrentHashMap<>(128); - dictionaryDTOList.forEach(dictionaryDTO -> dictionaryDtoMap.put(dictionaryDTO.getDictionaryCode(), dictionaryDTO)); - return dictionaryDtoMap; + @Override + public @NonNull Map> loadAll(@NonNull Iterable keys) { + log.info("刷新字典数据[loadAll]:数量 -> {}", IterUtil.size(keys)); + if (CollUtil.isEmpty(keys)) { + return Collections.emptyMap(); + } + List keysList = IterUtil.toList(keys).stream().map(String::toString).collect(Collectors.toList()); + List 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 dictTypes = Arrays.stream(DictTypeEnum.values()) + .map(DictTypeEnum::getKey) + .collect(Collectors.toList()); + dictCache.getAll(dictTypes); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java index 469a93f..a594939 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java @@ -1,5 +1,9 @@ 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.LoadingCache; 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.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.checkerframework.checker.nullness.qual.NonNull; import org.springframework.beans.factory.InitializingBean; import java.util.*; @@ -25,60 +30,82 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public abstract class AbstractTagsCache implements InitializingBean, TagCache { + protected static final int MAX_LEVEL = 4; private final IMetaTagService metaTagService; protected LoadingCache> tagsCache; - protected Map tagDtoMap; + protected Map tagCacheMap = new ConcurrentHashMap<>(); @Override public void afterPropertiesSet() { - tagsCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) - .refreshAfterWrite(5, TimeUnit.MINUTES) - .build(key -> { - // 查询全部 - List tagDTOList = metaTagService.queryAll(); - if (tagDTOList.isEmpty()) { - log.warn("当前层级对应树不存在:{}", key); - return Collections.emptyList(); + tagsCache = Caffeine.newBuilder() + .refreshAfterWrite(7, TimeUnit.DAYS) + .build(new CacheLoader>() { + + @Override + public List load(@NonNull String key) { + log.info("刷新当前标签树:{}", key); + // 查询全部 + List tags = metaTagService.queryLeLevel(Integer.parseInt(key)); + putToTagMap(tags); + return toTree(MetaTagAssembler.toTagTreeDTOList(tags)); } - tagDtoMap = buildCateMap(tagDTOList); - List tagInLevel = tagDTOList.stream().filter(tagDto -> { - // 只过滤出小于等于level的tag - if (Objects.isNull(tagDto.getTagLevel())) { - return false; + + @Override + public @NonNull Map> loadAll(@NonNull Iterable keys) { + if (CollUtil.isEmpty(keys)) { + return Collections.emptyMap(); + } + Optional 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 treeDtos = MetaTagAssembler.toTagTreeDTOList(tagInLevel); - return toTreeStructure(treeDtos); + Integer maxLevelVal = maxLevel.get(); + log.info("刷新当前标签树:最大层级为 -> {}", maxLevelVal); + List allTags = metaTagService.queryLeLevel(maxLevelVal); + putToTagMap(allTags); + Map> mapByKeys = new HashMap<>(); + keys.forEach(key -> { + int currLevel = Integer.parseInt(key); + List 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 buildCateMap(List tagDTOList) { - Map tagDtoMapTemp = new ConcurrentHashMap<>(1024); - tagDTOList.forEach(tagDTO -> tagDtoMapTemp.put(tagDTO.getTagCode(), tagDTO)); - return tagDtoMapTemp; + private void putToTagMap(List tagDTOList) { + tagDTOList.forEach(tagDTO -> tagCacheMap.put(tagDTO.getTagCode(), tagDTO)); } - private List toTreeStructure(List rootList) { + private List toTree(List tagTreeList) { List 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; } - public void warmUp() { - for (int level = 1; level <= MAX_LEVEL; level++) { - tagsCache.get(level + ""); - } + public void initAllTags() { + List allLevels = Arrays.stream(NumberUtil.range(1, MAX_LEVEL)) + .mapToObj(String::valueOf) + .collect(Collectors.toList()); + tagsCache.getAll(allLevels); } protected List getChildren(String tagCode, List list) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java index 68f4311..3bafdc7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java @@ -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.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 org.springframework.stereotype.Component; @@ -22,30 +22,30 @@ public class DictionaryCacheImpl extends AbstractDictionaryCache { } @Override - public List listDictByDictType(DictTypeEnum dictionaryType) { + public List listDictByDictType(DictTypeEnum dictionaryType) { return dictCache.get(dictionaryType.getKey()); } @Override - public List listDictByDictType(String dictType) { + public List listDictByDictType(String dictType) { return dictCache.get(dictType); } @Override - public DictDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code) { + public DictionaryDTO getDictionaryByDictionaryType(DictTypeEnum dictionaryType, String code) { return Objects.requireNonNull(dictCache.get(dictionaryType.getKey())) .stream().filter(w -> w.getDictionaryCode().equals(code)) .findFirst().orElse(null); } @Override - public Optional getByCode(String dictionaryCode) { + public Optional getByCode(String dictionaryCode) { return Optional.ofNullable(dictionaryMap.get(dictionaryCode)); } @Override - public Optional getByDictTypeAndName(String dictType, String name) { - List dicts = dictCache.get(dictType); + public Optional getByDictTypeAndName(String dictType, String name) { + List dicts = dictCache.get(dictType); if (dicts == null || dicts.isEmpty()) { return Optional.empty(); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java index 674c771..943968e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java @@ -1,17 +1,20 @@ package com.hz.pm.api.meta.helper.impl; 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.model.dto.TagDTO; 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 lombok.extern.slf4j.Slf4j; 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 @@ -28,8 +31,8 @@ public class TagsCacheImpl extends AbstractTagsCache { @Override public TagTreeDTO getTagTreeDTO(int level, String rootTagCode) { - List tagTreeDtos = tagsCache.get(level + ""); - for (TagTreeDTO tagTreeDTO : tagTreeDtos) { + List tagTrees = tagsCache.get(level + ""); + for (TagTreeDTO tagTreeDTO : tagTrees) { if (tagTreeDTO.getTagCode().equals(rootTagCode)) { return tagTreeDTO; } @@ -42,7 +45,7 @@ public class TagsCacheImpl extends AbstractTagsCache { if (StringUtils.isBlank(tagCode)) { return null; } - return tagDtoMap.get(tagCode); + return tagCacheMap.get(tagCode); } /** @@ -51,12 +54,12 @@ public class TagsCacheImpl extends AbstractTagsCache { * @return */ @Override - public Map getNameTagDtoMap() { - Map nameTagDtoMap = new HashMap<>(1024); - for (String key : tagDtoMap.keySet()) { - nameTagDtoMap.put(tagDtoMap.get(key).getTagName(), tagDtoMap.get(key)); + public Map getNameTagMap() { + Map 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 allTree = tagsCache.get(String.valueOf(MAX_LEVEL)); assert allTree != null; List children = getChildren(code, allTree); - TagDTO tagDTO = tagDtoMap.get(code); + TagDTO tagDTO = tagCacheMap.get(code); TagTreeDTO rootNode = BeanUtil.copyProperties(tagDTO, TagTreeDTO.class); rootNode.setChildren(children); return treeToList(rootNode); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java index 55dd286..950e6b6 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java @@ -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.helper.DictionaryCache; 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.entity.ExpertDictionary; import com.hz.pm.api.meta.model.entity.ExpertTag; @@ -59,7 +59,7 @@ public class MetaManage { for (String dictionaryType : dictionaryTypeList) { ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); resDictionaryListVO.setDictionaryName(dictionaryType); - List dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); + List dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); if (dictionaryList == null) { continue; } @@ -97,7 +97,7 @@ public class MetaManage { for (String dictionaryType : dictionaryTypeList) { ResDictionaryListVO resDictionaryListVO = new ResDictionaryListVO(); resDictionaryListVO.setDictionaryName(dictionaryType); - List dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); + List dictionaryList = dictionaryCache.listDictByDictType(dictionaryType); List resDictionaryVOList = dictionaryList.stream() .map(MetaDictionaryAssembler::toDictionaryVO).collect(Collectors.toList()); resDictionaryListVO.setDictionaryList(resDictionaryVOList); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictDTO.java deleted file mode 100644 index b8dbb6b..0000000 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.hz.pm.api.meta.model.dto; - -import lombok.Data; - -/** - * @author liuxinxin - * @date 2022/7/22 上午10:49 - */ -@Data -public class DictDTO { - - private String dictionaryType; - - /** - * 编码 随机数处理 - */ - private String dictionaryCode; - - /** - * 名称 - */ - private String name; - - /** - * 描述 - */ - private String describe; - - /** - * 排序 - */ - private Integer sortValue; - - /** - * 是否内置,内置不可删除 - */ - private String readonly; - -} - diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java new file mode 100644 index 0000000..07252a8 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java @@ -0,0 +1,40 @@ +package com.hz.pm.api.meta.model.dto; + +import lombok.Data; + +/** + * @author liuxinxin + * @date 2022/7/22 上午10:49 + */ +@Data +public class DictionaryDTO { + + private String dictionaryType; + + /** + * 编码 随机数处理 + */ + private String dictionaryCode; + + /** + * 名称 + */ + private String name; + + /** + * 描述 + */ + private String describe; + + /** + * 排序 + */ + private Integer sortValue; + + /** + * 是否内置,内置不可删除 + */ + private String readonly; + +} + diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java index 46051a2..f93e978 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java @@ -2,8 +2,9 @@ package com.hz.pm.api.meta.service; import com.hz.pm.api.meta.model.entity.MetaDictionary; 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; /** @@ -16,7 +17,10 @@ import java.util.List; */ public interface IMetaDictionaryService extends IService { - List queryAll(); + List queryAll(); + + List queryByDictType(String dictType); + List queryByDictTypes(Collection dictTypes); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java index 74eb54f..50fba80 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java @@ -8,7 +8,7 @@ import java.util.List; /** *

- * 服务类 + * 服务类 *

* * @author Liuxinxin @@ -18,4 +18,6 @@ public interface IMetaTagService extends IService { List queryAll(); + List queryLeLevel(int level); + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java index cb8103f..2f2ec85 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java @@ -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.service.IMetaDictionaryService; 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 java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** *

- * 服务实现类 + * 字典服务实现类 *

* * @author Liuxinxin @@ -23,10 +25,29 @@ import java.util.stream.Collectors; public class MetaDictionaryServiceImpl extends ServiceImpl implements IMetaDictionaryService { @Override - public List queryAll() { - List dictionaryList = this.lambdaQuery().ne(MetaDictionary::getId, -1).list(); - List dictionaryDTOList = dictionaryList.stream().map(MetaDictionaryAssembler::toDictionaryDTO).collect(Collectors.toList()); - return dictionaryDTOList; + public List queryAll() { + List dicts = this.lambdaQuery() + .ne(MetaDictionary::getId, -1) + .list(); + return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); + } + + @Override + public List queryByDictType(String dictType) { + List dicts = this.lambdaQuery() + .ne(MetaDictionary::getId, -1) + .eq(MetaDictionary::getDictionaryType, dictType) + .list(); + return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); + } + + @Override + public List queryByDictTypes(Collection dictTypes) { + List dicts = this.lambdaQuery() + .ne(MetaDictionary::getId, -1) + .in(MetaDictionary::getDictionaryType, dictTypes) + .list(); + return CollUtils.convert(dicts, MetaDictionaryAssembler::toDictionaryDTO); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java index 70852c0..dfeb6a2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java @@ -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.model.dto.TagDTO; import com.hz.pm.api.meta.service.IMetaTagService; +import com.ningdatech.basic.util.CollUtils; import org.springframework.stereotype.Service; import java.util.List; @@ -26,8 +27,17 @@ public class MetaTagServiceImpl extends ServiceImpl impl @Override public List queryAll() { List allTags = this.lambdaQuery().ne(MetaTag::getId, -1).list(); - List allTagDTOList = allTags.stream().map(MetaTagAssembler::toTagDTO).collect(Collectors.toList()); - return allTagDTOList; + return CollUtils.convert(allTags, MetaTagAssembler::toTagDTO); } + @Override + public List queryLeLevel(int level) { + List allTags = this.lambdaQuery() + .ne(MetaTag::getId, -1) + .le(MetaTag::getTagLevel, level) + .list(); + return CollUtils.convert(allTags, MetaTagAssembler::toTagDTO); + } + + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java index 06cccc9..cd0e937 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java @@ -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.external.MhUserOrgClient; 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.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.service.IExpertDictionaryService; 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 lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.SetUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import static com.hz.pm.api.meta.constant.ExpertDictTypeEnum.*; @@ -203,15 +199,15 @@ public class SyncMhUserOrgManage { expertUserFullInfoService.saveOrUpdate(eui); String expertLevel = expert.getExpertLevel(); List dicts = new ArrayList<>(); - Optional levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); + Optional levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); String grade = expert.getGrade(); - Optional gradeDict = dictionaryCache.getByDictTypeAndName(EXPERT_LIBRARY.getKey(), grade); + Optional gradeDict = dictionaryCache.getByDictTypeAndName(EXPERT_LIBRARY.getKey(), grade); gradeDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); String area = expert.getArea(); - Optional areaDict = dictionaryCache.getByDictTypeAndName(EXPERT_AREA.getKey(), area); + Optional areaDict = dictionaryCache.getByDictTypeAndName(EXPERT_AREA.getKey(), area); areaDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); String skills = expert.getSkills(); @@ -280,11 +276,11 @@ public class SyncMhUserOrgManage { List dicts = new ArrayList<>(); // 专家级别 String expertLevel = expert.getExpertLevel(); - Optional levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); + Optional levelDict = dictionaryCache.getByDictTypeAndName(EXPERT_LEVEL.getKey(), expertLevel); levelDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); // 专家来源 String expertCate = expert.getExpertCate(); - Optional sourceDict = dictionaryCache.getByDictTypeAndName(EXPERT_SOURCE.getKey(), expertCate); + Optional sourceDict = dictionaryCache.getByDictTypeAndName(EXPERT_SOURCE.getKey(), expertCate); sourceDict.ifPresent(dict -> dicts.add(getExpertDictionary(eui.getUserId(), dict))); String skills = expert.getSkills(); @@ -302,10 +298,10 @@ public class SyncMhUserOrgManage { private List getSkillsDicts(String skills, Long userId) { List dicts = new ArrayList<>(); - List skillsDict = dictionaryCache.listDictByDictType(EXPERT_SPECIALTY.getKey()); + List skillsDict = dictionaryCache.listDictByDictType(EXPERT_SPECIALTY.getKey()); if (StrUtil.isNotBlank(skills)) { for (String skill : CollUtil.newHashSet(skills.split("[,、,]"))) { - Optional first = skillsDict.stream() + Optional first = skillsDict.stream() .filter(dict -> dict.getName().equals(skill.trim())) .findFirst(); first.ifPresent(dict -> dicts.add(getExpertDictionary(userId, dict))); @@ -314,7 +310,7 @@ public class SyncMhUserOrgManage { return dicts; } - private ExpertDictionary getExpertDictionary(Long userId, DictDTO dict) { + private ExpertDictionary getExpertDictionary(Long userId, DictionaryDTO dict) { ExpertDictionary dictionary = new ExpertDictionary(); dictionary.setUserId(userId); dictionary.setDictionaryCode(dict.getDictionaryCode());