REQ-3581: 返回幂等信息

This commit is contained in:
yanglin 2025-02-24 17:51:29 +08:00
parent 6f13a02061
commit 19c3696f5d

View File

@ -197,25 +197,30 @@ public class EssService {
@BizTransactional
public void downloadContractPDF(EssContract contract, boolean retryDownload) {
if (StringUtils.isNotBlank(contract.getOssFileKey()) && !retryDownload) {
log.info("合同已下载PDF, contract={}", contract);
EssContract reload = essContractDao.findForUpdateOrNull(contract.getEssContractId());
if (reload == null) {
log.warn("合同不存在, essContractId={}", contract.getEssContractId());
return;
}
if (!shouldDownloadContractPDF(contract)) {
log.info("合同不需要下载PDF, contract={}", contract);
if (StringUtils.isNotBlank(reload.getOssFileKey()) && !retryDownload) {
log.info("合同已下载PDF, contract={}", reload);
return;
}
if (!shouldDownloadContractPDF(reload)) {
log.info("合同不需要下载PDF, contract={}", reload);
return;
}
try {
String pdfUrl = getContractPDFUrlFromEss(contract);
String fileName = String.format("%s.pdf", contract.getContractName());
String pdfUrl = getContractPDFUrlFromEss(reload);
String fileName = String.format("%s.pdf", reload.getContractName());
String fileKey = ossService.uploadToOss(pdfUrl, fileName);
essContractDao.setOssFileKey(contract, fileKey);
essLogDao.log("uploadContractToOss", contract.getEssContractId(),
essContractDao.setOssFileKey(reload, fileKey);
essLogDao.log("uploadContractToOss", reload.getEssContractId(),
"ossFileKey", fileKey, "forceDownload", retryDownload);
log.info("上传合同到OSS成功, essContractId={}", contract.getEssContractId());
log.info("上传合同到OSS成功, essContractId={}", reload.getEssContractId());
} catch (Exception e) {
log.warn("上传合同到OSS失败", e);
essLogDao.log(e, "uploadContractToOss", contract.getEssContractId());
essLogDao.log(e, "uploadContractToOss", reload.getEssContractId());
}
}