|
|
|
@ -7,6 +7,8 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
@ -95,6 +97,8 @@ public class HttpClient {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String mipsGet(String url, Map params) {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.add("Content-Type", "application/json");
|
|
|
|
|
StringBuffer stringBuffer = new StringBuffer(url);
|
|
|
|
|
if (params instanceof Map) {
|
|
|
|
|
Iterator iterator = ((Map) params).entrySet().iterator();
|
|
|
|
@ -117,10 +121,47 @@ public class HttpClient {
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String accessTokenRequestUrl = url;//"http://127.0.0.1:9997/mips/druginfo/list";
|
|
|
|
|
logger.info(accessTokenRequestUrl);
|
|
|
|
|
String response = restTemplate.getForObject(accessTokenRequestUrl, String.class);
|
|
|
|
|
return response;
|
|
|
|
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), String.class);
|
|
|
|
|
// String response = restTemplate.getForObject(accessTokenRequestUrl, String.class, new HttpEntity<String>(headers));
|
|
|
|
|
return response.getBody();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String mipsGetHead(String url, Map params, HttpHeaders headers) {
|
|
|
|
|
|
|
|
|
|
headers.add("Content-Type", "application/json");
|
|
|
|
|
if (params != null) {
|
|
|
|
|
StringBuffer stringBuffer = new StringBuffer(url);
|
|
|
|
|
if (params instanceof Map) {
|
|
|
|
|
Iterator iterator = ((Map) params).entrySet().iterator();
|
|
|
|
|
if (iterator.hasNext()) {
|
|
|
|
|
stringBuffer.append("?");
|
|
|
|
|
Object element;
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
|
element = iterator.next();
|
|
|
|
|
Map.Entry<String, Object> entry = (Map.Entry) element;
|
|
|
|
|
if (entry.getValue() != null) {
|
|
|
|
|
stringBuffer.append(element).append("&");
|
|
|
|
|
}
|
|
|
|
|
url = stringBuffer.substring(0, stringBuffer.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new RuntimeException("url请求:" + url + "请求参数有误不是map类型");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String accessTokenRequestUrl = url;//"http://127.0.0.1:9997/mips/druginfo/list";
|
|
|
|
|
logger.info(accessTokenRequestUrl);
|
|
|
|
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), String.class);
|
|
|
|
|
|
|
|
|
|
// String response = restTemplate.getForObject(accessTokenRequestUrl, String.class, new HttpEntity<String>(headers));
|
|
|
|
|
return response.getBody();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String mipsGetHead(String url, Map params) {
|
|
|
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
@ -146,9 +187,9 @@ public class HttpClient {
|
|
|
|
|
}
|
|
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
|
|
String accessTokenRequestUrl = url;//"http://127.0.0.1:9997/mips/druginfo/list";
|
|
|
|
|
logger.info(accessTokenRequestUrl);
|
|
|
|
|
HttpEntity<JSONObject> httpEntity = new HttpEntity<>(headers);
|
|
|
|
|
String response = restTemplate.getForObject(accessTokenRequestUrl, String.class, httpEntity);
|
|
|
|
|
return response;
|
|
|
|
|
logger.info(accessTokenRequestUrl+"---"+udiKey);
|
|
|
|
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), String.class);
|
|
|
|
|
// String response = restTemplate.getForObject(accessTokenRequestUrl, String.class, new HttpEntity<String>(headers));
|
|
|
|
|
return response.getBody();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|