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

华泰-处理车型找不到需二次查询车型;处理报价返回异常信息需二次报价参数调整的问题

lixiaolong 3 месяцев назад
Родитель
Сommit
6d915ac287

+ 12 - 4
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/entity/Request/HtCrawlerCarQueryRequest.java

@@ -5,12 +5,14 @@ import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.jzg.commons.entity.quote.vo.CarInfoVo;
 import com.jzg.commons.exception.SystemException;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.quotation.huatai.crawler.util.HuaTaiCryptUtil;
 import lombok.Data;
 
 import java.io.Serial;
 import java.io.Serializable;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @description: 华泰财险 查询车型 请求参数
@@ -22,9 +24,9 @@ public class HtCrawlerCarQueryRequest implements Serializable {
     @Serial
     private static final long serialVersionUID = 3366912683677575492L;
 
-    public HtCrawlerCarQueryRequest(CarInfoVo carInfoVo, String modelcodexh) {
+    public HtCrawlerCarQueryRequest(CarInfoVo carInfoVo, String modelcodexh, Map<String, Object> xbResult) {
         DataDTO dataDTO = new DataDTO();
-        dataDTO.setVehicleModel("");//carInfoVo.getBrandName()
+        dataDTO.setVehicleModel(carInfoVo.getBrandName());//carInfoVo.getBrandName()
         // 车辆类型自动判断
         if ("04".equals(carInfoVo.getVehicleUseCode())) {
             dataDTO.setMotortypecode("H0");
@@ -63,11 +65,17 @@ public class HtCrawlerCarQueryRequest implements Serializable {
         dataDTO.setLicenseplateno(carInfoVo.getLicenseNo());
         dataDTO.setEngineno(carInfoVo.getEngineNo());
         dataDTO.setVehicleregisterdate(carInfoVo.getRegisterDate());
+
+        if(StringUtils.isBlank(modelcodexh)) {
+            dataDTO.setJLlxVehicleList(xbResult.get("jLlxVehiclelList")==null?"":xbResult.get("jLlxVehiclelList").toString());
+        }
+
 //        dataDTO.setFueltype("");
 //        dataDTO.setPurerange("");
         dataDTO.setModelflag("1");
         dataDTO.setModelcodexh(modelcodexh);
         String data = JSON.toJSONString(dataDTO);
+        System.out.println("HtCrawlerCarQueryRequest,dataDTO:"+data);
         String key = HuaTaiCryptUtil.generateKey(16);
         try {
             String accessToken = HuaTaiCryptUtil.RSAEncrypt(key);
@@ -105,14 +113,14 @@ public class HtCrawlerCarQueryRequest implements Serializable {
      *   "modelflag": "1",
      *   "checkcode": "",
      *   "gdjgvehiclecheckflag": "",
-     *   "jLlxVehicleList": "{}"
+     *   "jLlxVehicleList": "{}"  "[{\"vehicleCode\":\"BMI1099DGB\",\"vehicleName\":\"迷你MINI COOPER 1.6L轿车\"}]"
      * }
      */
     @Data
     public static class DataDTO implements Serializable {
         @Serial
         private static final long serialVersionUID = -921901450062929380L;
-        @JsonProperty("vehicleModel")
+        @JsonProperty("vehiclemodel")
         private String vehicleModel;
         @JsonProperty("motortypecode")
         private String motortypecode;

+ 11 - 11
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/entity/Request/HtCrawlerQuoteRequest.java

@@ -72,11 +72,11 @@ public class HtCrawlerQuoteRequest implements Serializable {
             RiskInfoVo ciRiskInfoVo = quoteVo.getCiRiskInfoVo();
             RiskInfoVo biRiskInfoVo = quoteVo.getBiRiskInfoVo();
             VehicleAndVesselTaxVo taxVo = quoteVo.getVehicleAndVesselTaxVo();
-            this.isFirstCount = "false";
-            if (limitAmount.contains(",")) {
-                this.transferFlag = limitAmount.split(",")[1];
-            }
-            this.isGlmPrice = 0;
+            this.isFirstCount = "true";
+            //if (limitAmount.contains(",")) {
+            //    this.transferFlag = limitAmount.split(",")[1];
+            //}
+            this.isGlmPrice = "3";
             if (ciRiskInfoVo != null) {
                 this.isInsureTraffic = "true";
             } else {
@@ -87,7 +87,7 @@ public class HtCrawlerQuoteRequest implements Serializable {
             } else {
                 this.isInsureBusi = false;
             }
-            this.afloatValue = "0.0";
+            //this.afloatValue = "";
             this.hastax = this.isInsureTraffic;
             this.mealid = StringUtils.isBlank(mealid) ? "" : mealid;
             List<CovListDTO> covListDTOS = getCovListDTOS(quoteVo, limitAmount.contains(",") ? limitAmount.split(",")[0] : limitAmount);
@@ -324,17 +324,17 @@ public class HtCrawlerQuoteRequest implements Serializable {
 
             return personalInsuredDTOList;
         }
-        @JsonProperty("afloatValue")
-        private String afloatValue;
+        //@JsonProperty("afloatValue")
+        //private String afloatValue;
 
         @JsonProperty("isFirstCount")
         private String isFirstCount;
 
-        @JsonProperty("transferFlag")
-        private String transferFlag;
+        //@JsonProperty("transferFlag")
+        //private String transferFlag="";
 
         @JsonProperty("isGlmPrice")
-        private Integer isGlmPrice;
+        private String isGlmPrice;
 
         @JsonProperty("isInsureTraffic")
         private String isInsureTraffic;

+ 31 - 15
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/service/Impl/HuaTaiCrawlerRequestImpl.java

@@ -187,14 +187,14 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         Map<String, Object> m = new HashMap<>();
         m.put("licenseplateno", car.getLicenseNo());
         m.put("vin", car.getVinNo());
-        m.put("engineno", car.getEngineNo());
-        m.put("liceenseplatetype", car.getLicenseKindCode());
+        m.put("engineno", "");
+        m.put("liceenseplatetype", "02 小型汽车号牌");//
         m.put("ecdemicvehicleflag", "0");
         fillVehicleTypeCodes(car, m);
         m.put("xbcomcode", XBCOM_CODE);
         m.put("quotationNo", quotationNo);
         m.put("riskCode", RISK_CODE);
-        m.putAll(Map.of("engineno2", "", "enrollDate", "", "isJllxFlagType", "1",
+        m.putAll(Map.of("engineno2", car.getEngineNo(), "enrollDate", car.getRegisterDate(), "isJllxFlagType", "1",
                 "carModelCodexhQuery", "1", "telemarketFlag", ""));
         return m;
     }
@@ -221,9 +221,12 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         }, MAX_RETRIES, RETRY_DELAY_MS, "预报价获取登录信息");
 
         String quotationNo = str(xbResult, "quotationNo");
-        String modelcodexh = str(xbResult, "modelcodexh");
+        String modelcodexh = StringUtils.isBlank(str(xbResult, "modelcodexh")) ? car.getCarModelNo() : str(xbResult, "modelcodexh");
+        log.info("modelcodexh: {}", str(xbResult, "modelcodexh"));
+        log.info("modelcodexh: {}", modelcodexh);
+
         // 报价前预处理-保存车辆信息、过滤车型等处理
-        PreResult pre = prepareQuote(attr, mmap, car, modelcodexh, cookie, quotationNo);
+        PreResult pre = prepareQuote(attr, mmap, car, modelcodexh, cookie, quotationNo, xbResult);
         // 报价
         CoreResult core = executeQuote(quoteVo, quotationNo, dto, cookie, pre, gsInfo, attr);
         if (!core.success()) throw new SystemException("报价失败");
@@ -286,21 +289,33 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
 
     // ====================== 报价预处理 ======================
     private PreResult prepareQuote(AttributionInformationVo attr, Map<String, Object> mmap,
-                                   CarInfoVo car, String modelcodexh, String cookie, String quotationNo) throws Exception {
+                                   CarInfoVo car, String modelcodexh, String cookie, String quotationNo, Map<String, Object> xbResult) throws Exception {
         HtCrawlerConfigureParameters params = ConfigureParametersConversion.conversionEntity(
                 HtCrawlerConfigureParameters.class, attr.getConfigInfo());
         params.setFullComCode(params.getComCode());
-        //参数格式保持一致
+        //参数格式保持一致--方便过滤
         car.setPurchasePrice(car.getPurchasePrice().replace(".00", ""));
         //车辆查询
-        HtCrawlerCarQueryResponse.DataDTO dataDTO = req.carQuery(
-                new HtCrawlerCarQueryRequest(car, modelcodexh), req.getHeaders1(), car);
+        HtCrawlerCarQueryResponse.DataDTO dataDTO = req.carQuery(new HtCrawlerCarQueryRequest(car, modelcodexh, xbResult), req.getHeaders1(), car);
         //过滤车辆
-        HtCrawlerCarQueryResponse.DataDTO.DataListDTO carDTO = CarModelsFilterUtils.to(dataDTO.getDatalist(), car);
+        HtCrawlerCarQueryResponse.DataDTO.DataListDTO carDTO = null;
+        if(dataDTO.getDatalist() != null && !dataDTO.getDatalist().isEmpty()) {
+            carDTO = CarModelsFilterUtils.to(dataDTO.getDatalist(), car);
+        }
+        log.info("车辆查询,carDTO,{}",carDTO);
+        if (carDTO == null) {
+            // 未匹配则第二次carquery,带modelCName-->vehiclemodel
+            //dataDTO = req.carQuery(new HtCrawlerCarQueryRequest2(car), req.getHeaders1(), car);
+            dataDTO = req.carQuery(new HtCrawlerCarQueryRequest(car, "", xbResult), req.getHeaders1(), car);
+            log.info("未匹配则第二次车辆查询,dataDTO,{}",JSONObject.toJSONString(dataDTO));
+            //过滤车辆
+            carDTO = CarModelsFilterUtils.to(dataDTO.getDatalist(), car);
+            log.info("未匹配则第二次车辆查询,carDTO,{}",JSONObject.toJSONString(carDTO));
+        }
         log.info("过滤后的车型carDTO: {}", JSONObject.toJSONString(carDTO));
         //保存车辆信息
         executeSaveCarQuery(carDTO, dataDTO, car, cookie);
-        //车型查询
+        //车型查询 -- renewCarInfo
         String carData = executeCarModelCodexhQuery(carDTO, car, cookie, quotationNo);
         // 核心:关闭「未知字段抛出异常」,优先级 > 类注解
         MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -323,8 +338,9 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
             dataDTO.setDatalist2(dataList2);
             //过滤车型
             carDTO = CarModelsFilterUtils.to(dataDTO.getDatalist(), car);
+            log.info("二次过滤后的车型carDTO: {}", JSONObject.toJSONString(carDTO));
         }
-        //额外请求
+        //额外请求--消息中心心跳
         executeMessageCentreTimeBoom(cookie);
         //以上请求模拟浏览器请求流程,否则报价失败
         return new PreResult(params, dataDTO, carDTO);
@@ -343,14 +359,14 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         fd.add("vin", car.getVinNo());
         fd.add("modelcodexh", carDTO.getModelcodexh());
         fd.add("VehicleStyleUniqueId", "");
-
+        log.info("executeSaveCarQuery,{}",JSONObject.toJSONString(fd));
         post(BASE_URL + "/htcsp/VehicleInfoEntryAction.do?cmd=savecarquery", buildCarQueryHeaders(cookie), fd);
     }
 
     private String executeCarModelCodexhQuery(HtCrawlerCarQueryResponse.DataDTO.DataListDTO carDTO,
                                             CarInfoVo car, String cookie, String quotationNo) {
         MultiValueMap<String, String> fd = new LinkedMultiValueMap<>();
-        fd.add("modelCode", carDTO.getModelcodexh());
+        fd.add("modelCode", "BCHFCBUB0001");
         fd.add("licenseNo", car.getLicenseNo());
         fd.add("licenseKindCode", "02 小型汽车号牌");
         fd.add("engineNo", car.getEngineNo());
@@ -477,7 +493,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
                         AttributionInformationVo attr = q.getOrder().getAttributionInformationVo();
                         log.info(map.get("unMatchVehicleFrameMessage")+"已重新执行prepareQuote,新modelcodexh:{}", currentModelCodexh);
                         currentPre = prepareQuote(attr, gsInfo, q.getCarInfoVo(),
-                                currentModelCodexh, cookie, quotationNo);
+                                currentModelCodexh, cookie, quotationNo, map);
                         executeQuoteSteps(q, quotationNo, dto, cookie, currentPre, gsInfo);
 
                         // 跳过当前循环,重新执行报价流程