|
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.client.RestClientException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
/**
|
|
@@ -46,29 +47,38 @@ public class CoreServiceUitls {
|
|
|
}
|
|
|
|
|
|
private void updateIndexPost(String path){
|
|
|
- // 获取core服务器地址
|
|
|
- String coreServer = Global.getConfig("caimei.core");
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String uri = coreServer + "/commodity/search/index" + path;
|
|
|
- // 打印参数
|
|
|
- logger.info("更新索引uri:" + uri);
|
|
|
- // 发起Post请求
|
|
|
- MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
|
|
|
- String result = restTemplate.postForObject(uri, paramMap, String.class);
|
|
|
- logger.info("更新索引result:" + result);
|
|
|
+ try {
|
|
|
+ // 获取core服务器地址
|
|
|
+ String coreServer = Global.getConfig("caimei.core");
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String uri = coreServer + "/commodity/search/index" + path;
|
|
|
+ // 打印参数
|
|
|
+ logger.info("更新索引uri:" + uri);
|
|
|
+ // 发起Post请求
|
|
|
+ MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
|
|
|
+ String result = restTemplate.postForObject(uri, paramMap, String.class);
|
|
|
+ logger.info("更新索引result:" + result);
|
|
|
+ } catch (RestClientException e) {
|
|
|
+ logger.info("更新索引出现异常!" + e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public String queryLogisticsGet(String number, String companyCode, String mobile){
|
|
|
- // 获取core服务器地址
|
|
|
- String coreServer = Global.getConfig("caimei.core");
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String uri = coreServer + "/tools/query/logistics?number" + number + "&companyCode=" + companyCode + "&mobile=" + mobile;
|
|
|
- // 打印参数
|
|
|
- logger.info("查询物流uri:" + uri);
|
|
|
- // 发起Get请求
|
|
|
- String result = restTemplate.getForObject(uri, String.class);
|
|
|
- logger.info("查询物流result:" + result);
|
|
|
- return result;
|
|
|
+ try {
|
|
|
+ // 获取core服务器地址
|
|
|
+ String coreServer = Global.getConfig("caimei.core");
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String uri = coreServer + "/tools/query/logistics?number" + number + "&companyCode=" + companyCode + "&mobile=" + mobile;
|
|
|
+ // 打印参数
|
|
|
+ logger.info("查询物流uri:" + uri);
|
|
|
+ // 发起Get请求
|
|
|
+ String result = restTemplate.getForObject(uri, String.class);
|
|
|
+ logger.info("查询物流result:" + result);
|
|
|
+ return result;
|
|
|
+ } catch (RestClientException e) {
|
|
|
+ logger.info("查询物流出现异常!" + e);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|