Просмотр исходного кода

紫金获取登录信息,优化设置请求接口header

wangrq 3 месяцев назад
Родитель
Сommit
a7c3864f42

+ 1 - 1
tenant/insurance/quotation-zijin/src/main/java/com/jzg/quotation/zijin/crawler/component/ZiJinCrawlerCacheComponent.java

@@ -69,7 +69,7 @@ public class ZiJinCrawlerCacheComponent {
         String authorization = token;
         String authorization = token;
         authorizationMap.put(AUTHORIZATION, authorization);
         authorizationMap.put(AUTHORIZATION, authorization);
         authorizationMap.put(USER_CODE, userCode);
         authorizationMap.put(USER_CODE, userCode);
-        RMap<Object, Object> map = redissonClient.getMap(ZIJIN_AUTHORIZATION + userName);
+        RMap<Object, Object> map = redissonClient.getMap(ZIJIN_AUTHORIZATION + userCode);
         map.putAll(authorizationMap);
         map.putAll(authorizationMap);
         map.expire(Duration.ofHours(ZIJIN_AUTHORIZATION_TIME));
         map.expire(Duration.ofHours(ZIJIN_AUTHORIZATION_TIME));
         return authorization;
         return authorization;

+ 89 - 59
tenant/insurance/quotation-zijin/src/main/java/com/jzg/quotation/zijin/crawler/component/ZiJinCrawlerRequestComponent.java

@@ -2,18 +2,18 @@ package com.jzg.quotation.zijin.crawler.component;
 
 
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSON;
 import com.google.zxing.NotFoundException;
 import com.google.zxing.NotFoundException;
-import com.jzg.commons.exception.SystemException;
-import com.jzg.quotation.zijin.crawler.enums.RequestUrl;
+import com.jzg.quotation.commons.component.RequestComponent;
+import com.jzg.quotation.commons.service.ExteriorUtilsRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.*;
 import com.jzg.quotation.zijin.crawler.entity.request.*;
 import com.jzg.quotation.zijin.crawler.entity.response.*;
 import com.jzg.quotation.zijin.crawler.entity.response.*;
+import com.jzg.quotation.zijin.crawler.enums.RequestUrl;
 import com.jzg.quotation.zijin.crawler.properties.ZiJinCrawlerProperties;
 import com.jzg.quotation.zijin.crawler.properties.ZiJinCrawlerProperties;
-import com.jzg.quotation.zijin.crawler.util.*;
-import com.jzg.quotation.commons.component.RequestComponent;
+import com.jzg.quotation.zijin.crawler.util.DESEncryption;
+import com.jzg.quotation.zijin.crawler.util.RS6Item;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpHeaders;
-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.util.LinkedMultiValueMap;
 import org.springframework.util.LinkedMultiValueMap;
@@ -21,7 +21,10 @@ import org.springframework.util.MultiValueMap;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
 
 
 import java.io.IOException;
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @description: 紫金财险爬虫请求组件
  * @description: 紫金财险爬虫请求组件
@@ -39,9 +42,10 @@ public class ZiJinCrawlerRequestComponent {
 
 
     private final RequestComponent requestComponent;
     private final RequestComponent requestComponent;
 
 
-
     private final ZiJinCrawlerProperties ziJinCrawlerProperties;
     private final ZiJinCrawlerProperties ziJinCrawlerProperties;
 
 
+    private final ExteriorUtilsRequest exteriorUtilsRequest;
+
     /**
     /**
      * 获取验证码
      * 获取验证码
      *
      *
@@ -52,7 +56,7 @@ public class ZiJinCrawlerRequestComponent {
         ZiJinCrawlerCaptchaResponse ziJinCrawlerCaptchaResponse = null;
         ZiJinCrawlerCaptchaResponse ziJinCrawlerCaptchaResponse = null;
         try {
         try {
             if (frequency <= 0) {
             if (frequency <= 0) {
-                //throw new SystemException("验证码请求频次异常");
+                // throw new SystemException("验证码请求频次异常");
                 ziJinCrawlerCaptchaResponse = new ZiJinCrawlerCaptchaResponse();
                 ziJinCrawlerCaptchaResponse = new ZiJinCrawlerCaptchaResponse();
                 ziJinCrawlerCaptchaResponse.setRtnCode("500");
                 ziJinCrawlerCaptchaResponse.setRtnCode("500");
                 ziJinCrawlerCaptchaResponse.setRtnMsg("验证码请求频次异常");
                 ziJinCrawlerCaptchaResponse.setRtnMsg("验证码请求频次异常");
@@ -69,9 +73,11 @@ public class ZiJinCrawlerRequestComponent {
             ziJinCrawlerCaptchaResponse = responseEntity.getBody();
             ziJinCrawlerCaptchaResponse = responseEntity.getBody();
             log.info("获取验证码接口响应内容:{}", JSON.toJSONString(ziJinCrawlerCaptchaResponse));
             log.info("获取验证码接口响应内容:{}", JSON.toJSONString(ziJinCrawlerCaptchaResponse));
             String captchaImg = ziJinCrawlerCaptchaResponse.getCaptchaImg();
             String captchaImg = ziJinCrawlerCaptchaResponse.getCaptchaImg();
-            String captcha = captchaImg.split(",")[1].trim();
+            // String captcha = captchaImg.split(",")[1].trim();
             // 识别验证码的内容
             // 识别验证码的内容
-            String captchaContent = CaptchaUtil.performOCR(captcha);
+            // String captchaContent = CaptchaUtil.performOCR(captcha);
+            // 识别验证码
+            String captchaContent = exteriorUtilsRequest.captchaIdentify(captchaImg);
             log.info("验证码内容:{}", captchaContent);
             log.info("验证码内容:{}", captchaContent);
             ziJinCrawlerCaptchaResponse.setCaptchaContent(captchaContent);
             ziJinCrawlerCaptchaResponse.setCaptchaContent(captchaContent);
         } catch (Exception e) {
         } catch (Exception e) {
@@ -110,7 +116,7 @@ public class ZiJinCrawlerRequestComponent {
 
 
         HttpHeaders httpHeaders = setHttpHeaders();
         HttpHeaders httpHeaders = setHttpHeaders();
         httpHeaders.setContentLength(289);
         httpHeaders.setContentLength(289);
-        //需要单独设置这个
+        // 需要单独设置这个
         httpHeaders.set("Authorization", token);
         httpHeaders.set("Authorization", token);
         httpHeaders.set("loginToken", token);
         httpHeaders.set("loginToken", token);
         String jsonString = JSON.toJSONString(ziJinCrawlerCheckCaptchaRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerCheckCaptchaRequest);
@@ -119,7 +125,7 @@ public class ZiJinCrawlerRequestComponent {
     }
     }
 
 
     /**
     /**
-     * 校验token
+     * 校验token(Python没有这个接口)
      *
      *
      * @param ziJinCrawlerCheckTokenRequest
      * @param ziJinCrawlerCheckTokenRequest
      * @param token
      * @param token
@@ -127,12 +133,12 @@ public class ZiJinCrawlerRequestComponent {
      */
      */
     public ZiJinCrawlerCheckTokenResponse checkToken(ZiJinCrawlerCheckTokenRequest ziJinCrawlerCheckTokenRequest, String token) throws IOException {
     public ZiJinCrawlerCheckTokenResponse checkToken(ZiJinCrawlerCheckTokenRequest ziJinCrawlerCheckTokenRequest, String token) throws IOException {
         log.info("ziJinCrawlerCheckTokenRequest请求参数的值:{}", JSON.toJSONString(ziJinCrawlerCheckTokenRequest));
         log.info("ziJinCrawlerCheckTokenRequest请求参数的值:{}", JSON.toJSONString(ziJinCrawlerCheckTokenRequest));
-
         HttpHeaders httpHeaders = setHttpHeaders();
         HttpHeaders httpHeaders = setHttpHeaders();
         httpHeaders.setContentLength(66);
         httpHeaders.setContentLength(66);
-        //需要单独设置这个
+        // 需要单独设置这个
         httpHeaders.set("Authorization", token);
         httpHeaders.set("Authorization", token);
         httpHeaders.set("loginToken", token);
         httpHeaders.set("loginToken", token);
+
         String jsonString = JSON.toJSONString(ziJinCrawlerCheckTokenRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerCheckTokenRequest);
         ResponseEntity<ZiJinCrawlerCheckTokenResponse> responseEntity = requestComponent.post(RequestUrl.CHECK_TOKEN.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerCheckTokenResponse.class, httpHeaders);
         ResponseEntity<ZiJinCrawlerCheckTokenResponse> responseEntity = requestComponent.post(RequestUrl.CHECK_TOKEN.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerCheckTokenResponse.class, httpHeaders);
         return responseEntity.getBody();
         return responseEntity.getBody();
@@ -150,9 +156,9 @@ public class ZiJinCrawlerRequestComponent {
         ZiJinCrawlerCaptchaResponse captcha = captcha(CIRCULATE_NUMBER);
         ZiJinCrawlerCaptchaResponse captcha = captcha(CIRCULATE_NUMBER);
         // 登录存入缓存当中
         // 登录存入缓存当中
         ZiJinCrawlerAuthenticateRequest request = new ZiJinCrawlerAuthenticateRequest(captcha, username, password);
         ZiJinCrawlerAuthenticateRequest request = new ZiJinCrawlerAuthenticateRequest(captcha, username, password);
-        //ZiJinCrawlerBaseRequest crawlerBaseRequest = new ZiJinCrawlerBaseRequest(request);
+        // ZiJinCrawlerBaseRequest crawlerBaseRequest = new ZiJinCrawlerBaseRequest(request);
         ZiJinCrawlerBaseRequest crawlerBaseRequest = null;
         ZiJinCrawlerBaseRequest crawlerBaseRequest = null;
-        //return requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(""), crawlerBaseRequest, ZiJinCrawlerBaseResponse.class);
+        // return requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(""), crawlerBaseRequest, ZiJinCrawlerBaseResponse.class);
         return null;
         return null;
     }
     }
 
 
@@ -165,7 +171,7 @@ public class ZiJinCrawlerRequestComponent {
      * @return 获取渠道信息响应
      * @return 获取渠道信息响应
      */
      */
     public ZiJinCrawlerGetSaleInfoResponse getSaleInfo(String operatorCode, HttpHeaders headers) {
     public ZiJinCrawlerGetSaleInfoResponse getSaleInfo(String operatorCode, HttpHeaders headers) {
-        //String url = RequestUrl.GET_SALE_INFO.getRequestUrl("") + operatorCode;
+        // String url = RequestUrl.GET_SALE_INFO.getRequestUrl("") + operatorCode;
         String url = "";
         String url = "";
         MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
         MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
         map.add("operatorCode", operatorCode);
         map.add("operatorCode", operatorCode);
@@ -181,8 +187,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerCarResponse
      * @return ZiJinCrawlerCarResponse
      */
      */
     public ZiJinCrawlerCarResponse car(ZiJinCrawlerCarRequest ziJinCrawlerCarRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerCarResponse car(ZiJinCrawlerCarRequest ziJinCrawlerCarRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerCarRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerCarRequest);
         log.info("ziJinCrawlerCarRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerCarRequest请求参数的值:{}", jsonString);
@@ -198,8 +204,9 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerCarResponse
      * @return ZiJinCrawlerCarResponse
      */
      */
     public ZiJinCrawlerGetOrderNoResponse getOrderNo(ZiJinCrawlerGetOrderNoRequest ziJinCrawlerGetOrderNoRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerGetOrderNoResponse getOrderNo(ZiJinCrawlerGetOrderNoRequest ziJinCrawlerGetOrderNoRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
+
         String jsonString = JSON.toJSONString(ziJinCrawlerGetOrderNoRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerGetOrderNoRequest);
         log.info("ziJinCrawlerGetOrderNoRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerGetOrderNoRequest请求参数的值:{}", jsonString);
         ResponseEntity<ZiJinCrawlerGetOrderNoResponse> responseEntity = requestComponent.post(RequestUrl.GET_ORDER_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetOrderNoResponse.class, httpHeaders);
         ResponseEntity<ZiJinCrawlerGetOrderNoResponse> responseEntity = requestComponent.post(RequestUrl.GET_ORDER_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetOrderNoResponse.class, httpHeaders);
@@ -214,8 +221,9 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerGetCarActualValueResponse
      * @return ZiJinCrawlerGetCarActualValueResponse
      */
      */
     public ZiJinCrawlerGetCarActualValueResponse getCarActualValue(ZiJinCrawlerGetCarActualValueRequest ziJinCrawlerGetCarActualValueRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerGetCarActualValueResponse getCarActualValue(ZiJinCrawlerGetCarActualValueRequest ziJinCrawlerGetCarActualValueRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
+
         String jsonString = JSON.toJSONString(ziJinCrawlerGetCarActualValueRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerGetCarActualValueRequest);
         log.info("ziJinCrawlerGetCarActualValueRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerGetCarActualValueRequest请求参数的值:{}", jsonString);
         ResponseEntity<ZiJinCrawlerGetCarActualValueResponse> responseEntity = requestComponent.post(RequestUrl.GET_ACTUAL_VALUE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetCarActualValueResponse.class, httpHeaders);
         ResponseEntity<ZiJinCrawlerGetCarActualValueResponse> responseEntity = requestComponent.post(RequestUrl.GET_ACTUAL_VALUE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerGetCarActualValueResponse.class, httpHeaders);
@@ -230,10 +238,17 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerGetTaxRegistryNumberResponse
      * @return ZiJinCrawlerGetTaxRegistryNumberResponse
      */
      */
     public ZiJinCrawlerGetTaxRegistryNumberResponse getTaxRegistryNumber(String comCode, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerGetTaxRegistryNumberResponse getTaxRegistryNumber(String comCode, HttpHeaders headers) throws IOException {
-        HttpHeaders httpHeaders = setHttpHeaders();
-        String url = RequestUrl.GET_TAX_REGISTRY_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl());
-        log.info("获取税务登记证号请求URL:{}", url);
-        ZiJinCrawlerGetTaxRegistryNumberResponse response = requestComponent.get(url, new LinkedMultiValueMap<>(), "", ZiJinCrawlerGetTaxRegistryNumberResponse.class, httpHeaders);
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
+        httpHeaders.remove("Cache-Control");
+        httpHeaders.remove("Content-Length");
+        httpHeaders.remove("Origin");
+        httpHeaders.remove("Pragma");
+        httpHeaders.remove("content-type");
+
+        LinkedMultiValueMap<String, String> parameterMap = new LinkedMultiValueMap<>();
+        parameterMap.add("comCode", comCode);
+        ZiJinCrawlerGetTaxRegistryNumberResponse response = requestComponent.get(RequestUrl.GET_TAX_REGISTRY_NUMBER.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), parameterMap, "", ZiJinCrawlerGetTaxRegistryNumberResponse.class, httpHeaders);
         log.info("获取税务登记证号响应:{}", JSON.toJSONString(response));
         log.info("获取税务登记证号响应:{}", JSON.toJSONString(response));
         return response;
         return response;
     }
     }
@@ -246,8 +261,9 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerQuotationResponse
      * @return ZiJinCrawlerQuotationResponse
      */
      */
     public ZiJinCrawlerQuotationResponse quotation(ZiJinCrawlerQuotationRequest ziJinCrawlerQuotationRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerQuotationResponse quotation(ZiJinCrawlerQuotationRequest ziJinCrawlerQuotationRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
+
         String jsonString = JSON.toJSONString(ziJinCrawlerQuotationRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerQuotationRequest);
         log.info("ziJinCrawlerQuotationRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerQuotationRequest请求参数的值:{}", jsonString);
         ResponseEntity<ZiJinCrawlerQuotationResponse> post = requestComponent.post(RequestUrl.PRICE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerQuotationResponse.class, httpHeaders);
         ResponseEntity<ZiJinCrawlerQuotationResponse> post = requestComponent.post(RequestUrl.PRICE.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerQuotationResponse.class, httpHeaders);
@@ -258,13 +274,13 @@ public class ZiJinCrawlerRequestComponent {
      * 验证码(报价出现转保标志)
      * 验证码(报价出现转保标志)
      *
      *
      * @param ziJinCrawlerRecognizeCodesRequest
      * @param ziJinCrawlerRecognizeCodesRequest
-     * @param headers 请求头
+     * @param headers                           请求头
      * @return ZiJinCrawlerRecognizeCodesResponse
      * @return ZiJinCrawlerRecognizeCodesResponse
      */
      */
     public ZiJinCrawlerRecognizeCodesResponse recognizeCodes(List<ZiJinCrawlerRecognizeCodesRequest> ziJinCrawlerRecognizeCodesRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerRecognizeCodesResponse recognizeCodes(List<ZiJinCrawlerRecognizeCodesRequest> ziJinCrawlerRecognizeCodesRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
-        httpHeaders.set("Content-Type", "application/json");
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
+
         String jsonString = JSON.toJSONString(ziJinCrawlerRecognizeCodesRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerRecognizeCodesRequest);
         log.info("ziJinCrawlerRecognizeCodesRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerRecognizeCodesRequest请求参数的值:{}", jsonString);
         ResponseEntity<ZiJinCrawlerRecognizeCodesResponse> post = requestComponent.post(RequestUrl.SKIP_SING.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerRecognizeCodesResponse.class, httpHeaders);
         ResponseEntity<ZiJinCrawlerRecognizeCodesResponse> post = requestComponent.post(RequestUrl.SKIP_SING.getRequestUrl(ziJinCrawlerProperties.getBaseUrl()), jsonString, ZiJinCrawlerRecognizeCodesResponse.class, httpHeaders);
@@ -279,8 +295,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerSaveQuoteInformationResponse
      * @return ZiJinCrawlerSaveQuoteInformationResponse
      */
      */
     public ZiJinCrawlerSaveQuoteInfoResponse saveQuoteInformation(ZiJinCrawlerSaveQuoteInfoRequest ziJinCrawlerSaveQuoteInfoRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerSaveQuoteInfoResponse saveQuoteInformation(ZiJinCrawlerSaveQuoteInfoRequest ziJinCrawlerSaveQuoteInfoRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerSaveQuoteInfoRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerSaveQuoteInfoRequest);
         log.info("ziJinCrawlerSaveQuoteInfoRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerSaveQuoteInfoRequest请求参数的值:{}", jsonString);
@@ -288,7 +304,7 @@ public class ZiJinCrawlerRequestComponent {
         return responseEntity.getBody();
         return responseEntity.getBody();
     }
     }
 
 
-     /**
+    /**
      * 保存投保单
      * 保存投保单
      *
      *
      * @param ziJinCrawlerSaveProposalRequest
      * @param ziJinCrawlerSaveProposalRequest
@@ -296,8 +312,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerSaveProposalResponse
      * @return ZiJinCrawlerSaveProposalResponse
      */
      */
     public ZiJinCrawlerSaveProposalResponse saveProposal(ZiJinCrawlerSaveProposalRequest ziJinCrawlerSaveProposalRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerSaveProposalResponse saveProposal(ZiJinCrawlerSaveProposalRequest ziJinCrawlerSaveProposalRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerSaveProposalRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerSaveProposalRequest);
         log.info("ziJinCrawlerSaveProposalRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerSaveProposalRequest请求参数的值:{}", jsonString);
@@ -314,8 +330,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerUnderwritingResponse
      * @return ZiJinCrawlerUnderwritingResponse
      */
      */
     public ZiJinCrawlerUnderwritingResponse underwriting(ZiJinCrawlerUnderwritingRequest ziJinCrawlerUnderwritingRequest, HttpHeaders headers) throws Exception {
     public ZiJinCrawlerUnderwritingResponse underwriting(ZiJinCrawlerUnderwritingRequest ziJinCrawlerUnderwritingRequest, HttpHeaders headers) throws Exception {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerUnderwritingRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerUnderwritingRequest);
         log.info("ziJinCrawlerUnderwritingRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerUnderwritingRequest请求参数的值:{}", jsonString);
@@ -332,8 +348,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerImageUploadResponse
      * @return ZiJinCrawlerImageUploadResponse
      */
      */
     public ZiJinCrawlerImageUploadResponse uploadImage(ZiJinCrawlerImageUploadRequest ziJinCrawlerImageUploadRequest, HttpHeaders headers) throws Exception {
     public ZiJinCrawlerImageUploadResponse uploadImage(ZiJinCrawlerImageUploadRequest ziJinCrawlerImageUploadRequest, HttpHeaders headers) throws Exception {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerImageUploadRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerImageUploadRequest);
         log.info("ziJinCrawlerImageUploadRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerImageUploadRequest请求参数的值:{}", jsonString);
@@ -348,8 +364,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerImageUploadResponse
      * @return ZiJinCrawlerImageUploadResponse
      */
      */
     public ZiJinCrawlerImageUploadInfoListResponse uploadImageInfoList(ZiJinCrawlerUploadImageInfoListRequest ziJinCrawlerUploadImageInfoListRequest, HttpHeaders headers) throws Exception {
     public ZiJinCrawlerImageUploadInfoListResponse uploadImageInfoList(ZiJinCrawlerUploadImageInfoListRequest ziJinCrawlerUploadImageInfoListRequest, HttpHeaders headers) throws Exception {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerUploadImageInfoListRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerUploadImageInfoListRequest);
         log.info("ziJinCrawlerUploadImageInfoListRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerUploadImageInfoListRequest请求参数的值:{}", jsonString);
@@ -358,7 +374,6 @@ public class ZiJinCrawlerRequestComponent {
     }
     }
 
 
 
 
-
     /**
     /**
      * 获取支付链接
      * 获取支付链接
      *
      *
@@ -367,8 +382,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerPaymentLinkResponse
      * @return ZiJinCrawlerPaymentLinkResponse
      */
      */
     public ZiJinCrawlerPaymentLinkResponse payment(ZiJinCrawlerPaymentLinkRequest ziJinCrawlerPaymentLinkRequest, HttpHeaders headers) throws NotFoundException, IOException {
     public ZiJinCrawlerPaymentLinkResponse payment(ZiJinCrawlerPaymentLinkRequest ziJinCrawlerPaymentLinkRequest, HttpHeaders headers) throws NotFoundException, IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerPaymentLinkRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerPaymentLinkRequest);
         log.info("ziJinCrawlerPaymentLinkRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerPaymentLinkRequest请求参数的值:{}", jsonString);
@@ -384,8 +399,8 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerQueryOrderStatusResponse
      * @return ZiJinCrawlerQueryOrderStatusResponse
      */
      */
     public ZiJinCrawlerQueryOrderStatusResponse queryOrderStatus(ZiJinCrawlerQueryOrderStatusRequest ziJinCrawlerQueryOrderStatusRequest, HttpHeaders headers) throws IOException {
     public ZiJinCrawlerQueryOrderStatusResponse queryOrderStatus(ZiJinCrawlerQueryOrderStatusRequest ziJinCrawlerQueryOrderStatusRequest, HttpHeaders headers) throws IOException {
-        //设置headers
-        HttpHeaders httpHeaders = setHttpHeaders();
+        String token = headers.getFirst("Authorization");
+        HttpHeaders httpHeaders = setHttpHeaders(token);
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerQueryOrderStatusRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerQueryOrderStatusRequest);
         log.info("ziJinCrawlerQueryOrderStatusRequest请求参数的值:{}", jsonString);
         log.info("ziJinCrawlerQueryOrderStatusRequest请求参数的值:{}", jsonString);
@@ -454,7 +469,7 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerQueryCarPolicyListResponse
      * @return ZiJinCrawlerQueryCarPolicyListResponse
      */
      */
     public ZiJinCrawlerQueryCarPolicyListResponse queryCarPolicyList(ZiJinCrawlerQueryCarPolicyListRequest ziJinCrawlerQueryCarPolicyListRequest) throws IOException {
     public ZiJinCrawlerQueryCarPolicyListResponse queryCarPolicyList(ZiJinCrawlerQueryCarPolicyListRequest ziJinCrawlerQueryCarPolicyListRequest) throws IOException {
-        //设置headers
+        // 设置headers
         HttpHeaders httpHeaders = setHttpHeaders1();
         HttpHeaders httpHeaders = setHttpHeaders1();
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerQueryCarPolicyListRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerQueryCarPolicyListRequest);
@@ -471,7 +486,7 @@ public class ZiJinCrawlerRequestComponent {
      * @return ZiJinCrawlerDownloadResponse
      * @return ZiJinCrawlerDownloadResponse
      */
      */
     public ZiJinCrawlerDownloadPolicyResponse electronPolicyIODownload(ZiJinCrawlerDownloadPolicyRequest ziJinCrawlerDownloadPolicyRequest) throws IOException {
     public ZiJinCrawlerDownloadPolicyResponse electronPolicyIODownload(ZiJinCrawlerDownloadPolicyRequest ziJinCrawlerDownloadPolicyRequest) throws IOException {
-        //设置headers
+        // 设置headers
         HttpHeaders httpHeaders = setHttpHeaders();
         HttpHeaders httpHeaders = setHttpHeaders();
 
 
         String jsonString = JSON.toJSONString(ziJinCrawlerDownloadPolicyRequest);
         String jsonString = JSON.toJSONString(ziJinCrawlerDownloadPolicyRequest);
@@ -501,17 +516,18 @@ public class ZiJinCrawlerRequestComponent {
      * @throws IOException
      * @throws IOException
      */
      */
     @NotNull
     @NotNull
-    private static HttpHeaders setHttpHeaders() throws IOException {
+    private HttpHeaders setHttpHeaders() throws IOException {
+        return setHttpHeaders(null);
+    }
+
+    @NotNull
+    private HttpHeaders setHttpHeaders(String token) throws IOException {
         HttpHeaders headers = new HttpHeaders();
         HttpHeaders headers = new HttpHeaders();
-        //headers.setContentType(MediaType.APPLICATION_JSON);
-        //获取cookie的值
         String cookie = getCookie();
         String cookie = getCookie();
         headers.set("Cookie", "csrfToken=CrwLEmSfUevAb8PcN7kXff-I; "+ cookie);
         headers.set("Cookie", "csrfToken=CrwLEmSfUevAb8PcN7kXff-I; "+ cookie);
-        // 设置请求头
         headers.set("Accept", "application/json, text/plain, */*, application/problem+json");
         headers.set("Accept", "application/json, text/plain, */*, application/problem+json");
-        //headers.set("Accept-Encoding", "gzip, deflate, br, zstd");
+        // headers.set("Accept-Encoding", "gzip, deflate, br, zstd");
         headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
         headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
-        headers.set("Authorization", "FD385C99C9B35B64EF84590AACA95380");
         headers.set("Cache-Control", "no-cache");
         headers.set("Cache-Control", "no-cache");
         headers.set("Connection", "keep-alive");
         headers.set("Connection", "keep-alive");
         headers.set("Content-Length", "23");
         headers.set("Content-Length", "23");
@@ -524,17 +540,31 @@ public class ZiJinCrawlerRequestComponent {
         headers.set("Sec-Fetch-Site", "same-origin");
         headers.set("Sec-Fetch-Site", "same-origin");
         headers.set("Tokentype", "DEFULT");
         headers.set("Tokentype", "DEFULT");
         headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36");
         headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36");
-        headers.set("loginToken", "FD385C99C9B35B64EF84590AACA95380");
         headers.set("sec-ch-ua", "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"");
         headers.set("sec-ch-ua", "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"");
         headers.set("sec-ch-ua-mobile", "?0");
         headers.set("sec-ch-ua-mobile", "?0");
         headers.set("sec-ch-ua-platform", "\"Windows\"");
         headers.set("sec-ch-ua-platform", "\"Windows\"");
         headers.set("x-csrf-token", "CrwLEmSfUevAb8PcN7kXff-I");
         headers.set("x-csrf-token", "CrwLEmSfUevAb8PcN7kXff-I");
         headers.set("content-type", "application/json");
         headers.set("content-type", "application/json");
+        if (StringUtils.hasText(token)) {
+            headers.set("Authorization", token);
+            headers.set("loginToken", token);
+        }
         return headers;
         return headers;
     }
     }
 
 
+    /**
+     * 构建带有authorization的HTTP请求头
+     *
+     * @param authorization 认证token
+     * @return HttpHeaders
+     * @throws IOException
+     */
+    public HttpHeaders buildHttpHeaders(String authorization) throws IOException {
+        return setHttpHeaders(authorization);
+    }
+
     @NotNull
     @NotNull
-    private HttpHeaders setHttpHeaders1(){
+    private HttpHeaders setHttpHeaders1() {
         try {
         try {
             HttpHeaders headers = new HttpHeaders();
             HttpHeaders headers = new HttpHeaders();
             String cookie = getCookie();
             String cookie = getCookie();

+ 46 - 68
tenant/insurance/quotation-zijin/src/main/java/com/jzg/quotation/zijin/crawler/service/impl/ZiJinCrawlerQuoteProcessServiceImpl.java

@@ -10,19 +10,18 @@ import com.jzg.quotation.zijin.crawler.entity.ZiJinCrawlerTokenInfo;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCheckCaptchaRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCheckCaptchaRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCheckTokenRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCheckTokenRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCommonLoginRequest;
 import com.jzg.quotation.zijin.crawler.entity.request.ZiJinCrawlerCommonLoginRequest;
-import com.jzg.quotation.zijin.crawler.entity.response.*;
+import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerCaptchaResponse;
+import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerCheckCaptchaResponse;
+import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerCheckTokenResponse;
+import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerCommonLoginResponse;
 import com.jzg.quotation.zijin.crawler.service.ZiJinCrawlerQuoteProcessService;
 import com.jzg.quotation.zijin.crawler.service.ZiJinCrawlerQuoteProcessService;
-import com.jzg.quotation.zijin.crawler.util.DESEncryption;
-import com.jzg.quotation.zijin.crawler.util.RS6Item;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpHeaders;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.io.IOException;
 import java.io.IOException;
-import java.util.Map;
-import java.util.Optional;
 
 
 /**
 /**
  * @description: 紫金财险爬虫报价流程服务实现
  * @description: 紫金财险爬虫报价流程服务实现
@@ -41,6 +40,9 @@ public class ZiJinCrawlerQuoteProcessServiceImpl implements ZiJinCrawlerQuotePro
     // 登陆次数
     // 登陆次数
     public static final int LOGINS_NUMBER = 3;
     public static final int LOGINS_NUMBER = 3;
 
 
+    private final String USER_NAME = "214003053";
+    private final String PASSWORD = "Jieke896.";
+
     /**
     /**
      * 登录
      * 登录
      *
      *
@@ -68,15 +70,7 @@ public class ZiJinCrawlerQuoteProcessServiceImpl implements ZiJinCrawlerQuotePro
 
 
             // 3、校验验证码并获取token
             // 3、校验验证码并获取token
             ZiJinCrawlerCheckCaptchaRequest ziJinCrawlerCheckCaptchaRequest = new ZiJinCrawlerCheckCaptchaRequest();
             ZiJinCrawlerCheckCaptchaRequest ziJinCrawlerCheckCaptchaRequest = new ZiJinCrawlerCheckCaptchaRequest();
-            ZiJinCrawlerTokenInfo ziJinCrawlerTokenInfo = new ZiJinCrawlerTokenInfo();
-            ziJinCrawlerTokenInfo.setLoginComCode(ziJinCrawlerCommonLoginResponse.getData().getData().get(0).getComCode());
-            ziJinCrawlerTokenInfo.setUserCode(username);
-            ZiJinCrawlerTokenInfo.Attach attach = new ZiJinCrawlerTokenInfo.Attach();
-            attach.setLoginComName(ziJinCrawlerCommonLoginResponse.getData().getData().get(0).getComName());
-            attach.setLoginflag("common");
-            attach.setUserCode(username);
-            attach.setAccountType("9");
-            ziJinCrawlerTokenInfo.setAttach(attach);
+            ZiJinCrawlerTokenInfo ziJinCrawlerTokenInfo = getZiJinCrawlerTokenInfo(username, ziJinCrawlerCommonLoginResponse);
             log.info("ziJinCrawlerTokenInfo对象的值:{}", JSON.toJSONString(ziJinCrawlerTokenInfo));
             log.info("ziJinCrawlerTokenInfo对象的值:{}", JSON.toJSONString(ziJinCrawlerTokenInfo));
             // 设置校验验证码请求参数
             // 设置校验验证码请求参数
             ziJinCrawlerCheckCaptchaRequest.setTokenInfo(JSON.toJSONString(ziJinCrawlerTokenInfo));
             ziJinCrawlerCheckCaptchaRequest.setTokenInfo(JSON.toJSONString(ziJinCrawlerTokenInfo));
@@ -91,23 +85,23 @@ public class ZiJinCrawlerQuoteProcessServiceImpl implements ZiJinCrawlerQuotePro
                 // 获取token
                 // 获取token
                 String token = ziJinCrawlerCheckCaptchaResponse.getData().getToken();
                 String token = ziJinCrawlerCheckCaptchaResponse.getData().getToken();
                 // 4、校验token
                 // 4、校验token
-                ZiJinCrawlerCheckTokenRequest ziJinCrawlerCheckTokenRequest = new ZiJinCrawlerCheckTokenRequest();
-                ziJinCrawlerCheckTokenRequest.setExpirationType("H5");
-                ziJinCrawlerCheckTokenRequest.setToken(token);
-
-                ZiJinCrawlerCheckTokenResponse ziJinCrawlerCheckTokenResponse = ziJinCrawlerRequestComponent.checkToken(ziJinCrawlerCheckTokenRequest, token);
-                log.info("校验token响应:{}", JSON.toJSONString(ziJinCrawlerCheckTokenResponse));
-                if (ziJinCrawlerCheckTokenResponse.isValid()) {
-                    String userName = ziJinCrawlerCheckTokenResponse.getUserName();
-                    String tokenInfo = ziJinCrawlerCheckTokenResponse.getTokenInfo();
-                    ZiJinCrawlerTokenInfo ziJinCrawlerTokenInfo1 = JSON.parseObject(tokenInfo, ZiJinCrawlerTokenInfo.class);
-                    String userCode = ziJinCrawlerTokenInfo1.getUserCode();
-                    // 缓存用户信息
-                    return ziJinCrawlerCacheComponent.cacheAuthorization(token, userCode, userName);
-                } else {
-                    log.error("校验token失败,响应:{}", JSON.toJSONString(ziJinCrawlerCheckTokenResponse));
-                    return ziJinCrawlerCheckTokenResponse.getMsg();
-                }
+                // ZiJinCrawlerCheckTokenRequest ziJinCrawlerCheckTokenRequest = new ZiJinCrawlerCheckTokenRequest();
+                // ziJinCrawlerCheckTokenRequest.setExpirationType("H5");
+                // ziJinCrawlerCheckTokenRequest.setToken(token);
+                // ZiJinCrawlerCheckTokenResponse ziJinCrawlerCheckTokenResponse = ziJinCrawlerRequestComponent.checkToken(ziJinCrawlerCheckTokenRequest, token);
+                // log.info("校验token响应:{}", JSON.toJSONString(ziJinCrawlerCheckTokenResponse));
+                // if (ziJinCrawlerCheckTokenResponse.isValid()) {
+                //     String userName = ziJinCrawlerCheckTokenResponse.getUserName();
+                //     String tokenInfo = ziJinCrawlerCheckTokenResponse.getTokenInfo();
+                //     ZiJinCrawlerTokenInfo ziJinCrawlerTokenInfo1 = JSON.parseObject(tokenInfo, ZiJinCrawlerTokenInfo.class);
+                //     String userCode = ziJinCrawlerTokenInfo1.getUserCode();
+                //     // 缓存用户信息
+                //     return ziJinCrawlerCacheComponent.cacheAuthorization(token, userCode, userName);
+                // } else {
+                //     log.error("校验token失败,响应:{}", JSON.toJSONString(ziJinCrawlerCheckTokenResponse));
+                //     return ziJinCrawlerCheckTokenResponse.getMsg();
+                // }
+                return ziJinCrawlerCacheComponent.cacheAuthorization(token, username, "");
             } else {
             } else {
                 log.error("校验验证码并获取token失败,响应:{}", JSON.toJSONString(ziJinCrawlerCheckCaptchaResponse));
                 log.error("校验验证码并获取token失败,响应:{}", JSON.toJSONString(ziJinCrawlerCheckCaptchaResponse));
                 throw new SystemException("校验验证码并获取token失败");
                 throw new SystemException("校验验证码并获取token失败");
@@ -118,6 +112,20 @@ public class ZiJinCrawlerQuoteProcessServiceImpl implements ZiJinCrawlerQuotePro
         }
         }
     }
     }
 
 
+    @NotNull
+    private ZiJinCrawlerTokenInfo getZiJinCrawlerTokenInfo(String username, ZiJinCrawlerCommonLoginResponse ziJinCrawlerCommonLoginResponse) {
+        ZiJinCrawlerTokenInfo ziJinCrawlerTokenInfo = new ZiJinCrawlerTokenInfo();
+        ziJinCrawlerTokenInfo.setLoginComCode(ziJinCrawlerCommonLoginResponse.getData().getData().get(0).getComCode());
+        ziJinCrawlerTokenInfo.setUserCode(username);
+        ZiJinCrawlerTokenInfo.Attach attach = new ZiJinCrawlerTokenInfo.Attach();
+        attach.setLoginComName(ziJinCrawlerCommonLoginResponse.getData().getData().get(0).getComName());
+        attach.setLoginflag("common");
+        attach.setUserCode(username);
+        attach.setAccountType("9");
+        ziJinCrawlerTokenInfo.setAttach(attach);
+        return ziJinCrawlerTokenInfo;
+    }
+
     /**
     /**
      * 获取请求头
      * 获取请求头
      *
      *
@@ -129,47 +137,17 @@ public class ZiJinCrawlerQuoteProcessServiceImpl implements ZiJinCrawlerQuotePro
     public HttpHeaders getHeaders(String username, String password) {
     public HttpHeaders getHeaders(String username, String password) {
         String authorization = ziJinCrawlerCacheComponent.getAuthorization(username);
         String authorization = ziJinCrawlerCacheComponent.getAuthorization(username);
         log.info("authorization:{}", authorization);
         log.info("authorization:{}", authorization);
-        /*if (authorization == null) {
-            login(username, password);
-            authorization = ziJinCrawlerCacheComponent.getAuthorization(username);
-        }*/
+        if (authorization == null) {
+            // TODO: 暂时硬编码,后续调整
+            login(USER_NAME, PASSWORD);
+            authorization = ziJinCrawlerCacheComponent.getAuthorization(USER_NAME);
+        }
 
 
-        HttpHeaders headers = new HttpHeaders();
-        headers.set("Authorization", authorization);
-        headers.set("Content-Type", "application/json");
-        headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
-        // 获取cookie的值
-        String cookie = null;
         try {
         try {
-            cookie = ZiJinCrawlerRequestComponent.getCookie();
+            return ziJinCrawlerRequestComponent.buildHttpHeaders(authorization);
         } catch (IOException e) {
         } catch (IOException e) {
             throw new RuntimeException(e);
             throw new RuntimeException(e);
         }
         }
-        headers.set("Cookie", "csrfToken=CrwLEmSfUevAb8PcN7kXff-I; " + cookie);
-        // 设置请求头
-        headers.set("Accept", "application/json, text/plain, */*, application/problem+json");
-        // headers.set("Accept-Encoding", "gzip, deflate, br, zstd");
-        headers.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
-        headers.set("Authorization", "1B0234C742C12BD632AA5027EB3A501A");
-        headers.set("Cache-Control", "no-cache");
-        headers.set("Connection", "keep-alive");
-        headers.set("Content-Length", "23");
-        headers.set("Host", "kscd.zking.com");
-        headers.set("Origin", "https://kscd.zking.com");
-        headers.set("Pragma", "no-cache");
-        headers.set("Referer", "https://kscd.zking.com/app/vehicle/proposal/commonlogin");
-        headers.set("Sec-Fetch-Dest", "empty");
-        headers.set("Sec-Fetch-Mode", "cors");
-        headers.set("Sec-Fetch-Site", "same-origin");
-        headers.set("Tokentype", "DEFULT");
-        // headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36");
-        headers.set("loginToken", "1B0234C742C12BD632AA5027EB3A501A");
-        headers.set("sec-ch-ua", "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"");
-        headers.set("sec-ch-ua-mobile", "?0");
-        headers.set("sec-ch-ua-platform", "\"Windows\"");
-        headers.set("x-csrf-token", "CrwLEmSfUevAb8PcN7kXff-I");
-
-        return headers;
     }
     }
 
 
     @Override
     @Override

+ 17 - 20
tenant/insurance/quotation-zijin/src/main/java/com/jzg/quotation/zijin/crawler/service/impl/ZiJinCrawlerRequestImpl.java

@@ -118,9 +118,6 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
         HttpHeaders headers = ziJinCrawlerQuoteProcessService.getHeaders(attributionInformationVo.getUsername(), attributionInformationVo.getPassword());
         HttpHeaders headers = ziJinCrawlerQuoteProcessService.getHeaders(attributionInformationVo.getUsername(), attributionInformationVo.getPassword());
         log.info("headers参数的值:{}", JSON.toJSONString(headers));
         log.info("headers参数的值:{}", JSON.toJSONString(headers));
 
 
-        String authorization = "FD385C99C9B35B64EF84590AACA95380";
-        headers.set("Authorization", authorization);
-
         String userCode = ziJinCrawlerCacheComponent.getUserCode(attributionInformationVo.getUsername());
         String userCode = ziJinCrawlerCacheComponent.getUserCode(attributionInformationVo.getUsername());
         log.info("userCode:{}", userCode);
         log.info("userCode:{}", userCode);
 
 
@@ -209,9 +206,9 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
             // 设置车载设备保费列表(空列表)
             // 设置车载设备保费列表(空列表)
             ziJinCrawlerQuotationRequest.setCarDevicePremiumDtoList(new ArrayList<>());
             ziJinCrawlerQuotationRequest.setCarDevicePremiumDtoList(new ArrayList<>());
             // 报价
             // 报价
-            log.info("ziJinCrawlerQuotationRequest参数的值:{}", JSON.toJSONString(ziJinCrawlerQuotationRequest));
+            log.info("ziJinCrawlerQuotationRequest参数:{}", JSON.toJSONString(ziJinCrawlerQuotationRequest));
             ZiJinCrawlerQuotationResponse ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
             ZiJinCrawlerQuotationResponse ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
-            log.info("ziJinCrawlerQuotationResponse参数的值:{}", JSON.toJSONString(ziJinCrawlerQuotationResponse));
+            log.info("ziJinCrawlerQuotationResponse响应:{}", JSON.toJSONString(ziJinCrawlerQuotationResponse));
             // 设置紫金财险爬虫订单号,后面保存到数据库中
             // 设置紫金财险爬虫订单号,后面保存到数据库中
             ziJinCrawlerQuotationResponse.setOrderNo(ziJinCrawlerGetOrderNoResponse.getOrderNo());
             ziJinCrawlerQuotationResponse.setOrderNo(ziJinCrawlerGetOrderNoResponse.getOrderNo());
 
 
@@ -227,7 +224,7 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
                     // 修改交强险起保时间
                     // 修改交强险起保时间
                     ziJinCrawlerQuotationRequest.getBaseInfo().setStartDateCI(TimeProcessing.dateTimeToDate(startTime));
                     ziJinCrawlerQuotationRequest.getBaseInfo().setStartDateCI(TimeProcessing.dateTimeToDate(startTime));
                     ziJinCrawlerQuotationRequest.getBaseInfo().setEndDateCI(TimeProcessing.minusDays(TimeProcessing.dateTimeToDate(newEndTime), 1));
                     ziJinCrawlerQuotationRequest.getBaseInfo().setEndDateCI(TimeProcessing.minusDays(TimeProcessing.dateTimeToDate(newEndTime), 1));
-                    log.info("紫金报价重复投保参数: startTime={}, endTime={}", startTime, newEndTime);
+                    log.info("紫金报价重复投保日期参数: startTime={}, endTime={}", startTime, newEndTime);
                     ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
                     ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
                     log.info("紫金报价重复投保后响应: {}", JSON.toJSONString(ziJinCrawlerQuotationResponse));
                     log.info("紫金报价重复投保后响应: {}", JSON.toJSONString(ziJinCrawlerQuotationResponse));
                 }
                 }
@@ -237,11 +234,12 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
             if (ResponseCode.R_0001.getCode().equals(ziJinCrawlerQuotationResponse.getRtnCode())) {
             if (ResponseCode.R_0001.getCode().equals(ziJinCrawlerQuotationResponse.getRtnCode())) {
                 if (ziJinCrawlerQuotationResponse.getBasePart() != null) {
                 if (ziJinCrawlerQuotationResponse.getBasePart() != null) {
                     ZiJinCrawlerRecognizeCodesResponse ziJinCrawlerRecognizeCodesResponse = ziJinCrawlerRequestComponent.recognizeCodes(ZiJinCrawlerQuoteRequestBuild.buildRecognizeCodesRequests(ziJinCrawlerQuotationResponse), headers);
                     ZiJinCrawlerRecognizeCodesResponse ziJinCrawlerRecognizeCodesResponse = ziJinCrawlerRequestComponent.recognizeCodes(ZiJinCrawlerQuoteRequestBuild.buildRecognizeCodesRequests(ziJinCrawlerQuotationResponse), headers);
-                    log.info("ziJinCrawlerRecognizeCodesResponse参数的值:{}", JSON.toJSONString(ziJinCrawlerRecognizeCodesResponse));
+                    log.info("ziJinCrawlerRecognizeCodesResponse响应:{}", JSON.toJSONString(ziJinCrawlerRecognizeCodesResponse));
                     // 验证码通过后再次调用报价接口
                     // 验证码通过后再次调用报价接口
                     if (ResponseCode.R_0000.getCode().equals(ziJinCrawlerRecognizeCodesResponse.getRtnCode())) {
                     if (ResponseCode.R_0000.getCode().equals(ziJinCrawlerRecognizeCodesResponse.getRtnCode())) {
                         ZiJinCrawlerQuoteRequestBuild.buildReQuote(ziJinCrawlerQuotationResponse, ziJinCrawlerRecognizeCodesResponse, ziJinCrawlerQuotationRequest);
                         ZiJinCrawlerQuoteRequestBuild.buildReQuote(ziJinCrawlerQuotationResponse, ziJinCrawlerRecognizeCodesResponse, ziJinCrawlerQuotationRequest);
                         ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
                         ziJinCrawlerQuotationResponse = ziJinCrawlerRequestComponent.quotation(ziJinCrawlerQuotationRequest, headers);
+                        log.info("紫金报价转保标志ziJinCrawlerQuotationResponse响应: {}", JSON.toJSONString(ziJinCrawlerQuotationResponse));
                     }
                     }
                 }
                 }
             }
             }
@@ -254,9 +252,9 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
                 // 报价成功
                 // 报价成功
                 // 保存报价信息
                 // 保存报价信息
                 ZiJinCrawlerSaveQuoteInfoRequest ziJinCrawlerSaveQuoteInfoRequest = ziJinCrawlerSaveQuoteInfoRequestBuild.buildSaveQuoteInfoRequest(quoteVo, ziJinCrawlerQuotationRequest, ziJinCrawlerQuotationResponse);
                 ZiJinCrawlerSaveQuoteInfoRequest ziJinCrawlerSaveQuoteInfoRequest = ziJinCrawlerSaveQuoteInfoRequestBuild.buildSaveQuoteInfoRequest(quoteVo, ziJinCrawlerQuotationRequest, ziJinCrawlerQuotationResponse);
-                log.info("ziJinCrawlerSaveQuoteInfoRequest参数的值:{}", JSON.toJSONString(ziJinCrawlerSaveQuoteInfoRequest));
+                log.info("ziJinCrawlerSaveQuoteInfoRequest参数:{}", JSON.toJSONString(ziJinCrawlerSaveQuoteInfoRequest));
                 ZiJinCrawlerSaveQuoteInfoResponse ziJinCrawlerSaveQuoteInfoResponse = ziJinCrawlerRequestComponent.saveQuoteInformation(ziJinCrawlerSaveQuoteInfoRequest, headers);
                 ZiJinCrawlerSaveQuoteInfoResponse ziJinCrawlerSaveQuoteInfoResponse = ziJinCrawlerRequestComponent.saveQuoteInformation(ziJinCrawlerSaveQuoteInfoRequest, headers);
-                log.info("ziJinCrawlerSaveQuoteInfoResponse参数的值:{}", JSON.toJSONString(ziJinCrawlerSaveQuoteInfoResponse));
+                log.info("ziJinCrawlerSaveQuoteInfoResponse响应:{}", JSON.toJSONString(ziJinCrawlerSaveQuoteInfoResponse));
 
 
                 // 保存投保单
                 // 保存投保单
                 ZiJinCrawlerSaveProposalRequest ziJinCrawlerSaveProposalRequest = new ZiJinCrawlerSaveProposalRequest();
                 ZiJinCrawlerSaveProposalRequest ziJinCrawlerSaveProposalRequest = new ZiJinCrawlerSaveProposalRequest();
@@ -1086,8 +1084,7 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
      * @param headers      请求头
      * @param headers      请求头
      * @return ZiJinCrawlerQuotationRequest.TaxRelifInfo
      * @return ZiJinCrawlerQuotationRequest.TaxRelifInfo
      */
      */
-    private ZiJinCrawlerQuotationRequest.TaxRelifInfo buildTaxRelifInfo(QuoteVo quoteVo,
-                                                                        ZiJinCrawlerQuotationRequest.CarOwnerInfo carOwnerInfo, String comCode, HttpHeaders headers) {
+    private ZiJinCrawlerQuotationRequest.TaxRelifInfo buildTaxRelifInfo(QuoteVo quoteVo, ZiJinCrawlerQuotationRequest.CarOwnerInfo carOwnerInfo, String comCode, HttpHeaders headers) {
         ZiJinCrawlerQuotationRequest.TaxRelifInfo taxRelifInfo = new ZiJinCrawlerQuotationRequest.TaxRelifInfo();
         ZiJinCrawlerQuotationRequest.TaxRelifInfo taxRelifInfo = new ZiJinCrawlerQuotationRequest.TaxRelifInfo();
 
 
         // 只有投保交强险时才构建完整的税务信息
         // 只有投保交强险时才构建完整的税务信息
@@ -1095,15 +1092,15 @@ public class ZiJinCrawlerRequestImpl implements ZiJinCrawlerRequest {
         CarInfoVo carInfoVo = quoteVo.getCarInfoVo();
         CarInfoVo carInfoVo = quoteVo.getCarInfoVo();
 
 
         // 获取税务登记证号
         // 获取税务登记证号
-        String taxRegistryNumber = "91140100MAE72CK690";
-        // try {
-        //     ZiJinCrawlerGetTaxRegistryNumberResponse taxResponse = ziJinCrawlerRequestComponent.getTaxRegistryNumber(comCode, headers);
-        //     if (taxResponse != null && StringUtils.hasLength(taxResponse.getData())) {
-        //         taxRegistryNumber = taxResponse.getData();
-        //     }
-        // } catch (Exception e) {
-        //     log.error("获取税务登记证号失败: {}", e.getMessage());
-        // }
+        String taxRegistryNumber = "";
+        try {
+            ZiJinCrawlerGetTaxRegistryNumberResponse taxResponse = ziJinCrawlerRequestComponent.getTaxRegistryNumber(comCode, headers);
+            if (taxResponse != null && StringUtils.hasLength(taxResponse.getData())) {
+                taxRegistryNumber = taxResponse.getData();
+            }
+        } catch (Exception e) {
+            log.error("获取税务登记证号失败: {}", e.getMessage());
+        }
 
 
         // 设置税务信息
         // 设置税务信息
         taxRelifInfo.setTaxRelifFlag(quoteVo.getVehicleAndVesselTaxVo().getTaxRelifFlag());// 1 正常缴税 2 免税 3 减税 4 已完税 5 不征
         taxRelifInfo.setTaxRelifFlag(quoteVo.getVehicleAndVesselTaxVo().getTaxRelifFlag());// 1 正常缴税 2 免税 3 减税 4 已完税 5 不征