From 525e8dd14e4befe434cc457d965fbc3e6348dadc Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Sat, 15 Mar 2025 00:19:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text/ARecognizeVATInvoiceRequest.java | 2 +- ...bileNetworkTimeVerificationController.java | 2 +- .../tax/RecognizeVATInvoiceController.java | 85 ++++++++ .../tax/RecognizeVINCodeController.java | 89 +++++++++ .../api/controller/request/CommonRequest.java | 19 ++ .../request/tax/ARecognizeVATInvoiceReq.java | 17 ++ .../resp/tax/RecognizeVATInvoiceResp.java | 184 ++++++++++++++++++ .../resp/tax/RecognizeVINCodeResp.java | 31 +++ 8 files changed, 427 insertions(+), 2 deletions(-) create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVATInvoiceController.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVINCodeController.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/request/CommonRequest.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/request/tax/ARecognizeVATInvoiceReq.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVATInvoiceResp.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVINCodeResp.java diff --git a/api-third/src/main/java/com/heyu/api/alibaba/request/common/text/ARecognizeVATInvoiceRequest.java b/api-third/src/main/java/com/heyu/api/alibaba/request/common/text/ARecognizeVATInvoiceRequest.java index db20a78..23f51a6 100644 --- a/api-third/src/main/java/com/heyu/api/alibaba/request/common/text/ARecognizeVATInvoiceRequest.java +++ b/api-third/src/main/java/com/heyu/api/alibaba/request/common/text/ARecognizeVATInvoiceRequest.java @@ -16,7 +16,7 @@ public class ARecognizeVATInvoiceRequest extends ACommonTextRequest { * 枚举值: * jpg */ - public String fileType; + public String fileType = "jpg"; diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/mobile/MobileNetworkTimeVerificationController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/mobile/MobileNetworkTimeVerificationController.java index 1e1382d..db7410e 100644 --- a/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/mobile/MobileNetworkTimeVerificationController.java +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/mobile/MobileNetworkTimeVerificationController.java @@ -23,7 +23,7 @@ import java.util.Map; @RestController @RequestMapping("/mobile/network/time") @NotIntercept -public class MobileNetworkTimeVerificationController { +public class MobileNetworkTimeVerificationController { public final static Map checkResult = new HashMap<>(); diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVATInvoiceController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVATInvoiceController.java new file mode 100644 index 0000000..10a80f3 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVATInvoiceController.java @@ -0,0 +1,85 @@ +package com.heyu.api.controller.certificate.tax; + + +import com.aliyun.ocr20191230.models.RecognizeVATInvoiceResponse; +import com.aliyun.ocr20191230.models.RecognizeVATInvoiceResponseBody; +import com.heyu.api.alibaba.handle.common.text.ARecognizeVATInvoiceHandle; +import com.heyu.api.alibaba.request.common.text.ARecognizeVATInvoiceRequest; +import com.heyu.api.controller.BaseController; +import com.heyu.api.controller.resp.tax.RecognizeVATInvoiceResp; +import com.heyu.api.data.annotation.CacheResult; +import com.heyu.api.data.annotation.NotIntercept; +import com.heyu.api.data.utils.ApiR; +import com.heyu.api.data.utils.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/**** + *https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVATInvoice?tab=DEMO&lang=JAVA + * + * + * 增值税发票识别 RecognizeVATInvoice + * + * + * 功能描述 + * 增值税发票识别能力可以识别增值税发票(电子发票和纸质发票)关键字段内容,包括:校验码、复核人、开票人、发票代码、收款人等。 + * + * + */ +@Slf4j +@RestController +@RequestMapping("/vat/invoice") +@NotIntercept +public class RecognizeVATInvoiceController extends BaseController { + + + @Autowired + private ARecognizeVATInvoiceHandle arRecognizeVATInvoiceHandle; + + + @RequestMapping("/recognize") + @CacheResult + public R recognize(ARecognizeVATInvoiceRequest request) { + + + RecognizeVATInvoiceResp resp = new RecognizeVATInvoiceResp(); + + ApiR aR = arRecognizeVATInvoiceHandle.handle(request); + if (aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode())) { + RecognizeVATInvoiceResponse response = aR.getData(); + RecognizeVATInvoiceResponseBody responseBody = response.getBody(); + RecognizeVATInvoiceResponseBody.RecognizeVATInvoiceResponseBodyData responseBodyData = responseBody.getData(); + RecognizeVATInvoiceResponseBody.RecognizeVATInvoiceResponseBodyDataContent content = responseBodyData.getContent(); + + resp.setPayerAddress(content.getPayerAddress()); + resp.setPayeeRegisterNo(content.getPayeeRegisterNo()); + resp.setPayeeBankName(content.getPayeeBankName()); + resp.setInvoiceNo(content.getInvoiceNo()); + resp.setPayerRegisterNo(content.getPayerRegisterNo()); + resp.setChecker(content.getChecker()); + resp.setTaxAmount(content.getTaxAmount()); + resp.setInvoiceCode(content.getInvoiceCode()); + resp.setWithoutTaxAmount(content.getWithoutTaxAmount()); + resp.setInvoiceAmount(content.getInvoiceAmount()); + resp.setAntiFakeCode(content.getAntiFakeCode()); + resp.setPayerName(content.getPayerName()); + resp.setPayee(content.getPayee()); + resp.setSumAmount(content.getSumAmount()); + resp.setPayerBankName(content.getPayerBankName()); + resp.setClerk(content.getClerk()); + resp.setPayeeName(content.getPayeeName()); + resp.setPayeeAddress(content.getPayeeAddress()); + resp.setInvoiceCode(content.getInvoiceCode()); + resp.setItemName(content.getItemName()); + + return R.ok().setData(resp); + } + + + return R.ok(); + } + + +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVINCodeController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVINCodeController.java new file mode 100644 index 0000000..c2723ae --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/certificate/tax/RecognizeVINCodeController.java @@ -0,0 +1,89 @@ +package com.heyu.api.controller.certificate.tax; + + +import com.aliyun.ocr20191230.models.RecognizeVINCodeResponse; +import com.aliyun.ocr20191230.models.RecognizeVINCodeResponseBody; +import com.heyu.api.alibaba.handle.common.text.ARecognizeVINCodeHandle; +import com.heyu.api.alibaba.request.common.text.ARecognizeVINCodeRequest; +import com.heyu.api.controller.BaseController; +import com.heyu.api.controller.request.tax.ARecognizeVATInvoiceReq; +import com.heyu.api.controller.resp.tax.RecognizeVINCodeResp; +import com.heyu.api.data.annotation.CacheResult; +import com.heyu.api.data.annotation.NotIntercept; +import com.heyu.api.data.utils.ApiR; +import com.heyu.api.data.utils.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/*** + *https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVINCode?tab=DEMO&lang=JAVA + * + * + * VIN码识别 + * + * RecognizeVINCode + *功能描述 + * + * + * + * VIN 码识别能力可以识别车辆 VIN 码,输出车辆 VIN 码数值。 + */ +@Slf4j +@RestController +@RequestMapping("/vat/invoice") +@NotIntercept +public class RecognizeVINCodeController extends BaseController { + + + @Autowired + private ARecognizeVINCodeHandle arecognizeVINCodeHandle; + + + @RequestMapping("/recognize") + @CacheResult + public R recognize(ARecognizeVATInvoiceReq request) { + RecognizeVINCodeResp resp = new RecognizeVINCodeResp(); + + ARecognizeVINCodeRequest aRecognizeVINCodeRequest = new ARecognizeVINCodeRequest(); + aRecognizeVINCodeRequest.setImageUrl(request.getImageUrl()); + aRecognizeVINCodeRequest.setImageBase64(request.getImageBase64()); + + ApiR aR = arecognizeVINCodeHandle.handle(aRecognizeVINCodeRequest); + if (aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode())) { + RecognizeVINCodeResponseBody responseBody = aR.getData().getBody(); + RecognizeVINCodeResponseBody.RecognizeVINCodeResponseBodyData responseBodyData = responseBody.getData(); + resp.setVinCode(responseBodyData.getVinCode()); + return R.ok().setData(resp); + } + return R.ok(); + } + +} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/request/CommonRequest.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/request/CommonRequest.java new file mode 100644 index 0000000..19d0308 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/request/CommonRequest.java @@ -0,0 +1,19 @@ +package com.heyu.api.controller.request; + +import com.heyu.api.data.dto.BaseRequest; +import lombok.Data; + + + +@Data +public class CommonRequest extends BaseRequest { + /** + * 图片的url + */ + private String imageUrl; + + /** + * base 64 编码 + */ + private String imageBase64; +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/request/tax/ARecognizeVATInvoiceReq.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/request/tax/ARecognizeVATInvoiceReq.java new file mode 100644 index 0000000..47b5bd8 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/request/tax/ARecognizeVATInvoiceReq.java @@ -0,0 +1,17 @@ +package com.heyu.api.controller.request.tax; + + +import com.heyu.api.controller.request.CommonRequest; +import lombok.Data; + +/*** + * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVINCode?tab=DEMO&lang=JAVA + * + * + * + */ +@Data +public class ARecognizeVATInvoiceReq extends CommonRequest { + + +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVATInvoiceResp.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVATInvoiceResp.java new file mode 100644 index 0000000..817c376 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVATInvoiceResp.java @@ -0,0 +1,184 @@ +package com.heyu.api.controller.resp.tax; + + +import lombok.Data; + + +/*** + * + * + * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVATInvoice?tab=DOC&lang=JAVA + * + * + * 增值税发票识别 RecognizeVATInvoice + */ +@Data +public class RecognizeVATInvoiceResp { + + /*** + * 校验码。 + * + * 示例值: + * 02702870934284730434 + */ + public String antiFakeCode; + + /*** + * 复核人。 + * + * 示例值: + * 张三 + */ + public String checker; + + /*** + * 开票人。 + * + * 示例值: + * 张三 + */ + public String clerk; + + + /*** + * 价税合计(小写)。 + * + * 示例值: + * 200.00 + */ + public String invoiceAmount; + + + /*** + * 发票代码。 + * + * 示例值: + * 031001600311 + */ + public String invoiceCode; + + /*** + * 开票日期。 + * + * 示例值: + * 20190415 + */ + public String invoiceDate; + + /*** + * 发票号码。 + * + * 示例值: + * 03753869 + */ + public String invoiceNo; + + /** + *

1

+ */ + + public java.util.List itemName; + + /*** + * 收款人。 + * + * 示例值: + * 张三 + */ + public String payee; + + /*** + * 销售方地址、电话。 + * + * 示例值: + * 上海虹桥机场迎宾二路161号22342185 + */ + public String payeeAddress; + + /*** + * 销售方开户行及账号。 + * + * 示例值: + * 中国银行浙江省分行35845832**** + */ + + public String payeeBankName; + + + /*** + * 销售方名称。 + * + * 示例值: + * 上海机场(集团)有限公司 + */ + public String payeeName; + + + /*** + * 销售方纳税人识别号。 + * + * 示例值: + * 91420200000123403 + */ + public String payeeRegisterNo; + + + /*** + * 购买方地址、电话。 + * + * 示例值: + * 浙江省杭州市西湖区杭大路9号聚龙大厦西区15-18楼0571-87901580 + */ + public String payerAddress; + + /*** + * 购买方开户行及账号。 + * + * 示例值: + * 6221************1234 + */ + public String payerBankName; + + /*** + * 购买方名称。 + * + * 示例值: + * 三号技术有限责任公司 + */ + public String payerName; + + /*** + * 购买方纳税人识别号。 + * + * 示例值: + * 91420200000123403 + */ + public String payerRegisterNo; + + /*** + * 价税合计(大写)。 + * + * 示例值: + * 87 + */ + public String sumAmount; + + /*** + * 合计税额。 + * + * 示例值: + * 9.52 + */ + public String taxAmount; + + /*** + * 合计金额。 + * + * 示例值: + * 190.48 + */ + public String withoutTaxAmount; + + + +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVINCodeResp.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVINCodeResp.java new file mode 100644 index 0000000..535b178 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/resp/tax/RecognizeVINCodeResp.java @@ -0,0 +1,31 @@ +package com.heyu.api.controller.resp.tax; + + +import com.heyu.api.data.dto.BaseRequest; +import com.heyu.api.data.dto.BaseResp; +import lombok.Data; + +/*** + * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeVINCode?tab=DOC&lang=JAVA + * + * + */ +@Data +public class RecognizeVINCodeResp extends BaseResp { + + + /*** + * 识别的车辆 VIN 码。 + * + * 示例值: + * LVBB2FAF777999888 + */ + private String vinCode; + + + + + + + +}