Commit 9d7162d3 authored by hongguangwu's avatar hongguangwu

MVP1.7.17-法大大优化

parent 98abdd78
...@@ -35,6 +35,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; ...@@ -35,6 +35,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -67,6 +69,8 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr ...@@ -67,6 +69,8 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr
private static final String FASC_NO_EMP_CONTRACT = "未找到自动生成的员工合同"; private static final String FASC_NO_EMP_CONTRACT = "未找到自动生成的员工合同";
private static final String FASC_NO_TEMPLATE = "未找到新法大大模板"; private static final String FASC_NO_TEMPLATE = "未找到新法大大模板";
private static final Logger logger = LoggerFactory.getLogger(FascService.class);
@Override @Override
public R<String> getTemplate(String templateName) throws ApiException { public R<String> getTemplate(String templateName) throws ApiException {
...@@ -82,14 +86,43 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr ...@@ -82,14 +86,43 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr
// templateName 签署任务模板名称 // templateName 签署任务模板名称
List<TFascTemplate> tList = new ArrayList<>(); List<TFascTemplate> tList = new ArrayList<>();
List<SignTemplateListInfo> listSubList; List<SignTemplateListInfo> listSubList;
List<TFascTemplate> tempList = new ArrayList<>(); List<TFascTemplate> tempList;
List<TFascTemplateDetail> detailList = new ArrayList<>(); List<TFascTemplateDetail> detailList = new ArrayList<>();
List<TFascTemplateDetail> detailSubList; List<TFascTemplateDetail> detailSubList;
// 重试次数
int maxRetries = 3;
boolean success;
Exception lastException;
// 20秒后重试、40秒后重试、60秒后重试
long millis = 20000;
for (TFascCompany company : companyList) { for (TFascCompany company : companyList) {
listSubList = fascUtil.getTemplateList(templateName, tFascPushLogService, company); listSubList = fascUtil.getTemplateList(templateName, tFascPushLogService, company);
if (listSubList != null && !listSubList.isEmpty()) { if (listSubList != null && !listSubList.isEmpty()) {
detailSubList = new ArrayList<>(); detailSubList = new ArrayList<>();
tempList = new ArrayList<>();
success = false;
lastException = null;
for (int attempt = 0; attempt < maxRetries && !success; attempt++) {
try {
fascUtil.getTemplateDetailList(listSubList, tempList, detailSubList, tFascPushLogService, company); fascUtil.getTemplateDetailList(listSubList, tempList, detailSubList, tFascPushLogService, company);
success = true;
} catch (Exception e) {
lastException = e;
if (attempt < maxRetries - 1) { // Don't wait after the last attempt
try {
Thread.sleep(millis * (attempt + 1)); // Wait 10 seconds
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
}
}
}
if (!success) {
logger.error("法大大获取模板详情,重试 " + maxRetries + " 次依然失败", lastException);
continue;
}
if (!tempList.isEmpty() && !detailSubList.isEmpty()) { if (!tempList.isEmpty() && !detailSubList.isEmpty()) {
tList.addAll(tempList); tList.addAll(tempList);
detailList.addAll(detailSubList); detailList.addAll(detailSubList);
...@@ -342,6 +375,7 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr ...@@ -342,6 +375,7 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr
return fascUtil.urgeTask(contract, tFascPushLogService, tEmployeeContractPreMapper, company); return fascUtil.urgeTask(contract, tFascPushLogService, tEmployeeContractPreMapper, company);
} }
/** /**
* @param id TEmployeeContractPre主键 * @param id TEmployeeContractPre主键
* @Description: 获取附件 * @Description: 获取附件
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment