Browse Source

增加decimal工具类

tags/24080901
WendyYang 10 months ago
parent
commit
3c9c6c1b62
13 changed files with 145 additions and 487 deletions
  1. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/DictUtil.java
  2. +65
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegionInfoUtil.java
  3. +0
    -73
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegionInfoUtils.java
  4. +0
    -268
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegisterUtil.java
  5. +11
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/Md5Util.java
  6. +2
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/RefreshKeyUtil.java
  7. +3
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/RegionUtil.java
  8. +0
    -73
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java
  9. +46
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/TagUtil.java
  10. +0
    -42
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/TagUtils.java
  11. +7
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java
  12. +7
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java
  13. +2
    -8
      hz-pm-api/src/test/java/com/hz/pm/api/irs/CoreTest.java

hz-pm-api/src/main/java/com/hz/pm/api/common/util/DictUtils.java → hz-pm-api/src/main/java/com/hz/pm/api/common/util/DictUtil.java View File

@@ -10,9 +10,9 @@ import java.util.List;
* @author liuxinxin
* @date 2022/7/28 下午2:14
*/
public class DictUtils {
public class DictUtil {

private DictUtils() {
private DictUtil() {
}

public static Boolean isValueEquals(List<DictFieldInfoDTO> list1, List<DictFieldInfoDTO> list2) {

+ 65
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegionInfoUtil.java View File

@@ -0,0 +1,65 @@
package com.hz.pm.api.common.util;

import cn.hutool.core.collection.CollUtil;
import com.hz.pm.api.common.model.ExpertRegionModifyDiffBO;
import com.hz.pm.api.expert.model.RegionDtoMapKey;
import com.hz.pm.api.meta.model.ExpertRegionInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author liuxinxin
* @since 2022/7/28 下午4:33
*/

public class ExpertRegionInfoUtil {

private ExpertRegionInfoUtil() {
}

public static ExpertRegionModifyDiffBO diff(List<ExpertRegionInfo> preRegions, List<ExpertRegionInfo> currRegions) {
ExpertRegionModifyDiffBO diff = new ExpertRegionModifyDiffBO();
List<ExpertRegionInfo> addList = new ArrayList<>();
List<ExpertRegionInfo> removeList = new ArrayList<>();
if (CollUtil.isEmpty(preRegions) && CollUtil.isEmpty(currRegions)) {
diff.setAddList(addList);
diff.setRemoveList(removeList);
} else if (CollUtil.isEmpty(preRegions)) {
diff.setAddList(currRegions);
diff.setRemoveList(removeList);
} else if (CollUtil.isEmpty(currRegions)) {
diff.setAddList(addList);
diff.setRemoveList(preRegions);
} else {
List<RegionDtoMapKey> preRegionMapKey = convert(preRegions);
List<RegionDtoMapKey> currRegionMapKey = convert(currRegions);
removeList.addAll(notContains(currRegionMapKey, preRegionMapKey));
addList.addAll(notContains(preRegionMapKey, currRegionMapKey));
diff.setAddList(addList);
diff.setRemoveList(removeList);
}
return diff;

}

private static List<ExpertRegionInfo> notContains(List<RegionDtoMapKey> source, List<RegionDtoMapKey> target) {
return target.stream().filter(w -> !source.contains(w)).map(key -> {
ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
expertRegionInfo.setRegionCode(key.getRegionCode());
expertRegionInfo.setRegionLevel(key.getRegionLevel());
return expertRegionInfo;
}).collect(Collectors.toList());
}

private static List<RegionDtoMapKey> convert(List<ExpertRegionInfo> regionInfos) {
return regionInfos.stream().map(r -> {
RegionDtoMapKey regionDtoMapKey = new RegionDtoMapKey();
regionDtoMapKey.setRegionLevel(r.getRegionLevel());
regionDtoMapKey.setRegionCode(r.getRegionCode());
return regionDtoMapKey;
}).collect(Collectors.toList());
}

}

+ 0
- 73
hz-pm-api/src/main/java/com/hz/pm/api/common/util/ExpertRegionInfoUtils.java View File

@@ -1,73 +0,0 @@
package com.hz.pm.api.common.util;

import com.hz.pm.api.common.model.ExpertRegionModifyDiffBO;
import com.hz.pm.api.expert.model.RegionDtoMapKey;
import com.hz.pm.api.meta.model.ExpertRegionInfo;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author liuxinxin
* @date 2022/7/28 下午4:33
*/

public class ExpertRegionInfoUtils {

public static ExpertRegionModifyDiffBO modifyDiff(List<ExpertRegionInfo> beforeList, List<ExpertRegionInfo> afterList) {
ExpertRegionModifyDiffBO expertRegionModifyDiffBO = new ExpertRegionModifyDiffBO();
List<ExpertRegionInfo> addList = new ArrayList<>();
List<ExpertRegionInfo> removeList = new ArrayList<>();
if (CollectionUtils.isEmpty(beforeList) && CollectionUtils.isEmpty(afterList)) {
expertRegionModifyDiffBO.setAddList(addList);
expertRegionModifyDiffBO.setRemoveList(removeList);
return expertRegionModifyDiffBO;
} else if (CollectionUtils.isEmpty(beforeList)) {
expertRegionModifyDiffBO.setAddList(afterList);
expertRegionModifyDiffBO.setRemoveList(removeList);
return expertRegionModifyDiffBO;
} else if (CollectionUtils.isEmpty(afterList)) {
expertRegionModifyDiffBO.setAddList(addList);
expertRegionModifyDiffBO.setRemoveList(beforeList);
return expertRegionModifyDiffBO;
}

List<RegionDtoMapKey> beforeRegionDtoMapKeyList = beforeList.stream().map(r -> {
RegionDtoMapKey regionDtoMapKey = new RegionDtoMapKey();
regionDtoMapKey.setRegionLevel(r.getRegionLevel());
regionDtoMapKey.setRegionCode(r.getRegionCode());
return regionDtoMapKey;
}).collect(Collectors.toList());

List<RegionDtoMapKey> afterRegionDtoMapKeyList = afterList.stream().map(r -> {
RegionDtoMapKey regionDtoMapKey = new RegionDtoMapKey();
regionDtoMapKey.setRegionLevel(r.getRegionLevel());
regionDtoMapKey.setRegionCode(r.getRegionCode());
return regionDtoMapKey;
}).collect(Collectors.toList());

for (RegionDtoMapKey key : beforeRegionDtoMapKeyList) {
if (!afterRegionDtoMapKeyList.contains(key)) {
ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
expertRegionInfo.setRegionCode(key.getRegionCode());
expertRegionInfo.setRegionLevel(key.getRegionLevel());
removeList.add(expertRegionInfo);
}
}

for (RegionDtoMapKey key : afterRegionDtoMapKeyList) {
if (!beforeRegionDtoMapKeyList.contains(key)) {
ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
expertRegionInfo.setRegionCode(key.getRegionCode());
expertRegionInfo.setRegionLevel(key.getRegionLevel());
addList.add(expertRegionInfo);
}
}

expertRegionModifyDiffBO.setAddList(addList);
expertRegionModifyDiffBO.setRemoveList(removeList);
return expertRegionModifyDiffBO;
}
}

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

@@ -1,268 +0,0 @@
package com.hz.pm.api.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;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.helper.RegionCacheHelper;
import com.hz.pm.api.expert.controller.ExpertController;
import com.hz.pm.api.expert.model.*;
import com.hz.pm.api.expert.model.req.ExpertRegistrationRequest;
import com.hz.pm.api.meta.constant.DictTypeEnum;
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.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;
import com.hz.pm.api.sys.model.dto.RegionDTO;

import java.io.File;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* <p>
* ExpertRegisterUtil
* </p>
*
* @author WendyYang
* @since 10:03 2023/11/21
*/
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;

public static void registerExpertBatch(String path) {
ExcelReader reader = ExcelUtil.getReader(new File(path));
List<Map<String, Object>> experts = reader.readAll();
experts.forEach(w -> {
ExpertRegistrationRequest request = new ExpertRegistrationRequest();
ExpertBasicInfo basic = new ExpertBasicInfo();
basic.setBank(MapUtil.getStr(w, "开户行"));
basic.setBankNo(MapUtil.getStr(w, "银行卡号"));
basic.setName(MapUtil.getStr(w, "*姓名"));
basic.setPhoneNo(MapUtil.getStr(w, "*手机"));
basic.setGender("男".equals(MapUtil.getStr(w, "性别")) ? "1" : "0");
// 政治面貌
basic.setPolitical(new ArrayList<>());
String political = MapUtil.getStr(w, "政治面貌");
List<DictionaryDTO> politicalDicts = dictionaryCache.listDictByDictType(DictTypeEnum.POLITICAL.getKey());
if (!politicalDicts.isEmpty()) {
politicalDicts.stream()
.filter(dict -> dict.getName().equals(political))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
basic.getPolitical().add(dict);
});
}
ExpertEduInfo eduInfo = new ExpertEduInfo();
eduInfo.setSchool("暂无");
eduInfo.setAcademicTitle("暂无");
eduInfo.setGraduatedAt(LocalDate.now());
eduInfo.setEdu(new ArrayList<>());
eduInfo.setDegree(new ArrayList<>());
// 学历
String eduStr = MapUtil.getStr(w, "学历");
List<DictionaryDTO> eduDicts = dictionaryCache.listDictByDictType(DictTypeEnum.EDU.getKey());
if (!eduDicts.isEmpty()) {
eduDicts.stream()
.filter(dict -> dict.getName().equals(eduStr))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
eduInfo.getEdu().add(dict);
});
}
// 学位
String degreeStr = MapUtil.getStr(w, "学位");
List<DictionaryDTO> degreeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.DEGREE.getKey());
if (!degreeDicts.isEmpty()) {
degreeDicts.stream()
.filter(dict -> dict.getName().equals(degreeStr))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
eduInfo.getDegree().add(dict);
});
}
request.setEduInfo(eduInfo);
// 专家层级
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, "*履职意向").replace("景宁县", "景宁畲族自治县");
basic.setExpertIntentionWorkRegions(new ArrayList<>());
for (String intentionRegionStr : intentionRegions.split("")) {
RegionDTO currRegion = regionCacheHelper.getByRegionName(intentionRegionStr);
if (currRegion != null) {
basic.getExpertIntentionWorkRegions().add(BeanUtil.copyProperties(currRegion, ExpertRegionInfo.class));
}
}
request.setBasicInfo(basic);
// 职业信息
ExpertJobInfo jobInfo = new ExpertJobInfo();
jobInfo.setAddress("暂无");
jobInfo.setExperience("暂无");
jobInfo.setJobStatus(new ArrayList<>());
jobInfo.setCompany(MapUtil.getStr(w, "*工作单位"));
List<DingOrganization> organizations = organizationService.list(Wrappers.lambdaQuery(DingOrganization.class)
.eq(DingOrganization::getOrganizationName, jobInfo.getCompany()));
if (organizations.size() == 1) {
jobInfo.setCompanyUniqCode(organizations.get(0).getOrganizationCode());
}
jobInfo.setAdministrativeDuties(MapUtil.getStr(w, "行政职务"));
jobInfo.setAdministrativeRank(new ArrayList<>());
String administrativeRankStr = MapUtil.getStr(w, "行政职级");
List<DictionaryDTO> administrativeRankDicts = dictionaryCache.listDictByDictType(DictTypeEnum.ADMINISTRATIVE_RANK.getKey());
if (!administrativeRankDicts.isEmpty()) {
administrativeRankDicts.stream()
.filter(dict -> dict.getName().equals(administrativeRankStr))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
jobInfo.getAdministrativeRank().add(dict);
});
}
jobInfo.setCompanyAttribute(new ArrayList<>());
String companyTypeStr = MapUtil.getStr(w, "*单位类型");
List<DictionaryDTO> companyTypeDicts = dictionaryCache.listDictByDictType(DictTypeEnum.COMPANY_ATTRIBUTE.getKey());
if (!companyTypeDicts.isEmpty()) {
companyTypeDicts.stream()
.filter(dict -> dict.getName().equals(companyTypeStr))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
jobInfo.getCompanyAttribute().add(dict);
});
}
request.setJobInfo(jobInfo);
ExpertProfessionalInfo professionalInfo = new ExpertProfessionalInfo();
professionalInfo.setAwards("暂无");
professionalInfo.setIndustrySector(new ArrayList<>());
professionalInfo.setOther(new ArrayList<>());
Map<String, TagDTO> tagMap = tagCache.getNameTagMap();
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(SEPARATOR)));
if (!avoidOrges.isEmpty()) {
avoidOrges.forEach(org -> {
ExpertAvoidCompanyInfo companyInfo = new ExpertAvoidCompanyInfo();
companyInfo.setCompanyName(org.getOrganizationName());
companyInfo.setCompanyUniqCode(org.getOrganizationCode());
professionalInfo.getAvoidCompanyList().add(companyInfo);
});
}

