|
@@ -33,7 +33,12 @@ import com.jzg.quotation.commons.utils.TimeProcessing;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.time.Year;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -136,7 +141,6 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
|
|
|
// 报价
|
|
// 报价
|
|
|
AnShengCrawlerCalculatePremiumApplyMessage crawlerCalculatePremiumApply = new AnShengCrawlerCalculatePremiumApplyMessage(quoteVo, dataDTO, userDetailResponse, departmentPlanCode, checkVehicleCodeSecretGenerate);
|
|
AnShengCrawlerCalculatePremiumApplyMessage crawlerCalculatePremiumApply = new AnShengCrawlerCalculatePremiumApplyMessage(quoteVo, dataDTO, userDetailResponse, departmentPlanCode, checkVehicleCodeSecretGenerate);
|
|
|
log.info("安盛报价参数:{}", JSONObject.toJSONString(crawlerCalculatePremiumApply));
|
|
log.info("安盛报价参数:{}", JSONObject.toJSONString(crawlerCalculatePremiumApply));
|
|
|
-
|
|
|
|
|
InsuranceContractRequest insuranceContractRequest = new InsuranceContractRequest(crawlerCalculatePremiumApply);
|
|
InsuranceContractRequest insuranceContractRequest = new InsuranceContractRequest(crawlerCalculatePremiumApply);
|
|
|
PureRiskPremiumQueryResponse premiumQueryResponse = anShengCrawlerRequestComponent.pureRiskPremiumQuery(insuranceContractRequest, httpHeaders);
|
|
PureRiskPremiumQueryResponse premiumQueryResponse = anShengCrawlerRequestComponent.pureRiskPremiumQuery(insuranceContractRequest, httpHeaders);
|
|
|
PureRiskPremiumQueryResponse.TargetsBean targetsBean = premiumQueryResponse.getData().getContracts().get(0).getTargets().get(0);
|
|
PureRiskPremiumQueryResponse.TargetsBean targetsBean = premiumQueryResponse.getData().getContracts().get(0).getTargets().get(0);
|
|
@@ -176,7 +180,7 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
|
|
|
// 缓存数据
|
|
// 缓存数据
|
|
|
anShengCrawlerCacheComponent.cacheQuoteRequest(ordersNo, autoSpecialPromiseRequest);
|
|
anShengCrawlerCacheComponent.cacheQuoteRequest(ordersNo, autoSpecialPromiseRequest);
|
|
|
}
|
|
}
|
|
|
- anShengCrawlerOrderService.saveRecordingTime(ordersNo);
|
|
|
|
|
|
|
+ anShengCrawlerOrderService.saveRecordingTime(ordersNo,quoteVo.getCarInfoVo().getLicenseNo());
|
|
|
// 构造返回参数
|
|
// 构造返回参数
|
|
|
return AnShengCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(ordersNo, quoteVo, calculatePremiumApply);
|
|
return AnShengCrawlerQuoteResultsVoBuild.buildQuoteResultsVo(ordersNo, quoteVo, calculatePremiumApply);
|
|
|
}
|
|
}
|
|
@@ -382,33 +386,80 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
|
|
|
@Override
|
|
@Override
|
|
|
public DownloadPolicyResultVo downloadPolicy(DownloadPolicyVo downloadPolicyVo) {
|
|
public DownloadPolicyResultVo downloadPolicy(DownloadPolicyVo downloadPolicyVo) {
|
|
|
DownloadPolicyResultVo downloadPolicyResultVo = new DownloadPolicyResultVo();
|
|
DownloadPolicyResultVo downloadPolicyResultVo = new DownloadPolicyResultVo();
|
|
|
-
|
|
|
|
|
- HttpHeaders httpHeaders = anShengCrawlerQuoteProcessService.getHttpHeaders(downloadPolicyVo.getOrder().getAttributionInformationVo());
|
|
|
|
|
AnShengCrawlerOrder anShengCrawlerOrder = anShengCrawlerOrderService.getById(downloadPolicyVo.getOrder().getOrdersNo());
|
|
AnShengCrawlerOrder anShengCrawlerOrder = anShengCrawlerOrderService.getById(downloadPolicyVo.getOrder().getOrdersNo());
|
|
|
|
|
+ DownloadTokenResult obtainDownloadToken = anShengCrawlerQuoteProcessService.obtainDownloadToken(downloadPolicyVo.getOrder().getAttributionInformationVo());
|
|
|
|
|
+ // 缓存token,避免重复调用
|
|
|
|
|
+ String loginToken = obtainDownloadToken.getToken();
|
|
|
|
|
+ String bdToken = obtainDownloadToken.getBdToken();
|
|
|
|
|
+
|
|
|
|
|
+ MultiValueMap<String, String> urlParams = new LinkedMultiValueMap<>();
|
|
|
|
|
+ urlParams.add("method", "queryAll");
|
|
|
|
|
+ urlParams.add("loginToken", loginToken);
|
|
|
|
|
+ urlParams.add("orderStatus", "2");
|
|
|
|
|
+ //车牌
|
|
|
|
|
+ urlParams.add("searchValue", URLEncoder.encode(anShengCrawlerOrder.getLicenseNo(), StandardCharsets.UTF_8));
|
|
|
|
|
+ InsuranceResponse insuranceResponse = anShengCrawlerRequestComponent.newGsOrder(urlParams, loginToken);
|
|
|
|
|
+ if (!StringUtils.equals("成功", insuranceResponse.getMsg()) || CollectionUtil.isEmpty(insuranceResponse.getData())) {
|
|
|
|
|
+ throw new SystemException("暂无找到该车保单信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ String currentYear = String.valueOf(Year.now().getValue());
|
|
|
|
|
+ for (InsuranceResponse.InsurancePolicy policy : insuranceResponse.getData()) {
|
|
|
|
|
+ if (policy == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String applyDate = policy.getApplyDate();
|
|
|
|
|
|
|
|
- // 交强保单和标志
|
|
|
|
|
- Optional.ofNullable(anShengCrawlerOrder.getCiPolicyNo()).ifPresent(policyNo -> {
|
|
|
|
|
- AnShengCrawlerQueryPrintPdfRequest queryPrintPdfCi = new AnShengCrawlerQueryPrintPdfRequest(policyNo, "6");
|
|
|
|
|
- downloadPolicyResultVo.setJqUrl(anShengCrawlerRequestComponent.queryPrintPdf(queryPrintPdfCi, httpHeaders));
|
|
|
|
|
-
|
|
|
|
|
- AnShengCrawlerQueryPrintPdfRequest queryPrintPdfCiBz = new AnShengCrawlerQueryPrintPdfRequest(policyNo, "2");
|
|
|
|
|
- downloadPolicyResultVo.setJqFlagUrl(anShengCrawlerRequestComponent.queryPrintPdf(queryPrintPdfCiBz, httpHeaders));
|
|
|
|
|
- });
|
|
|
|
|
- // 商业保单和标志
|
|
|
|
|
- Optional.ofNullable(anShengCrawlerOrder.getBiPolicyNo()).ifPresent(policyNo -> {
|
|
|
|
|
- AnShengCrawlerQueryPrintPdfRequest queryPrintPdfCi = new AnShengCrawlerQueryPrintPdfRequest(policyNo, "6");
|
|
|
|
|
- downloadPolicyResultVo.setSyUrl(anShengCrawlerRequestComponent.queryPrintPdf(queryPrintPdfCi, httpHeaders));
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ String productName = policy.getProductName();
|
|
|
|
|
+ String policyNo = policy.getPolicyNo();
|
|
|
|
|
+ String signExt = policy.getSignExt();
|
|
|
|
|
|
|
|
- // 非车保单和标志
|
|
|
|
|
- anShengCrawlerOrder.getNiInfos().forEach(niInfo -> {
|
|
|
|
|
- Optional.ofNullable(niInfo.getNiPolicyNumber()).ifPresent(policyNo -> {
|
|
|
|
|
- anShengCrawlerRequestComponent.downloadPdf(policyNo, httpHeaders);
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ String applyYear = "";
|
|
|
|
|
+ if (applyDate != null && applyDate.length() >= 4) {
|
|
|
|
|
+ applyYear = applyDate.substring(0, 4);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 机动车辆交强险
|
|
|
|
|
+ if ("机动车辆交强险".equals(productName)) {
|
|
|
|
|
+ JSONObject mainJson = buildPdfJson(policyNo, "2", signExt, bdToken);
|
|
|
|
|
+ downloadPolicyResultVo.setJqUrl(anShengCrawlerRequestComponent.pdfUrl(mainJson, loginToken));
|
|
|
|
|
+ JSONObject flagJson = buildPdfJson(policyNo, "4", signExt, bdToken);
|
|
|
|
|
+ downloadPolicyResultVo.setJqFlagUrl(anShengCrawlerRequestComponent.pdfUrl(flagJson, loginToken));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 机动车辆综合险保险
|
|
|
|
|
+ if ("机动车辆综合险保险".equals(productName)) {
|
|
|
|
|
+ JSONObject syJson = buildPdfJson(policyNo, "2", signExt, bdToken);
|
|
|
|
|
+ downloadPolicyResultVo.setSyUrl(anShengCrawlerRequestComponent.pdfUrl(syJson, loginToken));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 其他险种且为当年投保
|
|
|
|
|
+ if (!"机动车辆综合险保险".equals(productName) && !"机动车辆交强险".equals(productName) && currentYear.equals(applyYear)) {
|
|
|
|
|
+ JSONObject otherJson = buildPdfJson(policyNo, "5", signExt, bdToken);
|
|
|
|
|
+ downloadPolicyResultVo.setJyUrl(anShengCrawlerRequestComponent.pdfUrl(otherJson, loginToken));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return downloadPolicyResultVo;
|
|
return downloadPolicyResultVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通用构建PDF请求JSON
|
|
|
|
|
+ */
|
|
|
|
|
+ private JSONObject buildPdfJson(String policyNo, String printType, String signExt, String bdToken) {
|
|
|
|
|
+ return JSONObject.of(
|
|
|
|
|
+ "head", JSONObject.of(
|
|
|
|
|
+ "requestType", "V113",
|
|
|
|
|
+ "account", "",
|
|
|
|
|
+ "password", "",
|
|
|
|
|
+ "token", bdToken
|
|
|
|
|
+ ),
|
|
|
|
|
+ "requestInfo", JSONObject.of(
|
|
|
|
|
+ "basePart", JSONObject.of(
|
|
|
|
|
+ "policyNo", policyNo,
|
|
|
|
|
+ "printType", printType,
|
|
|
|
|
+ "sign", signExt
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public OrderStatusResultVo queryOrderState(OrderStatusVo orderStatusVo) {
|
|
public OrderStatusResultVo queryOrderState(OrderStatusVo orderStatusVo) {
|
|
|
// 获取订单信息
|
|
// 获取订单信息
|