|
@@ -15,6 +15,8 @@ import com.jzg.quotation.commons.entity.DetectLoginRequest;
|
|
|
import com.jzg.quotation.commons.entity.GetCaptchaRequest;
|
|
import com.jzg.quotation.commons.entity.GetCaptchaRequest;
|
|
|
import com.jzg.quotation.commons.entity.GetCaptchaResponse;
|
|
import com.jzg.quotation.commons.entity.GetCaptchaResponse;
|
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
import com.jzg.quotation.commons.filter.CarModelsFilterUtils;
|
|
|
|
|
+import com.jzg.quotation.commons.utils.TimeProcessing;
|
|
|
|
|
+import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.quotation.taishan.crawler.build.TaiShanCrawlerQuoteRequestVoBuild;
|
|
import com.jzg.quotation.taishan.crawler.build.TaiShanCrawlerQuoteRequestVoBuild;
|
|
|
import com.jzg.quotation.taishan.crawler.build.TaiShanCrawlerQuoteResultsVoBuild;
|
|
import com.jzg.quotation.taishan.crawler.build.TaiShanCrawlerQuoteResultsVoBuild;
|
|
|
import com.jzg.quotation.taishan.crawler.component.TaiShanCrawlerRequestComponent;
|
|
import com.jzg.quotation.taishan.crawler.component.TaiShanCrawlerRequestComponent;
|
|
@@ -40,6 +42,8 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,6 +67,11 @@ public class TaiShanCrawlerRequestImpl implements TaiShanCrawlerRequest {
|
|
|
|
|
|
|
|
public static final int CIRCULATE_NUMBER = 3;
|
|
public static final int CIRCULATE_NUMBER = 3;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 截取重复投保终保日期的正则表达式(泰山格式:保险止期为:YYYY-MM-DD HH:mm:ss)
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final Pattern DUPLICATE_END_TIME_PATTERN = Pattern.compile("保险止期为:(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})");
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public GetCaptchaResponse getCaptcha(GetCaptchaRequest sendCaptchaRequest) {
|
|
public GetCaptchaResponse getCaptcha(GetCaptchaRequest sendCaptchaRequest) {
|
|
|
return taiShanCrawlerQuoteProcessService.getCaptcha(sendCaptchaRequest);
|
|
return taiShanCrawlerQuoteProcessService.getCaptcha(sendCaptchaRequest);
|
|
@@ -145,7 +154,38 @@ public class TaiShanCrawlerRequestImpl implements TaiShanCrawlerRequest {
|
|
|
// 3.1 保存报价信息接口
|
|
// 3.1 保存报价信息接口
|
|
|
this.resultCoverSave(quoteVo,taiShanCrawlerQuotationRequest,taiShanCrawlerQuotationResponse);
|
|
this.resultCoverSave(quoteVo,taiShanCrawlerQuotationRequest,taiShanCrawlerQuotationResponse);
|
|
|
log.info("taiShanCrawlerQuotationRequest:{}", JSON.toJSONString(taiShanCrawlerQuotationRequest));
|
|
log.info("taiShanCrawlerQuotationRequest:{}", JSON.toJSONString(taiShanCrawlerQuotationRequest));
|
|
|
- taiShanCrawlerQuotationSaveResponse = taiShanCrawlerRequestComponent.saveQuotation(taiShanCrawlerQuotationRequest, headers);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ taiShanCrawlerQuotationSaveResponse = taiShanCrawlerRequestComponent.saveQuotation(taiShanCrawlerQuotationRequest, headers);
|
|
|
|
|
+ } catch (SystemException e) {
|
|
|
|
|
+ // 重复投保,延保
|
|
|
|
|
+ if (e.getMessage() != null && e.getMessage().contains("重复投保")) {
|
|
|
|
|
+ String startTime = extractDuplicateEndTime(e.getMessage());
|
|
|
|
|
+ if (StringUtils.hasLength(startTime)) {
|
|
|
|
|
+ String newEndTime = TimeProcessing.minusOneSecondAfterYear(startTime);
|
|
|
|
|
+ String startDate = TimeProcessing.dateTimeToDate(startTime);
|
|
|
|
|
+ String endDate = TimeProcessing.minusDays(TimeProcessing.dateTimeToDate(newEndTime), 1);
|
|
|
|
|
+ buildDuplicateInsuranceDate(startDate, endDate, quoteVo, taiShanCrawlerQuotationRequest);
|
|
|
|
|
+ log.info("泰山报价重复投保日期参数: startTime={}, endTime={}", startTime, newEndTime);
|
|
|
|
|
+ // 重新报价
|
|
|
|
|
+ taiShanCrawlerQuotationResponse = taiShanCrawlerRequestComponent.quotation(taiShanCrawlerQuotationRequest, headers, CIRCULATE_NUMBER);
|
|
|
|
|
+ log.info("泰山报价重复投保后报价响应: {}", JSON.toJSONString(taiShanCrawlerQuotationResponse));
|
|
|
|
|
+ exception = taiShanCrawlerQuotationResponse.getResult().getException();
|
|
|
|
|
+ if (!exception.getCode().equals("H1")) {
|
|
|
|
|
+ errMsg = exception.getMsg();
|
|
|
|
|
+ return TaiShanCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(quoteVo, null, null, errMsg, false);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新报价信息
|
|
|
|
|
+ this.resultCoverSave(quoteVo, taiShanCrawlerQuotationRequest, taiShanCrawlerQuotationResponse);
|
|
|
|
|
+ // 重新保存
|
|
|
|
|
+ taiShanCrawlerQuotationSaveResponse = taiShanCrawlerRequestComponent.saveQuotation(taiShanCrawlerQuotationRequest, headers);
|
|
|
|
|
+ log.info("泰山报价重复投保后保存响应: {}", JSON.toJSONString(taiShanCrawlerQuotationSaveResponse));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
log.info("taiShanCrawlerQuotationSaveResponse参数的值:{}", JSON.toJSONString(taiShanCrawlerQuotationSaveResponse));
|
|
log.info("taiShanCrawlerQuotationSaveResponse参数的值:{}", JSON.toJSONString(taiShanCrawlerQuotationSaveResponse));
|
|
|
TaiShanCrawlerQuotationSaveResponse.Result.Exception saveException = taiShanCrawlerQuotationSaveResponse.getResult().getException();
|
|
TaiShanCrawlerQuotationSaveResponse.Result.Exception saveException = taiShanCrawlerQuotationSaveResponse.getResult().getException();
|
|
|
if (saveException.getCode().equals("H1")){
|
|
if (saveException.getCode().equals("H1")){
|
|
@@ -649,5 +689,40 @@ public class TaiShanCrawlerRequestImpl implements TaiShanCrawlerRequest {
|
|
|
return downloadPolicyResultVo;
|
|
return downloadPolicyResultVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取重复投保消息中的终保日期
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param returnMessage 返回消息
|
|
|
|
|
+ * @return 提取到的时间字符串,格式为 yyyy-MM-dd HH:mm:ss,未提取到返回 null
|
|
|
|
|
+ */
|
|
|
|
|
+ private String extractDuplicateEndTime(String returnMessage) {
|
|
|
|
|
+ if (returnMessage == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Matcher matcher = DUPLICATE_END_TIME_PATTERN.matcher(returnMessage);
|
|
|
|
|
+ if (matcher.find()) {
|
|
|
|
|
+ return matcher.group(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置重复投保日期(从重复投保消息中提取结束时间作为新的起保时间)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param startDate 起保日期
|
|
|
|
|
+ * @param endDate 终保日期
|
|
|
|
|
+ * @param quoteVo 报价实体
|
|
|
|
|
+ * @param request 泰山报价请求
|
|
|
|
|
+ */
|
|
|
|
|
+ private void buildDuplicateInsuranceDate(String startDate, String endDate, QuoteVo quoteVo, TaiShanCrawlerQuotationRequest request) {
|
|
|
|
|
+ // 设置交强险起止日期
|
|
|
|
|
+ request.getCompulsoryInsurance().getProductInfo().setStartDate(startDate);
|
|
|
|
|
+ request.getCompulsoryInsurance().getProductInfo().setEndDate(endDate);
|
|
|
|
|
+ // 设置商业险起止日期(仅在有商业险时)
|
|
|
|
|
+ if (quoteVo.getBiRiskInfoVo() != null) {
|
|
|
|
|
+ request.getBusinessInsurance().getProductInfo().setStartDate(startDate);
|
|
|
|
|
+ request.getBusinessInsurance().getProductInfo().setEndDate(endDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|