|
|
@@ -9,6 +9,7 @@ import com.jzg.quotation.chengtai.crawler.model.param.*;
|
|
|
import com.jzg.quotation.chengtai.crawler.model.result.*;
|
|
|
import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
import jakarta.annotation.Resource;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -25,152 +26,98 @@ import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class ChengTaiAPIService {
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(ChengTaiAPIService.class);
|
|
|
|
|
|
- @Resource
|
|
|
- private RequestComponent requestComponent;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private ChengTaiInsuranceItemService chengTaiInsuranceItemService;
|
|
|
-
|
|
|
- public void setRequestComponent(RequestComponent requestComponent) {
|
|
|
- this.requestComponent = requestComponent;
|
|
|
- }
|
|
|
+ private final RequestComponent requestComponent;
|
|
|
|
|
|
private <T> T post(ChengTaiAPI api, Object body, Class<T> resultClass, HttpHeaders headers) {
|
|
|
-// headers.add(":authority", "b2b.champion-ic.com");
|
|
|
-// headers.add(":method", "POST");
|
|
|
-// headers.add(":path", api.uri());
|
|
|
-// headers.add(":scheme", "https");
|
|
|
if (headers != null) {
|
|
|
headers.add("traceid", UUID.randomUUID().toString());
|
|
|
}
|
|
|
-
|
|
|
String paramString = JsonUtil.toJsonString(body);
|
|
|
-
|
|
|
ResponseEntity<String> responseEntity = requestComponent.post(api.url(), paramString, String.class, headers);
|
|
|
-
|
|
|
String responseEntityBody = responseEntity.getBody();
|
|
|
-
|
|
|
T objcet = JsonUtil.readObjcet(responseEntityBody, resultClass);
|
|
|
-
|
|
|
return objcet;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询险种
|
|
|
*
|
|
|
- * @param token
|
|
|
- * @return
|
|
|
+ * @param headers 请求头
|
|
|
+ * @return 险种
|
|
|
*/
|
|
|
- public List<ChengTaiDictionary> findDictionaryOfRisk(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public List<ChengTaiDictionary> findDictionaryOfRisk(HttpHeaders headers) {
|
|
|
ChengTaiFindDictionaryResult.Response result = post(ChengTaiAPI.FindDictionaryOfRisk, null, ChengTaiFindDictionaryResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询登录用户信息
|
|
|
*
|
|
|
- * @param token
|
|
|
- * @return
|
|
|
+ * @param headers 请求头
|
|
|
+ * @return 登录用户信息
|
|
|
*/
|
|
|
- public ChengTaiQueryLoginUserInfoResult queryLoginUserInfo(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiQueryLoginUserInfoResult queryLoginUserInfo(HttpHeaders headers) {
|
|
|
ChengTaiQueryLoginUserInfoResult.Response result = post(ChengTaiAPI.QueryLoginUserInfo, null, ChengTaiQueryLoginUserInfoResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询登录用户可用的业务归属机构
|
|
|
*
|
|
|
- * @param token
|
|
|
- * @return
|
|
|
+ * @param headers 请求头
|
|
|
+ * @return 业务归属机构
|
|
|
*/
|
|
|
- public List<ChengTaiFindAttributionOrgByUserResult> findAttributionOrgByUser(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public List<ChengTaiFindAttributionOrgByUserResult> findAttributionOrgByUser(HttpHeaders headers) {
|
|
|
ChengTaiFindAttributionOrgByUserResult.Response result = post(ChengTaiAPI.FindAttributionOrgByUser, null, ChengTaiFindAttributionOrgByUserResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
- public List<ChengTaiFindSaleManVoByDeptCodeResult> findSaleManVoByDeptCode(String token, String deptCode, String isOuter, List<String> riskCodes) {
|
|
|
+ public List<ChengTaiFindSaleManVoByDeptCodeResult> findSaleManVoByDeptCode(HttpHeaders headers, String deptCode, String isOuter, List<String> riskCodes) {
|
|
|
ChengTaiFindSaleManVoByDeptCodeParam param = new ChengTaiFindSaleManVoByDeptCodeParam();
|
|
|
param.setDeptCode(deptCode);
|
|
|
param.setIsOuter(isOuter);
|
|
|
param.setRiskCodes(riskCodes);
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiFindSaleManVoByDeptCodeResult.Response result = post(ChengTaiAPI.FindSaleManVoByDeptCode, param, ChengTaiFindSaleManVoByDeptCodeResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
- public ChengTaiQueryRiskAuthorityResult queryRiskAuthority(String token, String saleCode, String subAgreementCode) {
|
|
|
+ public ChengTaiQueryRiskAuthorityResult queryRiskAuthority(HttpHeaders headers, String saleCode, String subAgreementCode) {
|
|
|
Map<String, String> param = Maps.newHashMapWithExpectedSize(2);
|
|
|
-
|
|
|
param.put("saleCode", saleCode);
|
|
|
param.put("subAgreementCode", subAgreementCode);
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiQueryRiskAuthorityResult.Response result = post(ChengTaiAPI.QueryRiskAuthority, param, ChengTaiQueryRiskAuthorityResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询务人员可用的中介协议和代理机构
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers
|
|
|
* @param saleCode
|
|
|
* @param riskCodes
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiFindCoreConferInfoByHandleCodeResult findCoreConferInfoByHandleCode(String token, String saleCode, List<String> riskCodes) {
|
|
|
+ public ChengTaiFindCoreConferInfoByHandleCodeResult findCoreConferInfoByHandleCode(HttpHeaders headers, String saleCode, List<String> riskCodes) {
|
|
|
Map<String, Object> param = Maps.newHashMapWithExpectedSize(2);
|
|
|
-
|
|
|
param.put("saleCode", saleCode);
|
|
|
param.put("riskCodes", riskCodes);
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiFindCoreConferInfoByHandleCodeResult.Response result = post(ChengTaiAPI.FindCoreConferInfoByHandleCode, null, ChengTaiFindCoreConferInfoByHandleCodeResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
- public ChengTaiQueryVehicleListResult queryVehicleList(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiQueryVehicleListResult queryVehicleList(HttpHeaders headers) {
|
|
|
ChengTaiQueryVehicleListResult.Response result = post(ChengTaiAPI.QueryVehicleList, null, ChengTaiQueryVehicleListResult.Response.class, headers);
|
|
|
-
|
|
|
if (result == null) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
ChengTaiQueryVehicleListResult body = result.getBody();
|
|
|
-
|
|
|
if (body == null) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
List<ChengTaiJqxclassidDic> jqxclassidDic = body.getJqxclassidDic();
|
|
|
-
|
|
|
if (CollectionUtils.isNotEmpty(jqxclassidDic)) {
|
|
|
jqxclassidDic.forEach(jqxclassid -> {
|
|
|
String extdata = jqxclassid.getExtdata();
|
|
|
@@ -193,7 +140,7 @@ public class ChengTaiAPIService {
|
|
|
* @param vinCode 车架号
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiQueryCarInfoResult queryCarInfo(String token, String comCode, String plateNo, String vinCode) {
|
|
|
+ public ChengTaiQueryCarInfoResult queryCarInfo(HttpHeaders headers, String comCode, String plateNo, String vinCode) {
|
|
|
if (plateNo == null || plateNo.isBlank()) {
|
|
|
plateNo = "新车上牌";
|
|
|
}
|
|
|
@@ -203,12 +150,7 @@ public class ChengTaiAPIService {
|
|
|
param.put("comCode", comCode);
|
|
|
param.put("plateNo", plateNo);
|
|
|
param.put("vinCode", vinCode);
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiQueryCarInfoResult.Response result = post(ChengTaiAPI.QueryCarInfo, param, ChengTaiQueryCarInfoResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
|
|
|
}
|
|
|
@@ -216,22 +158,16 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 根据车牌号、车架号查询车型
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers
|
|
|
* @param modelCode 车型编号
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiFindCarModelResult findCarModel(String token, String modelCode) {
|
|
|
+ public ChengTaiFindCarModelResult findCarModel(HttpHeaders headers, String modelCode) {
|
|
|
Map<String, String> param = Maps.newHashMapWithExpectedSize(3);
|
|
|
-
|
|
|
param.put("modelcode: ", modelCode);
|
|
|
param.put("pageNo", "1");
|
|
|
param.put("pageSize", "100");
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiFindCarModelResult.Response result = post(ChengTaiAPI.FindCarModel, param, ChengTaiFindCarModelResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
|
|
|
}
|
|
|
@@ -239,75 +175,51 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 身份识别
|
|
|
*
|
|
|
- * @param token
|
|
|
* @param applicant
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiApplicant clientIdentify(String token, ChengTaiApplicant applicant) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiApplicant clientIdentify(HttpHeaders headers, ChengTaiApplicant applicant) {
|
|
|
ChengTaiClientIdentifyResult.Response response = post(ChengTaiAPI.ClientIdentify, applicant, ChengTaiClientIdentifyResult.Response.class, headers);
|
|
|
-
|
|
|
return response.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiSaveResult save(String token, ChengTaiPremiumcalParam param) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiSaveResult save(HttpHeaders headers, ChengTaiPremiumcalParam param) {
|
|
|
ChengTaiSaveResult.Response response = post(ChengTaiAPI.Save, param, ChengTaiSaveResult.Response.class, headers);
|
|
|
-
|
|
|
return response.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保费计算
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiPremiumcalResult premiumcal(String token, ChengTaiPremiumcalParam param) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiPremiumcalResult premiumcal(HttpHeaders headers, ChengTaiPremiumcalParam param) {
|
|
|
ChengTaiPremiumcalResult.Response result = post(ChengTaiAPI.Premiumcal, param, ChengTaiPremiumcalResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
- public ChengTaiSubmitResult submit(String token, ChengTaiPremiumcalParam param) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiSubmitResult submit(HttpHeaders headers, ChengTaiPremiumcalParam param) {
|
|
|
ChengTaiSubmitResult.Response result = post(ChengTaiAPI.Submit, param, ChengTaiSubmitResult.Response.class, headers);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 上传影像
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiImageUploadResult imageUpload(String token, byte[] file, ChengTaiImageUploadParam param) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
+ public ChengTaiImageUploadResult imageUpload(HttpHeaders headers, byte[] file, ChengTaiImageUploadParam param) {
|
|
|
|
|
|
MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
|
|
|
formData.add("uploadVo", param);
|
|
|
@@ -319,11 +231,8 @@ public class ChengTaiAPIService {
|
|
|
});
|
|
|
|
|
|
ResponseEntity<String> responseEntity = requestComponent.formData(ChengTaiAPI.ImageUpload.url(), formData, String.class, headers);
|
|
|
-
|
|
|
String responseEntityBody = responseEntity.getBody();
|
|
|
-
|
|
|
ChengTaiImageUploadResult.Response result = JsonUtil.readObjcet(responseEntityBody, ChengTaiImageUploadResult.Response.class);
|
|
|
-
|
|
|
return result.getBody();
|
|
|
}
|
|
|
|
|
|
@@ -342,7 +251,7 @@ public class ChengTaiAPIService {
|
|
|
|
|
|
param.add("captchaVerification", captcha);
|
|
|
|
|
|
- ResponseEntity<String> responseEntity = requestComponent.form(ChengTaiAPI.Login.url(), param, String.class, null);
|
|
|
+ ResponseEntity<String> responseEntity = requestComponent.form(ChengTaiAPI.LOGIN.url(), param, String.class, null);
|
|
|
|
|
|
String responseEntityBody = responseEntity.getBody();
|
|
|
|
|
|
@@ -358,15 +267,9 @@ public class ChengTaiAPIService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public ChengTaiSystemResult system(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public ChengTaiSystemResult system(HttpHeaders headers) {
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
-
|
|
|
ChengTaiSystemResult.Response response = requestComponent.get(ChengTaiAPI.System.url(), param, null, ChengTaiSystemResult.Response.class, headers);
|
|
|
-
|
|
|
List<ChengTaiSystemResult> body = response.getBody();
|
|
|
|
|
|
if (body == null || body.isEmpty()) {
|
|
|
@@ -376,11 +279,7 @@ public class ChengTaiAPIService {
|
|
|
return body.get(0);
|
|
|
}
|
|
|
|
|
|
- public boolean findAreaConfig(String token) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
-
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public boolean findAreaConfig(HttpHeaders headers) {
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
ChengTaiFindAreaConfigResult.Response response = requestComponent.get(ChengTaiAPI.FindAreaConfig.url(), param, null, ChengTaiFindAreaConfigResult.Response.class, headers);
|
|
|
|
|
|
@@ -404,17 +303,15 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 获取详情
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers 请求头
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiPremiumcalParam getPolicyModel(String token, String orderId) {
|
|
|
+ public ChengTaiPremiumcalParam getPolicyModel(HttpHeaders headers, String orderId) {
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
param.add("orderId", orderId);
|
|
|
param.add("businessType", "POLICY");
|
|
|
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
ResponseEntity<ChengTaiGetPolicyModelResult.Response> form = requestComponent.form(ChengTaiAPI.GetPolicyModel.url(), param, ChengTaiGetPolicyModelResult.Response.class, headers);
|
|
|
|
|
|
ChengTaiGetPolicyModelResult.Response response = form.getBody();
|
|
|
@@ -426,18 +323,13 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 获取支付链接
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers 请求头
|
|
|
* @param uuid
|
|
|
* @return 就是多个值
|
|
|
*/
|
|
|
- public List<ChengTaiInsureResult> insure(String token, String uuid) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
+ public List<ChengTaiInsureResult> insure(HttpHeaders headers, String uuid) {
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
-
|
|
|
ChengTaiInsureResult.Response response = requestComponent.get(ChengTaiAPI.Insure.url().replace("{uuid}", uuid), param, null, ChengTaiInsureResult.Response.class, headers);
|
|
|
-
|
|
|
return response.getBody();
|
|
|
|
|
|
}
|
|
|
@@ -445,23 +337,18 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 获取保单下载链接
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers 请求头
|
|
|
* @param contractNo
|
|
|
* @param policyUuid
|
|
|
* @return
|
|
|
*/
|
|
|
- public ChengTaiDownloadAddressResult downloadAddress(String token, String contractNo, String policyUuid, String expiryDate) {
|
|
|
+ public ChengTaiDownloadAddressResult downloadAddress(HttpHeaders headers, String contractNo, String policyUuid, String expiryDate) {
|
|
|
ChengTaiDownloadAddressParam param = new ChengTaiDownloadAddressParam();
|
|
|
param.setBusinessType("C");
|
|
|
param.setPolicyUuid(policyUuid);
|
|
|
param.setContractNo(contractNo);
|
|
|
param.setValidDate(expiryDate);
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiDownloadAddressResult.Response response = post(ChengTaiAPI.DownloadAddress, param, ChengTaiDownloadAddressResult.Response.class, headers);
|
|
|
-
|
|
|
return response.getBody();
|
|
|
|
|
|
}
|
|
|
@@ -469,22 +356,17 @@ public class ChengTaiAPIService {
|
|
|
/**
|
|
|
* 获取意外险
|
|
|
*
|
|
|
- * @param token
|
|
|
+ * @param headers 请求头
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<ChengTaiAccidentInsurance> hygeiaGet(String token) {
|
|
|
+ public List<ChengTaiAccidentInsurance> hygeiaGet(HttpHeaders headers) {
|
|
|
ChengTaiHygeiaGetParam param = new ChengTaiHygeiaGetParam();
|
|
|
param.setComCode("0105");
|
|
|
param.setSeat(5);
|
|
|
param.setRiskCode("1158");
|
|
|
param.setCarKindCode("A0");
|
|
|
param.setUseNatureCode("8A");
|
|
|
-
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("token", token);
|
|
|
-
|
|
|
ChengTaiHygeiaGetResult.Response response = post(ChengTaiAPI.HygeiaGet, param, ChengTaiHygeiaGetResult.Response.class, headers);
|
|
|
-
|
|
|
return response.getBody();
|
|
|
|
|
|
}
|