From eed8e33e9719150cf6c49d30e0f6ebd097a4eea5 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 23 Nov 2023 17:59:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=93=E5=AE=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AF=BC=E5=85=A5=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/util/ExpertRegisterUtil.java | 72 +++++++++++++--------- .../com/ningdatech/pmapi/region/RegionTest.java | 9 ++- 2 files changed, 52 insertions(+), 29 deletions(-) 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 e25587c..9bb3cbe 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 @@ -37,22 +37,21 @@ import java.util.Map; */ public class ExpertRegisterUtil { + private ExpertRegisterUtil() { + } + + private static final String SEPARATOR = ",|,|\\n"; + public static RegionCacheHelper regionCacheHelper; public static DictionaryCache dictionaryCache; public static IDingOrganizationService organizationService; public static TagCache tagCache; public static ExpertController expertController; - private static final String FILE_PATH = "/Users/wendy/Desktop/丽水市市本级专家导入用(1).xlsx"; - - public static void registerExpertBatch() { - ExcelReader reader = ExcelUtil.getReader(new File(FILE_PATH)); + public static void registerExpertBatch(String path) { + ExcelReader reader = ExcelUtil.getReader(new File(path)); List> experts = reader.readAll(); experts.forEach(w -> { - String rowNum = MapUtil.getStr(w, "序号"); - if (!StrUtils.isNumeric(rowNum) || Integer.parseInt(rowNum) <= 41 || Integer.parseInt(rowNum) >= 108) { - return; - } ExpertRegistrationRequest request = new ExpertRegistrationRequest(); ExpertBasicInfo basic = new ExpertBasicInfo(); basic.setBank(MapUtil.getStr(w, "开户行")); @@ -111,15 +110,15 @@ public class ExpertRegisterUtil { } request.setEduInfo(eduInfo); // 专家层级 - String expertRegionStr = MapUtil.getStr(w, "*专家层级"); + String expertRegionStr = MapUtil.getStr(w, "*专家层级").replace("景宁县", "景宁畲族自治县"); RegionDTO expertRegion = regionCacheHelper.getByRegionName(expertRegionStr); if (expertRegion != null) { basic.setExpertRegionInfo(BeanUtil.copyProperties(expertRegion, ExpertRegionInfo.class)); } // 履职意向 - String intentionRegions = MapUtil.getStr(w, "*履职意向"); + String intentionRegions = MapUtil.getStr(w, "*履职意向").replace("景宁县", "景宁畲族自治县"); basic.setExpertIntentionWorkRegions(new ArrayList<>()); - for (String intentionRegionStr : intentionRegions.split("\\n|,")) { + for (String intentionRegionStr : intentionRegions.split("")) { RegionDTO currRegion = regionCacheHelper.getByRegionName(intentionRegionStr); if (currRegion != null) { basic.getExpertIntentionWorkRegions().add(BeanUtil.copyProperties(currRegion, ExpertRegionInfo.class)); @@ -170,26 +169,28 @@ public class ExpertRegisterUtil { ExpertProfessionalInfo professionalInfo = new ExpertProfessionalInfo(); professionalInfo.setAwards("暂无"); professionalInfo.setIndustrySector(new ArrayList<>()); - String otherTagStr = MapUtil.getStr(w, "其他标签"); professionalInfo.setOther(new ArrayList<>()); Map tagMap = tagCache.getNameTagDtoMap(); - for (String othTag : otherTagStr.split(",")) { - tagMap.entrySet().stream() - .filter(tag -> tag.getValue().getParentCode().equals(ExpertTagEnum.OTHER.getKey()) - && tag.getValue().getTagName().equals(othTag)) - .forEach(tag -> { - TagFieldInfo expertTag = new TagFieldInfo(); - expertTag.setTagCode(tag.getValue().getTagCode()); - expertTag.setTagFieldName(tag.getValue().getParentCode()); - expertTag.setTagName(tag.getValue().getTagName()); - professionalInfo.getOther().add(expertTag); - }); + String otherTagStr = MapUtil.getStr(w, "其他标签"); + if (StrUtils.isNotBlank(otherTagStr)) { + for (String othTag : otherTagStr.split(SEPARATOR)) { + tagMap.entrySet().stream() + .filter(tag -> tag.getValue().getParentCode().equals(ExpertTagEnum.OTHER.getKey()) + && tag.getValue().getTagName().equals(othTag)) + .forEach(tag -> { + TagFieldInfo expertTag = new TagFieldInfo(); + expertTag.setTagCode(tag.getValue().getTagCode()); + expertTag.setTagFieldName(tag.getValue().getParentCode()); + expertTag.setTagName(tag.getValue().getTagName()); + professionalInfo.getOther().add(expertTag); + }); + } } String avoidCompanyStr = MapUtil.getStr(w, "*回避单位"); professionalInfo.setAvoidCompanyList(new ArrayList<>()); List avoidOrges = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class) - .in(DingOrganization::getOrganizationName, avoidCompanyStr.split(","))); + .in(DingOrganization::getOrganizationName, avoidCompanyStr.split(SEPARATOR))); if (!avoidOrges.isEmpty()) { avoidOrges.forEach(org -> { ExpertAvoidCompanyInfo companyInfo = new ExpertAvoidCompanyInfo(); @@ -201,7 +202,7 @@ public class ExpertRegisterUtil { professionalInfo.setGoodAt(new ArrayList<>()); String goodAtStr = MapUtil.getStr(w, "*擅长方向"); - for (String othTag : goodAtStr.split(",")) { + for (String othTag : goodAtStr.split(SEPARATOR)) { tagMap.entrySet().stream() .filter(tag -> tag.getValue().getTagName().equals(othTag)) .forEach(tag -> { @@ -212,9 +213,21 @@ public class ExpertRegisterUtil { professionalInfo.getGoodAt().add(expertTag); }); } + String industrySectorStr = MapUtil.getStr(w, "行业领域"); + for (String othTag : industrySectorStr.split(SEPARATOR)) { + tagMap.entrySet().stream() + .filter(tag -> tag.getValue().getTagName().equals(othTag)) + .forEach(tag -> { + TagFieldInfo expertTag = new TagFieldInfo(); + expertTag.setTagCode(tag.getValue().getTagCode()); + expertTag.setTagFieldName(ExpertTagEnum.INDUSTRY_SECTOR.getKey()); + expertTag.setTagName(tag.getValue().getTagName()); + professionalInfo.getIndustrySector().add(expertTag); + }); + } professionalInfo.setTechnicalExpertise(new ArrayList<>()); String techStr = MapUtil.getStr(w, "技术专长"); - for (String othTag : techStr.split(",|、")) { + for (String othTag : techStr.split(SEPARATOR)) { tagMap.entrySet().stream() .filter(tag -> tag.getValue().getTagName().equals(othTag)) .forEach(tag -> { @@ -245,8 +258,11 @@ public class ExpertRegisterUtil { recommendInfo.setRecommendedWay(new ArrayList<>()); recommendInfo.setRecommendationProofFile(new ArrayList<>()); request.setRecommendInfo(recommendInfo); - System.out.println(JSONUtil.toJsonStr(request)); - expertController.expertBasicInfoSubmit(request); + try { + expertController.expertBasicInfoSubmit(request); + } catch (Exception e) { + System.out.println(JSONUtil.toJsonStr(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 b9d08ca..10568d7 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java @@ -67,12 +67,19 @@ public class RegionTest extends AppTests { @Test public void test2() { + String[] paths = {"/Users/wendy/Desktop/景宁县专家(1).xlsx", + "/Users/wendy/Desktop/专家基础信息归集表(遂昌县).xlsx", + "/Users/wendy/Desktop/专家基础信息归集表-缙云县.xlsx", + "/Users/wendy/Desktop/松阳专家汇总.xlsx", + "/Users/wendy/Desktop/青田县---专家基础信息归集表.xlsx"}; ExpertRegisterUtil.regionCacheHelper = regionCacheHelper; ExpertRegisterUtil.tagCache = tagCache; ExpertRegisterUtil.dictionaryCache = dictionaryCache; ExpertRegisterUtil.organizationService = organizationService; ExpertRegisterUtil.expertController = expertController; - ExpertRegisterUtil.registerExpertBatch(); + for (String path : paths) { + ExpertRegisterUtil.registerExpertBatch(path); + } } }