Sfoglia il codice sorgente

新旧车判断修改

785834757 2 anni fa
parent
commit
22239d2ff1

+ 35 - 6
src/main/java/com/ydtech/modules/fee/dto/vo/RuleAttrMappingVo.java

@@ -10,10 +10,15 @@ import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.api.dajia.constants.TypeVehicleMapping;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.service.InsOrdersService;
+import com.ydtech.modules.protocol.entity.po.PtlNewCarJudgeRules;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.time.LocalDate;
+import java.time.Period;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -37,11 +42,11 @@ public class RuleAttrMappingVo {
         this.value = value;
     }
 
-    public static List<RuleAttrMappingVo> getRuleAttrMappingVoList(InsAreaCompany insAreaCompany, InsOrders insOrders) {
+    public static List<RuleAttrMappingVo> getRuleAttrMappingVoList(InsAreaCompany insAreaCompany, InsOrders insOrders,
+                                                                   List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList, PtlNewCarJudgeRules carJudgeRule) {
         List<RuleAttrMappingVo> ruleAttrMappingVoList = new ArrayList<>();
         CarInfoVo carInfo = insOrders.getCarinfo().toJavaObject(CarInfoVo.class);
         //车牌号
-
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("LicenseNo", carInfo.getLicenseNo()));
         //品牌型号
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("BrandandModel", carInfo.getModelcname()));
@@ -64,7 +69,31 @@ public class RuleAttrMappingVo {
         //是否过户
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("TransferVehicle", carInfo.isTransferFlag() ? "1" : "0"));
         //是否新车
-        ruleAttrMappingVoList.add(new RuleAttrMappingVo("NewAndOldCars", carInfo.isNoLicenseFlag() ? "1" : "0"));
+        //使用注册日期算出自然月 然后判断是否是新旧车
+        LocalDate registrationDate = LocalDate.parse(carInfo.getIssueDate());
+        LocalDate currentDate = LocalDate.now();
+        PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = undwrtRulesAttrList.stream().filter(x -> x.getAttrCode().equals("NewAndOldCars")).findFirst().get();
+        boolean isNoLicenseFlag = false;
+        if(carJudgeRule != null)
+        {
+            if(carJudgeRule.getUnitTypeCode().equals("天")){
+                long days = ChronoUnit.DAYS.between(registrationDate, currentDate);
+                if(days < Integer.parseInt(carJudgeRule.getUnitTypeValue()))
+                {
+                    isNoLicenseFlag = true;
+                }
+            }
+            if(carJudgeRule.getUnitTypeCode().equals("月")){
+                long months = ChronoUnit.MONTHS.between(registrationDate, currentDate);
+                if(months < Integer.parseInt(carJudgeRule.getUnitTypeValue()))
+                {
+                    isNoLicenseFlag = true;
+                }
+            }
+        }
+
+        ruleAttrMappingVoList.add(new RuleAttrMappingVo("NewAndOldCars", isNoLicenseFlag ? "1" : "0"));
+
         //发证日期
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("DateofIssuance", carInfo.getIssueDate()));
         //车长
@@ -175,11 +204,11 @@ public class RuleAttrMappingVo {
         //非车险
         ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonMotorInsurance", String.valueOf(insAreaCompany.getJypremium())));
         //总折扣率
-//        ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalDiscountRate", String.valueOf(insAreaCompany.())));
+        ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalDiscountRate", String.valueOf(insAreaCompany.getTotalAdjustRate())));
         //交强折扣
-//        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceDiscount", String.valueOf(quoteRespVo.getJqAdjustRate())));
+        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceDiscount", String.valueOf(insAreaCompany.getJqAdjustRate())));
         //商业折扣
-//        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialDiscount", String.valueOf(quoteRespVo.getSyAdjustRate())));
+        ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialDiscount", String.valueOf(insAreaCompany.getSyAdjustRate())));
         //数值型总评分
         Pattern pattern = Pattern.compile("[0-9]*");
         if (insAreaCompany.getScore() != null) {

+ 35 - 4
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -19,6 +19,8 @@ import com.ydtech.modules.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.vo.*;
 import com.ydtech.modules.order.service.InsOrdersService;
+import com.ydtech.modules.protocol.entity.po.PtlNewCarJudgeRules;
+import com.ydtech.modules.protocol.service.PtlNewCarJudgeRulesService;
 import com.ydtech.modules.protocols.entity.po.*;
 import com.ydtech.modules.protocols.entity.vo.AgreementProductCosts;
 import com.ydtech.modules.protocols.service.*;
@@ -72,6 +74,9 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
     @Autowired
     private SysUserAccountService  sysUserAccountService;
 
+    @Autowired
+    private PtlNewCarJudgeRulesService ptlNewCarJudgeRulesService;
+
 
     @Override
     public QueryOrderFeeVo queryFeeOrderInfo(String companyId) {
@@ -432,8 +437,10 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //匹配费用因子
         //获取所有费用属性
         List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        //获取新旧车信息
+        PtlNewCarJudgeRules carJudgeRule = getCarJudgeRule(insAreaCompany.getCompanyId());
         //获取所有费用属性关联
-        List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders);
+        List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders, undwrtRulesAttrList, carJudgeRule);
 
 //        List<AgreementProductCosts> filterAgreementProductCosts = new ArrayList<>();
 
@@ -489,7 +496,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //获取所有承保规则属性
         List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
         //获取所有费用属性关联
-        List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders);
+        List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders, undwrtRulesAttrList,getCarJudgeRule(insAreaCompany.getCompanyId()));
 
 
         for (int i = 0; i < ptlAgreementUndwrtRulesNews.size(); i++) {
@@ -530,8 +537,6 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 return false;
             }
 
-
-
             //查找 费用因子规则
             PtlAgreementUndwrtRulesAttr ptlAgreementUndwrtRulesAttr = rulesAttrs.stream().filter(x -> x.getAttrCode().equals(ptlAgreementProductCostsAttrLinks.get(finalI).getAttrCode())).findFirst().get();
 
@@ -809,6 +814,12 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         return false;
     }
 
+    /**
+     * 属性为选择框判断
+     * @param ptlAgreementUndwrtRulesAttrLink
+     * @param value
+     * @return
+     */
     private boolean selectEqual(PtlAgreementUndwrtRulesAttrLink ptlAgreementUndwrtRulesAttrLink, String value){
         if(ptlAgreementUndwrtRulesAttrLink.getMin() != null && ptlAgreementUndwrtRulesAttrLink.getMin().contains(value)){
             return false;
@@ -816,6 +827,12 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         return true;
     }
 
+    /**
+     * 属性为单选框判断
+     * @param ptlAgreementProductCostsAttrLink
+     * @param value
+     * @return
+     */
     private boolean radioEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value){
         //新能源判断
         if("NewEnergy".equals(ptlAgreementProductCostsAttrLink.getAttrCode())){
@@ -850,4 +867,18 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         }
         return true;
     }
+
+    /**
+     * 获取车辆新旧车信息
+     * @param companyId
+     * @return
+     */
+    private PtlNewCarJudgeRules getCarJudgeRule(String companyId){
+        //获取车辆新旧车信息
+        List<PtlNewCarJudgeRules> list = ptlNewCarJudgeRulesService.list(new LambdaQueryWrapper<PtlNewCarJudgeRules>().eq(PtlNewCarJudgeRules::getCompanyId, companyId));
+        if(list.size()>0){
+            return list.get(0);
+        }
+        return null;
+    }
 }