From afae2409d65e0c044b8119b3fd8f57e438c18a08 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期日, 09 十一月 2025 21:29:24 +0800
Subject: [PATCH] 修改了大量的代码块
---
archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java | 109 ++++++++++++++++++++++++++----------------------------
1 files changed, 52 insertions(+), 57 deletions(-)
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java
index 6b4c30d..20c9347 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/IArchiveDoublePdfGenerateServiceImpl.java
@@ -1,22 +1,21 @@
package com.ruoyi.service.impl;
import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.IArchiveDoublePdfGenerateService;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.ParseException;
-import org.apache.http.client.ClientProtocolException;
+
import cn.hutool.http.HttpRequest;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.springframework.stereotype.Service;
-import java.io.File;
-import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+
+import java.io.*;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -51,57 +50,53 @@
}
- public void testConnection() throws IOException {
- File pdfFile = new File("34.pdf");
- String base64 = java.util.Base64.getEncoder().encodeToString(Files.readAllBytes(pdfFile.toPath()));
+ public AjaxResult testConnection(MultipartFile multipartFile) throws IOException {
+
+ // 鍒涘缓涓存椂鏂囦欢
+ File file = File.createTempFile("temp", ".pdf");
+ // 灏� MultipartFile 杞瓨鍒扮洰鏍囨枃浠�
+ multipartFile.transferTo(file);
+
+ String response = HttpRequest.post("http://127.0.0.1:1224/api/doc/upload")
+ .contentType("multipart/form-data; boundary=<calculated when request is sent>")
+ .form("file", file)
+ .execute()
+ .body();
+
+ System.out.println(response);
+
+
+ JSONObject json = JSONUtil.parseObj(response);
+
+
+
+ // System.out.println(json.get("data"));
+
+
+
+
+
+ return AjaxResult.success(json);
+ // unicodeEscapeToChinese(response);
+ // System.out.println(res);
+ // unicodeEscapeToChinese(res);
+
+ }
+
+ @Override
+ public AjaxResult getDownLoadInfo(String id) {
JSONObject inputObject = new JSONObject();
- inputObject.put("base64", base64);
- //inputObject.put("options", new JSONObject().put("ocr.language", "models/config_chinese.txt"));
-
- String response = HttpRequest.post(OCRServer+ "api/doc/result")
+ inputObject.put("id", id);
+ String res = HttpRequest.post("http://127.0.0.1:1224/api/doc/download")
+ // .contentType("multipart/form-data; boundary=<calculated when request is sent>")
+ //.form("file", file)
.body(inputObject.toString())
.contentType("application/json")
.execute()
.body();
- unicodeEscapeToChinese(response);
- // System.out.println("unicodeEscapeToChinese("\u672a\u586b\u5199id\u3002"));
-// // 鑾峰緱Http瀹㈡埛绔�(鍙互鐞嗚В涓�:浣犲緱鍏堟湁涓�涓祻瑙堝櫒;娉ㄦ剰:瀹為檯涓奌ttpClient涓庢祻瑙堝櫒鏄笉涓�鏍风殑)
-// CloseableHttpClient httpClient = HttpClientBuilder.create().build();
-// // 鍒涘缓Get璇锋眰
-// HttpGet httpGet = new HttpGet(OCRServer);
-//
-// // 鍝嶅簲妯″瀷
-// CloseableHttpResponse response = null;
-// try {
-// // 鐢卞鎴风鎵ц(鍙戦��)Get璇锋眰
-// response = httpClient.execute(httpGet);
-// // 浠庡搷搴旀ā鍨嬩腑鑾峰彇鍝嶅簲瀹炰綋
-// HttpEntity responseEntity = response.getEntity();
-// System.out.println("鍝嶅簲鐘舵�佷负:" + response.getStatusLine());
-// if (responseEntity != null) {
-// System.out.println("鍝嶅簲鍐呭闀垮害涓�:" + responseEntity.getContentLength());
-// System.out.println("鍝嶅簲鍐呭涓�:" + EntityUtils.toString(responseEntity));
-// }
-// } catch (ClientProtocolException e) {
-// e.printStackTrace();
-// } catch (ParseException e) {
-// e.printStackTrace();
-// } catch (IOException e) {
-// e.printStackTrace();
-// } finally {
-// try {
-// // 閲婃斁璧勬簮
-// if (httpClient != null) {
-// httpClient.close();
-// }
-// if (response != null) {
-// response.close();
-// }
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// }
+ JSONObject json = JSONUtil.parseObj(res);
+ return AjaxResult.success(json);
}
--
Gitblit v1.9.1