소스 검색

fix: 处理大数据分批入库的优化

chenjianhua 3 달 전
부모
커밋
4aa1a4fc5c

+ 9 - 6
service-base/src/main/java/com/simuwang/base/common/util/ExcelUtil.java

@@ -227,25 +227,28 @@ public class ExcelUtil {
         if (!destFile.exists()) {
             destFile.mkdirs();
         }
-
-        try (BufferedInputStream fis = new BufferedInputStream(new FileInputStream(zipFilePath));
-             ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(fis)) {
+        logger.info("开始解压==================="+zipFilePath);
+        try {
+            BufferedInputStream fis = new BufferedInputStream(new FileInputStream(zipFilePath));
+            ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream(fis);
             ArchiveEntry entry;
             while ((entry = ais.getNextEntry()) != null) {
                 File entryFile = new File(destFilePath, entry.getName());
                 if (entry.isDirectory()) {
                     entryFile.mkdirs();
+                    logger.info("解压子文件:{}",entryFile.getName());
                 } else {
                     try (FileOutputStream fos = new FileOutputStream(entryFile)) {
                         IOUtils.copy(ais, fos);
                         filePathList.add(entryFile.getPath());
+                        logger.info("解压子文件:{}",entryFile.getPath());
                     }
                 }
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        }catch (Exception e) {
+            logger.error(zipFilePath+"======="+e.getMessage(),e);
         }
-
+        logger.info("开始结束================");
         return filePathList;
     }
 

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

@@ -121,6 +121,7 @@ public class NavEmailParser extends AbstractEmailParser {
             String destPath = filePath.replaceAll(".zip", "").replaceAll(".ZIP", "");
             log.info("压缩包地址:{},解压后文件地址:{}", filePath, destPath);
             List<String> dir = ExcelUtil.extractCompressedFiles(filePath, destPath);
+            log.info("解压后文件列表大小:{}", dir.size());
             for (String zipFilePath : dir) {
                 emailFundNavDTOList.addAll(parseZipFile(emailContentInfoDTO, zipFilePath, emailFieldMap));
                 File file = new File(zipFilePath);
@@ -156,6 +157,7 @@ public class NavEmailParser extends AbstractEmailParser {
     }
 
     private List<EmailFundNavDTO> parseZipFile(EmailContentInfoDTO emailContentInfoDTO, String zipFilePath, Map<String, List<String>> emailFieldMap) {
+        log.info(zipFilePath+"=====================");
         List<EmailFundNavDTO> fundNavDTOList = CollUtil.newArrayList();
         if (ExcelUtil.isPdf(zipFilePath)) {
             String excelFilePath = zipFilePath.replace(".pdf", System.currentTimeMillis()+".xlsx").replace(".PDF", System.currentTimeMillis()+".xlsx");