瀏覽代碼

feat:支持7z格式的压缩包解压

wangzaijun 2 周之前
父節點
當前提交
b9cf2e9048

+ 6 - 3
mo-daq/src/main/java/com/smppw/modaq/domain/service/EmailParseService.java

@@ -206,9 +206,11 @@ public class EmailParseService {
         String emailTitle = emailContentInfoDTO.getEmailTitle();
 
         if (ArchiveUtil.isZip(filepath)) {
-            handleCompressedFiles(emailTitle, filepath, ".zip", emailType, resultList);
+            this.handleCompressedFiles(emailTitle, filepath, ".zip", emailType, resultList);
         } else if (ArchiveUtil.isRAR(filepath)) {
-            handleCompressedFiles(emailTitle, filepath, ".rar", emailType, resultList);
+            this.handleCompressedFiles(emailTitle, filepath, ".rar", emailType, resultList);
+        } else if (ArchiveUtil.is7z(filepath)) {
+            this.handleCompressedFiles(emailTitle, filepath, ".7z", emailType, resultList);
         } else {
             // 不是压缩包时
             EmailZipFileDTO dto = new EmailZipFileDTO(emailTitle, emailContentInfoDTO);
@@ -247,7 +249,8 @@ public class EmailParseService {
         List<String> extractedDirs;
         if (ArchiveUtil.isZip(filepath)) {
             extractedDirs = ArchiveUtil.extractCompressedFiles(filepath, destPath);
-        } else if (ArchiveUtil.isRAR(filepath)) {
+        } else if (ArchiveUtil.isRAR(filepath) || ArchiveUtil.is7z(filepath)) {
+            // 7z和rar压缩包解压
             extractedDirs = ArchiveUtil.extractRar5(filepath, destPath);
         } else {
             return;

+ 8 - 4
mo-daq/src/main/java/com/smppw/modaq/infrastructure/util/ArchiveUtil.java

@@ -56,6 +56,10 @@ public class ArchiveUtil {
         return StrUtil.isNotBlank(fileName) && (fileName.endsWith("zip") || fileName.endsWith("ZIP"));
     }
 
+    public static boolean is7z(String fileName) {
+        return StrUtil.isNotBlank(fileName) && (fileName.endsWith("7z") || fileName.endsWith("7Z"));
+    }
+
     public static boolean isRAR(String fileName) {
         return StrUtil.isNotBlank(fileName) && (fileName.endsWith("rar") || fileName.endsWith("RAR"));
     }
@@ -352,8 +356,8 @@ public class ArchiveUtil {
     }
 
     public static void main(String[] args) throws Exception {
-        String zipFilePath = "D:\\home\\wwwroot\\mo_report_file\\wangzaijun@simuwang.com\\20250321\\20250321143709排排网确认单.rar";
-        String destFilePath = "D:\\home\\wwwroot\\mo_report_file\\wangzaijun@simuwang.com\\20250321";
+        String zipFilePath = "D:\\Documents\\新报告解析\\基协报告\\排排网代销-宏锡5月报告(公司及协会版).7z";
+        String destFilePath = "D:\\Documents\\新报告解析\\基协报告\\rar";
         List<String> strings = extractRar5(zipFilePath, destFilePath);
         for (String string : strings) {
             System.out.println(string);
@@ -363,8 +367,8 @@ public class ArchiveUtil {
 //            System.out.println(s);
 //        }
 
-        String currentZip = "D:\\Documents\\新报告解析\\确认单\\20250514_份额及交易确认函_上海量魁私募基金管理有限公司_深圳市前海排排网基金销售有限责任公司_TA确认数据.zip";
-        List<String> files = decompressZip(currentZip, "D:\\Documents\\新报告解析\\确认单\\", 2, "utf-8");
+        String currentZip = "D:\\Documents\\新报告解析\\基协报告\\排排网代销-宏锡5月报告(公司及协会版).7z";
+        List<String> files = decompressZip(currentZip, "D:\\Documents\\新报告解析\\基协报告\\zip\\", 2, "utf-8");
         System.out.println("解压后的文件路径:");
         files.forEach(System.out::println);
     }

+ 1 - 1
mo-daq/src/test/java/com/smppw/modaq/MoDaqApplicationTests.java

@@ -38,7 +38,7 @@ public class MoDaqApplicationTests {
     @Test
     public void reportTest() {
         MailboxInfoDTO emailInfoDTO = this.buildMailbox("*@simuwang.com", "*");
-        Date startDate = DateUtil.parse("2025-06-07 10:30:00", DateConst.YYYY_MM_DD_HH_MM_SS);
+        Date startDate = DateUtil.parse("2025-06-07 14:00:00", DateConst.YYYY_MM_DD_HH_MM_SS);
         Date endDate = DateUtil.parse("2025-06-07 17:05:00", DateConst.YYYY_MM_DD_HH_MM_SS);
         try {
             List<String> folderNames = ListUtil.list(false);