jinshihui 10 месяцев назад
Родитель
Сommit
35725309a7

+ 42 - 48
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/component/RequestComponent.java

@@ -67,9 +67,7 @@ public class RequestComponent {
         return filtered;
     }
 
-  
-    
-    
+
     private final WebClient webClient;
 
     private final WebClientConfig webClientConfig;
@@ -320,11 +318,11 @@ public class RequestComponent {
                     .block();
             if (rawResponse == null) {
                 throw new WebClientResponseException(
-                    500,
-                    "No response received",
-                    HttpHeaders.EMPTY,
-                    "No response received".getBytes(StandardCharsets.UTF_8),
-                    null
+                        500,
+                        "No response received",
+                        HttpHeaders.EMPTY,
+                        "No response received".getBytes(StandardCharsets.UTF_8),
+                        null
                 );
             }
             String responseBody = rawResponse.getBody();
@@ -341,11 +339,11 @@ public class RequestComponent {
             } catch (Exception e) {
                 log.error("JSON解析失败,过滤后的响应内容: {}", filteredResponse, e);
                 throw new WebClientResponseException(
-                    500,
-                    "JSON parsing failed after filtering: " + e.getMessage(),
-                    rawResponse.getHeaders(),
-                    filteredResponse.getBytes(StandardCharsets.UTF_8),
-                    null
+                        500,
+                        "JSON parsing failed after filtering: " + e.getMessage(),
+                        rawResponse.getHeaders(),
+                        filteredResponse.getBytes(StandardCharsets.UTF_8),
+                        null
                 );
             }
             // 构建返回的ResponseEntity
@@ -363,11 +361,11 @@ public class RequestComponent {
             // 处理其他异常
             log.error("请求失败", e);
             throw new WebClientResponseException(
-                500,
-                "Request failed: " + e.getMessage(),
-                HttpHeaders.EMPTY,
-                e.getMessage().getBytes(StandardCharsets.UTF_8),
-                null
+                    500,
+                    "Request failed: " + e.getMessage(),
+                    HttpHeaders.EMPTY,
+                    e.getMessage().getBytes(StandardCharsets.UTF_8),
+                    null
             );
         }
     }
