|
|
@@ -0,0 +1,158 @@
|
|
|
+package com.jzg.quotation.taikang.crawler.build;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
|
+import com.jzg.commons.entity.quote.vo.KindInfoVo;
|
|
|
+import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
|
+import com.jzg.commons.entity.quote.vo.RiskInfoVo;
|
|
|
+import com.jzg.commons.entity.quote.vo.TaxInfoVo;
|
|
|
+import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
|
|
|
+import com.jzg.commons.util.DateTimeUtils;
|
|
|
+import com.jzg.commons.util.idgen.IdGenerate;
|
|
|
+import com.jzg.quotation.commons.utils.DateTimeUtil;
|
|
|
+import com.jzg.quotation.taikang.crawler.ConvertUtil;
|
|
|
+import com.jzg.quotation.taikang.crawler.cache.RedisCacheUtil;
|
|
|
+import com.jzg.quotation.taikang.crawler.model.api.PreciseInitResult;
|
|
|
+import com.jzg.quotation.taikang.crawler.model.entity.TKCiKindsVo;
|
|
|
+import com.jzg.quotation.taikang.crawler.model.entity.TKDateInfo;
|
|
|
+import com.jzg.quotation.taikang.crawler.model.entity.TKOther;
|
|
|
+import com.jzg.quotation.taikang.crawler.model.entity.TKPremium;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 泰康爬虫报价返回结果构建器
|
|
|
+ * @author: wangrq
|
|
|
+ * @date: 2026/6/9 10:14
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class TkCrawlerQuoteResultsBuild {
|
|
|
+
|
|
|
+ private final RedisCacheUtil redisCacheUtil;
|
|
|
+
|
|
|
+ public TkCrawlerQuoteResultsBuild(RedisCacheUtil redisCacheUtil) {
|
|
|
+ this.redisCacheUtil = redisCacheUtil;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建失败结果
|
|
|
+ *
|
|
|
+ * @param preciseInitResult 报价初始化结果
|
|
|
+ * @return 构建结果,所有条件都不满足时返回 null
|
|
|
+ */
|
|
|
+ public QuoteResultsVo buildQuoteFailResultsVo(PreciseInitResult preciseInitResult) {
|
|
|
+ TKOther other = preciseInitResult.getOther();
|
|
|
+ String errorMessage = null;
|
|
|
+
|
|
|
+ if (other.getVehicleOwnerMessage() != null) {
|
|
|
+ errorMessage = other.getVehicleOwnerMessage();
|
|
|
+ } else if (other.getMessageBZ() != null && other.getMessageBZ().size() >= 2) {
|
|
|
+ errorMessage = other.getMessageBZ().get(0) + "\n" + other.getMessageBZ().get(1);
|
|
|
+ } else if (preciseInitResult.getPremium() == null) {
|
|
|
+ errorMessage = other.getNotice();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errorMessage == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ QuoteResultsVo quoteResultsVo = new QuoteResultsVo();
|
|
|
+ quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.QUOTE_FAIL);
|
|
|
+ quoteResultsVo.setErrorMessage(errorMessage);
|
|
|
+ return quoteResultsVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QuoteResultsVo buildQuoteResultsVo(QuoteVo commonQuoteVo, PreciseInitResult preciseInitResult) {
|
|
|
+ QuoteResultsVo quoteResultsVo = new QuoteResultsVo();
|
|
|
+ quoteResultsVo.setOrdersNo(commonQuoteVo.getOrder().getOrdersNo());
|
|
|
+ TKDateInfo date = preciseInitResult.getDate();
|
|
|
+
|
|
|
+ // 交强险
|
|
|
+ RiskInfoVo riskInfoVo1 = new RiskInfoVo();
|
|
|
+ LocalDateTime jyStart = DateTimeUtil.parseLocalDateTime(date.getInitStartDateBZ(), DateTimeUtil.DATETIME_PATTERN_EXT1);
|
|
|
+ riskInfoVo1.setStartDate(DateTimeUtil.getStartTimeOfDayStr(jyStart, DateTimeUtil.DATETIME_PATTERN));
|
|
|
+ riskInfoVo1.setEndDate(DateTimeUtils.convertToDateTime(date.getJqEndDate(), date.getJqEndHour(), date.getJqEndMinute()));
|
|
|
+ quoteResultsVo.setCiRiskInfoVo(riskInfoVo1);
|
|
|
+
|
|
|
+ // 商业险
|
|
|
+ if (commonQuoteVo.getBiRiskInfoVo() != null) {
|
|
|
+ RiskInfoVo riskInfoVo2 = new RiskInfoVo();
|
|
|
+ LocalDateTime syStart = DateTimeUtil.parseLocalDateTime(date.getInitStartDateCI(), DateTimeUtil.DATETIME_PATTERN_EXT1);
|
|
|
+ riskInfoVo2.setStartDate(DateTimeUtil.getStartTimeOfDayStr(syStart, DateTimeUtil.DATETIME_PATTERN));
|
|
|
+ riskInfoVo2.setEndDate(DateTimeUtils.convertToDateTime(date.getSyEndDate(), date.getSyEndHour(), date.getSyEndMinute()));
|
|
|
+ quoteResultsVo.setBiRiskInfoVo(riskInfoVo2);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 驾意险
|
|
|
+ if (commonQuoteVo.getAccidentalDrivings() != null) {
|
|
|
+ RiskInfoVo riskInfoVo3 = new RiskInfoVo();
|
|
|
+ riskInfoVo3.setStartDate(DateTimeUtils.convertToDateTime(date.getJcbStartDate(), date.getJcbStartHour(), date.getJcbStartMinute()));
|
|
|
+ riskInfoVo3.setEndDate(DateTimeUtils.convertToDateTime(date.getJcbEndDate(), date.getJcbEndHour(), date.getJcbEndMinute()));
|
|
|
+ quoteResultsVo.setJyRiskInfoVo(riskInfoVo3);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 商业险险种信息
|
|
|
+ List<TKCiKindsVo> ciKindsVo = preciseInitResult.getCiKindsVo();
|
|
|
+ if (ciKindsVo != null && !ciKindsVo.isEmpty()) {
|
|
|
+ List<KindInfoVo> kindInfoVos = new ArrayList<>();
|
|
|
+ for (TKCiKindsVo tKCiKindsVo : ciKindsVo) {
|
|
|
+ String kindCode = null; // 险种编码
|
|
|
+ String kindName = null; // 险种名称
|
|
|
+ String platformKindCode = tKCiKindsVo.getKindCode(); // 平台险种编码
|
|
|
+ String platformKindName = tKCiKindsVo.getKindCName(); // 平台险种名称
|
|
|
+ String amount = tKCiKindsVo.getQuoteAmount().toString(); // 保额
|
|
|
+ String unitAmount = tKCiKindsVo.getUnitAmount().toString(); // 每座保额
|
|
|
+ String quantity = tKCiKindsVo.getQuantity(); // 座位数
|
|
|
+ String premium = tKCiKindsVo.getPremium().toString(); // 保费
|
|
|
+ String deductibleRate = null; // 附加绝对免赔率
|
|
|
+ String serviceTimes = null; // 服务次数
|
|
|
+ KindInfoVo kindInfoVo = new KindInfoVo(IdGenerate.nextId(), kindCode, kindName, platformKindCode, platformKindName, amount, unitAmount, quantity, premium, deductibleRate, serviceTimes);
|
|
|
+ kindInfoVos.add(kindInfoVo);
|
|
|
+ }
|
|
|
+ quoteResultsVo.setKindInfoVo(kindInfoVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 交强保费 车船税 商业保费
|
|
|
+ TKPremium premium = preciseInitResult.getPremium();
|
|
|
+ // 设置交强险保费
|
|
|
+ quoteResultsVo.getCosts().setCiPremium(premium.getJqPremium().toString());
|
|
|
+ // 设置商业险保费
|
|
|
+ quoteResultsVo.getCosts().setBiPremium(premium.getSyPremium().toString());
|
|
|
+ // 设置车船税
|
|
|
+ quoteResultsVo.getCosts().setVvTax(premium.getTax().toString());
|
|
|
+ // 设置非车险(驾意险)保费
|
|
|
+ quoteResultsVo.getCosts().setNiPremium(premium.getJyxPremium().toString());
|
|
|
+ quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
|
|
|
+ // 缓存报价书据数据
|
|
|
+ redisCacheUtil.setPreciseInitResult(preciseInitResult, quoteResultsVo.getOrdersNo());
|
|
|
+ // 评分
|
|
|
+ JSONArray scoreJson = new JSONArray();
|
|
|
+ scoreJson.add(new JSONObject()
|
|
|
+ .fluentPut("scoreName", "保单综合评分")
|
|
|
+ .fluentPut("scoreKey", "businessScore")
|
|
|
+ .fluentPut("score", preciseInitResult.getBusinessScore()));
|
|
|
+ scoreJson.add(new JSONObject()
|
|
|
+ .fluentPut("scoreName", "风险评分")
|
|
|
+ .fluentPut("scoreKey", "riskScore")
|
|
|
+ .fluentPut("score", preciseInitResult.getRiskScore()));
|
|
|
+ quoteResultsVo.getScoreVo().setScoreJson(scoreJson);
|
|
|
+ // 欠税信息
|
|
|
+ if (null != preciseInitResult.getCarTax()) {
|
|
|
+ List<TaxInfoVo> taxArrearsList = new ArrayList<>();
|
|
|
+ TaxInfoVo taxArrear = new TaxInfoVo();
|
|
|
+ taxArrear.setYears(preciseInitResult.getCarTax().getRepaymentYear());
|
|
|
+ taxArrear.setTaxDefault(ConvertUtil.convertToDouble(preciseInitResult.getCarTax().getTax()));
|
|
|
+ taxArrear.setLateFee(ConvertUtil.convertToDouble(preciseInitResult.getCarTax().getSumtaxOverdue()));
|
|
|
+ taxArrearsList.add(taxArrear);
|
|
|
+ quoteResultsVo.setTaxVo(taxArrearsList);
|
|
|
+ }
|
|
|
+ return quoteResultsVo;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|