wangzaijun 1 周之前
父節點
當前提交
949760e33f

File diff suppressed because it is too large
+ 3 - 131
mo-daq/db/init.sql


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

@@ -1,87 +1,87 @@
-//package com.smppw.modaq.application.task;
-//
-//import cn.hutool.core.collection.ListUtil;
-//import cn.hutool.core.date.DateUtil;
-//import cn.hutool.core.exceptions.ExceptionUtil;
-//import com.smppw.modaq.application.service.EmailParseApiService;
-//import com.smppw.modaq.common.conts.EmailTypeConst;
-//import com.smppw.modaq.domain.entity.TaskRecordDO;
-//import com.smppw.modaq.domain.service.TaskRecordService;
-//import jakarta.annotation.PostConstruct;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.scheduling.annotation.Scheduled;
-//import org.springframework.stereotype.Component;
-//
-//import java.util.Date;
-//
-//@Component
-//public class ParseSchedulerTask {
-//    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-//
-//    private final EmailParseApiService emailParseApiService;
-//    private final TaskRecordService taskRecordService;
-//
-//    public ParseSchedulerTask(EmailParseApiService emailParseApiService, TaskRecordService taskRecordService) {
-//        this.emailParseApiService = emailParseApiService;
-//        this.taskRecordService = taskRecordService;
-//    }
-//
-//    @PostConstruct
-//    public void executeOnStartup() {
-////        try {
-////            // 定期报告从 其他文件夹/报告公告 文件夹获取邮件
-////            this.emailParseApiService.parseEmail(
-////                    DateUtil.parseDateTime("2025-06-06 18:00:00"),
-////                    DateUtil.parseDateTime("2025-06-06 18:10:01"),
-////                    ListUtil.of("其他文件夹/报告公告"), EmailTypeConst.REPORT_EMAIL_TYPES);
-////        } catch (Exception e) {
-////            logger.error(ExceptionUtil.getMessage(e));
-////        }
-////
-////        try {
-////            // 确认函从 INBOX 文件夹获取邮件
-////            this.emailParseApiService.parseEmail(
-////                    DateUtil.parseDateTime("2025-06-03 18:50:00"),
-////                    DateUtil.parseDateTime("2025-06-03 19:56:00"),
-////                    null, ListUtil.of(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE));
-////        } catch (Exception e) {
-////            logger.error(ExceptionUtil.getMessage(e));
-////        }
-//    }
-//
-//    /**
-//     * 定时任务每11分钟执行一次
-//     */
-//    @Scheduled(cron = "0 */11 * * * ?")
-//    public void letter() {
-//        String taskKey = "mo_email_parse_letter_task";
-//        TaskRecordDO task = this.taskRecordService.getTaskRecord(taskKey, 11 * 2 * 60);
-//        if (task == null) {
-//            return;
+package com.smppw.modaq.application.task;
+
+import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.exceptions.ExceptionUtil;
+import com.smppw.modaq.application.service.EmailParseApiService;
+import com.smppw.modaq.common.conts.EmailTypeConst;
+import com.smppw.modaq.domain.entity.TaskRecordDO;
+import com.smppw.modaq.domain.service.TaskRecordService;
+import jakarta.annotation.PostConstruct;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class ParseSchedulerTask {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private final EmailParseApiService emailParseApiService;
+    private final TaskRecordService taskRecordService;
+
+    public ParseSchedulerTask(EmailParseApiService emailParseApiService, TaskRecordService taskRecordService) {
+        this.emailParseApiService = emailParseApiService;
+        this.taskRecordService = taskRecordService;
+    }
+
+    @PostConstruct
+    public void executeOnStartup() {
+//        try {
+//            // 定期报告从 其他文件夹/报告公告 文件夹获取邮件
+//            this.emailParseApiService.parseEmail(
+//                    DateUtil.parseDateTime("2025-06-06 18:00:00"),
+//                    DateUtil.parseDateTime("2025-06-06 18:10:01"),
+//                    ListUtil.of("其他文件夹/报告公告"), EmailTypeConst.REPORT_EMAIL_TYPES);
+//        } catch (Exception e) {
+//            logger.error(ExceptionUtil.getMessage(e));
 //        }
-//        long start = System.currentTimeMillis();
-//        Date now = new Date();
+//
 //        try {
-//            // 尽可能往前找11分钟覆盖可能遗漏的邮件
-//            Date startTime = DateUtil.offsetMinute(task.getStartTime(), -11);
-//            // 确认单从 INBOX 默认文件夹获取邮件
-//            this.emailParseApiService.parseEmail(startTime, now,
+//            // 确认函从 INBOX 文件夹获取邮件
+//            this.emailParseApiService.parseEmail(
+//                    DateUtil.parseDateTime("2025-06-03 18:50:00"),
+//                    DateUtil.parseDateTime("2025-06-03 19:56:00"),
 //                    null, ListUtil.of(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE));
-//            task.setStatus(1);
 //        } catch (Exception e) {
-//            task.setStatus(2);
-//            task.setErrMsg(ExceptionUtil.stacktraceToString(e));
-//            this.logger.error("任务{} 执行错误:{}", taskKey, ExceptionUtil.stacktraceToString(e));
-//        } finally {
-//            task.setEndTime(now);
-//            this.taskRecordService.updateStatus(task);
-//            if (this.logger.isInfoEnabled()) {
-//                this.logger.info("任务{} 执行完成,耗时:{}ms", taskKey, System.currentTimeMillis() - start);
-//            }
+//            logger.error(ExceptionUtil.getMessage(e));
 //        }
-//    }
-//
+    }
+
+    /**
+     * 定时任务每11分钟执行一次
+     */
+    @Scheduled(cron = "0 */11 * * * ?")
+    public void letter() {
+        String taskKey = "mo_email_parse_letter_task";
+        TaskRecordDO task = this.taskRecordService.getTaskRecord(taskKey, 11 * 2 * 60);
+        if (task == null) {
+            return;
+        }
+        long start = System.currentTimeMillis();
+        Date now = new Date();
+        try {
+            // 尽可能往前找11分钟覆盖可能遗漏的邮件
+            Date startTime = DateUtil.offsetMinute(task.getStartTime(), -11);
+            // 确认单从 INBOX 默认文件夹获取邮件
+            this.emailParseApiService.parseEmail(startTime, now,
+                    null, ListUtil.of(EmailTypeConst.REPORT_LETTER_EMAIL_TYPE));
+            task.setStatus(1);
+        } catch (Exception e) {
+            task.setStatus(2);
+            task.setErrMsg(ExceptionUtil.stacktraceToString(e));
+            this.logger.error("任务{} 执行错误:{}", taskKey, ExceptionUtil.stacktraceToString(e));
+        } finally {
+            task.setEndTime(now);
+            this.taskRecordService.updateStatus(task);
+            if (this.logger.isInfoEnabled()) {
+                this.logger.info("任务{} 执行完成,耗时:{}ms", taskKey, System.currentTimeMillis() - start);
+            }
+        }
+    }
+
 //    /**
 //     * 定时任务每小时的15分和45分执行一次
 //     */
@@ -113,4 +113,4 @@
 //            }
 //        }
 //    }
-//}
+}

