private static ResultIf<PdfPlanIdsDto> get(String url) { ResultIf<PdfPlanIdsDto> pdfPlanIdsDto = null; try { log.info("url={}", url); HttpHeaders headers = new HttpHeaders(); headers.add("Accept", "application/json"); headers.add("Content-Encoding", "UTF-8"); headers.add("Content-Type", "application/json; charset=UTF-8"); org.springframework.http.HttpEntity<String> requestEntity = new org.springframework.http.HttpEntity<>(null, headers); ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class); if (response.getStatusCode().equals(HttpStatus.OK)) { String body = response.getBody(); //转对象 pdfPlanIdsDto= JSON.parseObject(body, new TypeReference<ResultIf<PdfPlanIdsDto>>() { }); } } catch (Exception e) { log.error("{},请求服务器异常:{}", url,e); } return pdfPlanIdsDto; }
|