浏览代码

fix:修复包含具体时间的季度、年度或月度报告的日期解析错误

wangzaijun 1 月之前
父节点
当前提交
0e1f99c89d
共有 1 个文件被更改,包括 28 次插入14 次删除
  1. 28 14
      mo-daq/src/main/java/com/smppw/modaq/application/components/ReportParseUtils.java

+ 28 - 14
mo-daq/src/main/java/com/smppw/modaq/application/components/ReportParseUtils.java

@@ -350,21 +350,20 @@ public final class ReportParseUtils {
                 return formatMonthEnd(year, month);
             }
         }
-        if (ReportType.WEEKLY.equals(reportType) || ReportType.LETTER.equals(reportType) || ReportType.OTHER.equals(reportType)) {
-            // 先用严格的日期匹配
-            Matcher matcher = PatternConsts.STRICT_DAY_PATTERN.matcher(text);
-            if (matcher.find()) {
-                return matcher.group();
-            }
-            // 匹配不了时
-            matcher = PatternConsts.DAY_PATTERN.matcher(text);
-            if (matcher.find()) {
-                String date = matcher.group();
-                if (NumberUtil.isNumber(date) && date.length() >= 10) {
-                    return StrUtil.sub(date, 0, 10);
-                }
-                return date;
+        // 其他所有场景下都支持的日期匹配规则
+        // 先用严格的日期匹配
+        Matcher matcher = PatternConsts.STRICT_DAY_PATTERN.matcher(text);
+        if (matcher.find()) {
+            return matcher.group();
+        }
+        // 匹配不了时
+        matcher = PatternConsts.DAY_PATTERN.matcher(text);
+        if (matcher.find()) {
+            String date = matcher.group();
+            if (NumberUtil.isNumber(date) && date.length() >= 10) {
+                return StrUtil.sub(date, 0, 10);
             }
+            return date;
         }
         return null;
     }
@@ -537,5 +536,20 @@ public final class ReportParseUtils {
         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));
+
     }
 }