+ 5 - 5
mo-daq/src/main/java/com/smppw/modaq/domain/service/EmailParseService.java

@@ -554,7 +554,7 @@ public class EmailParseService {
 //        }
 //        boolean isAmac = reportType == ReportType.ANNUALLY || reportType == ReportType.QUARTERLY
 //                || (reportType == ReportType.MONTHLY && ReportMonthlyType.AMAC == monthlyType);
-        boolean isAmac = false;
+//        boolean isAmac = false;
 //        // 不支持解析的格式文件
 //        boolean notSupportFile = false;
         // 解析报告
@@ -562,7 +562,7 @@ public class EmailParseService {
         ReportParserParams params = new ReportParserParams(fileId, fileName, filepath, reportType);
         long start = System.currentTimeMillis();
         try {
-            if (isAmac || reportType == ReportType.LETTER) {
+            if (reportType == ReportType.LETTER) {
                 ReportParser<ReportData> instance = this.reportParserFactory.getInstance(reportType, fileType);
                 reportData = instance.parse(params);
                 result = new ParseResult<>(1, "报告解析成功", reportData);
@@ -598,9 +598,6 @@ public class EmailParseService {
 //                    result = new ParseResult<>(ReportParseStatus.PARSE_FAIL, null, e.getMessage());
 //                }
 //            }
-            if (log.isInfoEnabled()) {
-                log.info("报告{} 用ocr补充解析结果。补充前的结果是:\n{}", fileName, reportData);
-            }
             // ocr信息提取(印章、联系人、基金名称和产品代码)
             this.ocrReportData(reportType, reportData, fileName, images);
 //            // 设置月报类型
@@ -681,6 +678,9 @@ public class EmailParseService {
         if (reportData == null || CollUtil.isEmpty(images)) {
             return;
         }
+        if (log.isInfoEnabled()) {
+            log.info("报告{} 用ocr补充解析结果。补充前的结果是:\n{}", fileName, reportData);
+        }
         // 报告才识别尾页的印章和联系人,确认单不识别尾页
         if (ReportType.LETTER != reportType) {
 //            OCRParseData parseRes = null;

+ 7 - 3
mo-daq/src/main/resources/application.yml

@@ -27,9 +27,9 @@ spring:
     # 指定为HikariDataSource
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://120.78.215.178:3306/rz_market_operate_ppwfund?allowMultiQueries=true&useSSL=false&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull
-    username: ai_dept_qiuruifeng
-    password: mx9ArjZIi2I8PubHK
+    url: jdbc:mysql://47.112.140.222:3306/rz_combination_master?allowMultiQueries=true&useSSL=false&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull
+    username: rz_cm_master
+    password: TbLuENLK
     # hikari连接池配置 对应 HikariConfig 配置属性类
     hikari:
       pool-name: HikariCP-daq
@@ -46,6 +46,10 @@ spring:
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: Asia/Shanghai
+  servlet:
+    multipart:
+      enabled: true
+      file-size-threshold: 10MB
 
 email:
   file: