update 同步委员会信息策略修改
This commit is contained in:
+4
-1
@@ -61,6 +61,10 @@ public class PayCommitteeInfoService extends ServiceImpl<PayCommitteeInfoMapper,
|
||||
}
|
||||
|
||||
public void sync(){
|
||||
JSONObject jsonObject = ZxdUtil.getWyh();
|
||||
if (jsonObject == null){
|
||||
return;
|
||||
}
|
||||
// 先把所有数据逻辑删除
|
||||
LambdaUpdateWrapper<PayCommitteeMemberInfo> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.set(PayCommitteeMemberInfo::getDelFlag, CommonConstant.DEL_FLAG_1);
|
||||
@@ -68,7 +72,6 @@ public class PayCommitteeInfoService extends ServiceImpl<PayCommitteeInfoMapper,
|
||||
LambdaUpdateWrapper<PayCommitteeInfo> wrapper1 = new LambdaUpdateWrapper<>();
|
||||
wrapper1.set(PayCommitteeInfo::getDelFlag, CommonConstant.DEL_FLAG_1);
|
||||
this.update(wrapper1);
|
||||
JSONObject jsonObject = ZxdUtil.getWyh();
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
List<CommitteeMemberInfoDTO> committeeMemberInfoList = JSONArray.parseArray(result.getString("commiteeMemberInfoList"), CommitteeMemberInfoDTO.class);
|
||||
List<PayCommitteeMemberInfo> payCommitteeMemberInfos = convertCommitteeMemberInfoDTO(committeeMemberInfoList);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jero.util;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.symmetric.SM4;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
@@ -13,6 +14,7 @@ import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -61,15 +63,33 @@ public class ZxdUtil {
|
||||
|
||||
public static JSONObject getWyh(){
|
||||
String encrypt = ZxdUtil.encrypt(PREFIXS, KEYS);
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("appId",APP_ID);
|
||||
map.put("abbreviation",encrypt);
|
||||
String url = URL + "?appId=" + APP_ID + "&abbreviation=" + encrypt;
|
||||
log.error("url:"+url);
|
||||
String s1 = HttpRequest.get(url)
|
||||
.timeout(60000)
|
||||
.execute()
|
||||
.body();
|
||||
log.info("url:"+url);
|
||||
int retryCount = 0;
|
||||
int maxRetryCount = 10;
|
||||
boolean shouldRetry = true;
|
||||
String s1 = null;
|
||||
while (shouldRetry) {
|
||||
try {
|
||||
log.info("开始第{}次{}",retryCount+1,"查询");
|
||||
// 重试请求...
|
||||
s1 = HttpRequest.get(url)
|
||||
.execute()
|
||||
.body();
|
||||
shouldRetry = false; // 如果请求成功,不再重试
|
||||
log.info("第{}次查询:成功",retryCount);
|
||||
} catch (IORuntimeException e) {
|
||||
retryCount++;
|
||||
log.info("第{}次查询:失败",retryCount);
|
||||
if (retryCount >= maxRetryCount) {
|
||||
shouldRetry = false; // 达到重试次数限制,不再重试
|
||||
}
|
||||
// 可以在这里添加重试间隔,例如Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
if (s1 == null){
|
||||
return null;
|
||||
}
|
||||
//String s1 = HttpUtil.get(url);
|
||||
SM4 sm4 = SmUtil.sm4(SM4_KEY.getBytes());
|
||||
String str = sm4.decryptStr(s1);
|
||||
|
||||
Reference in New Issue
Block a user