|
|
@@ -6,8 +6,10 @@ import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.ParameterizedTypeReference;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import org.thyy.scheduled.config.constant.Dpcc;
|
|
|
@@ -39,13 +41,13 @@ import java.util.List;
|
|
|
public class DpccService {
|
|
|
private final Dpcc dpcc;
|
|
|
private final DpccDao dao;
|
|
|
- private final RestTemplate restTemplate;
|
|
|
+ private final RestTemplate template;
|
|
|
|
|
|
@Autowired
|
|
|
- public DpccService(Dpcc dpcc, DpccDao dao, RestTemplate restTemplate) {
|
|
|
+ public DpccService(Dpcc dpcc, DpccDao dao, RestTemplate template) {
|
|
|
this.dpcc = dpcc;
|
|
|
this.dao = dao;
|
|
|
- this.restTemplate = restTemplate;
|
|
|
+ this.template = template;
|
|
|
}
|
|
|
|
|
|
public void getToken() {
|
|
|
@@ -58,7 +60,7 @@ public class DpccService {
|
|
|
+ "?grant_type=access_client&"
|
|
|
+ "username=" + dpcc.getClientName() + "&"
|
|
|
+ "password=" + dpcc.getPassword();
|
|
|
- JSONObject response = restTemplate.postForObject(url,
|
|
|
+ JSONObject response = template.postForObject(url,
|
|
|
new HttpEntity<>(null, headers), JSONObject.class);
|
|
|
log.info("DPCC获取TOKEN:{}", response);
|
|
|
if (null == response) {
|
|
|
@@ -130,8 +132,11 @@ public class DpccService {
|
|
|
.patientNumType(inquiry.getPatType()).patientNum(inquiry.getPatNo())
|
|
|
.startDate(inquiry.getReqStartTime()).endDate(inquiry.getReqEndTime()).build();
|
|
|
JSONObject json = JSONObject.from(request);
|
|
|
- ResultVo<List<JyIndexResponse>> resultVo =
|
|
|
- restTemplate.postForObject(dpcc.getJyApi() + "/queryJyIndex", json, ResultVo.class);
|
|
|
+ String url = dpcc.getJyApi() + "/queryJyIndex";
|
|
|
+ ResultVo<List<JyIndexResponse>> resultVo = template.exchange(
|
|
|
+ url, HttpMethod.POST, new HttpEntity<>(json),
|
|
|
+ new ParameterizedTypeReference<ResultVo<List<JyIndexResponse>>>() {}
|
|
|
+ ).getBody();
|
|
|
if (null == resultVo) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
@@ -142,8 +147,11 @@ public class DpccService {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("reportId", reportId);
|
|
|
json.put("responseMode", "Json");
|
|
|
- ResultVo<JyDetailResponse> resultVo =
|
|
|
- restTemplate.postForObject(dpcc.getJyApi() + "/queryJyDetail", json, ResultVo.class);
|
|
|
+ String url = dpcc.getJyApi() + "/queryJyDetail";
|
|
|
+ ResultVo<JyDetailResponse> resultVo = template.exchange(
|
|
|
+ url, HttpMethod.POST, new HttpEntity<>(json),
|
|
|
+ new ParameterizedTypeReference<ResultVo<JyDetailResponse>>() {}
|
|
|
+ ).getBody();
|
|
|
if (null == resultVo) {
|
|
|
throw new BizException(ExceptionEnum.API_ERROR);
|
|
|
}
|