|
|
@@ -6,6 +6,7 @@ import com.jzg.commons.util.StringUtils;
|
|
|
import com.jzg.quotation.commons.component.RequestComponent;
|
|
|
import com.jzg.quotation.commons.constant.CacheConstant;
|
|
|
import com.jzg.quotation.commons.service.ExteriorUtilsRequest;
|
|
|
+import com.jzg.quotation.commons.utils.RequestObjectConversion;
|
|
|
import com.jzg.quote.hengbang.crawler.constant.RequestConstant;
|
|
|
import com.jzg.quote.hengbang.crawler.constant.enums.RequestUrl;
|
|
|
import com.jzg.quote.hengbang.crawler.entity.dto.HbEncDTO;
|
|
|
@@ -49,6 +50,7 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 验证码
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public HbCrawlerCaptchaResponse captcha(int frequency) {
|
|
|
@@ -104,6 +106,7 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 登录次数
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @param password 密码
|
|
|
* @param loginsNumber 登录次数
|
|
|
@@ -115,7 +118,9 @@ public class HengBangCrawlerRequestComponent {
|
|
|
// 登录存入缓存当中
|
|
|
HbCrawlerAuthenticateRequest authenticateRequest = new HbCrawlerAuthenticateRequest(captchaResponse, username, password);
|
|
|
ResponseEntity<HbCrawlerAuthenticateResponse> responseEntity = requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), JSONObject.toJSONString(authenticateRequest), HbCrawlerAuthenticateResponse.class);
|
|
|
- HbCrawlerAuthenticateResponse authenticateResponse = Optional.of(responseEntity).map(ResponseEntity::getBody).orElseThrow();
|
|
|
+ HbCrawlerAuthenticateResponse authenticateResponse = Optional.of(responseEntity)
|
|
|
+ .map(ResponseEntity::getBody)
|
|
|
+ .orElseThrow();
|
|
|
|
|
|
if (!StringUtils.isEmpty(authenticateResponse.getId_token())) {
|
|
|
Map<String, String> authorizationMap = buildCache(authenticateResponse);
|
|
|
@@ -140,23 +145,29 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 获取授权信息
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @return 授权token
|
|
|
*/
|
|
|
public String getAuthorization(String username) {
|
|
|
- return (String) redissonClient.getMap(CacheConstant.HENGBANG_AUTHORIZATION + username).get(RequestConstant.AUTHORIZATION);
|
|
|
+ return (String) redissonClient.getMap(CacheConstant.HENGBANG_AUTHORIZATION + username)
|
|
|
+ .get(RequestConstant.AUTHORIZATION);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取手机号
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @return 授权token
|
|
|
*/
|
|
|
public String getPhoneNumber(String username) {
|
|
|
- return (String) redissonClient.getMap(CacheConstant.HENGBANG_AUTHORIZATION + username).get(RequestConstant.PHONE_NUMBER);
|
|
|
+ return (String) redissonClient.getMap(CacheConstant.HENGBANG_AUTHORIZATION + username)
|
|
|
+ .get(RequestConstant.PHONE_NUMBER);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取请求头
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
public HttpHeaders getHeaders(String username, String password) {
|
|
|
@@ -165,31 +176,35 @@ public class HengBangCrawlerRequestComponent {
|
|
|
authorization = authenticate(username, password, RequestConstant.REQUEST_NUMBER);
|
|
|
}
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.set(HttpHeaders.AUTHORIZATION , RequestConstant.BEARER + authorization);
|
|
|
+ headers.set(HttpHeaders.AUTHORIZATION, RequestConstant.BEARER + authorization);
|
|
|
return headers;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询车型
|
|
|
+ *
|
|
|
* @param queryCarRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
*/
|
|
|
public List<HbCrawlerQueryCarResponse.ContentDTO> queryCar(HbCrawlerQueryCarRequest queryCarRequest, HttpHeaders headers) {
|
|
|
- HbCrawlerQueryCarResponse queryCarResponse = requestComponent.objectPost(RequestUrl.QUERY_CAR.getRequestUrl(hbCrawlerProperties.getBaseUrl()), queryCarRequest, HbCrawlerQueryCarResponse.class, headers).getBody();
|
|
|
+ HbCrawlerQueryCarResponse queryCarResponse = requestComponent.objectPost(RequestUrl.QUERY_CAR.getRequestUrl(hbCrawlerProperties.getBaseUrl()), queryCarRequest, HbCrawlerQueryCarResponse.class, headers)
|
|
|
+ .getBody();
|
|
|
return queryCarResponse.getContent();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取归属信息
|
|
|
+ *
|
|
|
* @param saleInfoRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public HbEncDTO getSalesInfo(HbCrawlerSaleInfoRequest saleInfoRequest, HttpHeaders headers) throws Exception {
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("mobile", saleInfoRequest.getMobile());
|
|
|
+ LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
+ params.add("mobile", saleInfoRequest.getMobile());
|
|
|
+
|
|
|
HbCrawlerSaleInfoResponse saleInfoResponse = requestComponent.get(RequestUrl.FIND_SALE_INFO.getRequestUrl(hbCrawlerProperties.getBaseUrl()), params, "", HbCrawlerSaleInfoResponse.class, headers);
|
|
|
String hbEncD = saleInfoResponse.getHbEncD();
|
|
|
return JSONObject.parseObject(HengBangAESUtil.decryptStr(hbEncD), HbEncDTO.class);
|
|
|
@@ -197,18 +212,20 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 获取折旧价
|
|
|
+ *
|
|
|
* @param depreciationRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
*/
|
|
|
public String getDepreciationPrice(HbCrawlerDepreciationRequest depreciationRequest, HttpHeaders headers) {
|
|
|
- Map<String, Object> params = JSONObject.parseObject(JSONObject.toJSONString(depreciationRequest), Map.class);
|
|
|
+ MultiValueMap<String, String> params = RequestObjectConversion.convertMultiValueStringMap(depreciationRequest);
|
|
|
HbCrawlerDepreciationResponse depreciationResponse = requestComponent.get(RequestUrl.DEPRECIATIONRATE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), params, "", HbCrawlerDepreciationResponse.class, headers);
|
|
|
return String.valueOf(depreciationResponse.getDepreciationRate());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 报价第一步,提交报价基础数据,获取订单号
|
|
|
+ *
|
|
|
* @param quoteimmediatelyRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
@@ -220,6 +237,7 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 报价第二步,提交报价险种数据 返回是否重复投保提示信息
|
|
|
+ *
|
|
|
* @param calculationRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
@@ -232,41 +250,41 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 报价第三步 获取报价返回数据
|
|
|
+ *
|
|
|
* @param plyappno 投保单号
|
|
|
* @param headers
|
|
|
* @return
|
|
|
*/
|
|
|
public HbCrawlerProposalResponse proposal(String plyappno, HttpHeaders headers) {
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
String encryptPlyappno;
|
|
|
try {
|
|
|
- encryptPlyappno = new StringBuilder(RequestConstant.ENCRYPTPRE).append(HengBangAESUtil.encryptStr(plyappno)).toString();
|
|
|
+ encryptPlyappno = new StringBuilder(RequestConstant.ENCRYPTPRE).append(HengBangAESUtil.encryptStr(plyappno))
|
|
|
+ .toString();
|
|
|
} catch (Exception e) {
|
|
|
throw new SystemException(e.getMessage());
|
|
|
}
|
|
|
- params.put("plyappno", encryptPlyappno);
|
|
|
+ params.add("plyappno", encryptPlyappno);
|
|
|
HbCrawlerProposalResponse proposalResponse = requestComponent.get(RequestUrl.PROPOSAL.getRequestUrl(hbCrawlerProperties.getBaseUrl()), params, "", HbCrawlerProposalResponse.class, headers);
|
|
|
return proposalResponse;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param fileUploadRequest
|
|
|
* @param headers
|
|
|
* @param plyappno
|
|
|
- * @return
|
|
|
- * 上传成功返回数据
|
|
|
+ * @return 上传成功返回数据
|
|
|
* {
|
|
|
- * "status" : "1",
|
|
|
- * "errorCode" : null,
|
|
|
- * "message" : null,
|
|
|
- * "responseBody" : null,
|
|
|
- * "map" : {
|
|
|
- * "responseBody" : null,
|
|
|
- * "errorCode" : null,
|
|
|
- * "message" : null,
|
|
|
- * "status" : "1"
|
|
|
- * }
|
|
|
+ * "status" : "1",
|
|
|
+ * "errorCode" : null,
|
|
|
+ * "message" : null,
|
|
|
+ * "responseBody" : null,
|
|
|
+ * "map" : {
|
|
|
+ * "responseBody" : null,
|
|
|
+ * "errorCode" : null,
|
|
|
+ * "message" : null,
|
|
|
+ * "status" : "1"
|
|
|
+ * }
|
|
|
* }
|
|
|
*/
|
|
|
public Map<String, Object> uploadImage(HbCrawlerFileUploadRequest fileUploadRequest, HttpHeaders headers, String plyappno) {
|
|
|
@@ -277,6 +295,7 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 提交核保
|
|
|
+ *
|
|
|
* @param plyappno
|
|
|
* @param headers
|
|
|
* @return
|
|
|
@@ -290,12 +309,12 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 查询订单状态
|
|
|
+ *
|
|
|
* @param licenseNo 车牌号
|
|
|
- * @param appTime 订单创建时间
|
|
|
- * @param creator 订单创建人
|
|
|
+ * @param appTime 订单创建时间
|
|
|
+ * @param creator 订单创建人
|
|
|
* @param headers
|
|
|
- * @return
|
|
|
- * 待提核:-1;审核通过:1,3,5;下发修改:2;拒保:4;承保确认:6;初始状态:0
|
|
|
+ * @return 待提核:-1;审核通过:1,3,5;下发修改:2;拒保:4;承保确认:6;初始状态:0
|
|
|
*/
|
|
|
public HbCrawlerOrderStateResponse orderState(String licenseNo, String appTime, String creator, HttpHeaders headers) {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -314,6 +333,7 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 获取保单数据
|
|
|
+ *
|
|
|
* @param getPolicyRequest
|
|
|
* @param headers
|
|
|
* @return
|
|
|
@@ -339,11 +359,13 @@ public class HengBangCrawlerRequestComponent {
|
|
|
|
|
|
/**
|
|
|
* 获取支付链接
|
|
|
+ *
|
|
|
* @param plyappno
|
|
|
* @param headers
|
|
|
* @return
|
|
|
*/
|
|
|
public HbCrawlerPayUrlResponse getPayUrl(String plyappno, HttpHeaders headers) {
|
|
|
- return requestComponent.objectPost(RequestUrl.PAY_URL.getRequestUrl(hbCrawlerProperties.getBaseUrl()).concat(plyappno), null, HbCrawlerPayUrlResponse.class, headers).getBody();
|
|
|
+ return requestComponent.objectPost(RequestUrl.PAY_URL.getRequestUrl(hbCrawlerProperties.getBaseUrl())
|
|
|
+ .concat(plyappno), null, HbCrawlerPayUrlResponse.class, headers).getBody();
|
|
|
}
|
|
|
}
|