professionalInfo.setGoodAt(new ArrayList<>());
String goodAtStr = MapUtil.getStr(w, "*擅长方向");
for (String othTag : goodAtStr.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.GOOD_AT.getKey());
expertTag.setTagName(tag.getValue().getTagName());
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(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.TECHNICAL_EXPERTISE.getKey());
expertTag.setTagName(tag.getValue().getTagName());
professionalInfo.getTechnicalExpertise().add(expertTag);
});
}
professionalInfo.setTitleLevel(new ArrayList<>());
String titleLevel = MapUtil.getStr(w, "*职称级别");
List<DictionaryDTO> titleLevelDicts = dictionaryCache.listDictByDictType(DictTypeEnum.TITLE_LEVEL.getKey());
if (!titleLevelDicts.isEmpty()) {
titleLevelDicts.stream()
.filter(dict -> dict.getName().equals(titleLevel))
.findFirst().ifPresent(dictionary -> {
DictFieldInfoDTO dict = new DictFieldInfoDTO();
dict.setDictionaryName(dictionary.getName());
dict.setDictionaryCode(dictionary.getDictionaryCode());
dict.setDictionaryFieldName(dictionary.getDictionaryType());
professionalInfo.getTitleLevel().add(dict);
});
}
professionalInfo.setTechnicalTitles(MapUtil.getStr(w, "技术职称"));
request.setProfessionalInfo(professionalInfo);
ExpertRecommendInfo recommendInfo = new ExpertRecommendInfo();
recommendInfo.setRecommendedWay(new ArrayList<>());
request.setRecommendInfo(recommendInfo);
try {
expertController.expertBasicInfoSubmit(request);
} catch (Exception e) {
System.out.println(JSONUtil.toJsonStr(request));
}
});
}

}

