Explorar el Código

fix:修复其他报告的日期解析错误问题

wangzaijun hace 1 mes
padre
commit
b90d1be432

+ 93 - 65
mo-daq/src/main/java/com/smppw/modaq/application/components/ReportParseUtils.java

@@ -323,7 +323,7 @@ public final class ReportParseUtils {
             return null;
         }
         text = StrUtil.trim(text);
-        if (ReportType.QUARTERLY.equals(reportType) || ReportType.OTHER.equals(reportType)) {
+        if (ReportType.QUARTERLY.equals(reportType)) {
             Matcher matcher = PatternConsts.QUARTERLY_PATTERN.matcher(text);
             if (matcher.find()) {
                 String year = matcher.group(1);
@@ -336,13 +336,13 @@ public final class ReportParseUtils {
                 };
             }
         }
-        if (ReportType.ANNUALLY.equals(reportType) || ReportType.OTHER.equals(reportType)) {
+        if (ReportType.ANNUALLY.equals(reportType)) {
             Matcher matcher = PatternConsts.ANNUALLY_PATTERN.matcher(text);
             if (matcher.find()) {
                 return matcher.group(1) + "-12-31";
             }
         }
-        if (ReportType.MONTHLY.equals(reportType) || ReportType.OTHER.equals(reportType)) {
+        if (ReportType.MONTHLY.equals(reportType)) {
             Matcher matcher = PatternConsts.MONTHLY_PATTERN.matcher(text);
             if (matcher.find()) {
                 int year = Integer.parseInt(matcher.group(1));
@@ -365,6 +365,30 @@ public final class ReportParseUtils {
             }
             return date;
         }
+        // 其他报告的日期
+        if (ReportType.OTHER.equals(reportType)) {
+            matcher = PatternConsts.MONTHLY_PATTERN.matcher(text);
+            if (matcher.find()) {
+                int year = Integer.parseInt(matcher.group(1));
+                int month = Integer.parseInt(matcher.group(2));
+                return formatMonthEnd(year, month);
+            }
+            matcher = PatternConsts.QUARTERLY_PATTERN.matcher(text);
+            if (matcher.find()) {
+                String year = matcher.group(1);
+                return switch (matcher.group(2)) {
+                    case "一", "1" -> year + "-03-31";
+                    case "二", "2" -> year + "-06-30";
+                    case "三", "3" -> year + "-09-30";
+                    case "四", "4" -> year + "-12-31";
+                    default -> null;
+                };
+            }
+            matcher = PatternConsts.ANNUALLY_PATTERN.matcher(text);
+            if (matcher.find()) {
+                return matcher.group(1) + "-12-31";
+            }
+        }
         return null;
     }
 
@@ -485,71 +509,75 @@ public final class ReportParseUtils {
 //        text = "大岩市场中性2号私募证券投资基金_2025年_4月_月报.pdf";
 //        System.out.println(matchReportDate(matchReportType(EmailUtil.getEmailTypeBySubject(text), text), text));
 
-        text = "投资策略调整.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        System.out.println(emailType + "," + matchReportType(emailType, text));
-
-        text = "SSH640_天演恒心精选3号私募证券投资基金(SSH640SM200010202504).pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "【复胜周度观点】 2025_04_07-2025_04_11.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "交睿宏观配置2号私募证券投资基金B类_孙怡乐_20250429_073248861_赎回确认单.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "远澜宏观周报20250418.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-
-        text = "官方公众号市场周报披露250430(1).docx";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-
-        text = "涌津涌赢11号私募证券投资基金-月度报告-25250508.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "年报_多元化CTA私募证券基金_2024年年度报告.pdf";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "投资基金C_20250515_刁志勋-确认单";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "投资基金C_2025年05月15号_刁志勋-确认单";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "证券投资基金_20250331_季报";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
-        text = "证券投资基金_20241231_年报";
-        emailType = EmailUtil.getEmailTypeBySubject(text);
-        reportType = matchReportType(emailType, text);
-        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//        text = "投资策略调整.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        System.out.println(emailType + "," + matchReportType(emailType, text));
+//
+//        text = "SSH640_天演恒心精选3号私募证券投资基金(SSH640SM200010202504).pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "【复胜周度观点】 2025_04_07-2025_04_11.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "交睿宏观配置2号私募证券投资基金B类_孙怡乐_20250429_073248861_赎回确认单.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "远澜宏观周报20250418.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//
+//        text = "官方公众号市场周报披露250430(1).docx";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//
+//        text = "涌津涌赢11号私募证券投资基金-月度报告-25250508.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "年报_多元化CTA私募证券基金_2024年年度报告.pdf";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "投资基金C_20250515_刁志勋-确认单";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "投资基金C_2025年05月15号_刁志勋-确认单";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "证券投资基金_20250331_季报";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "证券投资基金_20241231_年报";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
+//
+//        text = "证券投资基金_20250430_月报";
+//        emailType = EmailUtil.getEmailTypeBySubject(text);
+//        reportType = matchReportType(emailType, text);
+//        System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
 
-        text = "证券投资基金_20250430_月报";
+        text = "潼骁长益3号私募证券投资基金分红预通知公告20250520.pdf";
         emailType = EmailUtil.getEmailTypeBySubject(text);
         reportType = matchReportType(emailType, text);
         System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
-
     }
 }