|
@@ -495,7 +495,7 @@ public class EmailParseService {
|
|
|
}
|
|
|
}
|
|
|
// ocr信息提取
|
|
|
- this.ocrReportData(reportData, fileName, images);
|
|
|
+ this.ocrReportData(reportType, reportData, fileName, images);
|
|
|
parserWatch.stop();
|
|
|
if (log.isInfoEnabled()) {
|
|
|
log.info("报告{}解析结果为{},耗时{}ms", fileName, reportData, parserWatch.getTotalTimeMillis());
|
|
@@ -513,29 +513,32 @@ public class EmailParseService {
|
|
|
* @param fileName 报告名称
|
|
|
* @param images 报告的收益和尾页png图片
|
|
|
*/
|
|
|
- private void ocrReportData(ReportData reportData, String fileName, List<String> images) {
|
|
|
+ private void ocrReportData(ReportType reportType, ReportData reportData, String fileName, List<String> images) {
|
|
|
if (reportData == null || CollUtil.isEmpty(images)) {
|
|
|
return;
|
|
|
}
|
|
|
OCRParseData parseRes = null;
|
|
|
- try {
|
|
|
- // 首页和尾页相等时只读首页
|
|
|
- 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));
|
|
|
- }
|
|
|
- // ocr识别尾页是否包含印章和联系人信息
|
|
|
- if (parseRes != null) {
|
|
|
- if (reportData.getBaseInfo() != null) {
|
|
|
- Date reportDate = DateUtils.toDate(parseRes.getReportDate());
|
|
|
- if (reportData.getBaseInfo().getReportDate() == null && reportDate != null) {
|
|
|
- reportData.getBaseInfo().setReportDate(reportDate);
|
|
|
- }
|
|
|
- reportData.getBaseInfo().setWithSeals(parseRes.getWithSeals());
|
|
|
- reportData.getBaseInfo().setWithContacts(parseRes.getWithContacts());
|
|
|
- if (fileName.contains("用印") && !Objects.equals(true, reportData.getBaseInfo().getWithSeals())) {
|
|
|
- reportData.getBaseInfo().setWithSeals(true);
|
|
|
+ // 报告才识别尾页的印章和联系人,确认单不识别尾页
|
|
|
+ if (ReportType.LETTER != reportType) {
|
|
|
+ try {
|
|
|
+ // 首页和尾页相等时只读首页
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ // ocr识别尾页是否包含印章和联系人信息
|
|
|
+ if (parseRes != null) {
|
|
|
+ if (reportData.getBaseInfo() != null) {
|
|
|
+ Date reportDate = DateUtils.toDate(parseRes.getReportDate());
|
|
|
+ if (reportData.getBaseInfo().getReportDate() == null && reportDate != null) {
|
|
|
+ reportData.getBaseInfo().setReportDate(reportDate);
|
|
|
+ }
|
|
|
+ reportData.getBaseInfo().setWithSeals(parseRes.getWithSeals());
|
|
|
+ reportData.getBaseInfo().setWithContacts(parseRes.getWithContacts());
|
|
|
+ if (fileName.contains("用印") && !Objects.equals(true, reportData.getBaseInfo().getWithSeals())) {
|
|
|
+ reportData.getBaseInfo().setWithSeals(true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|