|
@@ -7,17 +7,21 @@ import com.jzg.quotation.bohai.api.entity.request.*;
|
|
|
import com.jzg.quotation.bohai.api.entity.response.*;
|
|
import com.jzg.quotation.bohai.api.entity.response.*;
|
|
|
import com.jzg.quotation.commons.component.RequestComponent;
|
|
import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
|
|
|
+import com.jzg.quotation.commons.constant.enums.base.InsuranceEnum;
|
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
|
import com.jzg.quotation.bohai.api.constant.enums.RequestType;
|
|
import com.jzg.quotation.bohai.api.constant.enums.RequestType;
|
|
|
import com.jzg.quotation.bohai.api.constant.enums.ResponseCode;
|
|
import com.jzg.quotation.bohai.api.constant.enums.ResponseCode;
|
|
|
import com.jzg.quotation.bohai.api.properties.BohaiApiConfigurationProperties;
|
|
import com.jzg.quotation.bohai.api.properties.BohaiApiConfigurationProperties;
|
|
|
import com.jzg.quotation.bohai.api.util.BoHaiEncrypted;
|
|
import com.jzg.quotation.bohai.api.util.BoHaiEncrypted;
|
|
|
import com.jzg.quotation.bohai.api.util.SignatureUtils;
|
|
import com.jzg.quotation.bohai.api.util.SignatureUtils;
|
|
|
|
|
+import com.jzg.quotation.commons.utils.InsuranceLog;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -35,14 +39,16 @@ public class BoHaiRequestApiComponent {
|
|
|
|
|
|
|
|
private final RequestComponent requestComponent;
|
|
private final RequestComponent requestComponent;
|
|
|
|
|
|
|
|
|
|
+ private final RestTemplate restTemplate;
|
|
|
|
|
+
|
|
|
public <T extends BoHaiBaseRequest, B extends BoHaiBaseResponse> B requestUrl(String url, T requestBody, Class<B> responseType, String sysSourceCode, RequestType requestType) throws Exception {
|
|
public <T extends BoHaiBaseRequest, B extends BoHaiBaseResponse> B requestUrl(String url, T requestBody, Class<B> responseType, String sysSourceCode, RequestType requestType) throws Exception {
|
|
|
requestBody.setBaseParamRequestType(requestType.getCode());
|
|
requestBody.setBaseParamRequestType(requestType.getCode());
|
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
String busReqString = JSON.toJSONString(requestBody, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String busReqString = JSON.toJSONString(requestBody, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
|
-// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> URl: {} \n\t---------> 请求参数:{}",
|
|
|
|
|
-// requestType.getDesc(), url, busReqString);
|
|
|
|
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> URl: {} \n\t---------> 请求参数:{}",
|
|
|
|
|
+ requestType.getDesc(), url, busReqString);
|
|
|
BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties, sysSourceCode);
|
|
BoHaiEncrypted boHaiEncrypted = new BoHaiEncrypted(busReqString, properties, sysSourceCode);
|
|
|
|
|
|
|
|
String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
String json = JSON.toJSONString(boHaiEncrypted, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
|
@@ -54,14 +60,15 @@ public class BoHaiRequestApiComponent {
|
|
|
httpHeaders.set("signature", signature);
|
|
httpHeaders.set("signature", signature);
|
|
|
// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 加密后的参数:{} \n\t---------> " +
|
|
// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 加密后的参数:{} \n\t---------> " +
|
|
|
// "请求头内容signature:{}", requestType.getDesc(), content, signature);
|
|
// "请求头内容signature:{}", requestType.getDesc(), content, signature);
|
|
|
-
|
|
|
|
|
- ResponseEntity<B> bResponseEntity = requestComponent.objectPost(url, content, responseType, httpHeaders);
|
|
|
|
|
- String body = JSON.toJSONString(bResponseEntity.getBody());//需要联调观察数据格式
|
|
|
|
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
|
|
|
|
|
+ ResponseEntity<String> response = restTemplate.postForEntity(url, httpEntity, String.class);
|
|
|
|
|
+ String body = response.getBody();
|
|
|
|
|
+// ResponseEntity<B> bResponseEntity = requestComponent.objectPost(url, content, responseType, httpHeaders);
|
|
|
|
|
+// String body = JSON.toJSONString(bResponseEntity.getBody());//需要联调观察数据格式
|
|
|
// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密前的参数:{}", requestType.getDesc(), body);
|
|
// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密前的参数:{}", requestType.getDesc(), body);
|
|
|
-
|
|
|
|
|
BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
|
|
BoHaiEncrypted encrypted = JSON.parseObject(body).toJavaObject(BoHaiEncrypted.class);
|
|
|
String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
|
|
String info = SignatureUtils.decryptByPrivateKey(encrypted.getBizContent(), properties.getSelfPrivateKey());
|
|
|
-// InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密后的参数:{}", requestType.getDesc(), info);
|
|
|
|
|
|
|
+ InsuranceLog.infoLog(InsuranceEnum.BPIC.getPinyin(), "\n\t---------> {} \n\t---------> 解密后的参数:{}", requestType.getDesc(), info);
|
|
|
return JSON.parseObject(info).toJavaObject(responseType);
|
|
return JSON.parseObject(info).toJavaObject(responseType);
|
|
|
}
|
|
}
|
|
|
|
|
|