Browse Source

修改专家数据导入工具类

master
WendyYang 10 months ago
parent
commit
eed8e33e97
2 changed files with 52 additions and 29 deletions
  1. +44
    -28
      pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java
  2. +8
    -1
      pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java

+ 44
- 28
pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExpertRegisterUtil.java View File

@@ -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<Map<String, Object>> 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<String, TagDTO> 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<DingOrganization> 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));
}
});
}



+ 8
- 1
pmapi/src/test/java/com/ningdatech/pmapi/region/RegionTest.java View File

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

}

Loading…
Cancel
Save