|
@@ -1,6 +1,7 @@
|
|
|
package com.jzg.quotation.huanong.crawler.service.impl;
|
|
package com.jzg.quotation.huanong.crawler.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
|
import com.jzg.commons.entity.quote.vo.AttributionInformationVo;
|
|
import com.jzg.commons.entity.quote.vo.AttributionInformationVo;
|
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
import com.jzg.commons.entity.quote.vo.CarInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
@@ -29,13 +30,13 @@ import com.jzg.quotation.huanong.enums.dictionary.Risk;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.redisson.api.RMap;
|
|
import org.redisson.api.RMap;
|
|
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@QuoteCrawlerService(InsuranceCode.INSURANCE_HNIC)
|
|
@QuoteCrawlerService(InsuranceCode.INSURANCE_HNIC)
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -43,6 +44,7 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(HuaNongCrawlerRequestImpl.class);
|
|
private static final Logger log = LoggerFactory.getLogger(HuaNongCrawlerRequestImpl.class);
|
|
|
private final HuaNongCrawlerRequestComponent huaNongCrawlerRequestComponent;
|
|
private final HuaNongCrawlerRequestComponent huaNongCrawlerRequestComponent;
|
|
|
|
|
+ private final RedissonClient redissonClient;
|
|
|
|
|
|
|
|
private final HuaNongCrawlerOrderService huaNongCrawlerOrderService;
|
|
private final HuaNongCrawlerOrderService huaNongCrawlerOrderService;
|
|
|
|
|
|
|
@@ -85,30 +87,118 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
HuaNongCrawlerQuotedPriceRequestRequest huaNongCrawlerQuotedPriceRequest = new HuaNongCrawlerQuotedPriceRequestRequest(loginInfoDto.getToken(), attributionInformationVo.getUsername(), quoteVo, loginInfoDto.getLoginComCode(), actualValue, loginInfoDto.getParameters(), carModel, saleInfoDTO);
|
|
HuaNongCrawlerQuotedPriceRequestRequest huaNongCrawlerQuotedPriceRequest = new HuaNongCrawlerQuotedPriceRequestRequest(loginInfoDto.getToken(), attributionInformationVo.getUsername(), quoteVo, loginInfoDto.getLoginComCode(), actualValue, loginInfoDto.getParameters(), carModel, saleInfoDTO);
|
|
|
|
|
|
|
|
HuaNongCrawlerQuotedPriceResponse huaNongCrawlerQuotedPriceResponse = huaNongCrawlerRequestComponent.quotedPrice(huaNongCrawlerQuotedPriceRequest, httpHeaders);
|
|
HuaNongCrawlerQuotedPriceResponse huaNongCrawlerQuotedPriceResponse = huaNongCrawlerRequestComponent.quotedPrice(huaNongCrawlerQuotedPriceRequest, httpHeaders);
|
|
|
|
|
+
|
|
|
// 处理重复投保
|
|
// 处理重复投保
|
|
|
if ("0".equals(huaNongCrawlerQuotedPriceResponse.getHead().getReturnCode())) {
|
|
if ("0".equals(huaNongCrawlerQuotedPriceResponse.getHead().getReturnCode())) {
|
|
|
- List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO> contractList = huaNongCrawlerQuotedPriceResponse.getBusinessData().getContract();
|
|
|
|
|
- for (HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO contract : contractList) {
|
|
|
|
|
- String ciReinsureMsg = contract.getPlatFormMessage().getCiReinsureMessage();
|
|
|
|
|
- String biReinsureMsg = contract.getPlatFormMessage().getBiReinsureMessage();
|
|
|
|
|
- boolean isCiReInsure = ciReinsureMsg != null && ciReinsureMsg.contains("重复投保");
|
|
|
|
|
- boolean isBiReInsure = biReinsureMsg != null && biReinsureMsg.contains("重复投保");
|
|
|
|
|
- if (isCiReInsure || isBiReInsure) {
|
|
|
|
|
- huaNongCrawlerQuotedPriceResponse = repeatQuote(huaNongCrawlerQuotedPriceRequest,contract ,httpHeaders);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ huaNongCrawlerQuotedPriceResponse = handleDuplicateInsurance(
|
|
|
|
|
+ huaNongCrawlerQuotedPriceRequest,
|
|
|
|
|
+ huaNongCrawlerQuotedPriceResponse,
|
|
|
|
|
+ httpHeaders);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 检查报价异常
|
|
|
|
|
+ checkQuoteError(huaNongCrawlerQuotedPriceResponse);
|
|
|
|
|
+
|
|
|
// 6 保存
|
|
// 6 保存
|
|
|
- HuaNongCrawlerSaveRequestRequest huaNongCrawlerSaveRequest = getHuaNongCrawlerSaveRequestRequest(huaNongCrawlerQuotedPriceResponse, loginInfoDto.getToken(), loginInfoDto.getLoginComCode());
|
|
|
|
|
|
|
+ String agentCode = huaNongCrawlerQuotedPriceRequest.getAgentCode();
|
|
|
|
|
+ HuaNongCrawlerSaveRequestRequest huaNongCrawlerSaveRequest = getHuaNongCrawlerSaveRequestRequest(huaNongCrawlerQuotedPriceResponse, loginInfoDto.getToken(), loginInfoDto.getLoginComCode(), agentCode);
|
|
|
HuaNongCrawlerSaveResponse saveResponse = huaNongCrawlerRequestComponent.save(huaNongCrawlerSaveRequest, httpHeaders);
|
|
HuaNongCrawlerSaveResponse saveResponse = huaNongCrawlerRequestComponent.save(huaNongCrawlerSaveRequest, httpHeaders);
|
|
|
|
|
|
|
|
QuoteResultsVo quoteResultsVo = HuaNongCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(quoteVo.getOrder()
|
|
QuoteResultsVo quoteResultsVo = HuaNongCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(quoteVo.getOrder()
|
|
|
.getOrdersNo(), quoteVo, huaNongCrawlerQuotedPriceResponse, saveResponse);
|
|
.getOrdersNo(), quoteVo, huaNongCrawlerQuotedPriceResponse, saveResponse);
|
|
|
// 7 将订单信息保存到mongodb(后续需要使用)
|
|
// 7 将订单信息保存到mongodb(后续需要使用)
|
|
|
- huaNongCrawlerOrderService.saveOrder(quoteResultsVo.getOrdersNo(), quoteResultsVo.getCiPolicyNumber(), quoteResultsVo.getBiPolicyNumber());
|
|
|
|
|
|
|
+ huaNongCrawlerOrderService.saveOrder(quoteResultsVo.getOrdersNo(), quoteResultsVo.getCiPolicyNumber(), quoteResultsVo.getBiPolicyNumber(),quoteResultsVo.getJyPolicyNumber());
|
|
|
return quoteResultsVo;
|
|
return quoteResultsVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理重复投保逻辑
|
|
|
|
|
+ * 检测到重复投保时调整日期后重试,重试后仍重复投保则抛出异常
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param request 报价请求
|
|
|
|
|
+ * @param response 报价响应
|
|
|
|
|
+ * @param httpHeaders 请求头
|
|
|
|
|
+ * @return 处理后的报价响应
|
|
|
|
|
+ */
|
|
|
|
|
+ private HuaNongCrawlerQuotedPriceResponse handleDuplicateInsurance(
|
|
|
|
|
+ HuaNongCrawlerQuotedPriceRequestRequest request,
|
|
|
|
|
+ HuaNongCrawlerQuotedPriceResponse response,
|
|
|
|
|
+ HttpHeaders httpHeaders) {
|
|
|
|
|
+ // 检查是否有重复投保
|
|
|
|
|
+ if (response == null || response.getBusinessData() == null) {
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO> contractList = response.getBusinessData().getContract();
|
|
|
|
|
+ if (contractList == null) {
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历检查并处理重复投保
|
|
|
|
|
+ for (HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO contract : contractList) {
|
|
|
|
|
+ if (contract.getPlatFormMessage() == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String ciReinsureMsg = contract.getPlatFormMessage().getCiReinsureMessage();
|
|
|
|
|
+ String biReinsureMsg = contract.getPlatFormMessage().getBiReinsureMessage();
|
|
|
|
|
+ boolean isCiReInsure = StringUtils.hasText(ciReinsureMsg) && ciReinsureMsg.contains("重复投保");
|
|
|
|
|
+ boolean isBiReInsure = StringUtils.hasText(biReinsureMsg) && biReinsureMsg.contains("重复投保");
|
|
|
|
|
+
|
|
|
|
|
+ if (isCiReInsure || isBiReInsure) {
|
|
|
|
|
+ // 调整日期并重试
|
|
|
|
|
+ response = repeatQuote(request, contract, httpHeaders);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 重试后再次检查,如果仍然重复投保则抛出异常
|
|
|
|
|
+ for (HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO contract : response.getBusinessData().getContract()) {
|
|
|
|
|
+ if (contract.getPlatFormMessage() == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String ciReinsureMsg = contract.getPlatFormMessage().getCiReinsureMessage();
|
|
|
|
|
+ String biReinsureMsg = contract.getPlatFormMessage().getBiReinsureMessage();
|
|
|
|
|
+ if ((StringUtils.hasText(ciReinsureMsg) && ciReinsureMsg.contains("重复投保")) ||
|
|
|
|
|
+ (StringUtils.hasText(biReinsureMsg) && biReinsureMsg.contains("重复投保"))) {
|
|
|
|
|
+ String errorMsg = (StringUtils.hasText(ciReinsureMsg) ? "交强险:" + ciReinsureMsg : "") +
|
|
|
|
|
+ (StringUtils.hasText(biReinsureMsg) ? " 商业险:" + biReinsureMsg : "");
|
|
|
|
|
+ throw new SystemException("重复投保处理失败:" + errorMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查报价异常
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param response 报价响应
|
|
|
|
|
+ */
|
|
|
|
|
+ private void checkQuoteError(HuaNongCrawlerQuotedPriceResponse response) {
|
|
|
|
|
+ if (response == null) {
|
|
|
|
|
+ throw new SystemException("报价响应为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ HuaNongCrawlerBaseResponseHead head = response.getHead();
|
|
|
|
|
+ if (head == null) {
|
|
|
|
|
+ throw new SystemException("报价响应头为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查 returnMessage 是否为成功
|
|
|
|
|
+ String returnMessage = head.getReturnMessage();
|
|
|
|
|
+ if (returnMessage != null && !"成功".equals(returnMessage)) {
|
|
|
|
|
+ throw new SystemException(returnMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查下发修改
|
|
|
|
|
+ if (response.getBusinessData() != null && response.getBusinessData().getBusinessMain() != null) {
|
|
|
|
|
+ HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.BusinessMainDTO businessMain = response.getBusinessData().getBusinessMain();
|
|
|
|
|
+ String iLogPreUdwMess = businessMain.getILogPreUdwMess();
|
|
|
|
|
+ if (iLogPreUdwMess != null && !iLogPreUdwMess.isEmpty() && iLogPreUdwMess.contains("下发修改")) {
|
|
|
|
|
+ // 去除换行和空格
|
|
|
|
|
+ String errorMessage = iLogPreUdwMess.replace("\n", "").replace(" ", "");
|
|
|
|
|
+ throw new SystemException(errorMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 处理重复投保
|
|
// 处理重复投保
|
|
|
private HuaNongCrawlerQuotedPriceResponse repeatQuote(HuaNongCrawlerQuotedPriceRequestRequest huaNongCrawlerQuotedPriceRequest,HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO contract,HttpHeaders httpHeaders) {
|
|
private HuaNongCrawlerQuotedPriceResponse repeatQuote(HuaNongCrawlerQuotedPriceRequestRequest huaNongCrawlerQuotedPriceRequest,HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO contract,HttpHeaders httpHeaders) {
|
|
|
String riskCode = contract.getContractMain().getRiskCode();
|
|
String riskCode = contract.getContractMain().getRiskCode();
|
|
@@ -124,7 +214,7 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
} else if ("0507".equals(riskCode)) {
|
|
} else if ("0507".equals(riskCode)) {
|
|
|
- String lastExpireDate = contract.getPlatFormMessage().getCiReinsureEndDate();
|
|
|
|
|
|
|
+ String lastExpireDate = ensureDateTimeFormat(contract.getPlatFormMessage().getCiReinsureEndDate());;
|
|
|
if (lastExpireDate != null && !lastExpireDate.trim().isEmpty()) {
|
|
if (lastExpireDate != null && !lastExpireDate.trim().isEmpty()) {
|
|
|
huaNongCrawlerQuotedPriceRequest.getBusinessData().getContract().stream()
|
|
huaNongCrawlerQuotedPriceRequest.getBusinessData().getContract().stream()
|
|
|
.filter(dto -> "0507".equals(dto.getContractMain().getRiskCode()))
|
|
.filter(dto -> "0507".equals(dto.getContractMain().getRiskCode()))
|
|
@@ -138,14 +228,39 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
return huaNongCrawlerRequestComponent.quotedPrice(huaNongCrawlerQuotedPriceRequest, httpHeaders);
|
|
return huaNongCrawlerRequestComponent.quotedPrice(huaNongCrawlerQuotedPriceRequest, httpHeaders);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String ensureDateTimeFormat(String dateStr) {
|
|
|
|
|
+ if (dateStr == null || dateStr.trim().isEmpty()) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ dateStr = dateStr.trim();
|
|
|
|
|
+
|
|
|
|
|
+ // 如果已经是完整格式 (19字符 yyyy-MM-dd HH:mm:ss),直接返回
|
|
|
|
|
+ if (dateStr.length() >= 19) {
|
|
|
|
|
+ return dateStr.substring(0, 19);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是 yyyy-MM-dd 格式 (10字符),补充时间部分
|
|
|
|
|
+ if (dateStr.length() == 10) {
|
|
|
|
|
+ return dateStr + " 00:00:00";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是 yyyy-MM-dd HH:mm 格式 (16字符),补充秒
|
|
|
|
|
+ if (dateStr.length() == 16) {
|
|
|
|
|
+ return dateStr + ":00";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 其他情况原样返回
|
|
|
|
|
+ return dateStr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@NotNull
|
|
@NotNull
|
|
|
- private static HuaNongCrawlerSaveRequestRequest getHuaNongCrawlerSaveRequestRequest(HuaNongCrawlerQuotedPriceResponse huaNongCrawlerQuotedPriceResponse, String token, String loginComCode) {
|
|
|
|
|
|
|
+ private static HuaNongCrawlerSaveRequestRequest getHuaNongCrawlerSaveRequestRequest(HuaNongCrawlerQuotedPriceResponse huaNongCrawlerQuotedPriceResponse, String token, String loginComCode, String agentCode) {
|
|
|
List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO> contract = huaNongCrawlerQuotedPriceResponse.getBusinessData()
|
|
List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractDTO> contract = huaNongCrawlerQuotedPriceResponse.getBusinessData()
|
|
|
.getContract();
|
|
.getContract();
|
|
|
List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractAccidentDTO> contractAccident = Optional.ofNullable(huaNongCrawlerQuotedPriceResponse.getBusinessData()
|
|
List<HuaNongCrawlerQuotedPriceResponse.BusinessDataDTO.ContractAccidentDTO> contractAccident = Optional.ofNullable(huaNongCrawlerQuotedPriceResponse.getBusinessData()
|
|
|
.getContractAccident()).orElse(new ArrayList<>());
|
|
.getContractAccident()).orElse(new ArrayList<>());
|
|
|
|
|
|
|
|
- return new HuaNongCrawlerSaveRequestRequest(contract, contractAccident, token, loginComCode);
|
|
|
|
|
|
|
+ return new HuaNongCrawlerSaveRequestRequest(contract, contractAccident, token, loginComCode, agentCode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -158,13 +273,156 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
// 获取订单
|
|
// 获取订单
|
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(underwritingVo.getOrder()
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(underwritingVo.getOrder()
|
|
|
.getOrdersNo());
|
|
.getOrdersNo());
|
|
|
- // 提交核保
|
|
|
|
|
|
|
+
|
|
|
|
|
+ log.info("开始提交核保...");
|
|
|
HuaNongCrawlerSubmitRequestRequest huaNongCrawlerSubmitRequest = new HuaNongCrawlerSubmitRequestRequest(huaNongCrawlerOrder, token, huaNongCrawlerConfigureParameters.getComCode());
|
|
HuaNongCrawlerSubmitRequestRequest huaNongCrawlerSubmitRequest = new HuaNongCrawlerSubmitRequestRequest(huaNongCrawlerOrder, token, huaNongCrawlerConfigureParameters.getComCode());
|
|
|
HuaNongCrawlerSubmitResponse submit = huaNongCrawlerRequestComponent.submit(huaNongCrawlerSubmitRequest, new HttpHeaders());
|
|
HuaNongCrawlerSubmitResponse submit = huaNongCrawlerRequestComponent.submit(huaNongCrawlerSubmitRequest, new HttpHeaders());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否需要转人工
|
|
|
|
|
+ if (isManualSubmitRequired(submit)) {
|
|
|
|
|
+ log.info("核保返回状态9,需要转人工...");
|
|
|
|
|
+ // 提取核保失败原因
|
|
|
|
|
+ String manualMessage = extractManualMessage(submit);
|
|
|
|
|
+ log.info("转人工原因: {}", manualMessage);
|
|
|
|
|
+ // 调用转人工接口 (appliType = "1")
|
|
|
|
|
+ HuaNongCrawlerSubmitRequestRequest manualSubmitRequest = new HuaNongCrawlerSubmitRequestRequest(huaNongCrawlerOrder, token, huaNongCrawlerConfigureParameters.getComCode(), "1");
|
|
|
|
|
+ HuaNongCrawlerSubmitResponse manualSubmit = huaNongCrawlerRequestComponent.submit(manualSubmitRequest, new HttpHeaders());
|
|
|
|
|
+ log.info("转人工调用完成");
|
|
|
|
|
+ // 正常核保:获取支付链接
|
|
|
|
|
+ log.info("核保成功,开始获取支付链接...");
|
|
|
|
|
+ // 获取用户名(与Python一致,使用username作为operatorCode)
|
|
|
|
|
+ String username = attributionInformationVo.getUsername();
|
|
|
|
|
+ String ciPolicyNumber = huaNongCrawlerOrder.getCiPolicyNumber();
|
|
|
|
|
+ String biPolicyNumber = huaNongCrawlerOrder.getBiPolicyNumber();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取支付链接
|
|
|
|
|
+ String payUrl = huaNongCrawlerRequestComponent.getPayUrl(ciPolicyNumber, biPolicyNumber, username);
|
|
|
|
|
+ log.info("支付链接获取完成: {}", payUrl);
|
|
|
|
|
+ // 返回转人工结果
|
|
|
|
|
+ return convertToUnderwritingResultsVo(manualSubmit,payUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 正常核保:获取支付链接
|
|
|
|
|
+ log.info("核保成功,开始获取支付链接...");
|
|
|
|
|
+ // 获取用户名(与Python一致,使用username作为operatorCode)
|
|
|
|
|
+ String username = attributionInformationVo.getUsername();
|
|
|
|
|
+ String ciPolicyNumber = huaNongCrawlerOrder.getCiPolicyNumber();
|
|
|
|
|
+ String biPolicyNumber = huaNongCrawlerOrder.getBiPolicyNumber();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取支付链接
|
|
|
|
|
+ String payUrl = huaNongCrawlerRequestComponent.getPayUrl(ciPolicyNumber, biPolicyNumber, username);
|
|
|
|
|
+ log.info("支付链接获取完成: {}", payUrl);
|
|
|
|
|
+
|
|
|
|
|
+ // 正常核保结果
|
|
|
|
|
+ return convertToUnderwritingResultsVo(submit,payUrl);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查是否需要转人工
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param submit 核保响应
|
|
|
|
|
+ * @return true-需要转人工,false-不需要
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean isManualSubmitRequired(HuaNongCrawlerSubmitResponse submit) {
|
|
|
|
|
+ if (submit == null || submit.getAppliResult() == null || submit.getAppliResult().isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查状态是否为9
|
|
|
|
|
+ String status = submit.getAppliResult().get(0).getStatus();
|
|
|
|
|
+ return "9".equals(status);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取转人工原因
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param submit 核保响应
|
|
|
|
|
+ * @return 转人工原因
|
|
|
|
|
+ */
|
|
|
|
|
+ private String extractManualMessage(HuaNongCrawlerSubmitResponse submit) {
|
|
|
|
|
+ if (submit == null || submit.getAppliResult() == null || submit.getAppliResult().isEmpty()) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ StringBuilder message = new StringBuilder();
|
|
|
|
|
+ for (HuaNongCrawlerSubmitResponse.AppliResultDTO appliResult : submit.getAppliResult()) {
|
|
|
|
|
+ if (appliResult.getNotion() != null && !appliResult.getNotion().isEmpty()) {
|
|
|
|
|
+ for (HuaNongCrawlerSubmitResponse.AppliResultDTO.NotionDTO notion : appliResult.getNotion()) {
|
|
|
|
|
+ if (notion.getUWNotion() != null && !notion.getUWNotion().isEmpty()) {
|
|
|
|
|
+ if (!message.isEmpty()) {
|
|
|
|
|
+ message.append("\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ message.append(notion.getUWNotion());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return message.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将华农核保响应转换为系统核保结果
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param submit 华农核保响应
|
|
|
|
|
+ * @param payUrl 系统订单号
|
|
|
|
|
+ * @return 系统核保结果
|
|
|
|
|
+ */
|
|
|
|
|
+ private UnderwritingResultsVo convertToUnderwritingResultsVo(HuaNongCrawlerSubmitResponse submit,String payUrl) {
|
|
|
UnderwritingResultsVo underwritingResultsVo = new UnderwritingResultsVo();
|
|
UnderwritingResultsVo underwritingResultsVo = new UnderwritingResultsVo();
|
|
|
- return underwritingResultsVo;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (submit == null || submit.getAppliResult() == null || submit.getAppliResult().isEmpty()) {
|
|
|
|
|
+ return underwritingResultsVo;
|
|
|
|
|
+ }
|
|
|
|
|
+ String status = submit.getAppliResult().get(0).getStatus();
|
|
|
|
|
+ // 核保返回状态8 是 成功,9 是人工核保
|
|
|
|
|
+ if("8".equals(status) || "9".equals(status)){
|
|
|
|
|
+ // 遍历所有险种结果(交强、商业等)
|
|
|
|
|
+ StringBuilder underwritingResultBuilder = new StringBuilder();
|
|
|
|
|
+ for (HuaNongCrawlerSubmitResponse.AppliResultDTO appliResult : submit.getAppliResult()) {
|
|
|
|
|
+ String contractNo = appliResult.getContractNo();
|
|
|
|
|
+ String riskType = appliResult.getRiskType();
|
|
|
|
|
+
|
|
|
|
|
+ // 根据险种类型设置对应投保单号
|
|
|
|
|
+ if ("CI".equals(riskType)) {
|
|
|
|
|
+ underwritingResultsVo.setJqApplyNo(contractNo);
|
|
|
|
|
+ } else if ("BI".equals(riskType)) {
|
|
|
|
|
+ underwritingResultsVo.setSyApplyNo(contractNo);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 状态转换:以第一个为准
|
|
|
|
|
+ if (underwritingResultsVo.getUnderwritingStatus() == null) {
|
|
|
|
|
+ underwritingResultsVo.setUnderwritingStatus(InsOrderStatusEnum.PAY_PENDING);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 拼接核保意见
|
|
|
|
|
+ if (appliResult.getNotion() != null && !appliResult.getNotion().isEmpty()) {
|
|
|
|
|
+ String notion = appliResult.getNotion().stream()
|
|
|
|
|
+ .map(HuaNongCrawlerSubmitResponse.AppliResultDTO.NotionDTO::getUWNotion)
|
|
|
|
|
+ .filter(java.util.Objects::nonNull)
|
|
|
|
|
+ .collect(java.util.stream.Collectors.joining(";"));
|
|
|
|
|
+
|
|
|
|
|
+ if (!underwritingResultBuilder.isEmpty()) {
|
|
|
|
|
+ underwritingResultBuilder.append(" | ");
|
|
|
|
|
+ }
|
|
|
|
|
+ underwritingResultBuilder.append(riskType).append(":").append(notion);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置保司订单号(取第一个)
|
|
|
|
|
+ underwritingResultsVo.setCompanyOrderNo(submit.getAppliResult().get(0).getContractNo());
|
|
|
|
|
+ underwritingResultsVo.setUnderwritingResult(underwritingResultBuilder.toString());
|
|
|
|
|
+ underwritingResultsVo.setPaymentLink(payUrl);
|
|
|
|
|
+
|
|
|
|
|
+ return underwritingResultsVo;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new SystemException(submit.getAppliResult().get(0).getNotion().get(0).getUWNotion());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public PaymentLinkResultsVo getPaymentLink(PaymentLinkVo paymentLinkVo) {
|
|
public PaymentLinkResultsVo getPaymentLink(PaymentLinkVo paymentLinkVo) {
|
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(paymentLinkVo.getOrder()
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(paymentLinkVo.getOrder()
|
|
@@ -186,13 +444,53 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
public void uploadImage(InsuranceUploadImageVo insuranceUploadImageVo) {
|
|
public void uploadImage(InsuranceUploadImageVo insuranceUploadImageVo) {
|
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(insuranceUploadImageVo.getOrder()
|
|
HuaNongCrawlerOrder huaNongCrawlerOrder = huaNongCrawlerOrderService.getById(insuranceUploadImageVo.getOrder()
|
|
|
.getOrdersNo());
|
|
.getOrdersNo());
|
|
|
- String contractNo = huaNongCrawlerOrder.getOrdersNo();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String biPolicyNumber = huaNongCrawlerOrder.getBiPolicyNumber();
|
|
|
|
|
+ String ciPolicyNumber = huaNongCrawlerOrder.getCiPolicyNumber();
|
|
|
|
|
+ List<HuaNongCrawlerOrder.NiInfo> niInfos = huaNongCrawlerOrder.getNiInfos();
|
|
|
|
|
+ String contractNo = buildContractNo(biPolicyNumber, ciPolicyNumber);
|
|
|
|
|
+
|
|
|
|
|
+ List<String> policyNumbers = buildPolicyNumbers(biPolicyNumber, ciPolicyNumber, niInfos);
|
|
|
|
|
+
|
|
|
AttributionInformationVo attributionInformationVo = insuranceUploadImageVo.getOrder()
|
|
AttributionInformationVo attributionInformationVo = insuranceUploadImageVo.getOrder()
|
|
|
.getAttributionInformationVo();
|
|
.getAttributionInformationVo();
|
|
|
LoginInfoBO loginInfoDto = getLoginInfoDto(attributionInformationVo);
|
|
LoginInfoBO loginInfoDto = getLoginInfoDto(attributionInformationVo);
|
|
|
- // 上传影像 封装
|
|
|
|
|
- huaNongCrawlerQuoteProcessService.uploadImage(loginInfoDto, insuranceUploadImageVo.getOrder()
|
|
|
|
|
- .getAgreementId(), contractNo, insuranceUploadImageVo.getImageVoList());
|
|
|
|
|
|
|
+ huaNongCrawlerQuoteProcessService.uploadImageToUnclassified(loginInfoDto, insuranceUploadImageVo.getOrder()
|
|
|
|
|
+ .getAgreementId(), contractNo, policyNumbers,insuranceUploadImageVo.getImageVoList());
|
|
|
|
|
+ }
|
|
|
|
|
+ private String buildContractNo(String biPolicyNumber, String ciPolicyNumber) {
|
|
|
|
|
+ boolean hasBi = biPolicyNumber != null && !biPolicyNumber.isEmpty();
|
|
|
|
|
+ boolean hasCi = ciPolicyNumber != null && !ciPolicyNumber.isEmpty();
|
|
|
|
|
+
|
|
|
|
|
+ if (hasBi && hasCi) {
|
|
|
|
|
+ return biPolicyNumber + "," + ciPolicyNumber;
|
|
|
|
|
+ } else if (hasCi) {
|
|
|
|
|
+ return "," + ciPolicyNumber;
|
|
|
|
|
+ } else if (hasBi) {
|
|
|
|
|
+ return biPolicyNumber;
|
|
|
|
|
+ }
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<String> buildPolicyNumbers(String biPolicyNumber, String ciPolicyNumber, List<HuaNongCrawlerOrder.NiInfo> niInfos) {
|
|
|
|
|
+ List<String> policyNumbers = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ if (biPolicyNumber != null && !biPolicyNumber.isEmpty()) {
|
|
|
|
|
+ policyNumbers.add(biPolicyNumber);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ciPolicyNumber != null && !ciPolicyNumber.isEmpty()) {
|
|
|
|
|
+ policyNumbers.add(ciPolicyNumber);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (niInfos != null && !niInfos.isEmpty()) {
|
|
|
|
|
+ for (HuaNongCrawlerOrder.NiInfo niInfo : niInfos) {
|
|
|
|
|
+ String niPolicyNumber = niInfo.getNiPolicyNumber();
|
|
|
|
|
+ if (niPolicyNumber != null && !niPolicyNumber.isEmpty()) {
|
|
|
|
|
+ policyNumbers.add(niPolicyNumber);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return policyNumbers;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -270,6 +568,8 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
*/
|
|
*/
|
|
|
private LoginInfoBO getLoginInfoDto(AttributionInformationVo attributionInformationVo) {
|
|
private LoginInfoBO getLoginInfoDto(AttributionInformationVo attributionInformationVo) {
|
|
|
HuaNongCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(HuaNongCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
HuaNongCrawlerConfigureParameters parameters = ConfigureParametersConversion.conversionEntity(HuaNongCrawlerConfigureParameters.class, attributionInformationVo.getConfigInfo());
|
|
|
|
|
+ //todo 验证码问题,临时使用token
|
|
|
|
|
+ cacheLoginInfo(attributionInformationVo);
|
|
|
RMap<String, Object> authorization = huaNongCrawlerGetToken.getAuthorization(attributionInformationVo.getUsername(), attributionInformationVo.getPassword());
|
|
RMap<String, Object> authorization = huaNongCrawlerGetToken.getAuthorization(attributionInformationVo.getUsername(), attributionInformationVo.getPassword());
|
|
|
String token = (String) authorization.get(HuaNongCrawlerCacheComponent.TOKEN);
|
|
String token = (String) authorization.get(HuaNongCrawlerCacheComponent.TOKEN);
|
|
|
String userCode = (String) authorization.get(HuaNongCrawlerCacheComponent.USER_CODE);
|
|
String userCode = (String) authorization.get(HuaNongCrawlerCacheComponent.USER_CODE);
|
|
@@ -279,5 +579,18 @@ public class HuaNongCrawlerRequestImpl implements HuaNongCrawlerRequest {
|
|
|
return new LoginInfoBO(token, loginCom, loginComCode, userCode, userName, parameters);
|
|
return new LoginInfoBO(token, loginCom, loginComCode, userCode, userName, parameters);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void cacheLoginInfo(AttributionInformationVo attributionInformationVo) {
|
|
|
|
|
+ Map<String, Object> collect = new HashMap<>();
|
|
|
|
|
+ String redisKey = "hunong:crawler:authorization:"+attributionInformationVo.getUsername();
|
|
|
|
|
+ RMap<String, Object> rMap = redissonClient.getMap(redisKey);
|
|
|
|
|
+ collect.put("TOKEN", attributionInformationVo.getConfigInfo().get("token"));
|
|
|
|
|
+ collect.put("USER_CODE", attributionInformationVo.getUsername());
|
|
|
|
|
+ collect.put(attributionInformationVo.getConfigInfo().get("loginCom"), attributionInformationVo.getConfigInfo().get("loginCom"));
|
|
|
|
|
+ collect.put("USER_NAME", "潘建红");
|
|
|
|
|
+ rMap.putAll(collect);
|
|
|
|
|
+ rMap.expire(Duration.ofHours(3L));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|