|
|
@@ -65,12 +65,6 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
|
|
|
private final ZhongAnCrawlerCacheComponent zhongAnCrawlerCacheComponent;
|
|
|
|
|
|
- @Value("${zhongAn.id}")
|
|
|
- private String zhongAnId;
|
|
|
-
|
|
|
- @Value("${zhongAn.productId}")
|
|
|
- private String productId;
|
|
|
-
|
|
|
private final PlatformClient platformClient;
|
|
|
|
|
|
@Autowired
|
|
|
@@ -86,23 +80,23 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
private static final String FLOWID = "flowId";
|
|
|
private static final String ZHONGAN_COOKIE = "zhongan:cookie:";
|
|
|
|
|
|
- public LoginResult login(String zhongAnId, String productId) {
|
|
|
+ public LoginResult login(ZhongAnCrawlerConfigureParameters parameters) {
|
|
|
// 先从缓存取
|
|
|
- Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
|
|
|
+ Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + parameters.getUsername());
|
|
|
if (cacheMap != null && !cacheMap.isEmpty()) {
|
|
|
String zaLoginCookieKey = (String) cacheMap.get(COOKIE);
|
|
|
String flowId = (String) cacheMap.get(FLOWID);
|
|
|
|
|
|
- System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
|
|
|
+ System.out.println("[" + parameters.getUsername() + "] 从 Redisson 缓存读取登录信息");
|
|
|
return new LoginResult(200, "缓存登录成功", zaLoginCookieKey, flowId);
|
|
|
}
|
|
|
|
|
|
// 缓存没有 执行登录
|
|
|
- LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId, productId);
|
|
|
+ LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache( parameters.getUsername(), parameters.getProductId());
|
|
|
|
|
|
// 登录成功 存缓存
|
|
|
if (result.getCode() == 200) {
|
|
|
- zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
|
|
|
+ zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), parameters.getUsername());
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
@@ -111,18 +105,18 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
@Override
|
|
|
public boolean detectLogin(DetectLoginRequest detectLoginRequest) {
|
|
|
// 先从缓存取
|
|
|
- Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + zhongAnId);
|
|
|
+ Map<Object, Object> cacheMap = redissonClient.getMap(ZHONGAN_COOKIE + detectLoginRequest.getUsername());
|
|
|
if (cacheMap != null && !cacheMap.isEmpty()) {
|
|
|
- System.out.println("[" + zhongAnId + "] 从 Redisson 缓存读取登录信息");
|
|
|
+ System.out.println("[" + detectLoginRequest.getUsername() + "] 从 Redisson 缓存读取登录信息");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// 缓存没有 执行登录
|
|
|
- LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(zhongAnId, productId);
|
|
|
+ LoginResult result = zhongAnCrawlerCacheComponent.loginCookieCache(detectLoginRequest.getUsername(), detectLoginRequest.getProductId());
|
|
|
|
|
|
// 登录成功 存缓存
|
|
|
if (result.getCode() == 200) {
|
|
|
- zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), zhongAnId);
|
|
|
+ zhongAnCrawlerCacheComponent.cacheCookie(result.getZaLoginCookieKey(), result.getFlowId(), detectLoginRequest.getProductId());
|
|
|
}
|
|
|
return result.getCode() == 200;
|
|
|
}
|
|
|
@@ -136,18 +130,19 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public QuoteResultsVo quote(QuoteVo quoteVo) {
|
|
|
+ AttributionInformationVo attributionInformationVo = quoteVo.getOrder().getAttributionInformationVo();
|
|
|
+ //获取配置信息
|
|
|
+ ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
// 检查登录
|
|
|
- login(zhongAnId, productId);
|
|
|
+ login(parameters);
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
+
|
|
|
zhongAnCrawlerCacheComponent.setCache(quoteVo.getOwnersInfo().getIdentifyNumber(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.IDENTIFY_NUMBER);
|
|
|
CarInfoVo carInfoVo = quoteVo.getCarInfoVo();
|
|
|
zhongAnCrawlerCacheComponent.setCache(carInfoVo.getLicenseNo(), quoteVo.getOrder().getOrdersNo() + ZhongAnCrawlerCacheComponent.LICENSE);
|
|
|
- AttributionInformationVo attributionInformationVo = quoteVo.getOrder().getAttributionInformationVo();
|
|
|
- //获取配置信息
|
|
|
- ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
String flowId = parameters.getFlowId();
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
- parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
+ parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
|
|
|
}
|
|
|
// 查询归属信息
|
|
|
ZhongAnCrawlerQueryInitInfoRequest queryInitInfoRequest = new ZhongAnCrawlerQueryInitInfoRequest(parameters.getFlowId());
|
|
|
@@ -323,14 +318,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public UnderwritingResultsVo underwriting(UnderwritingVo underwritingVo) throws Exception {
|
|
|
- // 检查登录
|
|
|
- login(zhongAnId, productId);
|
|
|
AttributionInformationVo attributionInformationVo = underwritingVo.getOrder().getAttributionInformationVo();
|
|
|
ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(parameters);
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
String flowId = parameters.getFlowId();
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
- parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
+ parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
|
|
|
}
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(underwritingVo.getOrder().getOrdersNo());
|
|
|
ZhongAnCrawlerMarkRequest markRequest = new ZhongAnCrawlerMarkRequest(parameters, zhongAnCrawlerOrder.getOrderNo());
|
|
|
@@ -360,12 +355,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public PaymentLinkResultsVo getPaymentLink(PaymentLinkVo paymentLinkVo) {
|
|
|
+ //获取配置信息
|
|
|
+ AttributionInformationVo attributionInformationVo = paymentLinkVo.getOrder().getAttributionInformationVo();
|
|
|
+ ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
// 检查登录
|
|
|
- login(zhongAnId, productId);
|
|
|
+ login(parameters);
|
|
|
PaymentLinkResultsVo paymentLinkResultsVo = new PaymentLinkResultsVo();
|
|
|
OrderBase orderBase = paymentLinkVo.getOrder();
|
|
|
- //获取配置信息
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
|
|
|
|
|
|
@@ -390,16 +387,17 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public void uploadImage(InsuranceUploadImageVo insuranceUploadImageVo) {
|
|
|
- // 检查登录
|
|
|
- login(zhongAnId, productId);
|
|
|
OrderBase orderBase = insuranceUploadImageVo.getOrder();
|
|
|
AttributionInformationVo attributionInformationVo = orderBase.getAttributionInformationVo();
|
|
|
//获取配置信息
|
|
|
ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
+ // 检查登录
|
|
|
+ login(parameters);
|
|
|
+
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
String flowId = parameters.getFlowId();
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
- parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
+ parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
|
|
|
}
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
|
|
|
for (InsuranceImageVo insuranceImageVo : insuranceUploadImageVo.getImageVoList()) {
|
|
|
@@ -472,11 +470,14 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
*/
|
|
|
@Override
|
|
|
public DownloadPolicyResultVo downloadPolicy(DownloadPolicyVo downloadPolicyVo) {
|
|
|
+ AttributionInformationVo attributionInformationVo = downloadPolicyVo.getOrder().getAttributionInformationVo();
|
|
|
+ //获取配置信息
|
|
|
+ ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
// 检查登录
|
|
|
- login(zhongAnId, productId);
|
|
|
+ login(parameters);
|
|
|
OrderBase orderBase = downloadPolicyVo.getOrder();
|
|
|
//获取配置信息
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderBase.getOrdersNo());
|
|
|
String orderNo = zhongAnCrawlerOrder.getOrderNo();
|
|
|
@@ -527,11 +528,11 @@ public class ZhongAnCrawlerRequestImpl implements ZhongAnCrawlerRequest {
|
|
|
AttributionInformationVo attributionInformationVo = orderStatusVo.getOrder().getAttributionInformationVo();
|
|
|
//获取配置信息
|
|
|
ZhongAnCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(ZhongAnCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
- login(zhongAnId, productId);
|
|
|
- HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(zhongAnId);
|
|
|
+ login(parameters);
|
|
|
+ HttpHeaders headers = zhongAnCrawlerRequestComponent.getHeaders(parameters.getUsername());
|
|
|
String flowId = parameters.getFlowId();
|
|
|
if (StringUtils.isEmpty(flowId)) {
|
|
|
- parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(zhongAnId));
|
|
|
+ parameters.setFlowId(zhongAnCrawlerCacheComponent.getFlowId(parameters.getUsername()));
|
|
|
}
|
|
|
ZhongAnCrawlerOrder zhongAnCrawlerOrder = zhongAnCrawlerOrderService.findByOrdersNo(orderStatusVo.getOrder().getOrdersNo());
|
|
|
// 车牌号
|