Skip to content
Snippets Groups Projects
Commit 353a0844 authored by ah_zjn's avatar ah_zjn
Browse files

ocr识别接口调整

parent 43478a52
Branches feature/zhaojinnan
1 merge request!111ocr识别接口调整
Pipeline #166084 failed with stage
......@@ -492,14 +492,32 @@ public class CommServiceImpl implements CommService {
return null;
}
log.info("调用OCR接口...");
/** 接口停用 2024年12月18日
JSONObject jsonObject = new JSONObject();
jsonObject.put("file_url", url);
String result = HttpRequest.post(ocrUrl).contentType("application/json; charset=UTF-8").timeout(1000 * 60 * 10).setConnectionTimeout(1000 * 60 * 10).body(jsonObject.toString()).execute().body();
//String result= HttpUtils.doPost(ocrUrl,jsonObject.toString());
*/
//OCR文档处理(新)
//API: https://admin.aiagentsflow.com/document/ocr
//示例参数(body): { "file_list": [ { "file_id": "test", "file_url": "http://", "file_base64": "" } ], "return_horizontal_base64": "", "return_image_base64": "", "image_enhance": "" }
JSONObject ocrParam=new JSONObject();
JSONArray file_list=new JSONArray();
JSONObject file=new JSONObject();
file.put("file_id", childCareFeeFilesEntity.getFileName());
file.put("file_url", url);
file.put("file_base64", "");
file_list.add(file);
ocrParam.put("file_list", file_list);
ocrParam.put("return_horizontal_base64", false);
ocrParam.put("return_image_base64", false);
ocrParam.put("image_enhance", false);
log.info("OCR接口 入参:..." + ocrParam.toString());
String result = HttpRequest.post(ocrUrl).contentType("application/json; charset=UTF-8").timeout(1000 * 60 * 10).setConnectionTimeout(1000 * 60 * 10).body(ocrParam.toString()).execute().body();
log.info("OCR接口 返回信息:..." + result);
JSONObject recognizeOutResult = JSONObject.parseObject(result);
if (recognizeOutResult.get("code").equals(200)) {
String content = recognizeOutResult.get("content").toString();
//String content = recognizeOutResult.get("content").toString();
String content = recognizeOutResult.getJSONArray("data").getJSONObject(0).getString("file_content");
oCRLogEntity.setResult(content);
this.ocrLogMapper.insert(oCRLogEntity);
return content;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment