|
@@ -26,6 +26,7 @@ import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
@@ -261,11 +262,9 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private RestTemplate rest;
|
|
|
|
-
|
|
|
|
private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
|
|
private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
|
|
try {
|
|
try {
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
|
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
|
if (!Check.isNullMap(paramMap)) {
|
|
if (!Check.isNullMap(paramMap)) {
|
|
for (String key : paramMap.keySet()) {
|
|
for (String key : paramMap.keySet()) {
|
|
@@ -277,8 +276,13 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
headers.add(key, headerMap.get(key));
|
|
headers.add(key, headerMap.get(key));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
|
|
|
+ requestFactory.setConnectTimeout(1000 * 500);// 设置超时
|
|
|
|
+ requestFactory.setReadTimeout(1000 * 500);
|
|
|
|
+ RestTemplate rest = new RestTemplate(requestFactory);
|
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(param, headers);
|
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(param, headers);
|
|
ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, httpEntity, String.class);
|
|
ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, httpEntity, String.class);
|
|
|
|
+ log.info("上传素材时间:{} s ,账户:{}。code:{}", (System.currentTimeMillis() - l) / 1000, paramMap.get("advertiser_id"), paramMap.get("signature"));
|
|
return responseEntity.getBody();
|
|
return responseEntity.getBody();
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|