From 6e7df467bdae2f2961ee77c9b45469b9fc0403c8 Mon Sep 17 00:00:00 2001 From: "zhenghaiyang@ele-cloud.com" Date: Sat, 15 Apr 2023 15:51:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E7=AE=B1=E9=87=87=E9=9B=86-=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=BC=A0=E5=88=B0=E7=A5=A8=E5=A4=B9=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/OpenServicePlatformServiceImpl.java | 2 - .../model/ocr/SnpjInvoiceTypeEnum.java | 78 +++++++++++++++++++ .../com/dxhy/core/task/SnEmailGatherTask.java | 5 +- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java index 8fe4a8f7..1710424c 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java @@ -205,7 +205,6 @@ public class OpenServicePlatformServiceImpl implements IOpenServicePlatformServi */ public List OcrToSn(String picture){ //判断是否为图片流文件, 兼容公司平台进行base64解密 - String str = Base64Decoder.decodeStr(picture); String requestUrl = snOcrUrl; String result = FileUtil.uploadFile(requestUrl, Base64Decoder.decode(picture)); if(StringUtils.isBlank(result)){ @@ -227,7 +226,6 @@ public class OpenServicePlatformServiceImpl implements IOpenServicePlatformServi */ public static List OcrToSnTest(String picture){ //判断是否为图片流文件, 兼容公司平台进行base64解密 - String str = Base64Decoder.decodeStr(picture); String requestUrl = "http://192.168.33.102:30006/cci_ai/service/v1/receipt_crop_and_recog?crop_complete_image=1"; String result = FileUtil.uploadFile(requestUrl, Base64Decoder.decode(picture)); if(StringUtils.isBlank(result)){ diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java new file mode 100644 index 00000000..0dc78f77 --- /dev/null +++ b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java @@ -0,0 +1,78 @@ +package com.dxhy.core.service.openservice.model.ocr; + +import lombok.AllArgsConstructor; + +@AllArgsConstructor +public enum SnpjInvoiceTypeEnum { + + TAX_SPECIAL_INVOICE("01","100", "增值税专用发票"), + TAX_INVOICE("04","101", "增值税普通发票" ), + ELECTRONIC_INVOICE("10","102","增值税电子普通发票"), + ROLL_TICKET("11","103","增值税普通发票(卷票)"), + MOTOR_VEHICLE_SALE("15","104","机动车销售统一发票"), + USED_CAR_SALES("15","105","二手车销售统一发票"), + QUOTA_INVOICE("95","106","定额发票"), + AIRCRAFT_INVOICE("97","107","机打发票"), + TAXI_TICKETS("91","108","出租车发票"), + RAILWAY_TICKET("92","109","火车票"), + PASSENGER_TICKET("94","110","客运汽车票"), + FLIGHT_ITINERARY("93","111","航空运输电子客票行程单"), + STEAMER_TICKET("00","112","船票"), + TOLL_ROADS("98","113","过路费"), + RECEIPT("96","115","小票"), + DIDI_ITINERARY("86","116","滴滴出行行程单"), + DUTY_PAID_PROOF("87","117","完税证明"), + ELECTRONIC_INVOICE_ITINERARY("14","118","增值税电子普通发票(通行费)"), +// ELECTRONIC_INVOICE_QUKUAILIAN("119","区块链发票", ""), +// PLACE_AIRCRAFT_INVOICE("120","浙江通用机打发票", ""), + ELECTRONIC_OFD_INVOICE("04","121","增值税电子专用发票"), + ELECTRONIC_TAX_SPECIAL_INVOICE("31","130","电子发票(增值税专用发票)"), + ELECTRONIC_TAX_INVOICE("32","131","电子发票(普通发票)"), +// FINAL_STATEMENT("200","结算单", ""), +// RECEIPT_OF_RECEIPT("201","验收单", ""), + IMAGE_OTHERS("00","444","其他"); + + private String key; + + private String value; + + private String msg; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public static String getVal(String key) { + for (SnpjInvoiceTypeEnum typeEnum : SnpjInvoiceTypeEnum.values()) { + if (typeEnum.key.equals(key)) { + return typeEnum.getValue(); + } + } + return null; + } + + public static void main(String[] args) { + String val = getVal("00"); + System.out.println(val); + } +} diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java index 32aab53b..622f3e94 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java @@ -19,6 +19,7 @@ import com.dxhy.core.service.mailGather.EmailMaintainService; import com.dxhy.core.service.mailGather.MailGatherLogService; import com.dxhy.core.service.openservice.IOpenServicePlatformService; import com.dxhy.core.service.openservice.impl.OpenServicePlatformServiceImpl; +import com.dxhy.core.service.openservice.model.ocr.SnpjInvoiceTypeEnum; import com.dxhy.core.util.EmailParseUtils; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -163,7 +164,7 @@ public class SnEmailGatherTask { map.put("emailName",emailName); String pdfStream = map.get("pdfStream"); if(StringUtils.isNotBlank(pdfStream)){ - List openServiceOcrs = OpenServicePlatformServiceImpl.OcrToSnTest(pdfStream); + List openServiceOcrs = openServicePlatformService.ocrInvoice(pdfStream); if(openServiceOcrs != null && !openServiceOcrs.isEmpty()){ Map ocrResult = convertToOcrResult(openServiceOcrs, map, maintainVo); try { @@ -236,7 +237,7 @@ public class SnEmailGatherTask { resultToyxVo.setBuyerName(invoiceOcrData.getGMFMC()); resultToyxVo.setSellerName(invoiceOcrData.getXHFMC()); resultToyxVo.setFileName(map.get("fileName")); - resultToyxVo.setFileType("102"); + resultToyxVo.setFileType(SnpjInvoiceTypeEnum.getVal(openServiceOcr.getFPLXDM())); resultToyxVo.setFileByte(map.get("pdfStream")); resultToyxVo.setEmail(map.get("emailName")); resultToyxVo.setEmployeeId(maintainVo.getUserId());