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

@@ -0,0 +1,58 @@
package com.czg.product.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 数签子的外链渠道 实体类。
*
* @author ww
* @since 2025-12-24
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mk_ocr_count_stick")
public class MkOcrCountStick implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id
private Long id;
/**
* 渠道名称
*/
private String name;
/**
* 标记
*/
private String mark;
/**
* 地址
*/
private String url;
/**
* 状态 0/1
*/
private Integer status;
private Integer sort;
private String token;
private String account;
private String pwd;
}

View File

@@ -1,8 +1,11 @@
package com.czg.product.entity;
import com.czg.product.param.ConsInOutStockHeadParam;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkOcr;
import java.io.InputStream;
/**
* ocr识别结果 服务层。
*
@@ -11,4 +14,7 @@ import com.czg.market.entity.MkOcr;
*/
public interface MkOcrService extends IService<MkOcr> {
ConsInOutStockHeadParam ocrDetail(Long id);
Integer ocr(String originalFilename, InputStream inputStream, String type);
}

View File

@@ -10,7 +10,6 @@ import com.czg.product.vo.ConsCheckStockRecordVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import java.io.InputStream;
import java.util.List;
/**
@@ -25,7 +24,6 @@ public interface ConsStockFlowService extends IService<ConsStockFlow> {
* 手动入库
*
* @param param 手动出库入参
* @return
*/
ConsInOutStockHeadParam inStock(ConsInOutStockHeadParam param);
@@ -78,8 +76,4 @@ public interface ConsStockFlowService extends IService<ConsStockFlow> {
* @param entity 库存变动记录实体
*/
void saveFlow(ConsStockFlow entity);
Integer ocr(String originalFilename, InputStream inputStream);
ConsInOutStockHeadParam ocrDetail(Long id);
}

View File

@@ -0,0 +1,15 @@
package com.czg.product.service;
import com.czg.product.entity.MkOcrCountStick;
import com.mybatisflex.core.service.IService;
/**
* 数签子的外链渠道 服务层。
*
* @author ww
* @since 2025-12-24
*/
public interface MkOcrCountStickService extends IService<MkOcrCountStick> {
int getCountStick(byte[] stream, String fileName);
}

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())