ocr 数签子

登录更新了用户名称的问题
更新用户信息的问题
This commit is contained in:
2025-12-25 11:18:14 +08:00
parent 22a5ae8f68
commit bae1762dba
18 changed files with 866 additions and 388 deletions

View File

@@ -34,7 +34,6 @@ public class AliOcrUtil {
* <p>使用凭据初始化账号Client</p>
*
* @return Client
* @throws Exception
*/
public static com.aliyun.bailian20231229.Client createClient() {
@@ -114,7 +113,7 @@ public class AliOcrUtil {
// 复制代码运行请自行打印 API 的返回值
DescribeFileResponse describeFileResponse = client.describeFileWithOptions("llm-9zg04s7wlbvi32tq", fileId, headers, runtime);
log.info("file status: {}", describeFileResponse.getBody());
log.info("file status: {}", describeFileResponse.getStatusCode());
return describeFileResponse.getBody().getData() != null && "FILE_IS_READY".equals(describeFileResponse.getBody().getData().getStatus());
} catch (Exception error) {
throw new RuntimeException(error);
@@ -154,7 +153,8 @@ public class AliOcrUtil {
}
public static String appCall(byte[] bytes, String fileName) {
//地址 https://bailian.console.aliyun.com
public static String appCall(byte[] bytes, String fileName, String detail) {
String id;
try {
id = getSessionId(bytes, fileName);
@@ -164,7 +164,7 @@ public class AliOcrUtil {
ApplicationParam param = ApplicationParam.builder()
.apiKey("sk-2343af4413834ad1ab43b036e3a903de")
.appId("cd612ac509a4499f8ac68a656532d4ae")
.prompt("你是一名票据OCR结构化专家请从我提供的票据图片中智能提取信息并只输出JSON不得添加解释、不补充不存在内容、不得返回空字符串、字段缺失填null、字段不可省略、数字一律用字符串使用以下固定JSON结构{\"documentType\":\"\",\"orderNumber\":\"\",\"date\":\"\",\"customerName\":\"\",\"operator\":\"\",\"items\":[{\"conName\":\"\",\"spec\":\"\",\"unitName\":\"\",\"inOutNumber\":\"\",\"purchasePrice\":\"\",\"subTotal\":\"\"}],\"totalAmount\":\"\",\"remark\":\"\"}。字段映射规则documentType对应单据类型/销售单/采购单/出货单orderNumber对应单号/编号/Nodate对应日期/开单日期customerName对应客户名称/收货单位/供应商operator对应业务员/经办人/制单人/操作员items.conName对应品名/名称items.spec对应规格/型号items.unitName对应单位items.inOutNumber对应数量items.purchasePrice对应单价items.subTotal对应金额/小计totalAmount对应总金额/合计金额remark对应备注。严禁生成图片中不存在的字段内容看不清或未出现的字段必须为null不允许推测或补全不得生成多余字段items只能根据识别到的行生成不得虚构。必须能识别旋转、倾斜、模糊、撕裂、光照差异、列顺序混乱、无表格线等情况并尽量恢复信息。最终输出必须是纯JSON不得包含任何非JSON字符。")
.prompt(detail)
.ragOptions(RagOptions.builder()
.sessionFileIds(List.of(id))
.build())