hz-pm-api/src/main/java/com/hz/pm/api/common/util/Md5Utils.java → hz-pm-api/src/main/java/com/hz/pm/api/common/util/Md5Util.java View File

@@ -6,12 +6,20 @@ import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;

public class Md5Utils {
/**
* <p>
* Md5Utils
* </p>
*
* @author WendyYang
* @since 19:21 2024/2/21
*/
public class Md5Util {

private Md5Utils() {
private Md5Util() {
}

private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class);
private static final Logger LOGGER = LoggerFactory.getLogger(Md5Util.class);

public static byte[] md5(String s) {
MessageDigest algorithm;

+ 2
- 2
hz-pm-api/src/main/java/com/hz/pm/api/common/util/RefreshKeyUtil.java View File

@@ -24,7 +24,7 @@ public class RefreshKeyUtil {
// 刷新秘钥
HttpUtil httpUtil = HttpUtil.getInstance();
log.info("请求密钥" + appSecret);
String sign = Md5Utils.hash (appKey + appSecret + requestTime);
String sign = Md5Util.hash (appKey + appSecret + requestTime);
String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenByKey.htm";
log.info(refreshUrl);
Map<String,String> map = new HashMap<>();
@@ -44,7 +44,7 @@ public class RefreshKeyUtil {
// 刷新秘钥
HttpUtil httpUtil = HttpUtil.getInstance();
log.info("刷新密钥" + refreshSecret);
String refreshSign = Md5Utils.hash (appKey + refreshSecret + requestTime);
String refreshSign = Md5Util.hash (appKey + refreshSecret + requestTime);
String refreshUrl = "http://interface.zjzwfw.gov.cn/gateway/app/refreshTokenBySec.htm";
log.info(refreshUrl);
Map<String,String> map = new HashMap<>();


hz-pm-api/src/main/java/com/hz/pm/api/common/util/RegionUtils.java → hz-pm-api/src/main/java/com/hz/pm/api/common/util/RegionUtil.java View File

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

/**
* @author liuxinxin
* @date 2022/7/28 下午2:27
* @since 2022/7/28 下午2:27
*/
public class RegionUtils {
public class RegionUtil {

private RegionUtils() {
private RegionUtil() {
}

public static Boolean isValueEquals(ExpertRegionInfo regionInfo1, ExpertRegionInfo regionInfo2) {

+ 0
- 73
hz-pm-api/src/main/java/com/hz/pm/api/common/util/SendWorkNoticeUtil.java View File

@@ -1,73 +0,0 @@
package com.hz.pm.api.common.util;

import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.zwdd.client.ZwddClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;

/**
* 异步发送工作通知工具类
*
* @author CMM
* @since 2023/02/23 13:50
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class SendWorkNoticeUtil {

private final ZwddClient zwddClient;

/**
* 初始化线程池
*/
public static final ThreadPoolTaskExecutor EXECUTOR;

static {
EXECUTOR = new ThreadPoolTaskExecutor();
EXECUTOR.setCorePoolSize(2);
EXECUTOR.setMaxPoolSize(4);
EXECUTOR.setQueueCapacity(200);
EXECUTOR.setKeepAliveSeconds(120);
EXECUTOR.setThreadNamePrefix("sendWorkNotice-");
EXECUTOR.setWaitForTasksToCompleteOnShutdown(true);
EXECUTOR.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
EXECUTOR.initialize();
}

public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo) {

// 将发送工作通知交给异步任务Future
String msg = workNoticeInfo.getMsg();
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
// 调用浙政钉的接口发送工作通知
long startTime = System.currentTimeMillis();
GenericResult<Void> result =
zwddClient.sendWorkNotice(workNoticeInfo.getReceiverUserId(), workNoticeInfo.getBizMsgId(), msg);
String resultMsg = result.getMsg();
if ("success".equals(resultMsg)) {
log.info("异步任务执行完成, " + workNoticeInfo.getBizMsgId() + " 当前线程:" + Thread.currentThread().getName());
long endTime = System.currentTimeMillis();
log.info("方法执行完成返回,耗时:" + (endTime - startTime));
} else {
return "发送工作通知失败!";
}
return "发送工作通知成功!";
}, EXECUTOR);
try {
future.get();
} catch (InterruptedException | ExecutionException e) {
log.error("获取异步线程处理结果失败!", e);
Thread.currentThread().interrupt();
}
return Boolean.TRUE;
}

}

+ 46
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/TagUtil.java View File

@@ -0,0 +1,46 @@
package com.hz.pm.api.common.util;

import cn.hutool.core.collection.CollUtil;
import com.hz.pm.api.expert.model.TagFieldInfo;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Comparator;
import java.util.List;

/**
* @author liuxinxin
* @since 2022/7/28 下午2:14
*/
public class TagUtil {

private TagUtil() {
}

private static final Comparator<TagFieldInfo> COMPARATOR = Comparator.comparing(TagFieldInfo::getTagFieldName)
.thenComparing(TagFieldInfo::getTagCode);

public static Boolean isValEq(List<TagFieldInfo> list1, List<TagFieldInfo> list2) {
if (CollUtil.isEmpty(list1) && CollUtil.isEmpty(list2)) {
return true;
}

boolean collStatusNotEq = (CollUtil.isEmpty(list1) && CollUtil.isNotEmpty(list2))
|| (CollUtil.isEmpty(list2) && CollUtil.isNotEmpty(list1));
if (collStatusNotEq) {
return false;
}
if (list1.size() != list2.size()) {
return false;
}
list1.sort(COMPARATOR);
list2.sort(COMPARATOR);

for (int i = 0; i < list1.size(); i++) {
if (!StrUtils.trimEquals(list1.get(i).getTagFieldName(), list2.get(i).getTagFieldName())
|| !StrUtils.trimEquals(list1.get(i).getTagCode(), list2.get(i).getTagCode())) {
return false;
}
}
return true;
}
}

+ 0
- 42
hz-pm-api/src/main/java/com/hz/pm/api/common/util/TagUtils.java View File

@@ -1,42 +0,0 @@
package com.hz.pm.api.common.util;

import com.hz.pm.api.expert.model.TagFieldInfo;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Comparator;
import java.util.List;

/**
* @author liuxinxin
* @date 2022/7/28 下午2:14
*/
public class TagUtils {

private TagUtils() {
}

public static Boolean isValueEquals(List<TagFieldInfo> list1, List<TagFieldInfo> list2) {
if (CollectionUtils.isEmpty(list1) && CollectionUtils.isEmpty(list2)) {
return true;
}

boolean collectionStatusNotEquals = (CollectionUtils.isEmpty(list1) && CollectionUtils.isNotEmpty(list2))
|| (CollectionUtils.isEmpty(list2) && CollectionUtils.isNotEmpty(list1));
if (collectionStatusNotEquals) {
return false;
}
if (list1.size() != list2.size()) {
return false;
}
list1.sort(Comparator.comparing(TagFieldInfo::getTagFieldName).thenComparing(TagFieldInfo::getTagCode));
list2.sort(Comparator.comparing(TagFieldInfo::getTagFieldName).thenComparing(TagFieldInfo::getTagCode));

for (int i = 0; i < list1.size(); i++) {
if (!StrUtils.trimEquals(list1.get(i).getTagFieldName(), list2.get(i).getTagFieldName())
|| !StrUtils.trimEquals(list1.get(i).getTagCode(), list2.get(i).getTagCode())) {
return false;
}
}
return true;
}
}

+ 7
- 7
hz-pm-api/src/main/java/com/hz/pm/api/expert/model/SensitiveModifySegment.java View File

@@ -1,10 +1,10 @@
package com.hz.pm.api.expert.model;


import com.hz.pm.api.common.util.DictUtils;
import com.hz.pm.api.common.util.RegionUtils;
import com.hz.pm.api.common.util.DictUtil;
import com.hz.pm.api.common.util.RegionUtil;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.common.util.TagUtils;
import com.hz.pm.api.common.util.TagUtil;
import com.hz.pm.api.expert.constant.ExpertSensitiveFieldTypeEnum;
import com.hz.pm.api.expert.constant.ExpertUserInfoSensitiveFieldEnum;
import com.hz.pm.api.meta.model.ExpertRegionInfo;
@@ -55,19 +55,19 @@ public class SensitiveModifySegment {
}
case administrative_rank:
case title_level: {
return DictUtils.isValueEquals((List<DictFieldInfoDTO>) this.original
return DictUtil.isValueEquals((List<DictFieldInfoDTO>) this.original
, (List<DictFieldInfoDTO>) this.apply);
}
case good_at:
case technical_expertise:
case industry_sector:
case other: {
return TagUtils.isValueEquals((List<TagFieldInfo>) this.original, (List<TagFieldInfo>) this.apply);
return TagUtil.isValEq((List<TagFieldInfo>) this.original, (List<TagFieldInfo>) this.apply);
}
case expert_region:
return RegionUtils.isValueEquals((ExpertRegionInfo) this.original, (ExpertRegionInfo) this.apply);
return RegionUtil.isValueEquals((ExpertRegionInfo) this.original, (ExpertRegionInfo) this.apply);
case expert_intention_work_region:
return RegionUtils.isValueEquals((List<ExpertRegionInfo>) this.original, (List<ExpertRegionInfo>) this.apply);
return RegionUtil.isValueEquals((List<ExpertRegionInfo>) this.original, (List<ExpertRegionInfo>) this.apply);
default:
return Objects.equals(this.original, this.apply);
}


+ 7
- 6
hz-pm-api/src/main/java/com/hz/pm/api/expert/service/impl/ExpertInfoServiceImpl.java View File

@@ -2,6 +2,7 @@ package com.hz.pm.api.expert.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PhoneUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -9,7 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.common.enumeration.BoolDisplayEnum;
import com.hz.pm.api.common.model.ExpertRegionModifyDiffBO;
import com.hz.pm.api.common.util.ExpertRegionInfoUtils;
import com.hz.pm.api.common.util.ExpertRegionInfoUtil;
import com.hz.pm.api.common.util.GzipUtil;
import com.hz.pm.api.expert.assembler.ExpertUserInfoAssembler;
import com.hz.pm.api.expert.constant.ExpertApplyStatusEnum;
@@ -543,7 +544,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
SensitiveModifySegment segment = expertIntentionFieldSegmentList.get(0);
List<ExpertRegionInfo> apply = (List<ExpertRegionInfo>) segment.getApply();
List<ExpertRegionInfo> original = (List<ExpertRegionInfo>) segment.getOriginal();
ExpertRegionModifyDiffBO expertRegionModifyDiffBO = ExpertRegionInfoUtils.modifyDiff(original, apply);
ExpertRegionModifyDiffBO expertRegionModifyDiffBO = ExpertRegionInfoUtil.diff(original, apply);
List<ExpertRegionInfo> addList = expertRegionModifyDiffBO.getAddList();
List<ExpertRegionInfo> removeList = expertRegionModifyDiffBO.getRemoveList();

@@ -571,7 +572,7 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
@Transactional(rollbackFor = Exception.class)
public Long createExpertInfoModifyApply(List<SensitiveModifySegment> expertSensitiveInfoFieldSegmentList
, ExpertUserFullInfo originalExpertUserFullInfo, ModifyApplyExtraInfoDTO modifyApplyExtraInfo) {
expertSensitiveInfoFieldSegmentList = expertSensitiveInfoFieldSegmentList.stream().filter(r -> !r.isValueEquals()).collect(Collectors.toList());
expertSensitiveInfoFieldSegmentList.removeIf(SensitiveModifySegment::isValueEquals);
String compressedModifyJsonStr = GzipUtil.zip(JSONObject.toJSONString(expertSensitiveInfoFieldSegmentList));

ExpertMetaApply expertMetaApply = new ExpertMetaApply();
@@ -629,9 +630,9 @@ public class ExpertInfoServiceImpl implements ExpertInfoService {
/**
* 创建层级变更审核
*
* @param expertRegionFieldSegmentList
* @param originalExpertUserFullInfo
* @param modifyApplyExtraInfo
* @param expertRegionFieldSegmentList \
* @param originalExpertUserFullInfo \
* @param modifyApplyExtraInfo \
*/
private Long createExpertRegionModifyApply(List<SensitiveModifySegment> expertRegionFieldSegmentList
, ExpertUserFullInfo originalExpertUserFullInfo, ModifyApplyExtraInfoDTO modifyApplyExtraInfo) {


+ 2
- 8
hz-pm-api/src/test/java/com/hz/pm/api/irs/CoreTest.java View File

@@ -1,19 +1,13 @@
package com.hz.pm.api.irs;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.ningdatech.irs.service.IRefreshTokenService;
import com.hz.pm.api.AppTests;
import com.hz.pm.api.common.util.CryptUtils;
import com.hz.pm.api.common.util.HttpUtil;
import com.hz.pm.api.common.util.Md5Utils;
import com.hz.pm.api.common.util.RefreshKeyUtil;
import com.hz.pm.api.gov.model.req.ProjectPushReq;
import com.hz.pm.api.common.util.Md5Util;
import com.hz.pm.api.irs.model.dto.ForwardDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@@ -87,7 +81,7 @@ public class CoreTest {//extends AppTests
dto.setAppKey(appKey);
dto.setSecret(secret);
dto.setRequestTime(requestTime);
String sign = Md5Utils.hash(appKey + secret + requestTime);
String sign = Md5Util.hash(appKey + secret + requestTime);
dto.setSign(sign);
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");


Loading…
Cancel
Save