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

update
恒邦财险
1.报价流程修改

wks 1 год назад
Родитель
Сommit
72b7207a62

+ 2 - 41
tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/component/HengBangCrawlerRequestComponent.java

@@ -57,53 +57,14 @@ public class HengBangCrawlerRequestComponent {
         if (frequency <= 0) {
             throw new SystemException("验证码异常");
         }
-        HbCrawlerCaptchaRequest captchaRequest = new HbCrawlerCaptchaRequest();
         // 请求
-        HbCrawlerCaptchaResponse HbCrawlerCaptchaResponse = requestComponent.objectPost(RequestUrl.VERIFY_CODE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), JSONObject.toJSONString(captchaRequest), "", HbCrawlerCaptchaResponse.class);
+        HbCrawlerCaptchaResponse HbCrawlerCaptchaResponse = requestComponent.objectPost(RequestUrl.VERIFY_CODE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), new HbCrawlerCaptchaRequest(), "", HbCrawlerCaptchaResponse.class);
         // 识别验证码
         String s = exteriorUtilsRequest.captchaIdentify(HbCrawlerCaptchaResponse.getVerifyImg());
-        try {
-            int i = processCaptcha(s);
-            s = String.valueOf(i);
-        } catch (Exception e) {
-            frequency = frequency - 1;
-            return captcha(frequency);
-        }
         HbCrawlerCaptchaResponse.setVerifyCode(s);
         return HbCrawlerCaptchaResponse;
     }
 
-    public int processCaptcha(String res) {
-        // 检查字符串长度是否足够,并且第三个字符不是'='
-        if (res.length() >= 3 && res.charAt(2) != '=') {
-            char operator = res.charAt(1);
-            try {
-                int operand1 = Integer.parseInt(res.substring(0, 1));
-                int operand2 = Integer.parseInt(res.substring(2, 3));
-                // 注意:这里假设操作符和操作数都是有效的,实际应用中应该添加更多的错误处理
-
-                switch (operator) {
-                    case '+':
-                    case 'f': // 通常'f'不是加法运算符,但根据原代码保留
-                        return operand1 + operand2;
-                    case 'x':
-                    case 'X':
-                    case '4': // 通常'4'不是乘法运算符,但保留以匹配原代码
-                    case '9': // 通常'9'也不是乘法运算符,但保留以匹配原代码
-                        return operand1 * operand2;
-                    case '-':
-                    case 'e': // 通常'e'不是减法运算符,但根据原代码保留
-                    case '=': // 通常'='不是减法运算符,但根据原代码保留
-                    case '2': // 通常'2'也不是减法运算符,但根据原代码保留
-                        return operand1 - operand2;
-                    // 如果操作符不匹配,则获取新的验证码图片(模拟)
-                }
-            } catch (NumberFormatException ignored) {
-            }
-        }
-        throw new SystemException("");
-    }
-
     /**
      * 登录次数
      *
@@ -117,7 +78,7 @@ public class HengBangCrawlerRequestComponent {
         HbCrawlerCaptchaResponse captchaResponse = captcha(RequestConstant.REQUEST_NUMBER);
         // 登录存入缓存当中
         HbCrawlerAuthenticateRequest authenticateRequest = new HbCrawlerAuthenticateRequest(captchaResponse, username, password);
-        ResponseEntity<HbCrawlerAuthenticateResponse> responseEntity = requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), JSONObject.toJSONString(authenticateRequest), HbCrawlerAuthenticateResponse.class);
+        ResponseEntity<HbCrawlerAuthenticateResponse> responseEntity = requestComponent.objectPost(RequestUrl.AUTHENTICATE.getRequestUrl(hbCrawlerProperties.getBaseUrl()), authenticateRequest, HbCrawlerAuthenticateResponse.class);
         HbCrawlerAuthenticateResponse authenticateResponse = Optional.of(responseEntity)
                 .map(ResponseEntity::getBody)
                 .orElseThrow();

+ 3 - 3
tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/entity/request/HbCrawlerQueryCarRequest.java

@@ -1,5 +1,6 @@
 package com.jzg.quotation.hengbang.crawler.entity.request;
 
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -29,9 +30,7 @@ public class HbCrawlerQueryCarRequest extends HbBaseRequest {
     private static final long serialVersionUID = 2573166312583296895L;
 
     public HbCrawlerQueryCarRequest(String brand, String modelCode, Integer VehicleStyleUniqueId) {
-        this.cbitData.Brand = brand;
-        this.cbitData.ModelCode = modelCode;
-        this.cbitData.VehicleStyleUniqueId = VehicleStyleUniqueId;
+        this.cbitData = new CbitDataDTO(brand, modelCode, VehicleStyleUniqueId);
         this.pageNo = 0;
         this.pageSize = 5;
     }
@@ -43,6 +42,7 @@ public class HbCrawlerQueryCarRequest extends HbBaseRequest {
     private Integer pageSize;
 
     @Data
+    @AllArgsConstructor
     @NoArgsConstructor
     public static class CbitDataDTO implements Serializable {
         @Serial

+ 3 - 0
tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/entity/response/HbBaseResponse.java

@@ -1,5 +1,6 @@
 package com.jzg.quotation.hengbang.crawler.entity.response;
 
+import java.io.Serial;
 import java.io.Serializable;
 
 /**
@@ -8,4 +9,6 @@ import java.io.Serializable;
  * @date: 2025/4/7 15:45
  **/
 public class HbBaseResponse implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 8468085174218499877L;
 }

+ 5 - 0
tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/entity/response/HbCrawlerCaptchaResponse.java

@@ -2,6 +2,8 @@ package com.jzg.quotation.hengbang.crawler.entity.response;
 
 import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 
 import java.io.Serial;
 
@@ -10,9 +12,12 @@ import java.io.Serial;
  * @author: shenwd
  * @date: 2025/4/7 15:45
  **/
+@EqualsAndHashCode(callSuper = true)
 @Data
 @AllArgsConstructor
+@NoArgsConstructor
 public class HbCrawlerCaptchaResponse extends HbBaseResponse{
+
     @Serial
     private static final long serialVersionUID = -8992172251538749662L;