|
@@ -166,21 +166,11 @@ public class EmailParseService {
|
|
|
while (entryIterator.hasNext()) {
|
|
|
Map.Entry<EmailContentInfoDTO, List<EmailZipFileDTO>> entry = entryIterator.next();
|
|
|
EmailContentInfoDTO key = entry.getKey();
|
|
|
- String emailTitle = key.getEmailTitle();
|
|
|
List<EmailZipFileDTO> dtos = entry.getValue();
|
|
|
|
|
|
List<Integer> types = ListUtil.list(false);
|
|
|
types.add(key.getEmailType());
|
|
|
if (CollUtil.isNotEmpty(dtos)) {
|
|
|
- Iterator<EmailZipFileDTO> iterator = dtos.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- EmailZipFileDTO dto = iterator.next();
|
|
|
- String filename = dto.getFilename();
|
|
|
- if (filename != null && filename.contains("复核函")) {
|
|
|
- log.warn("邮件{} 附件中的压缩文件{} 是复核函,不用解析上传。", emailTitle, filename);
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
List<Integer> list = dtos.stream().map(EmailZipFileDTO::getEmailType).distinct().toList();
|
|
|
CollUtil.addAllIfNotContains(types, list);
|
|
|
}
|
|
@@ -314,8 +304,13 @@ public class EmailParseService {
|
|
|
Iterator<EmailZipFileDTO> iterator = dtos.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
EmailZipFileDTO dto = iterator.next();
|
|
|
- Integer emailType = dto.getEmailType();
|
|
|
String filename = dto.getFilename();
|
|
|
+ // 删除复核函或基金合同
|
|
|
+ if (filename.contains("复核函") || filename.contains("基金合同")) {
|
|
|
+ log.warn("邮件{} 中的报告{} 是复核函或基金合同,不用解析上传。", emailTitle, filename);
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ Integer emailType = dto.getEmailType();
|
|
|
int fileSize = dto.getFileSize();
|
|
|
int count = 0;
|
|
|
if (Objects.equals(emailType, EmailTypeConst.REPORT_LETTER_EMAIL_TYPE)) {
|
|
@@ -429,15 +424,10 @@ public class EmailParseService {
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("报告[{}] 生成的图片地址是:{}", fileName, images);
|
|
|
}
|
|
|
- // 首页和尾页相等
|
|
|
- if (images.size() == 1) {
|
|
|
- images.add(images.get(0));
|
|
|
- }
|
|
|
} catch (Exception e) {
|
|
|
log.warn("报告[{}] 生成图片失败:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
}
|
|
|
- } else if (Objects.equals(ReportParserFileType.IMG_PNG, fileType)) {
|
|
|
- images.add(filepath);
|
|
|
+ } else if (Objects.equals(ReportParserFileType.IMG, fileType)) {
|
|
|
images.add(filepath);
|
|
|
}
|
|
|
|
|
@@ -524,12 +514,14 @@ public class EmailParseService {
|
|
|
* @param images 报告的收益和尾页png图片
|
|
|
*/
|
|
|
private void ocrReportData(ReportData reportData, String fileName, List<String> images) {
|
|
|
- if (reportData == null || CollUtil.isEmpty(images) || images.size() != 2) {
|
|
|
+ if (reportData == null || CollUtil.isEmpty(images)) {
|
|
|
return;
|
|
|
}
|
|
|
OCRParseData parseRes = null;
|
|
|
try {
|
|
|
- parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, images.get(1));
|
|
|
+ // 首页和尾页相等时只读首页
|
|
|
+ String imageUrl = images.size() == 1 ? images.get(0) : images.get(1);
|
|
|
+ parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, imageUrl);
|
|
|
} catch (Exception e) {
|
|
|
log.error("报告{} OCR识别印章和联系人出错:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
}
|
|
@@ -551,10 +543,13 @@ public class EmailParseService {
|
|
|
if ((reportData.getBaseInfo() != null && reportData.getBaseInfo().getReportDate() == null)
|
|
|
|| (reportData.getFundInfo() != null && StrUtil.isBlank(reportData.getFundInfo().getFundName()))
|
|
|
|| (reportData.getFundInfo() != null && StrUtil.isBlank(reportData.getFundInfo().getFundCode()))) {
|
|
|
- try {
|
|
|
- parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, images.get(0));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("报告{} OCR识别首页基金名称和报告日期出错:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
+ // 首页和尾页不相等时解析首页的数据
|
|
|
+ if (images.size() != 1) {
|
|
|
+ try {
|
|
|
+ parseRes = new OCRReportParser().parse(fileName, this.ocrParserUrl, images.get(0));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("报告{} OCR识别首页基金名称和报告日期出错:{}", fileName, ExceptionUtil.stacktraceToString(e));
|
|
|
+ }
|
|
|
}
|
|
|
if (reportData.getBaseInfo() != null && parseRes != null) {
|
|
|
Date reportDate = DateUtils.toDate(parseRes.getReportDate());
|