From 19c3696f5d5bd28823ae0a2801560946fd53796f Mon Sep 17 00:00:00 2001 From: yanglin Date: Mon, 24 Feb 2025 17:51:29 +0800 Subject: [PATCH] =?UTF-8?q?REQ-3581:=20=E8=BF=94=E5=9B=9E=E5=B9=82?= =?UTF-8?q?=E7=AD=89=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nanopart/ess/server/ess/EssService.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ess/ess-server/src/main/java/cn/axzo/nanopart/ess/server/ess/EssService.java b/ess/ess-server/src/main/java/cn/axzo/nanopart/ess/server/ess/EssService.java index 4b990c1d..4dfbc5ef 100644 --- a/ess/ess-server/src/main/java/cn/axzo/nanopart/ess/server/ess/EssService.java +++ b/ess/ess-server/src/main/java/cn/axzo/nanopart/ess/server/ess/EssService.java @@ -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()); } }