对接比亚迪-下载比亚迪的文件接口,传参方式修按照他们的接口,改成URL传参。
This commit is contained in:
+17
-11
@@ -61,6 +61,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
@@ -221,19 +222,24 @@ public class FileSpiltService {
|
|||||||
try {
|
try {
|
||||||
// 根据byd传过来的文件下载路径获取文件。
|
// 根据byd传过来的文件下载路径获取文件。
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
HttpHeaders headers = new HttpHeaders();
|
// HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
//
|
||||||
// 创建MultiValueMap对象,用于存储请求参数
|
// // 创建MultiValueMap对象,用于存储请求参数
|
||||||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
// MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
String fileId = sarFileSplitInfoEO.getId();
|
// String fileId = sarFileSplitInfoEO.getId();
|
||||||
params.add("fileId", fileId);
|
// params.add("fileId", fileId);
|
||||||
|
//
|
||||||
// 使用HttpEntity对象包装请求体和请求头
|
// // 使用HttpEntity对象包装请求体和请求头
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
// HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
//
|
||||||
|
// // 发送POST请求并获取响应
|
||||||
|
// ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);
|
||||||
|
|
||||||
|
Long fileId = Long.valueOf(sarFileSplitInfoEO.getId());
|
||||||
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(bydDownLoadFileUrl).queryParam("fileId", fileId);
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);
|
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(builder.toUriString(), null, byte[].class);
|
||||||
// 获取文件流
|
// 获取文件流
|
||||||
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
|
|||||||
Reference in New Issue
Block a user