Commit f9ee4bf5 authored by 鹿朋's avatar 鹿朋

结清证明

parent cf152f00
......@@ -45,6 +45,7 @@ public interface IHttpService {
* @return
*/
String get(String uri, Map<String, String> headers, Map<String, ?> parameters);
byte[] getByte(String uri, Map<String, String> headers, Map<String, ?> parameters);
/**
* Http Post
......
......@@ -88,6 +88,20 @@ public class RestTemplateServiceImpl implements IHttpService {
return builder.toString();
}
@Override
public byte[] getByte(String uri, Map<String, String> hs, Map<String, ?> parameters) {
HttpHeaders headers = new HttpHeaders();
hs.forEach((k, v) -> {
headers.add(k, v);
});
HttpEntity<?> en = new HttpEntity<>(headers);
ResponseEntity<byte[]> entity = restTemplate.exchange(buildUrl(uri, parameters), HttpMethod.GET, en, byte[].class, parameters);
if (entity.getStatusCode().is2xxSuccessful()) {
return entity.getBody();
}
throw new HttpClientErrorException(entity.getStatusCode());
}
@Override
public String get(String uri, Map<String, String> hs, Map<String, ?> parameters) {
HttpHeaders headers = new HttpHeaders();
......
......@@ -226,22 +226,19 @@ public class IceServiceImpl implements IIceService {
Map<String, String> header = Maps.newHashMap();
header.put("Content-Type", "application/x-www-form-urlencoded");
String result;
byte[] result;
try {
result = httpService.get(url, header, param);
result = httpService.getByte(url, header, param);
log.info("{} 结清证明下载 loanId={},result:{}", logPre, loanId, result);
} catch (Exception e) {
log.error("{} 通讯异常 url={},param={}", logPre, url, param, e);
return JsonResult.buildErrorStateResult("通讯异常", null);
}
if (StringUtils.isBlank(result)) {
if (result.length <= 0) {
log.error("{} 调用失败 url={}, header={},param={},result={}", logPre, url, header, param, result);
return JsonResult.buildErrorStateResult("结清证明下载失败", null);
}
TypeReference<JsonResult> typeToken = new TypeReference<JsonResult>() {
};
JsonResult<byte[]> jsonResult = JSONTools.deserialize(result, typeToken);
return fileService.outputFile(response, System.currentTimeMillis() + loanId +"settle.pdf", jsonResult.getData());
return fileService.outputFile(response, System.currentTimeMillis() + String.valueOf(loanId) +"settle.pdf", result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment