Browse Source

标签、字典缓存优化

tags/24080901
WendyYang 10 months ago
parent
commit
c3e9520ee3
22 changed files with 218 additions and 135 deletions
  1. +8
    -8
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java
  2. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java
  3. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java
  4. +2
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java
  5. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java
  6. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java
  7. +2
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java
  8. +2
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java
  9. +4
    -4
      hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java
  10. +6
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java
  11. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java
  12. +40
    -20
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java
  13. +59
    -32
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java
  14. +7
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java
  15. +16
    -13
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java
  16. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java
  17. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java
  18. +6
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java
  19. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java
  20. +27
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java
  21. +12
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java
  22. +9
    -13
      hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java

+ 8
- 8
hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java View File

@@ -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<DictDTO> politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey());
List<DictionaryDTO> 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<DictDTO> eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey());
List<DictionaryDTO> 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<DictDTO> degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey());
List<DictionaryDTO> 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<DictDTO> administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey());
List<DictionaryDTO> 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<DictDTO> companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey());
List<DictionaryDTO> 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<String, TagDTO> tagMap = tagCache.getNameTagDtoMap();
Map<String, TagDTO> 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<DictDTO> titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey());
List<DictionaryDTO> titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey());
if (!titleLevelDicts.isEmpty()) {
titleLevelDicts.stream()
.filter(dict -> dict.getName().equals(titleLevel))


+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertAdminExpertManageAssembler.java View File

@@ -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<DictDTO> dict = dictionaryCache.getByCode(r.getDictionaryCode());
Optional<DictionaryDTO> dict = dictionaryCache.getByCode(r.getDictionaryCode());
dict.ifPresent(dictDTO -> r.setDictionaryName(dictDTO.getName()));
}).collect(Collectors.toList());
}


+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/expert/assembler/ExpertUserInfoAssembler.java View File

@@ -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<DictDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode());
Optional<DictionaryDTO> dictionaryDTO = dictionaryCache.getByCode(r.getDictionaryCode());
dictionaryDTO.ifPresent(dictDTO -> dictionaryFieldInfo.setDictionaryName(dictDTO.getName()));
return dictionaryFieldInfo;
}).collect(Collectors.groupingBy(DictionaryFieldInfo::getDictionaryFieldName));


+ 2
- 3
hz-pm-api/src/main/java/com/hz/pm/api/expert/helper/ExpertManageHelper.java View File