@@ -380,8 +378,8 @@ public class RequestComponent {
      * @param body
      * @param responseClass
      * @param headers
-     * @return ResponseEntity<Response>
      * @param <Response>
+     * @return ResponseEntity<Response>
      */
     public <Response> ResponseEntity<Response> postWithMono(String url, String body, Class<Response> responseClass, HttpHeaders headers) {
         WebClient webClient = selectNoSSLWebClient();
@@ -396,7 +394,6 @@ public class RequestComponent {
     }
 
 
-
     /**
      * 构造post请求
      *
@@ -431,11 +428,11 @@ public class RequestComponent {
 
             if (rawResponse == null) {
                 throw new WebClientResponseException(
-                    500,
-                    "No response received",
-                    HttpHeaders.EMPTY,
-                    "No response received".getBytes(StandardCharsets.UTF_8),
-                    null
+                        500,
+                        "No response received",
+                        HttpHeaders.EMPTY,
+                        "No response received".getBytes(StandardCharsets.UTF_8),
+                        null
                 );
             }
 
@@ -453,11 +450,11 @@ public class RequestComponent {
             } catch (Exception e) {
                 log.error("JSON解析失败,过滤后的响应内容: {}", filteredResponse, e);
                 throw new WebClientResponseException(
-                    500,
-                    "JSON parsing failed after filtering: " + e.getMessage(),
-                    rawResponse.getHeaders(),
-                    filteredResponse.getBytes(StandardCharsets.UTF_8),
-                    null
+                        500,
+                        "JSON parsing failed after filtering: " + e.getMessage(),
+                        rawResponse.getHeaders(),
+                        filteredResponse.getBytes(StandardCharsets.UTF_8),
+                        null
                 );
             }
 
@@ -478,11 +475,11 @@ public class RequestComponent {
             // 处理其他异常
             log.error("请求失败", e);
             throw new WebClientResponseException(
-                500,
-                "Request failed: " + e.getMessage(),
-                HttpHeaders.EMPTY,
-                e.getMessage().getBytes(StandardCharsets.UTF_8),
-                null
+                    500,
+                    "Request failed: " + e.getMessage(),
+                    HttpHeaders.EMPTY,
+                    e.getMessage().getBytes(StandardCharsets.UTF_8),
+                    null
             );
         }
     }
@@ -524,20 +521,18 @@ public class RequestComponent {
                 } catch (Exception e) {
                     // 如果JSON解析失败,抛出异常
                     return Mono.error(new WebClientResponseException(
-                        500,
-                        "JSON parsing failed after filtering: " + e.getMessage(),
-                        HttpHeaders.EMPTY,
-                        filteredResponse.getBytes(StandardCharsets.UTF_8),
-                        null
+                            500,
+                            "JSON parsing failed after filtering: " + e.getMessage(),
+                            HttpHeaders.EMPTY,
+                            filteredResponse.getBytes(StandardCharsets.UTF_8),
+                            null
                     ));
                 }
             });
-
             // 等待结果并构建ResponseEntity
             Response result = resultMono.block();
             HttpHeaders responseHeaders = new HttpHeaders();
             responseHeaders.setContentType(MediaType.APPLICATION_JSON);
-
             // 获取原始响应状态码
             ResponseEntity<String> rawResponse = webClient.post()
                     .uri(url)
@@ -552,18 +547,17 @@ public class RequestComponent {
 
             int statusCode = rawResponse != null ? rawResponse.getStatusCode().value() : 200;
             return ResponseEntity.status(statusCode).headers(responseHeaders).body(result);
-
         } catch (WebClientResponseException e) {
             e.printStackTrace();
             throw e;
         } catch (Exception e) {
             // 处理其他异常
             throw new WebClientResponseException(
-                500,
-                "Request failed: " + e.getMessage(),
-                HttpHeaders.EMPTY,
-                e.getMessage().getBytes(StandardCharsets.UTF_8),
-                null
+                    500,
+                    "Request failed: " + e.getMessage(),
+                    HttpHeaders.EMPTY,
+                    e.getMessage().getBytes(StandardCharsets.UTF_8),
+                    null
             );
         }
     }

+ 29 - 2
tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/component/TaiShanCrawlerRequestComponent.java

@@ -1,4 +1,5 @@
 package com.jzg.quotation.taishan.crawler.component;
+
 import com.alibaba.fastjson2.JSON;
 import com.jzg.commons.exception.SystemException;
 import com.jzg.quotation.taishan.crawler.constant.enums.RequestUrl;
@@ -39,12 +40,11 @@ public class TaiShanCrawlerRequestComponent {
     private final TaiShanCrawlerProperties taiShanCrawlerProperties;
 
 
-
     /**
      * 创建Token
      *
      * @param operatorCode 操作员代码
-     * @param headers 请求头
+     * @param headers      请求头
      * @return Token字符串
      */
     public String createToken(String operatorCode, HttpHeaders headers) {
@@ -123,6 +123,33 @@ public class TaiShanCrawlerRequestComponent {
         return response.getBody();
     }
 
+    /**
+     * 保存报价信息
+     *
+     * @param taiShanCrawlerQuotationSaveRequest
+     * @param headers
+     * @return TaiShanCrawlerQuotationSaveResponse
+     */
+    public TaiShanCrawlerQuotationSaveResponse saveQuotation(TaiShanCrawlerQuotationSaveRequest taiShanCrawlerQuotationSaveRequest, HttpHeaders headers) {
+        try {
+            String jsonString = JSON.toJSONString(taiShanCrawlerQuotationSaveRequest);
+            log.info("taiShanCrawlerQuotationSaveRequest参数的值: {}", jsonString);
+
+            // 使用post2方法,该方法包含更好的错误处理和字符过滤功能
+            ResponseEntity<TaiShanCrawlerQuotationSaveResponse> response = requestComponent.post2(
+                    RequestUrl.SAVE.getRequestUrl(taiShanCrawlerProperties.getBaseUrl()),
+                    jsonString,
+                    TaiShanCrawlerQuotationSaveResponse.class,
+                    headers
+            );
+            return response.getBody();
+        } catch (Exception e) {
+            log.error("保存报价信息失败", e);
+            throw new RuntimeException("保存报价信息失败: " + e.getMessage(), e);
+        }
+    }
+
+
     /**
      * 核保
      *

+ 1 - 0
tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/constant/enums/RequestUrl.java

@@ -12,6 +12,7 @@ public enum RequestUrl {
 
     // 报价相关
     PRICE("/api_prod/ins/api/proposal/price", "报价"),
+    SAVE("/api_prod/ins/api/proposal/save", "保存报价"),
     UNDERWRITING("/quotation/underwriting", "核保"),
 
     // 影像上传

+ 1 - 1
tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/entity/request/TaiShanCrawlerQuotationSaveRequest.java

@@ -2187,7 +2187,7 @@ public class TaiShanCrawlerQuotationSaveRequest implements Serializable {
 
         @JsonProperty("personAge")
         @JSONField(name = "personAge", ordinal = 11)
-        private Integer personAge;
+        private String personAge;
     }
 
 }

Разница между файлами не показана из-за своего большого размера
+ 566 - 281
tenant/insurance/quotation-taishan/src/main/java/com/jzg/quotation/taishan/crawler/service/impl/TaiShanCrawlerRequestImpl.java


Некоторые файлы не были показаны из-за большого количества измененных файлов