فهرست منبع

fix: 修复同名附件的PDF和excel导致PDF转为excel把原来的excel附件覆盖问题

chenjianhua 3 ماه پیش
والد
کامیت
f6a7a241c0

+ 1 - 1
service-daq/src/main/java/com/simuwang/daq/service/EmailTemplateService.java

@@ -537,7 +537,7 @@ public class EmailTemplateService {
             excelFilePath = ExcelUtil.contentConvertToExcel(content, excelFilePath);
             emailFileContentDTOList.add(new EmailFileContentDTO(excelFilePath, getTextFromHtml(content)));
         } else if (ExcelUtil.isPdf(filePath)) {
-            String excelFilePath = filePath.replace(".pdf", ".xlsx").replace(".PDF", ".xlsx");
+            String excelFilePath = filePath.replace(".pdf", System.currentTimeMillis()+".xlsx").replace(".PDF", System.currentTimeMillis()+".xlsx");
             excelFilePath = ExcelUtil.pdfConvertToExcel(filePath, excelFilePath);
             emailFileContentDTOList.add(new EmailFileContentDTO(excelFilePath, null));
         } else if (ExcelUtil.isZip(filePath)) {

+ 2 - 2
service-daq/src/main/java/com/simuwang/daq/service/NavEmailParser.java

@@ -77,7 +77,7 @@ public class NavEmailParser extends AbstractEmailParser {
         // 3.解析邮件pdf附件
         if (StrUtil.isNotBlank(emailContentInfoDTO.getFilePath()) && ExcelUtil.isPdf(emailContentInfoDTO.getFileName())) {
             String excelFilePath = path + emailContentInfoDTO.getEmailAddress() + "/" + emailContentInfoDTO.getEmailDate().substring(0, 10).replaceAll("-", "")
-                    + "/" + emailContentInfoDTO.getFileName().replace(".pdf", ".xlsx").replace(".PDF", ".xlsx");
+                    + "/" + emailContentInfoDTO.getFileName().replace(".pdf", System.currentTimeMillis()+".xlsx").replace(".PDF", System.currentTimeMillis()+".xlsx");
             List<EmailFundNavDTO> fundNavDTOList = parsePdfFile(emailContentInfoDTO.getFilePath(), excelFilePath, emailFieldMap);
             Optional.ofNullable(fundNavDTOList).ifPresent(emailFundNavDTOList::addAll);
         }
@@ -158,7 +158,7 @@ public class NavEmailParser extends AbstractEmailParser {
     private List<EmailFundNavDTO> parseZipFile(EmailContentInfoDTO emailContentInfoDTO, String zipFilePath, Map<String, List<String>> emailFieldMap) {
         List<EmailFundNavDTO> fundNavDTOList = CollUtil.newArrayList();
         if (ExcelUtil.isPdf(zipFilePath)) {
-            String excelFilePath = zipFilePath.replace(".pdf", ".xlsx").replace(".PDF", ".xlsx");
+            String excelFilePath = zipFilePath.replace(".pdf", System.currentTimeMillis()+".xlsx").replace(".PDF", System.currentTimeMillis()+".xlsx");
             fundNavDTOList = parsePdfFile(zipFilePath, excelFilePath, emailFieldMap);
         }
         if (ExcelUtil.isExcel(zipFilePath)) {

+ 1 - 1
service-daq/src/main/java/com/simuwang/daq/service/PdfToExcelService.java

@@ -70,7 +70,7 @@ public class PdfToExcelService {
         List<ValuationPdfTransformToExcelDTO> pdfToExcelDTOList = CollUtil.newArrayList();
         String excelUploadDir = path + File.separator + "valuation_table_excel" + File.separator;
         for (File multipartFile : pdfFileList) {
-            String excelFilePath = excelUploadDir + multipartFile.getName().replace(".pdf", "") + ".xlsx";
+            String excelFilePath = excelUploadDir + multipartFile.getName().replace(".pdf", "") + System.currentTimeMillis()+".xlsx";
             File savefile = new File(excelFilePath);
             if (!savefile.exists()) {
                 if (!savefile.getParentFile().exists()) {