进件 支付调整

This commit is contained in:
2026-01-08 15:58:52 +08:00
parent 3a0ca901f8
commit d321393e12
26 changed files with 1342 additions and 1452 deletions

View File

@@ -0,0 +1,68 @@
package com.czg;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse;
import com.aliyun.tea.*;
import com.czg.exception.CzgException;
import lombok.extern.slf4j.Slf4j;
/**
* @author ww
*/
@Slf4j
public class OcrUtils {
/**
* 阿里 ocr识别图片
* 本接口支持PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
* 图片长宽需要大于 15 像素,小于 8192 像素。
* 长宽比需要小于 50。长宽均大于 500px。
* 图片二进制文件不能超过 10MB。
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
*
* @param url 图片地址
* @param type IdCard 身份证
* BankCard 银行卡
* BusinessLicense 营业执照
* 目前使用的角色为 czg-oss@1413456038175003.onaliyun.com
* 需要 AliyunOCRFullAccess 权限
* AliyunBSSContractFullAccess 权限
* 文档地址 <a href="https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizealltext?spm=a2c4g.11186623.0.0.543669f32I79Gw#api-detail-35">
*/
public static JSONObject getInfoByImg(String accessKeyId, String accessKeySecret,
String url, String type) throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId(accessKeyId)
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret(accessKeySecret);
config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
com.aliyun.ocr_api20210707.Client client = new com.aliyun.ocr_api20210707.Client(config);
com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest recognizeAllTextRequest = new com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest()
.setUrl(url).setType(type);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
RecognizeAllTextResponse resp = client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime);
return JSONObject.from(resp.body.data);
} catch (TeaException error) {
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// // 错误 message
// System.out.println(error.getMessage());
// // 诊断地址
// System.out.println(error.getData().get("Recommend"));
// com.aliyun.teautil.Common.assertAsString(error.message);
log.error("识别失败, msg: {}", error.getMessage());
throw new CzgException(error.getMessage());
} catch (Exception error) {
// TeaException error = new TeaException(_error.getMessage(), _error);
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// // 错误 message
// System.out.println(error.getMessage());
// // 诊断地址
// System.out.println(error.getData().get("Recommend"));
// com.aliyun.teautil.Common.assertAsString(error.message);
log.error("识别失败, msg: {}", error.getMessage());
throw new CzgException(error.getMessage());
}
}
}