Просмотр исходного кода

fix:报告解析的ai提示词优化

wangzaijun 1 месяц назад
Родитель
Сommit
5e63ca6a73

+ 1 - 1
mo-daq/src/main/java/com/smppw/modaq/application/components/report/parser/AbstractReportParser.java

@@ -92,7 +92,7 @@ public abstract class AbstractReportParser<T extends ReportData> implements Repo
             ReportBaseInfoDTO reportInfo = this.buildReportInfo(params);
             // 解析报告中主体基金的基本信息
             ReportFundInfoDTO reportFundInfo = this.buildFundInfo(params);
-            if (StrUtil.isBlank(reportFundInfo.getFundCode())) {
+            if (reportFundInfo != null && StrUtil.isBlank(reportFundInfo.getFundCode())) {
                 reportFundInfo.setFundCode(ReportParseUtils.matchFundCode(params.getFilename()));
             }
             // 解析其他表格信息并且设置结果字段

+ 9 - 13
mo-daq/src/main/java/com/smppw/modaq/application/components/report/parser/ai/AIMonthlyReportParser.java

@@ -2,7 +2,6 @@ package com.smppw.modaq.application.components.report.parser.ai;
 
 import cn.hutool.core.util.ObjUtil;
 import com.smppw.modaq.application.components.report.parser.ReportParserConstant;
-import com.smppw.modaq.common.enums.ReportParseStatus;
 import com.smppw.modaq.common.exception.ReportParseException;
 import com.smppw.modaq.domain.dto.report.MonthlyReportData;
 import com.smppw.modaq.domain.dto.report.ReportBaseInfoDTO;
@@ -11,8 +10,6 @@ import com.smppw.modaq.domain.dto.report.ReportParserParams;
 import com.smppw.modaq.domain.mapper.EmailFieldMappingMapper;
 import org.springframework.stereotype.Component;
 
-import java.util.Map;
-
 @Component(ReportParserConstant.PARSER_AI_MONTHLY)
 public class AIMonthlyReportParser extends AbstractAIReportParser<MonthlyReportData> {
     public AIMonthlyReportParser(EmailFieldMappingMapper fieldMappingMapper) {
@@ -27,8 +24,8 @@ public class AIMonthlyReportParser extends AbstractAIReportParser<MonthlyReportD
     @Override
     protected String prompt() {
         return """
-                识别文件中的基金概况,并且解析文件中的联系人等信息
-                要求准确识别金额等小数的位数,去掉金额单位、英文和多余的空格,结果用json返回
+                识别报告中的基金名称、基金编码和联系人信息,基金编码的正则表达式是`S[A-Z0-9]{5}`,如果没有联系人信息则返回空字符串
+                结果用json返回
                 """;
     }
 
@@ -61,14 +58,13 @@ public class AIMonthlyReportParser extends AbstractAIReportParser<MonthlyReportD
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     protected ReportFundInfoDTO buildFundInfo(ReportParserParams params) {
-        // 获取并移除基金概况信息
-        Object fundInfo = this.allInfoMap.remove("基金概况");
-        if (fundInfo == null) {
-            throw new ReportParseException(ReportParseStatus.PARSE_FUND_INFO_FAIL, params.getFilename());
-        }
-        Map<String, Object> fundInfoMap = (Map<String, Object>) fundInfo;
-        return this.buildDto(params.getFileId(), ReportFundInfoDTO.class, fundInfoMap);
+//        // 获取并移除基金概况信息
+//        Object fundInfo = this.allInfoMap.get("基金概况");
+//        if (fundInfo == null) {
+//            throw new ReportParseException(ReportParseStatus.PARSE_FUND_INFO_FAIL, params.getFilename());
+//        }
+//        Map<String, Object> fundInfoMap = (Map<String, Object>) fundInfo;
+        return this.buildDto(params.getFileId(), ReportFundInfoDTO.class, this.allInfoMap);
     }
 }

+ 1 - 1
mo-daq/src/main/java/com/smppw/modaq/application/components/report/parser/ai/AIWeeklyReportParser.java

@@ -24,7 +24,7 @@ public class AIWeeklyReportParser extends AbstractAIReportParser<WeeklyReportDat
         return """
                 识别文件中的基金名称、基金编码、基金管理人和报告日期,
                 并且解析文件中的联系人等信息,
-                基金编码的正则表达式是`S[A-Z0-9]{5}`,
+                基金编码的正则表达式是`S[A-Z0-9]{5}`,联系人信息包含电话、传真、邮箱、地址和二维码,
                 如果日期是区间段则取截止日期,如果无法识别就返回空字符串,结果用json返回
                 """;
     }

+ 3 - 0
mo-daq/src/main/java/com/smppw/modaq/application/components/report/parser/pdf/PDMonthlyReportParser.java

@@ -63,6 +63,9 @@ public class PDMonthlyReportParser extends AbstractPDReportParser<MonthlyReportD
 
     @Override
     protected ReportFundInfoDTO buildFundInfo(ReportParserParams params) {
+        if (this.fundInfoTable == null) {
+            return null;
+        }
         // 月报的基金基本信息是四列的表格
         Map<String, Object> baseInfoMap = MapUtil.newHashMap(32);
         for (int i = 0; i < fundInfoTable.getRows().size(); i++) {

+ 9 - 9
mo-daq/src/main/java/com/smppw/modaq/application/task/ParseSchedulerTask.java

@@ -31,15 +31,15 @@ public class ParseSchedulerTask {
 
     @PostConstruct
     public void executeOnStartup() {
-//        try {
-//            // 定期报告从 我的文件夹.报告公告 文件夹获取邮件
-//            this.emailParseApiService.parseEmail(
-//                    DateUtil.parseDateTime("2025-05-09 19:21:00"),
-//                    DateUtil.parseDateTime("2025-05-09 19:23:00"),
-//                    ListUtil.of("其他文件夹/报告公告"), EmailTypeConst.REPORT_EMAIL_TYPES);
-//        } catch (Exception e) {
-//            logger.error(ExceptionUtil.getMessage(e));
-//        }
+        try {
+            // 定期报告从 我的文件夹.报告公告 文件夹获取邮件
+            this.emailParseApiService.parseEmail(
+                    DateUtil.parseDateTime("2025-05-12 09:40:00"),
+                    DateUtil.parseDateTime("2025-05-12 09:43:00"),
+                    ListUtil.of("其他文件夹/报告公告"), EmailTypeConst.REPORT_EMAIL_TYPES);
+        } catch (Exception e) {
+            logger.error(ExceptionUtil.getMessage(e));
+        }
     }
 
     /**