From df1ffbe941d06d6fd61df6d968cdfea783ad03de Mon Sep 17 00:00:00 2001
From: liyj <1003249715@qq.com>
Date: Thu, 05 Sep 2024 15:31:20 +0800
Subject: [PATCH] 1、新增一期综治中心数据对接微服务2
---
dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java b/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java
index 463a767..a093e16 100644
--- a/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java
+++ b/dyh-service/dyh-sys/src/main/java/cn/huge/module/file/controller/web/FileInfoWebController.java
@@ -1,7 +1,6 @@
package cn.huge.module.file.controller.web;
import cn.huge.base.common.exception.ClientException;
-import cn.huge.module.sys.dto.IdcardOcrResultDTO;
import cn.huge.module.utils.BaiduOcrUtils;
import cn.huge.base.common.utils.ContentTypeUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
@@ -185,6 +184,33 @@
}
/**
+ * ocr识别文字
+ * @url {ctx}/api/web/fileInfo/recognitionText?ownerId=&ownerType=
+ * @param request
+ * @return Object
+ */
+ @PostMapping(value = "/recognitionText")
+ public Object recognitionText(MultipartHttpServletRequest request){
+ try{
+ Map<String , Object> result = Maps.newHashMap();
+ Iterator<String> itr = request.getFileNames();
+ while (itr.hasNext()) {
+ MultipartFile file = request.getFile(itr.next());
+ try{
+ Map<String , Object> map = BaiduOcrUtils.ocrText(file.getBytes());
+ result.put("ocrResult", map);
+ }catch (Exception e){
+ log.error("Controller接口[FileInfoController.recognitionText]请求异常:"+e, e);
+ return ReturnFailUtils.getRepInfo("OCR失败!");
+ }
+ }
+ return ReturnSucUtils.getRepInfo("识别成功", result);
+ }catch (Exception e){
+ return ReturnFailUtils.getRepInfo(e.getMessage());
+ }
+ }
+
+ /**
* 查看附件组件-分类查询附件
* @url {ctx}/api/web/fileInfo/listFileByCat
* @param mainId 所属业务主体编号
--
Gitblit v1.8.0