@@ -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<DictDTO> dict = dictionaryCache.getByCode(dictCode);
Optional<DictionaryDTO> dict = dictionaryCache.getByCode(dictCode);
if (!dict.isPresent()) {
String dictFieldName = dictField.getDictionaryFieldName();
throw BizException.wrap("字典数据无效:%s=%s", dictFieldName, dictCode);


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertManage.java View File

@@ -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<String, List<DictionaryVO>> listExpertDictionary(Long userId) {
List<ExpertDictionary> dicts = expertDictionaryService.listByUserId(Collections.singleton(userId));
return dicts.stream().map(w -> {
Optional<DictDTO> dict = dictionaryCache.getByCode(w.getDictionaryCode());
Optional<DictionaryDTO> 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;


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/expert/manage/ExpertMetaApplyManage.java View File

@@ -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<ExpertDictionary> titleLevelDictionaryList = titleLevelDictMap.get(userId);
if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) {
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.setDictionaryCode(r.getDictionaryCode());
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField());
@@ -409,7 +409,7 @@ public class ExpertMetaApplyManage {
List<ExpertDictionary> expertTypeDictionaryList = expertTypeDictMap.get(userId);
if (CollectionUtils.isNotEmpty(titleLevelDictionaryList)) {
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.setDictionaryCode(r.getDictionaryCode());
dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField());


+ 2
- 0
hz-pm-api/src/main/java/com/hz/pm/api/external/controller/MhSyncController.java View File

@@ -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")


+ 2
- 3
hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingManageHelper.java View File

@@ -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<DictDTO> dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode());
Optional<DictionaryDTO> dictInfo = dictionaryCache.getByCode(first.get().getDictionaryCode());
dictInfo.ifPresent(d -> basicInfoVo.setJobLevel(d.getName()));
} else {
basicInfoVo.setJobLevel("");


+ 4
- 4
hz-pm-api/src/main/java/com/hz/pm/api/meta/assembler/MetaDictionaryAssembler.java View File

@@ -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());


+ 6
- 6
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/DictionaryCache.java View File

@@ -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<DictDTO> listDictByDictType(DictTypeEnum dictionaryType);
List<DictionaryDTO> listDictByDictType(DictTypeEnum dictionaryType);

/**
* 根据字典类型 获取 字典列表
@@ -28,7 +28,7 @@ public interface DictionaryCache {
* @param dictType \
* @return \
*/
List<DictDTO> listDictByDictType(String dictType);
List<DictionaryDTO> 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<DictDTO> getByCode(String dictCode);
Optional<DictionaryDTO> getByCode(String dictCode);

Optional<DictDTO> getByDictTypeAndName(String dictType, String name);
Optional<DictionaryDTO> getByDictTypeAndName(String dictType, String name);

}

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/TagCache.java View File

@@ -34,7 +34,7 @@ public interface TagCache {
*
* @return
*/
Map<String, TagDTO> getNameTagDtoMap();
Map<String, TagDTO> getNameTagMap();

/**
* 获取所有子节点包含当前节点


+ 40
- 20
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractDictionaryCache.java View File

@@ -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<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
public void afterPropertiesSet() {
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);
}

}

+ 59
- 32
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/basic/AbstractTagsCache.java View File

@@ -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<String, List<TagTreeDTO>> tagsCache;

protected Map<String, TagDTO> tagDtoMap;
protected Map<String, TagDTO> tagCacheMap = new ConcurrentHashMap<>();

@Override
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<>();
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<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) {


+ 7
- 7
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/DictionaryCacheImpl.java View File

@@ -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<DictDTO> listDictByDictType(DictTypeEnum dictionaryType) {
public List<DictionaryDTO> listDictByDictType(DictTypeEnum dictionaryType) {
return dictCache.get(dictionaryType.getKey());
}

@Override
public List<DictDTO> listDictByDictType(String dictType) {
public List<DictionaryDTO> 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<DictDTO> getByCode(String dictionaryCode) {
public Optional<DictionaryDTO> getByCode(String dictionaryCode) {
return Optional.ofNullable(dictionaryMap.get(dictionaryCode));
}

@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()) {
return Optional.empty();
}


+ 16
- 13
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java View File

@@ -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<TagTreeDTO> tagTreeDtos = tagsCache.get(level + "");
for (TagTreeDTO tagTreeDTO : tagTreeDtos) {
List<TagTreeDTO> 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<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));
assert allTree != null;
List<TagTreeDTO> 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);


+ 3
- 3
hz-pm-api/src/main/java/com/hz/pm/api/meta/manage/MetaManage.java View File

@@ -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<DictDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType);
List<DictionaryDTO> 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<DictDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType);
List<DictionaryDTO> dictionaryList = dictionaryCache.listDictByDictType(dictionaryType);
List<ResDictionaryVO> resDictionaryVOList = dictionaryList.stream()
.map(MetaDictionaryAssembler::toDictionaryVO).collect(Collectors.toList());
resDictionaryListVO.setDictionaryList(resDictionaryVOList);


hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictDTO.java → hz-pm-api/src/main/java/com/hz/pm/api/meta/model/dto/DictionaryDTO.java View File

@@ -7,7 +7,7 @@ import lombok.Data;
* @date 2022/7/22 上午10:49
*/
@Data
public class DictDTO {
public class DictionaryDTO {

private String dictionaryType;


+ 6
- 2
hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaDictionaryService.java View File

@@ -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<MetaDictionary> {

List<DictDTO> queryAll();
List<DictionaryDTO> queryAll();

List<DictionaryDTO> queryByDictType(String dictType);
List<DictionaryDTO> queryByDictTypes(Collection<String> dictTypes);


}

+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/meta/service/IMetaTagService.java View File

@@ -8,7 +8,7 @@ import java.util.List;

/**
* <p>
* 服务类
* 服务类
* </p>
*
* @author Liuxinxin
@@ -18,4 +18,6 @@ public interface IMetaTagService extends IService<MetaTag> {

List<TagDTO> queryAll();

List<TagDTO> queryLeLevel(int level);

}

+ 27
- 6
hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaDictionaryServiceImpl.java View File

@@ -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;

/**
* <p>
* 服务实现类
* 字典服务实现类
* </p>
*
* @author Liuxinxin
@@ -23,10 +25,29 @@ import java.util.stream.Collectors;
public class MetaDictionaryServiceImpl extends ServiceImpl<MetaDictionaryMapper, MetaDictionary> implements IMetaDictionaryService {

@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);
}

}

+ 12
- 2
hz-pm-api/src/main/java/com/hz/pm/api/meta/service/impl/MetaTagServiceImpl.java View File

@@ -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<MetaTagMapper, MetaTag> impl
@Override
public List<TagDTO> queryAll() {
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);
}


}

+ 9
- 13
hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java View File

@@ -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<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)));

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)));

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)));

String skills = expert.getSkills();
@@ -280,11 +276,11 @@ public class SyncMhUserOrgManage {
List<ExpertDictionary> dicts = new ArrayList<>();
// 专家级别
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)));
// 专家来源
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)));

String skills = expert.getSkills();
@@ -302,10 +298,10 @@ public class SyncMhUserOrgManage {

private List<ExpertDictionary> getSkillsDicts(String skills, Long userId) {
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)) {
for (String skill : CollUtil.newHashSet(skills.split("[,、,]"))) {
Optional<DictDTO> first = skillsDict.stream()
Optional<DictionaryDTO> 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());


Loading…
Cancel
Save