From fc27d8f770678fff12e913c59093adb06d8edfc9 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 22 Nov 2023 09:47:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=93=E5=AE=B6=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=B7=A5=E5=85=B7=E7=B1=BB=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=88=9B=E5=BB=BA=E4=B8=93=E5=AE=B6?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E6=A0=87=E7=AD=BE=E6=9C=AA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/helper/RegionCacheHelper.java | 8 ++++ .../common/helper/impl/RegionsCacheHelperImpl.java | 19 +++++++++ .../pmapi/common/util/ExpertRegisterUtil.java | 49 +++++++--------------- .../pmapi/expert/controller/ExpertController.java | 2 +- .../com/ningdatech/pmapi/region/RegionTest.java | 20 ++++++++- 5 files changed, 60 insertions(+), 38 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java index f9ee333..2519262 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java @@ -109,4 +109,12 @@ public interface RegionCacheHelper { */ String getUnionPath(String code, Integer level); + /** + * 根据区域名称获取区域信息(参数格式:浙江省-杭州市-滨江区) + * + * @param regionName 地区名称 + * @return \ + **/ + RegionDTO getByRegionName(String regionName); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java index 4bc4194..bf2a57c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java @@ -211,6 +211,25 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements return String.join("@@", unionPathStrList); } + @Override + public RegionDTO getByRegionName(String regionName) { + if (StrUtils.isBlank(regionName)) { + return null; + } + String[] regionArray = regionName.split("-"); + int length = regionArray.length; + return all().stream() + .filter(w -> { + boolean lastEq = w.getRegionLevel().equals(length) + && w.getRegionName().equals(regionArray[length - 1]); + if (lastEq && length > 1) { + RegionDTO parent = getByCodeAndLevel(w.getParentCode(), w.getRegionLevel() - 1); + return parent.getRegionName().equals(regionArray[length - 2]); + } + return false; + }).findFirst().orElse(null); + } + protected void buildUnionPathStrList(String code, Integer level, List unionPathStrList) { if (level <= 0 || super.getParentCodeRoot().equals(code)) { return; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java index 6e60ae9..e25587c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.common.util; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.json.JSONUtil; import cn.hutool.poi.excel.ExcelReader; @@ -25,7 +26,6 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Optional; /** *

@@ -60,7 +60,6 @@ public class ExpertRegisterUtil { basic.setName(MapUtil.getStr(w, "*姓名")); basic.setPhoneNo(MapUtil.getStr(w, "*手机")); basic.setGender("男".equals(MapUtil.getStr(w, "性别")) ? "1" : "0"); - String expertRegion = MapUtil.getStr(w, "*专家层级"); // 政治面貌 basic.setPolitical(new ArrayList<>()); String political = MapUtil.getStr(w, "政治面貌"); @@ -112,36 +111,18 @@ public class ExpertRegisterUtil { } request.setEduInfo(eduInfo); // 专家层级 - String lastRegionName = expertRegion.substring(expertRegion.lastIndexOf("-") + 1); - List regions = regionCacheHelper.all(); - Optional firstExpertRegion = regions.stream() - .filter(region -> region.getRegionLevel().equals(3) - && region.getRegionName().equals(lastRegionName)) - .findFirst(); - if (firstExpertRegion.isPresent()) { - RegionDTO dto = firstExpertRegion.get(); - ExpertRegionInfo regionInfo = new ExpertRegionInfo(); - regionInfo.setRegionCode(dto.getRegionCode()); - regionInfo.setRegionLevel(dto.getRegionLevel()); - regionInfo.setRegionName(dto.getRegionName()); - basic.setExpertRegionInfo(regionInfo); + String expertRegionStr = MapUtil.getStr(w, "*专家层级"); + RegionDTO expertRegion = regionCacheHelper.getByRegionName(expertRegionStr); + if (expertRegion != null) { + basic.setExpertRegionInfo(BeanUtil.copyProperties(expertRegion, ExpertRegionInfo.class)); } // 履职意向 - String intentionRegionStr = MapUtil.getStr(w, "*履职意向"); + String intentionRegions = MapUtil.getStr(w, "*履职意向"); basic.setExpertIntentionWorkRegions(new ArrayList<>()); - for (String intentionRegion : intentionRegionStr.split("\\n")) { - String[] split = intentionRegion.split("-"); - Optional first = regions.stream() - .filter(region -> region.getRegionName().equals(split[split.length - 1]) - && region.getRegionLevel().equals(split.length)) - .findFirst(); - if (first.isPresent()) { - RegionDTO dto = first.get(); - ExpertRegionInfo regionInfo = new ExpertRegionInfo(); - regionInfo.setRegionCode(dto.getRegionCode()); - regionInfo.setRegionLevel(dto.getRegionLevel()); - regionInfo.setRegionName(dto.getRegionName()); - basic.getExpertIntentionWorkRegions().add(regionInfo); + for (String intentionRegionStr : intentionRegions.split("\\n|,")) { + RegionDTO currRegion = regionCacheHelper.getByRegionName(intentionRegionStr); + if (currRegion != null) { + basic.getExpertIntentionWorkRegions().add(BeanUtil.copyProperties(currRegion, ExpertRegionInfo.class)); } } request.setBasicInfo(basic); @@ -222,12 +203,11 @@ public class ExpertRegisterUtil { String goodAtStr = MapUtil.getStr(w, "*擅长方向"); for (String othTag : goodAtStr.split(",")) { tagMap.entrySet().stream() - .filter(tag -> tag.getValue().getParentCode().equals(ExpertTagEnum.GOOD_AT.getKey()) - && tag.getValue().getTagName().equals(othTag)) + .filter(tag -> tag.getValue().getTagName().equals(othTag)) .forEach(tag -> { TagFieldInfo expertTag = new TagFieldInfo(); expertTag.setTagCode(tag.getValue().getTagCode()); - expertTag.setTagFieldName(tag.getValue().getParentCode()); + expertTag.setTagFieldName(ExpertTagEnum.GOOD_AT.getKey()); expertTag.setTagName(tag.getValue().getTagName()); professionalInfo.getGoodAt().add(expertTag); }); @@ -236,12 +216,11 @@ public class ExpertRegisterUtil { String techStr = MapUtil.getStr(w, "技术专长"); for (String othTag : techStr.split(",|、")) { tagMap.entrySet().stream() - .filter(tag -> tag.getValue().getParentCode().equals(ExpertTagEnum.TECHNICAL_EXPERTISE.getKey()) - && tag.getValue().getTagName().equals(othTag)) + .filter(tag -> tag.getValue().getTagName().equals(othTag)) .forEach(tag -> { TagFieldInfo expertTag = new TagFieldInfo(); expertTag.setTagCode(tag.getValue().getTagCode()); - expertTag.setTagFieldName(tag.getValue().getParentCode()); + expertTag.setTagFieldName(ExpertTagEnum.TECHNICAL_EXPERTISE.getKey()); expertTag.setTagName(tag.getValue().getTagName()); professionalInfo.getTechnicalExpertise().add(expertTag); }); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java index 0c43225..39ce8eb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java @@ -68,7 +68,7 @@ public class ExpertController { @PostMapping("/basic-info-submit") @ApiOperation("专家管理员新增专家)") - @WebLog("专家管理员新增专家") + //@WebLog("专家管理员新增专家") public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { expertManage.expertBasicInfoSubmit(request); } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java index 2a76e19..b9d08ca 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java @@ -1,9 +1,17 @@ package com.ningdatech.pmapi.region; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.common.helper.RegionCacheHelper; import com.ningdatech.pmapi.common.util.ExpertRegisterUtil; +import com.ningdatech.pmapi.expert.constant.ExpertApplyStatusEnum; +import com.ningdatech.pmapi.expert.constant.ExpertApplyTypeEnum; import com.ningdatech.pmapi.expert.controller.ExpertController; +import com.ningdatech.pmapi.expert.entity.ExpertIntentionWorkRegion; +import com.ningdatech.pmapi.expert.entity.ExpertMetaApply; +import com.ningdatech.pmapi.expert.service.IExpertIntentionWorkRegionService; +import com.ningdatech.pmapi.expert.service.IExpertMetaApplyService; import com.ningdatech.pmapi.meta.helper.DictionaryCache; import com.ningdatech.pmapi.meta.helper.TagCache; import com.ningdatech.pmapi.organization.service.IDingOrganizationService; @@ -12,7 +20,10 @@ import com.ningdatech.pmapi.sys.service.IRegionService; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -28,7 +39,7 @@ public class RegionTest extends AppTests { private IRegionService regionService; @Test - public void test(){ + public void test() { Set set = regionService.list().stream().collect(Collectors.toSet()); Set ids = set.stream().map(Region::getId).collect(Collectors.toSet()); @@ -50,7 +61,12 @@ public class RegionTest extends AppTests { private ExpertController expertController; @Test - public void test1(){ + public void test1() { + System.out.println(regionCacheHelper.getByRegionName("浙江省-杭州市-滨江区")); + } + + @Test + public void test2() { ExpertRegisterUtil.regionCacheHelper = regionCacheHelper; ExpertRegisterUtil.tagCache = tagCache; ExpertRegisterUtil.dictionaryCache = dictionaryCache;