|
|
@@ -0,0 +1,122 @@
|
|
|
+package com.ydtech.modules.order.components.zhongmei;
|
|
|
+
|
|
|
+
|
|
|
+import com.ydtech.constants.enums.InsuranceRisk;
|
|
|
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
|
|
|
+import com.ydtech.modules.order.components.ZhongmeiRequestApiComponents;
|
|
|
+import com.ydtech.modules.order.entity.api.zm.constants.TimeConstants;
|
|
|
+import com.ydtech.modules.order.entity.api.zm.request.QuotedPriceRequest;
|
|
|
+import com.ydtech.modules.order.entity.api.zm.response.QuotedPriceResponse;
|
|
|
+import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
+import com.ydtech.utils.DateTimeUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 中煤重复投保保期处理
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class ZhongmeiRepeatInsuranceComponents {
|
|
|
+
|
|
|
+ private final ZhongmeiRequestApiComponents zhongmeiRequestApiComponents;
|
|
|
+
|
|
|
+ public ZhongmeiRepeatInsuranceComponents(@Lazy ZhongmeiRequestApiComponents zhongmeiRequestApiComponents) {
|
|
|
+ this.zhongmeiRequestApiComponents = zhongmeiRequestApiComponents;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public QuotedPriceResponse dealRepeatDate(QuotedPriceRequest quotedPriceRequest, QuotedPriceResponse quotedPriceResponse, BaseQuoteInfoVo quoteInfo) {
|
|
|
+ //InsuranceLog.infoLog(InsuranceEnum.ZMBX.getPinyin(), "\n\t---------> {}\n\t---------> {}", "中煤财险重复投保处理", quotedPriceResponse.getBizPlatformMsg().getAnswer());
|
|
|
+ String rtnMsgBz = "";
|
|
|
+ String rtnMsgBusi = "";
|
|
|
+ List<RiskInfoVo> riskList = quoteInfo.getRiskList();
|
|
|
+ if(quotedPriceResponse.getForcePlatformMsg()!=null){
|
|
|
+ rtnMsgBz = quotedPriceResponse.getForcePlatformMsg().getAnswer();
|
|
|
+ }
|
|
|
+ if(quotedPriceResponse.getBizPlatformMsg()!=null){
|
|
|
+ rtnMsgBusi = quotedPriceResponse.getBizPlatformMsg().getAnswer();
|
|
|
+ }
|
|
|
+ /* rtnMsgBz = "交强险平台返回:号牌号码“晋HQE092”的保单发生重复投保,与其重复投保的其它公司的保单信息如下:投保确认码 02CCIC140022102196416712744293;保单号 PDFA22140123250000001413;起保日期 2022-10-24 00:00;终保日期 2023-10-24 00:00;号牌号码 晋HQE092;号牌种类 02;车架号 LSGBC5356HG101426;发动机号 170971343;地区 山西。";
|
|
|
+ rtnMsgBusi = "平台校验:成功 投保查询码:V0101ZMBX140023092205710579353 平台校验,可能存在重复投保,请关注以下平台返回的信息。保单号:6605212022140193005587; 保险公司:中国人寿财产保险公司: 起保日期:2022-10-1600:00:00; 终保日期:2023-10-16; 录单日期:2022-09-15; 险种名称:机动车第三者责任保险: 号牌号码:晋A711BW; 号牌种类代码:02; 号牌底色:01; 车辆识别代号: LGWEF4A52HF424155; 发动机号:1725091016";
|
|
|
+*/
|
|
|
+ QuotedPriceRequest.ContractDTO.ContractMainDTO contractMainDTOBiz = null;
|
|
|
+ QuotedPriceRequest.ContractDTO.ContractMainDTO contractMainDTOBusi = null;
|
|
|
+ List<QuotedPriceRequest.ContractDTO> contractDTOList = quotedPriceRequest.getBusinessData().getContract();
|
|
|
+
|
|
|
+ for(QuotedPriceRequest.ContractDTO contractDTO :contractDTOList){
|
|
|
+ QuotedPriceRequest.ContractDTO.ContractMainDTO contractMainDTO =contractDTO.getContractMain();
|
|
|
+ if("0330".equals(contractMainDTO.getRiskCode())){
|
|
|
+ contractMainDTOBiz = contractDTO.getContractMain();
|
|
|
+ }else{
|
|
|
+ contractMainDTOBusi = contractDTO.getContractMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ String jqEndDate = "";
|
|
|
+ String syEndDate = "";
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(rtnMsgBz)) {
|
|
|
+ String coverageEndDate = rtnMsgBz.substring(rtnMsgBz.indexOf("终保日期") + 5, rtnMsgBz.indexOf("终保日期") + 5 + 16);
|
|
|
+ LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.DATETIME_PATTERN_EXT1);
|
|
|
+ jqEndDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
|
|
|
+ contractMainDTOBiz = getPeriodDate(jqEndDate,contractMainDTOBiz);
|
|
|
+ for (RiskInfoVo riskInfoVo : riskList){
|
|
|
+ if(InsuranceRisk.TRAFFIC.getCode().equals(riskInfoVo.getRiskCode())){
|
|
|
+ riskInfoVo.setStartDate(contractMainDTOBiz.getValidDate());
|
|
|
+ riskInfoVo.setEndDate(contractMainDTOBiz.getExpiryDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 商业险
|
|
|
+ if (StringUtils.isNotEmpty(rtnMsgBz)) {
|
|
|
+ String coverageEndDate = rtnMsgBusi.substring(rtnMsgBusi.indexOf("终保日期") + 5, rtnMsgBusi.indexOf("终保日期") + 5 + 10);
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime start = LocalDate.parse(coverageEndDate, dateTimeFormatter).atStartOfDay();
|
|
|
+ syEndDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
|
|
|
+ contractMainDTOBusi = getPeriodDate(syEndDate,contractMainDTOBusi);
|
|
|
+ for (RiskInfoVo riskInfoVo : riskList){
|
|
|
+ if(InsuranceRisk.BUSINESS.getCode().equals(riskInfoVo.getRiskCode())){
|
|
|
+ riskInfoVo.setStartDate(contractMainDTOBiz.getValidDate());
|
|
|
+ riskInfoVo.setEndDate(contractMainDTOBiz.getExpiryDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* if (jqEndDate.isEmpty() && syEndDate.isEmpty()) {
|
|
|
+ throw new SystemException(rtnMsg);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ return zhongmeiRequestApiComponents.quotedPrice(quotedPriceRequest, QuotedPriceResponse.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private QuotedPriceRequest.ContractDTO.ContractMainDTO getPeriodDate(String startDate, QuotedPriceRequest.ContractDTO.ContractMainDTO contractMainDTO){
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDate localDate = LocalDate.parse(startDate, formatter);
|
|
|
+ LocalDate nextYears = localDate.plusYears(1);
|
|
|
+ if (startDate.contains(TimeConstants.START_TIME)) {
|
|
|
+ LocalDate expiry = nextYears.minusDays(1);
|
|
|
+ contractMainDTO.setValidDate(startDate);
|
|
|
+ contractMainDTO.setExpiryDate(expiry + " " + TimeConstants.END_TIME);
|
|
|
+ contractMainDTO.setReinsuranceFlag("0");
|
|
|
+ } else {
|
|
|
+ // 及时
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.parse(startDate, formatter);
|
|
|
+ LocalDateTime expiryDateTime = localDateTime.plusYears(1);
|
|
|
+ contractMainDTO.setValidDate(startDate);
|
|
|
+ contractMainDTO.setExpiryDate(expiryDateTime.format(formatter));
|
|
|
+ contractMainDTO.setReinsuranceFlag("1");
|
|
|
+ }
|
|
|
+ return contractMainDTO;
|
|
|
+ }
|
|
|
+}
|