|
@@ -1,11 +1,14 @@
|
|
|
package com.jzg.quotation.zijin.crawler.build;
|
|
package com.jzg.quotation.zijin.crawler.build;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
|
import com.jzg.commons.entity.quote.vo.KindInfoVo;
|
|
import com.jzg.commons.entity.quote.vo.KindInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
|
import com.jzg.commons.entity.quote.vo.RiskInfoVo;
|
|
import com.jzg.commons.entity.quote.vo.RiskInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
|
|
import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
|
|
|
|
|
+import com.jzg.commons.util.DateTimeUtils;
|
|
|
|
|
+import com.jzg.quotation.zijin.api.constant.enums.RiskCodeEnum;
|
|
|
import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerQuotationResponse;
|
|
import com.jzg.quotation.zijin.crawler.entity.response.ZiJinCrawlerQuotationResponse;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
@@ -53,10 +56,28 @@ public class ZiJinCrawlerQuoteResultsVoBuild {
|
|
|
quoteResultsVo.setCiRiskInfoVo(buildCiRiskInfoVo(ziJinCrawlerQuotationResponse));
|
|
quoteResultsVo.setCiRiskInfoVo(buildCiRiskInfoVo(ziJinCrawlerQuotationResponse));
|
|
|
// 设置商业险信息
|
|
// 设置商业险信息
|
|
|
quoteResultsVo.setBiRiskInfoVo(buildBiRiskInfoVo(ziJinCrawlerQuotationResponse));
|
|
quoteResultsVo.setBiRiskInfoVo(buildBiRiskInfoVo(ziJinCrawlerQuotationResponse));
|
|
|
|
|
+ // 设置驾意险信息
|
|
|
|
|
+ // quoteResultsVo.setJyRiskInfoVo(buildJyRiskInfoVo(ziJinCrawlerQuotationResponse));
|
|
|
|
|
+ // 设置险种明细列表
|
|
|
|
|
+ quoteResultsVo.setKindInfoVo(buildKindInfoVoList(ziJinCrawlerQuotationResponse));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 交强保费 车船税 商业保费
|
|
// 交强保费 车船税 商业保费
|
|
|
buildPremium(quoteResultsVo, ziJinCrawlerQuotationResponse);
|
|
buildPremium(quoteResultsVo, ziJinCrawlerQuotationResponse);
|
|
|
|
|
+
|
|
|
|
|
+ // 设置投保单号
|
|
|
|
|
+ // if (ziJinCrawlerQuotationResponse.getBasePart() != null) {
|
|
|
|
|
+ // quoteResultsVo.setCiPolicyNumber(ziJinCrawlerQuotationResponse.getBasePart().getProposalCheckNo());
|
|
|
|
|
+ // quoteResultsVo.setBiPolicyNumber(ziJinCrawlerQuotationResponse.getBasePart().getProposalCheckNo());
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置警告消息(预核保消息)
|
|
|
|
|
+ if (ziJinCrawlerQuotationResponse.getBasePart() != null) {
|
|
|
|
|
+ List<String> warnMessages = new java.util.ArrayList<>();
|
|
|
|
|
+ warnMessages.add(ziJinCrawlerQuotationResponse.getBasePart().getPreUnderwriteMessage());
|
|
|
|
|
+ quoteResultsVo.setWarnMessageList(warnMessages);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//设置报价状态:带核保
|
|
//设置报价状态:带核保
|
|
|
quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
|
|
quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
|
|
|
|
|
|
|
@@ -71,8 +92,9 @@ public class ZiJinCrawlerQuoteResultsVoBuild {
|
|
|
*/
|
|
*/
|
|
|
public static RiskInfoVo buildCiRiskInfoVo(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
public static RiskInfoVo buildCiRiskInfoVo(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
|
RiskInfoVo riskInfoVo = new RiskInfoVo();
|
|
RiskInfoVo riskInfoVo = new RiskInfoVo();
|
|
|
- riskInfoVo.setStartDate(quotationResponse.getBasePart().getStartDateCI());
|
|
|
|
|
- riskInfoVo.setEndDate(quotationResponse.getBasePart().getEndDateCI());
|
|
|
|
|
|
|
+ ZiJinCrawlerQuotationResponse.BasePart basePart = quotationResponse.getBasePart();
|
|
|
|
|
+ riskInfoVo.setStartDate(basePart.getStartDateCI() == null ? null : DateTimeUtils.convertToDateTime(basePart.getStartDateCI(), basePart.getStartHourCI(), basePart.getStartMinuteCI()));
|
|
|
|
|
+ riskInfoVo.setEndDate(basePart.getEndDateCI() == null ? null : DateTimeUtils.convertToDateTime(basePart.getEndDateCI(), basePart.getEndHourCI(), basePart.getEndMinuteCI()));
|
|
|
return riskInfoVo;
|
|
return riskInfoVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -83,32 +105,136 @@ public class ZiJinCrawlerQuoteResultsVoBuild {
|
|
|
*/
|
|
*/
|
|
|
public static RiskInfoVo buildBiRiskInfoVo(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
public static RiskInfoVo buildBiRiskInfoVo(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
|
RiskInfoVo riskInfoVo = new RiskInfoVo();
|
|
RiskInfoVo riskInfoVo = new RiskInfoVo();
|
|
|
- riskInfoVo.setStartDate(quotationResponse.getBasePart().getStartDate());
|
|
|
|
|
- riskInfoVo.setEndDate(quotationResponse.getBasePart().getEndDate());
|
|
|
|
|
|
|
+ ZiJinCrawlerQuotationResponse.BasePart basePart = quotationResponse.getBasePart();
|
|
|
|
|
+ riskInfoVo.setStartDate(basePart.getStartDate() == null ? null : DateTimeUtils.convertToDateTime(basePart.getStartDate(), basePart.getStartHour(), basePart.getStartMinute()));
|
|
|
|
|
+ riskInfoVo.setEndDate(basePart.getEndDate() == null ? null : DateTimeUtils.convertToDateTime(basePart.getEndDate(), basePart.getEndHour(), basePart.getEndMinute()));
|
|
|
return riskInfoVo;
|
|
return riskInfoVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理驾意险数据
|
|
|
|
|
+ * @param quotationResponse
|
|
|
|
|
+ * @return RiskInfoVo
|
|
|
|
|
+ */
|
|
|
|
|
+ // public static RiskInfoVo buildJyRiskInfoVo(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
|
|
|
+ // RiskInfoVo riskInfoVo = new RiskInfoVo();
|
|
|
|
|
+ // riskInfoVo.setStartDate(quotationResponse.getBasePart().getStartDateJY());
|
|
|
|
|
+ // riskInfoVo.setEndDate(quotationResponse.getBasePart().getEndDateJY());
|
|
|
|
|
+ // return riskInfoVo;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理险种明细列表
|
|
|
|
|
+ * @param quotationResponse
|
|
|
|
|
+ * @return List<KindInfoVo>
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<KindInfoVo> buildKindInfoVoList(ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
|
|
|
+ List<KindInfoVo> kindInfoVoList = new java.util.ArrayList<>();
|
|
|
|
|
+ if (quotationResponse.getItemKindList() == null) {
|
|
|
|
|
+ return kindInfoVoList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (ZiJinCrawlerQuotationResponse.ItemKindList item : quotationResponse.getItemKindList()) {
|
|
|
|
|
+ KindInfoVo kindInfoVo = new KindInfoVo();
|
|
|
|
|
+ kindInfoVo.setKindCode(item.getKindCode());
|
|
|
|
|
+ kindInfoVo.setKindName(item.getKindName());
|
|
|
|
|
+ kindInfoVo.setAmount(item.getAmount());
|
|
|
|
|
+ kindInfoVo.setUnitAmount(item.getUnitAmount());
|
|
|
|
|
+ kindInfoVo.setQuantity(item.getQuantity());
|
|
|
|
|
+ kindInfoVo.setPremium(item.getPremium());
|
|
|
|
|
+ kindInfoVoList.add(kindInfoVo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return kindInfoVoList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 设置商业险,交强险保费
|
|
* 设置商业险,交强险保费
|
|
|
* @param quoteResultsVo
|
|
* @param quoteResultsVo
|
|
|
* @param quotationResponse
|
|
* @param quotationResponse
|
|
|
*/
|
|
*/
|
|
|
private static void buildPremium(QuoteResultsVo quoteResultsVo, ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
private static void buildPremium(QuoteResultsVo quoteResultsVo, ZiJinCrawlerQuotationResponse quotationResponse) {
|
|
|
- // 设置交强险保费
|
|
|
|
|
- if (Objects.nonNull(quotationResponse.getPlanList())) {
|
|
|
|
|
- quoteResultsVo.getCosts().setCiPremium(String.valueOf(quotationResponse.getPlanList().get(1).getPlanFee()));
|
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(quotationResponse.getPlanList())) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- // 设置车船税
|
|
|
|
|
- quoteResultsVo.getCosts().setVvTax(String.valueOf(quotationResponse.getPlanList().get(2).getPlanFee()));
|
|
|
|
|
- // 设置商业险保费
|
|
|
|
|
- if (Objects.nonNull(quotationResponse.getPlanList())){
|
|
|
|
|
- quoteResultsVo.getCosts().setBiPremium(String.valueOf(quotationResponse.getPlanList().get(0).getPlanFee()));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历 planList,根据 riskCode 或 planText 来识别不同类型的费用
|
|
|
|
|
+ for (ZiJinCrawlerQuotationResponse.PlanList plan : quotationResponse.getPlanList()) {
|
|
|
|
|
+ if (plan == null || plan.getPlanFee() == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String riskCode = plan.getRiskCode();
|
|
|
|
|
+ String planText = plan.getPlanText();
|
|
|
|
|
+
|
|
|
|
|
+ // 根据 riskCode 判断类型
|
|
|
|
|
+ if (RiskCodeEnum.TRAFFIC_CODE.equals(riskCode)) {
|
|
|
|
|
+ // 交强险
|
|
|
|
|
+ quoteResultsVo.getCosts().setCiPremium(String.valueOf(plan.getPlanFee()));
|
|
|
|
|
+ } else if (RiskCodeEnum.ACCIDENT_CODE.equals(riskCode)) {
|
|
|
|
|
+ // 车船税
|
|
|
|
|
+ quoteResultsVo.getCosts().setVvTax(String.valueOf(plan.getPlanFee()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 商业险或其他险种
|
|
|
|
|
+ // 如果还没有设置商业险保费,则设置为商业险
|
|
|
|
|
+ if (quoteResultsVo.getCosts().getBiPremium() == null) {
|
|
|
|
|
+ quoteResultsVo.getCosts().setBiPremium(String.valueOf(plan.getPlanFee()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 设置非车险(驾意险)保费
|
|
// 设置非车险(驾意险)保费
|
|
|
- ZiJinCrawlerQuotationResponse.CarPolicySubInfoList carPolicySubInfoList = quotationResponse.getCarPolicySubInfoList().get(0);
|
|
|
|
|
- if (carPolicySubInfoList != null) {
|
|
|
|
|
- quoteResultsVo.getCosts().setNiPremium(carPolicySubInfoList.getActualPremium());
|
|
|
|
|
|
|
+ if (quotationResponse.getCarPolicySubInfoList() != null && !quotationResponse.getCarPolicySubInfoList().isEmpty()) {
|
|
|
|
|
+ ZiJinCrawlerQuotationResponse.CarPolicySubInfoList carPolicySubInfoList = quotationResponse.getCarPolicySubInfoList().get(0);
|
|
|
|
|
+ if (carPolicySubInfoList != null && carPolicySubInfoList.getActualPremium() != null) {
|
|
|
|
|
+ quoteResultsVo.getCosts().setNiPremium(carPolicySubInfoList.getActualPremium());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 计算总保费
|
|
|
|
|
+ // calculateSumPremium(quoteResultsVo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 计算总保费
|
|
|
|
|
+ * @param quoteResultsVo
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void calculateSumPremium(QuoteResultsVo quoteResultsVo) {
|
|
|
|
|
+ double sumPremium = 0.0;
|
|
|
|
|
+
|
|
|
|
|
+ if (quoteResultsVo.getCosts().getCiPremium() != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sumPremium += Double.parseDouble(quoteResultsVo.getCosts().getCiPremium());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ log.warn("交强险保费解析失败: {}", quoteResultsVo.getCosts().getCiPremium());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (quoteResultsVo.getCosts().getBiPremium() != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sumPremium += Double.parseDouble(quoteResultsVo.getCosts().getBiPremium());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ log.warn("商业险保费解析失败: {}", quoteResultsVo.getCosts().getBiPremium());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (quoteResultsVo.getCosts().getVvTax() != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sumPremium += Double.parseDouble(quoteResultsVo.getCosts().getVvTax());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ log.warn("车船税解析失败: {}", quoteResultsVo.getCosts().getVvTax());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (quoteResultsVo.getCosts().getNiPremium() != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ sumPremium += Double.parseDouble(quoteResultsVo.getCosts().getNiPremium());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ log.warn("非车险保费解析失败: {}", quoteResultsVo.getCosts().getNiPremium());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ quoteResultsVo.getCosts().setSumPremium(String.valueOf(sumPremium));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|