|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.smppw.modaq.application.util.EmailUtil;
|
|
|
import com.smppw.modaq.common.conts.EmailTypeConst;
|
|
|
import com.smppw.modaq.common.conts.PatternConsts;
|
|
|
import com.smppw.modaq.common.enums.ReportType;
|
|
@@ -372,7 +373,7 @@ public final class ReportParseUtils {
|
|
|
if (matcher.find()) {
|
|
|
return matcher.group();
|
|
|
}
|
|
|
- // 匹配不了时
|
|
|
+ // 严格日期匹配不了时
|
|
|
matcher = PatternConsts.DAY_PATTERN.matcher(text);
|
|
|
if (matcher.find()) {
|
|
|
String date = matcher.group();
|
|
@@ -381,7 +382,7 @@ public final class ReportParseUtils {
|
|
|
}
|
|
|
return date;
|
|
|
}
|
|
|
- // 其他报告的日期
|
|
|
+ // 其他报告的日期(匹配到日)
|
|
|
if (ReportType.OTHER.equals(reportType)) {
|
|
|
matcher = PatternConsts.MONTHLY_PATTERN.matcher(text);
|
|
|
if (matcher.find()) {
|
|
@@ -389,21 +390,6 @@ public final class ReportParseUtils {
|
|
|
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;
|
|
|
}
|
|
@@ -449,16 +435,16 @@ public final class ReportParseUtils {
|
|
|
return reportType;
|
|
|
}
|
|
|
|
|
|
- private static int getLastDayOfMonth(int year, int month) {
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.set(Calendar.YEAR, year);
|
|
|
- calendar.set(Calendar.MONTH, month - 1); // Calendar.MONTH 是从0开始的
|
|
|
- return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
- }
|
|
|
-
|
|
|
- private static String padZero(String number) {
|
|
|
- return String.format("%02d", Integer.parseInt(number));
|
|
|
- }
|
|
|
+// private static int getLastDayOfMonth(int year, int month) {
|
|
|
+// Calendar calendar = Calendar.getInstance();
|
|
|
+// calendar.set(Calendar.YEAR, year);
|
|
|
+// calendar.set(Calendar.MONTH, month - 1); // Calendar.MONTH 是从0开始的
|
|
|
+// return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
|
+// }
|
|
|
+//
|
|
|
+// private static String padZero(String number) {
|
|
|
+// return String.format("%02d", Integer.parseInt(number));
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 计算指定月份的最后一天
|
|
@@ -579,7 +565,17 @@ public final class ReportParseUtils {
|
|
|
// reportType = matchReportType(emailType, text);
|
|
|
// System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
|
|
|
|
|
|
- String date = "2025-06-04 11:36:43";
|
|
|
+ text = "三希赤霄二号月报2025.05.png";
|
|
|
+ emailType = EmailUtil.getEmailTypeBySubject(text);
|
|
|
+ reportType = matchReportType(emailType, text);
|
|
|
+ System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
|
|
|
+
|
|
|
+ text = "第一创业2025年合同变更公告.png";
|
|
|
+ emailType = EmailUtil.getEmailTypeBySubject(text);
|
|
|
+ reportType = matchReportType(emailType, text);
|
|
|
+ System.out.println(emailType + ",reportType=" + reportType + ",reportDate=" + matchReportDate(reportType, text));
|
|
|
+
|
|
|
+ String date = "2025年6月6日";
|
|
|
String input = ReportParseUtils.cleaningValue(date, false);
|
|
|
Date date1 = DateUtils.toDate(input);
|
|
|
System.out.println(date1);
|