|
@@ -370,7 +370,7 @@ public final class ReportParseUtils {
|
|
|
Matcher matcher = entry.getKey().matcher(str);
|
|
|
return matcher.find() ? entry.getValue().apply(matcher) : null;
|
|
|
})
|
|
|
- .filter(result -> result != null)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
.findFirst())
|
|
|
.orElse(null);
|
|
|
}
|
|
@@ -378,36 +378,38 @@ public final class ReportParseUtils {
|
|
|
/**
|
|
|
* 匹配报告类型,如“季度”、“年度”
|
|
|
*
|
|
|
- * @param emailTYpe 邮件类型
|
|
|
+ * @param emailType 邮件类型
|
|
|
* @param string 输入字符串
|
|
|
* @return 匹配到的报告类型子字符串,如果没有匹配到则返回null
|
|
|
*/
|
|
|
- public static ReportType matchReportType(Integer emailTYpe, String string) {
|
|
|
- if (emailTYpe == null) {
|
|
|
+ public static ReportType matchReportType(Integer emailType, String string) {
|
|
|
+ if (emailType == null) {
|
|
|
return null;
|
|
|
}
|
|
|
ReportType reportType = null;
|
|
|
- if (Objects.equals(EmailTypeConst.REPORT_EMAIL_TYPE, emailTYpe)) {
|
|
|
- // 类型识别---先识别季度报告,没有季度再识别年度报告,最后识别月报
|
|
|
- Pattern pattern = Pattern.compile("(\\d{1,2})月"); // xxxx_xx月
|
|
|
- Matcher matcher = pattern.matcher(string);
|
|
|
- if (StrUtil.containsAny(string, ReportType.QUARTERLY.getPatterns())) {
|
|
|
- reportType = ReportType.QUARTERLY;
|
|
|
- } else if (StrUtil.containsAny(string, ReportType.ANNUALLY.getPatterns())) {
|
|
|
- reportType = ReportType.ANNUALLY;
|
|
|
- } else if (StrUtil.containsAny(string, ReportType.MONTHLY.getPatterns())) {
|
|
|
- reportType = ReportType.MONTHLY;
|
|
|
- } else if (matcher.find()) {
|
|
|
- // 特殊的月报(当季度->年度->月度报告无法识别时,如果包含“\\d{1,2}月”就说明也是月报)
|
|
|
- reportType = ReportType.MONTHLY;
|
|
|
+ // 优先确认函、周报,然后才匹配定期报告,最后匹配其他观点
|
|
|
+ boolean isAmac = Objects.equals(EmailTypeConst.REPORT_EMAIL_TYPE, emailType);
|
|
|
+ if (!isAmac) {
|
|
|
+ if (Objects.equals(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE, emailType)
|
|
|
+ || StrUtil.containsAny(string, ReportType.LETTER.getPatterns())) {
|
|
|
+ reportType = ReportType.LETTER;
|
|
|
+ } else if (StrUtil.containsAny(string, ReportType.WEEKLY.getPatterns())) {
|
|
|
+ reportType = ReportType.WEEKLY;
|
|
|
}
|
|
|
return reportType;
|
|
|
}
|
|
|
- //
|
|
|
- if (StrUtil.containsAny(string, ReportType.LETTER.getPatterns())) {
|
|
|
- reportType = ReportType.LETTER;
|
|
|
- } else if (StrUtil.containsAny(string, ReportType.WEEKLY.getPatterns())) {
|
|
|
- reportType = ReportType.WEEKLY;
|
|
|
+ // 类型识别---先识别季度报告,没有季度再识别年度报告,最后识别月报
|
|
|
+ Pattern pattern = Pattern.compile("(\\d{1,2})月"); // xxxx_xx月
|
|
|
+ Matcher matcher = pattern.matcher(string);
|
|
|
+ if (StrUtil.containsAny(string, ReportType.QUARTERLY.getPatterns())) {
|
|
|
+ reportType = ReportType.QUARTERLY;
|
|
|
+ } else if (StrUtil.containsAny(string, ReportType.ANNUALLY.getPatterns())) {
|
|
|
+ reportType = ReportType.ANNUALLY;
|
|
|
+ } else if (StrUtil.containsAny(string, ReportType.MONTHLY.getPatterns())) {
|
|
|
+ reportType = ReportType.MONTHLY;
|
|
|
+ } else if (matcher.find()) {
|
|
|
+ // 特殊的月报(当季度->年度->月度报告无法识别时,如果包含“\\d{1,2}月”就说明也是月报)
|
|
|
+ reportType = ReportType.MONTHLY;
|
|
|
} else if (StrUtil.containsAny(string, ReportType.OTHER.getPatterns())) {
|
|
|
reportType = ReportType.OTHER;
|
|
|
}
|