|
@@ -343,7 +343,6 @@ public class EmailParseService {
|
|
entity.setParseStatus(result.getStatus());
|
|
entity.setParseStatus(result.getStatus());
|
|
entity.setFailReason(result.getMsg());
|
|
entity.setFailReason(result.getMsg());
|
|
entity.setAiParse(result.getData().getAiParse());
|
|
entity.setAiParse(result.getData().getAiParse());
|
|
- entity.setAiFileId(result.getData().getAiFileId());
|
|
|
|
entityList.add(entity);
|
|
entityList.add(entity);
|
|
}
|
|
}
|
|
return entityList;
|
|
return entityList;
|
|
@@ -368,7 +367,6 @@ public class EmailParseService {
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
log.warn("报告{} 压缩包解压失败:{}", reportPath, ExceptionUtil.stacktraceToString(ex));
|
|
log.warn("报告{} 压缩包解压失败:{}", reportPath, ExceptionUtil.stacktraceToString(ex));
|
|
ReportData reportData = new ReportData.DefaultReportData();
|
|
ReportData reportData = new ReportData.DefaultReportData();
|
|
- reportData.setReportPath(reportPath);
|
|
|
|
dataList.add(new ParseResult<>(ReportParseStatus.ARCHIVE_FAIL, reportData));
|
|
dataList.add(new ParseResult<>(ReportParseStatus.ARCHIVE_FAIL, reportData));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -431,7 +429,9 @@ public class EmailParseService {
|
|
&& ReportParseUtils.containsAny(emailTitle, ReportParseUtils.MONTHLY_REPORT_KEYWORDS)) {
|
|
&& ReportParseUtils.containsAny(emailTitle, ReportParseUtils.MONTHLY_REPORT_KEYWORDS)) {
|
|
type = EmailTypeConst.REPORT_EMAIL_TYPE;
|
|
type = EmailTypeConst.REPORT_EMAIL_TYPE;
|
|
}
|
|
}
|
|
- emailFile.setEmailType(type);
|
|
|
|
|
|
+ if (EmailTypeConst.SUPPORT_EMAIL_TYPES.contains(type)) {
|
|
|
|
+ emailFile.setEmailType(type);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -516,7 +516,6 @@ public class EmailParseService {
|
|
this.checkEmailFileInfo(emailTitle, dtos);
|
|
this.checkEmailFileInfo(emailTitle, dtos);
|
|
// 解析邮件报告
|
|
// 解析邮件报告
|
|
for (EmailZipFileDTO zipFile : dtos) {
|
|
for (EmailZipFileDTO zipFile : dtos) {
|
|
-// EmailFileInfoDO emailFile = this.saveEmailFileInfo(emailId, zipFile.getFilename(), zipFile.getFilepath());
|
|
|
|
// 解析并保存报告
|
|
// 解析并保存报告
|
|
ParseResult<ReportData> parseResult = this.parseReportAndHandleResult(emailTitle, emailInfo.getSenderEmail(), zipFile);
|
|
ParseResult<ReportData> parseResult = this.parseReportAndHandleResult(emailTitle, emailInfo.getSenderEmail(), zipFile);
|
|
if (!Objects.equals(1, parseResult.getStatus())) {
|
|
if (!Objects.equals(1, parseResult.getStatus())) {
|
|
@@ -525,7 +524,6 @@ public class EmailParseService {
|
|
if (parseResult.getData() == null) {
|
|
if (parseResult.getData() == null) {
|
|
parseResult.setData(new ReportData.DefaultReportData());
|
|
parseResult.setData(new ReportData.DefaultReportData());
|
|
}
|
|
}
|
|
- parseResult.getData().setReportPath(zipFile.getFilepath());
|
|
|
|
resultList.add(parseResult);
|
|
resultList.add(parseResult);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -561,11 +559,13 @@ public class EmailParseService {
|
|
ReportParserFileType fileType = ReportParserFileType.getBySuffix(zipFile.getExtName());
|
|
ReportParserFileType fileType = ReportParserFileType.getBySuffix(zipFile.getExtName());
|
|
// 不支持的格式
|
|
// 不支持的格式
|
|
if (fileType == null) {
|
|
if (fileType == null) {
|
|
- return new ParseResult<>(ReportParseStatus.NO_SUPPORT_TEMPLATE, null, fileName);
|
|
|
|
|
|
+ ReportData reportData = this.buildNvlReportData(fileId, reportType, null, fileName);
|
|
|
|
+ return new ParseResult<>(ReportParseStatus.NO_SUPPORT_TEMPLATE, reportData, fileName);
|
|
}
|
|
}
|
|
// 不是定期报告的判断逻辑放在不支持的格式下面
|
|
// 不是定期报告的判断逻辑放在不支持的格式下面
|
|
if (reportType == null) {
|
|
if (reportType == null) {
|
|
- return new ParseResult<>(ReportParseStatus.NOT_A_REPORT, null, fileName);
|
|
|
|
|
|
+ ReportData reportData = this.buildNvlReportData(fileId, ReportType.OTHER, null, fileName);
|
|
|
|
+ return new ParseResult<>(ReportParseStatus.NOT_A_REPORT, reportData, fileName);
|
|
}
|
|
}
|
|
|
|
|
|
// docx转pdf
|
|
// docx转pdf
|
|
@@ -661,7 +661,7 @@ public class EmailParseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// ocr信息提取(印章、联系人、基金名称和产品代码)
|
|
// ocr信息提取(印章、联系人、基金名称和产品代码)
|
|
- reportData = this.ocrReportData(fileId, reportType, reportData, fileName, senderEmail, images);
|
|
|
|
|
|
+ reportData = this.ocrReportData(fileId, reportType, monthlyType, reportData, fileName, senderEmail, images);
|
|
result.setData(reportData);
|
|
result.setData(reportData);
|
|
if (log.isInfoEnabled()) {
|
|
if (log.isInfoEnabled()) {
|
|
log.info("报告{} 解析耗时{}ms,结果是:{}", fileName, (System.currentTimeMillis() - start), reportData);
|
|
log.info("报告{} 解析耗时{}ms,结果是:{}", fileName, (System.currentTimeMillis() - start), reportData);
|
|
@@ -726,12 +726,17 @@ public class EmailParseService {
|
|
/**
|
|
/**
|
|
* ocr 提取信息(包括首页的基金名称或报告日期,尾页的印章或联系人等信息)
|
|
* ocr 提取信息(包括首页的基金名称或报告日期,尾页的印章或联系人等信息)
|
|
*
|
|
*
|
|
- * @param reportData 报告解析结果
|
|
|
|
- * @param fileName 报告名称
|
|
|
|
- * @param images 报告的收益和尾页png图片
|
|
|
|
|
|
+ * @param fileId 文件表ID
|
|
|
|
+ * @param reportType 报告类型
|
|
|
|
+ * @param monthlyType 月报类型
|
|
|
|
+ * @param reportData 报告解析结果
|
|
|
|
+ * @param fileName 报告名称
|
|
|
|
+ * @param senderEmail 邮件发送人邮箱
|
|
|
|
+ * @param images 报告的收益和尾页png图片
|
|
*/
|
|
*/
|
|
private ReportData ocrReportData(Integer fileId,
|
|
private ReportData ocrReportData(Integer fileId,
|
|
ReportType reportType,
|
|
ReportType reportType,
|
|
|
|
+ ReportMonthlyType monthlyType,
|
|
ReportData reportData,
|
|
ReportData reportData,
|
|
String fileName,
|
|
String fileName,
|
|
String senderEmail,
|
|
String senderEmail,
|
|
@@ -754,18 +759,25 @@ public class EmailParseService {
|
|
}
|
|
}
|
|
// ocr识别尾页是否包含印章和联系人信息
|
|
// ocr识别尾页是否包含印章和联系人信息
|
|
if (parseRes != null && reportData.getBaseInfo() != null) {
|
|
if (parseRes != null && reportData.getBaseInfo() != null) {
|
|
- if (TG_EMAIL_LIST.contains(senderEmail)) {
|
|
|
|
- reportData.getBaseInfo().setWithSeals(true);
|
|
|
|
- } else {
|
|
|
|
- reportData.getBaseInfo().setWithSeals(parseRes.getWithSeals());
|
|
|
|
- if (fileName.contains("用印") && !Objects.equals(true, reportData.getBaseInfo().getWithSeals())) {
|
|
|
|
|
|
+ // 协会报告才设置印章标识
|
|
|
|
+ boolean isAmac = reportType == ReportType.ANNUALLY || reportType == ReportType.QUARTERLY
|
|
|
|
+ || (reportType == ReportType.MONTHLY && ReportMonthlyType.AMAC == monthlyType);
|
|
|
|
+ if (isAmac) {
|
|
|
|
+ if (TG_EMAIL_LIST.contains(senderEmail)) {
|
|
reportData.getBaseInfo().setWithSeals(true);
|
|
reportData.getBaseInfo().setWithSeals(true);
|
|
|
|
+ } else {
|
|
|
|
+ reportData.getBaseInfo().setWithSeals(parseRes.getWithSeals());
|
|
|
|
+ if (fileName.contains("用印") && !Objects.equals(true, reportData.getBaseInfo().getWithSeals())) {
|
|
|
|
+ reportData.getBaseInfo().setWithSeals(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ // 管理人报告才设置联系人标识
|
|
|
|
+ reportData.getBaseInfo().setWithContacts(parseRes.getWithContacts());
|
|
}
|
|
}
|
|
- reportData.getBaseInfo().setWithContacts(parseRes.getWithContacts());
|
|
|
|
}
|
|
}
|
|
// 首页和尾页不相等时解析首页的数据
|
|
// 首页和尾页不相等时解析首页的数据
|
|
- if (images.size() != 1) {
|
|
|
|
|
|
+ if (images.size() != 1 || parseRes == null) {
|
|
try {
|
|
try {
|
|
parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, images.get(0));
|
|
parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, images.get(0));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -851,6 +863,9 @@ public class EmailParseService {
|
|
if (reportData != null) {
|
|
if (reportData != null) {
|
|
return reportData;
|
|
return reportData;
|
|
}
|
|
}
|
|
|
|
+ if (reportType == null) {
|
|
|
|
+ reportType = ReportType.OTHER;
|
|
|
|
+ }
|
|
ReportBaseInfoDTO baseInfo = new ReportBaseInfoDTO(fileId);
|
|
ReportBaseInfoDTO baseInfo = new ReportBaseInfoDTO(fileId);
|
|
baseInfo.setReportName(fileName);
|
|
baseInfo.setReportName(fileName);
|
|
baseInfo.setReportType(reportType.name());
|
|
baseInfo.setReportType(reportType.name());
|
|
@@ -901,7 +916,7 @@ public class EmailParseService {
|
|
|
|
|
|
private EmailFileInfoDO saveEmailFileInfo(Integer emailId, String fileName, String filePath) {
|
|
private EmailFileInfoDO saveEmailFileInfo(Integer emailId, String fileName, String filePath) {
|
|
EmailFileInfoDO emailFileInfoDO = buildEmailFileInfoDO(emailId, fileName, filePath);
|
|
EmailFileInfoDO emailFileInfoDO = buildEmailFileInfoDO(emailId, fileName, filePath);
|
|
- emailFileInfoDO.setAiFileId(null);
|
|
|
|
|
|
+// emailFileInfoDO.setAiFileId(null);
|
|
if (emailFileInfoDO.getId() != null) {
|
|
if (emailFileInfoDO.getId() != null) {
|
|
this.emailFileInfoMapper.updateTimeById(emailFileInfoDO.getId(), new Date());
|
|
this.emailFileInfoMapper.updateTimeById(emailFileInfoDO.getId(), new Date());
|
|
return emailFileInfoDO;
|
|
return emailFileInfoDO;
|