Merge remote-tracking branch 'origin/wms_pzh' into wms_pzh

wms_pzh
x_z 3 years ago
commit 0da5f83df7

@ -25,12 +25,16 @@ public class AsyncDiDlHelper {
@Value("${UDI_SERVER_URL}")
private String udiUrl;
@Resource
HttpClient httpClient;
public List<ProductInfoEntity> dlByTime(String udiUrl, int page, int limit, String updateTime) {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("page", page);
paramMap.put("limit", limit);
paramMap.put("updateTime", updateTime);
String response = HttpClient.mipsGet(udiUrl + "/udidl/udiwms/syncUdi", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/udiwms/syncUdi", paramMap);
try {
BaseResponse<List<ProductInfoEntity>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {
@ -51,7 +55,7 @@ public class AsyncDiDlHelper {
paramMap.put("page", page);
paramMap.put("limit", limit);
paramMap.put("updateTime", updateTime);
String response = HttpClient.mipsGet(udiUrl + "/udidl/udiwms/syncCompany", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/udiwms/syncCompany", paramMap);
try {
BaseResponse<List<UdiCompanyEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<UdiCompanyEntity>>>() {
@ -70,7 +74,7 @@ public class AsyncDiDlHelper {
public List<ProductInfoEntity> dlByDi(String deviceId) {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("deviceId", deviceId);
String response = HttpClient.mipsGet(udiUrl + "/udidl/device/serchDlByDi", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/device/serchDlByDi", paramMap);
try {
BaseResponse<List<ProductInfoEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {
@ -92,7 +96,7 @@ public class AsyncDiDlHelper {
public BaseResponse<List<ProductInfoEntity>> dlByDiRes(String deviceId) {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("deviceId", deviceId);
String response = HttpClient.mipsGet(udiUrl + "/udidl/device/serchDlByDi", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/device/serchDlByDi", paramMap);
try {
BaseResponse<List<ProductInfoEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {
@ -108,7 +112,7 @@ public class AsyncDiDlHelper {
public BaseResponse<List<ProductInfoEntity>> dlLastVersionByDi(String deviceId) {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("deviceId", deviceId);
String response = HttpClient.mipsGet(udiUrl + "/udidl/device/dlLastVersionByDi", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/device/dlLastVersionByDi", paramMap);
try {
BaseResponse<List<ProductInfoEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {
@ -131,7 +135,7 @@ public class AsyncDiDlHelper {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("uuid", uuid);
String response = HttpClient.mipsGet(udiUrl + "/udidl/device/searchDlByUuid", paramMap);
String response = httpClient.mipsGetUdiHead(udiUrl + "/udidl/device/searchDlByUuid", paramMap);
try {
BaseResponse<List<ProductInfoEntity>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {

@ -2,10 +2,15 @@ package com.glxp.api.admin.util;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
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.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
@ -14,8 +19,16 @@ import java.util.Iterator;
import java.util.Map;
@Slf4j
@Service
public class HttpClient {
@Value("${UDI_APPID}")
private String appId;
@Value("${UDI_SECRET}")
private String appSecret;
// public static String uCloudPost(String url, Object object) {
// RestTemplate restTemplate = new RestTemplate();
// String json = JSONObject.toJSON(object).toString();
@ -92,6 +105,38 @@ public class HttpClient {
}
public String mipsGetUdiHead(String url, Map params) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
headers.add("appId", appId);
headers.add("appSecret", appSecret);
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";
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 uCloudPostSmp(String url, Object object, String appKey, String secretKey) {
RestTemplate restTemplate = new RestTemplate();
String json = JSONUtil.toJsonStr(object);

Loading…
Cancel
Save