diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java index 5b2f8ac..3f751a8 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/RestUtil.java @@ -5,6 +5,7 @@ import com.xkcoding.http.HttpUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.config.RestTemplateConfig; +import org.jeecg.config.sign.util.HttpUtils; import org.springframework.http.*; import org.springframework.http.client.SimpleClientHttpRequestFactory; import org.springframework.http.converter.StringHttpMessageConverter; @@ -13,6 +14,7 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import java.net.URL; +import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStoreException; @@ -284,21 +286,15 @@ public class RestUtil { } catch (KeyStoreException e) { e.printStackTrace(); } - MultiValueMap headers = new LinkedMultiValueMap(); - headers.add("Accept", "*/*"); - headers.add("Content-Type", "application/json"); try { SslUtils.ignoreSsl(); } catch (Exception e) { e.printStackTrace(); } - - String requestBody = requestBodyJson.toJSONString(); String result = HttpUtil.post(httpUrl, requestBodyJson.toJSONString()); + //打开建立连接 log.debug("post_responseBody:"); log.debug(result); - /*HttpEntity entity = new HttpEntity(requestBody, headers); - ResponseEntity responseEntity=restTemplate.postForEntity(httpUrl,entity,String.class);*/ //获取返回结果 return JSONObject.parseObject(result); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index 126d08a..c588e5c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -158,7 +158,7 @@ public class ApiController { String ss = "{\t\"requestId\":\"10001\",\t\"result\":{\t\t\"ocrResult\":[\t\t\t{\t\t\t\t\"tag\":\"hospitalName\",\t\t\t\t\"inputText\":\"仁和医院\",\t\t\t\t\"ocrText\":\"仁和医院\",\t\t\t\t\"ocrPrecisionRate\":0.8,\t\t\t\t\"sourceImage\":{\t\t\t\t\t\"fileName\":\"test1.png\",\t\t\t\t\t\"path\":\"/usr/local/ocr/test1.png\"\t\t\t\t},\t\t\t\t\"failureReason\":\"\"\t\t\t}\t\t],\t\t\"ruleValidation\":false,\t\t\"retrieveReviewCompliance\":\"80\",\t\t\"imageTagRetrievePercentage\":\"66.6\",\t\t\"failureReason\":\"医生名称不匹配\"\t}}"; JSONObject requestBody = JSONObject.parseObject(ss); requestBody = new JSONObject(); - JSONObject semanticResponseJson = RestUtil.postTest("https://192.168.1.21:8686/api/task/image/ocr/callback", requestBody); + JSONObject semanticResponseJson = RestUtil.post("https://192.168.1.21:8686/api/task/image/ocr/callback", requestBody); return semanticResponseJson; /*String requestId = jsonObject.getString("requestId"); String fileName = jsonObject.getString("fileName");