|
@@ -178,18 +178,27 @@ public class HengBangCrawlerRequestImpl implements HengBangCrawlerRequest {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 重复投保:循环重试,优先从responseBody.begintimeBi获取建议起保时间
|
|
|
|
|
|
|
+ // 重复投保:循环重试,优先从responseBody获取建议起保时间
|
|
|
int maxRetry = 3;
|
|
int maxRetry = 3;
|
|
|
while (errorMsg.contains("重复投保") && maxRetry-- > 0) {
|
|
while (errorMsg.contains("重复投保") && maxRetry-- > 0) {
|
|
|
String time = getDuplicateBegintime(resJsonObj, errorMsg);
|
|
String time = getDuplicateBegintime(resJsonObj, errorMsg);
|
|
|
- log.info("重复投保,重试次数:{}, 建议起保时间:{}", 3 - maxRetry, time);
|
|
|
|
|
|
|
+ log.info("重复投保,重试次数:{}, 建议起保时间:{}, 错误信息前100字符:{}", 3 - maxRetry, time,
|
|
|
|
|
+ errorMsg.length() > 100 ? errorMsg.substring(0, 100) : errorMsg);
|
|
|
if (time == null) {
|
|
if (time == null) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
String utcTime = DateUtil.toUtcDateTime(time);
|
|
String utcTime = DateUtil.toUtcDateTime(time);
|
|
|
- calculationRequest.setBegintimeCi(utcTime);
|
|
|
|
|
- calculationRequest.setBegintimeBi(utcTime);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 根据重复投保类型分别设置起保时间:交强险只改 begintimeCi,商业险只改 begintimeBi
|
|
|
|
|
+ // 注意:商业险错误信息不含"商业险平台返回",故通过"交强险平台返回"反推
|
|
|
|
|
+ if (errorMsg.contains("交强险平台返回")) {
|
|
|
|
|
+ calculationRequest.setBegintimeCi(utcTime);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 不含交强险标识则为商业险重复投保
|
|
|
|
|
+ calculationRequest.setBegintimeBi(utcTime);
|
|
|
|
|
+ }
|
|
|
calculationRequest.setBegintimeAccident(utcTime);
|
|
calculationRequest.setBegintimeAccident(utcTime);
|
|
|
|
|
+
|
|
|
resJsonObj = callCalculation(calculationRequest, headers);
|
|
resJsonObj = callCalculation(calculationRequest, headers);
|
|
|
if (resJsonObj == null) {
|
|
if (resJsonObj == null) {
|
|
|
return buildErrorResult(quoteVo);
|
|
return buildErrorResult(quoteVo);
|
|
@@ -254,19 +263,44 @@ public class HengBangCrawlerRequestImpl implements HengBangCrawlerRequest {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取重复投保场景的建议起保时间(yyyy-MM-dd HH:mm:ss 格式)
|
|
* 获取重复投保场景的建议起保时间(yyyy-MM-dd HH:mm:ss 格式)
|
|
|
- * 优先从 responseBody.begintimeBi 获取,兜底从 message 正则提取
|
|
|
|
|
|
|
+ * 优先从 responseBody.begintimeCi/begintimeBi 获取,兜底从 message 正则提取
|
|
|
*/
|
|
*/
|
|
|
private String getDuplicateBegintime(JSONObject resJsonObj, String errorMsg) {
|
|
private String getDuplicateBegintime(JSONObject resJsonObj, String errorMsg) {
|
|
|
- // 优先从 responseBody.begintimeBi 获取
|
|
|
|
|
- JSONObject responseBody = resJsonObj.getJSONObject("responseBody");
|
|
|
|
|
|
|
+ // 优先从 responseBody 获取建议起保时间(支持顶层和 map.responseBody 嵌套)
|
|
|
|
|
+ JSONObject responseBody = getNestedResponseBody(resJsonObj);
|
|
|
if (responseBody != null) {
|
|
if (responseBody != null) {
|
|
|
|
|
+ // 检查 begintimeCi(交强险建议起保时间),保司返回可能带前导空格
|
|
|
|
|
+ String begintimeCi = responseBody.getString("begintimeCi");
|
|
|
|
|
+ if (StrUtil.isNotBlank(begintimeCi)) {
|
|
|
|
|
+ log.info("重复投保,从 responseBody.begintimeCi 获取建议起保时间:{}", begintimeCi);
|
|
|
|
|
+ return normalizeTimeFormat(begintimeCi.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查 begintimeBi(商业险建议起保时间)
|
|
|
String begintimeBi = responseBody.getString("begintimeBi");
|
|
String begintimeBi = responseBody.getString("begintimeBi");
|
|
|
- if (begintimeBi != null) {
|
|
|
|
|
- return normalizeTimeFormat(begintimeBi);
|
|
|
|
|
|
|
+ if (StrUtil.isNotBlank(begintimeBi)) {
|
|
|
|
|
+ log.info("重复投保,从 responseBody.begintimeBi 获取建议起保时间:{}", begintimeBi);
|
|
|
|
|
+ return normalizeTimeFormat(begintimeBi.trim());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 兼容:从 message 正则提取终保日期
|
|
|
|
|
- return hbCrawlerRequestComponent.extractDuplicateEndTime(errorMsg);
|
|
|
|
|
|
|
+ // 兜底:从 message 正则提取终保日期
|
|
|
|
|
+ String endTime = hbCrawlerRequestComponent.extractDuplicateEndTime(errorMsg);
|
|
|
|
|
+ log.info("重复投保,从 errorMsg 正则提取终保日期:{}", endTime);
|
|
|
|
|
+ return endTime;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取嵌套的 responseBody(保司返回可能在顶层或 map.responseBody 中)
|
|
|
|
|
+ */
|
|
|
|
|
+ private JSONObject getNestedResponseBody(JSONObject resJsonObj) {
|
|
|
|
|
+ JSONObject responseBody = resJsonObj.getJSONObject("responseBody");
|
|
|
|
|
+ if (responseBody != null) {
|
|
|
|
|
+ return responseBody;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject map = resJsonObj.getJSONObject("map");
|
|
|
|
|
+ if (map != null) {
|
|
|
|
|
+ return map.getJSONObject("responseBody");
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|