|
@@ -32,6 +32,7 @@ import com.smppw.modaq.domain.entity.EmailParseInfoDO;
|
|
import com.smppw.modaq.domain.mapper.EmailFileInfoMapper;
|
|
import com.smppw.modaq.domain.mapper.EmailFileInfoMapper;
|
|
import com.smppw.modaq.domain.mapper.EmailParseInfoMapper;
|
|
import com.smppw.modaq.domain.mapper.EmailParseInfoMapper;
|
|
import com.smppw.modaq.infrastructure.util.ArchiveUtil;
|
|
import com.smppw.modaq.infrastructure.util.ArchiveUtil;
|
|
|
|
+import com.smppw.modaq.infrastructure.util.PdfUtil;
|
|
import jakarta.mail.*;
|
|
import jakarta.mail.*;
|
|
import jakarta.mail.internet.MimeUtility;
|
|
import jakarta.mail.internet.MimeUtility;
|
|
import jakarta.mail.search.ComparisonTerm;
|
|
import jakarta.mail.search.ComparisonTerm;
|
|
@@ -415,21 +416,17 @@ public class EmailParseService {
|
|
Integer fileId = emailFileInfo.getId();
|
|
Integer fileId = emailFileInfo.getId();
|
|
String aiFileId = emailFileInfo.getAiFileId();
|
|
String aiFileId = emailFileInfo.getAiFileId();
|
|
|
|
|
|
-// // 首页和尾页转为png图片,首页用来识别基金名称和基金代码、尾页用来识别印章和联系人
|
|
|
|
-// List<String> images = null;
|
|
|
|
-// try {
|
|
|
|
-// String output = FileUtil.getParent(filepath, 1) + File.separator + "image";
|
|
|
|
-// images = PdfUtil.convertFirstAndLastPagesToPng(filepath, FileUtil.file(output), 300);
|
|
|
|
-// if (log.isInfoEnabled()) {
|
|
|
|
-// log.info("报告[{}] 生成的图片地址是:{}", fileName, images);
|
|
|
|
-// }
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// log.warn("报告[{}] 生成图片失败:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
|
-// }
|
|
|
|
-// // todo 用图片来解析报告印章和联系人
|
|
|
|
-// if (CollUtil.isNotEmpty(images)) {
|
|
|
|
-// // do something ...
|
|
|
|
-// }
|
|
|
|
|
|
+ // 首页和尾页转为png图片,首页用来识别基金名称和基金代码、尾页用来识别印章和联系人
|
|
|
|
+ List<String> images = ListUtil.empty();
|
|
|
|
+ try {
|
|
|
|
+ String output = FileUtil.getParent(filepath, 1) + File.separator + "image";
|
|
|
|
+ images = PdfUtil.convertFirstAndLastPagesToPng(filepath, FileUtil.file(output), 300);
|
|
|
|
+ if (log.isInfoEnabled()) {
|
|
|
|
+ log.info("报告[{}] 生成的图片地址是:{}", fileName, images);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.warn("报告[{}] 生成图片失败:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
|
+ }
|
|
|
|
|
|
// 不支持解析的格式文件
|
|
// 不支持解析的格式文件
|
|
boolean notSupportFile = false;
|
|
boolean notSupportFile = false;
|
|
@@ -471,8 +468,15 @@ public class EmailParseService {
|
|
} finally {
|
|
} finally {
|
|
// 如果解析结果是空的就用AI工具解析一次
|
|
// 如果解析结果是空的就用AI工具解析一次
|
|
if (reportData == null && !notSupportFile) {
|
|
if (reportData == null && !notSupportFile) {
|
|
- if (log.isInfoEnabled()) {
|
|
|
|
- log.info("报告{} 开始AI解析......", fileName);
|
|
|
|
|
|
+ if (reportType == ReportType.QUARTERLY || reportType == ReportType.ANNUALLY) {
|
|
|
|
+ if (log.isInfoEnabled()) {
|
|
|
|
+ log.info("报告{} 开始AI解析......", fileName);
|
|
|
|
+ }
|
|
|
|
+ } else if (CollUtil.isNotEmpty(images)) {
|
|
|
|
+ filepath = images.get(0);
|
|
|
|
+ if (log.isInfoEnabled()) {
|
|
|
|
+ log.info("报告{} 用首页图片{} 开始AI解析......", fileName, filepath);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
ReportParserParams params = ReportParserParams.builder().fileId(fileId).filename(fileName).filepath(filepath)
|
|
ReportParserParams params = ReportParserParams.builder().fileId(fileId).filename(fileName).filepath(filepath)
|
|
.registerNumber(registerNumber).reportType(reportType).aiFileId(aiFileId).build();
|
|
.registerNumber(registerNumber).reportType(reportType).aiFileId(aiFileId).build();
|