RuleAttrMappingVo.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. package com.ydtech.modules.fee.dto.vo;
  2. import com.ydtech.constants.enums.InsurKind;
  3. import com.ydtech.constants.enums.dict.ZmTransferType;
  4. import com.ydtech.constants.enums.dict.insurance.VehicleType;
  5. import com.ydtech.modules.ins.model.vo.CarInfoVo;
  6. import com.ydtech.modules.ins.model.vo.CustomerInfoVo;
  7. import com.ydtech.modules.ins.model.vo.KindInfoVo;
  8. import com.ydtech.modules.ins.model.vo.QuoteRespVo;
  9. import com.ydtech.modules.order.entity.InsAreaCompany;
  10. import com.ydtech.modules.order.entity.InsOrders;
  11. import com.ydtech.modules.order.entity.api.dajia.constants.TypeVehicleMapping;
  12. import com.ydtech.modules.protocol.entity.po.PtlNewCarJudgeRules;
  13. import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
  14. import com.ydtech.utils.StringUtils;
  15. import io.swagger.annotations.ApiModelProperty;
  16. import lombok.Data;
  17. import java.time.LocalDate;
  18. import java.time.LocalDateTime;
  19. import java.time.format.DateTimeFormatter;
  20. import java.time.temporal.ChronoUnit;
  21. import java.util.ArrayList;
  22. import java.util.List;
  23. import java.util.Objects;
  24. import java.util.Optional;
  25. import java.util.regex.Pattern;
  26. /**
  27. * @author: tz
  28. * @description: 规则属性映射费用因子Vo
  29. * @create: 2024-2-28 08:35:57
  30. */
  31. @Data
  32. public class RuleAttrMappingVo {
  33. @ApiModelProperty(value = "因子属性Code")
  34. private String attrCode;
  35. @ApiModelProperty(value = "值")
  36. private String value;
  37. public RuleAttrMappingVo(String attrCode, String value) {
  38. this.attrCode = attrCode;
  39. this.value = value;
  40. }
  41. public static List<RuleAttrMappingVo> getRuleAttrMappingVoList(QuoteRespVo quoteRespVo, InsAreaCompany insAreaCompany, InsOrders insOrders,
  42. List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList,
  43. PtlNewCarJudgeRules carJudgeRule) {
  44. List<RuleAttrMappingVo> ruleAttrMappingVoList = new ArrayList<>();
  45. CarInfoVo carInfo = insOrders.getCarinfo().toJavaObject(CarInfoVo.class);
  46. //车牌号
  47. ruleAttrMappingVoList.add(new RuleAttrMappingVo("LicenseNo", carInfo.getLicenseNo()));
  48. //品牌型号
  49. ruleAttrMappingVoList.add(new RuleAttrMappingVo("BrandandModel", carInfo.getModelcname()));
  50. //座位数
  51. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerCarSeatingCapacity", carInfo.getSeatCount()));
  52. //新车购置价
  53. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PurchasePriceofNewVehicle", carInfo.getPurchasePrice()));
  54. //车辆用途
  55. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NatureOfUse", TypeVehicleMapping.getByCode(carInfo.getVehicleUse())));
  56. //车辆种类
  57. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarType", VehicleType.getByCode(carInfo.getCimodelclass())));
  58. //车辆类型
  59. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarClass", carInfo.getCartype()));
  60. //核定载质量
  61. ruleAttrMappingVoList.add(new RuleAttrMappingVo("AuthorizedLoadWeight", carInfo.getLimitLoad()));
  62. //汽车排量
  63. ruleAttrMappingVoList.add(new RuleAttrMappingVo("EngineCapacity", carInfo.getEnginedesc()));
  64. //整备质量
  65. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CurbWeight", carInfo.getVehicleweight()));
  66. //能源类型
  67. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NewEnergy", carInfo.getEnergyType()));
  68. //注册日期
  69. ruleAttrMappingVoList.add(new RuleAttrMappingVo("RegistrationDate", carInfo.getRegisterDate()));
  70. //是否过户
  71. ruleAttrMappingVoList.add(new RuleAttrMappingVo("TransferVehicle", carInfo.isTransferFlag() ? "1" : "0"));
  72. //是否新车
  73. //使用注册日期算出自然月 然后判断是否是新旧车
  74. LocalDate registrationDate = LocalDate.parse(carInfo.getRegisterDate());
  75. LocalDate currentDate = LocalDate.now();
  76. //特种车判断
  77. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SpecialVehicle", Objects.nonNull(carInfo.getImportFlag()) && carInfo.getImportFlag()
  78. .equals("特种车类") ? "1" : "0"));
  79. //交强起保日期
  80. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqStartTime", insAreaCompany.getJqStartDate()));
  81. //商业起保日期
  82. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyStartTime", insAreaCompany.getSyStartDate()));
  83. // 中煤不浮动原因
  84. if (Objects.nonNull(quoteRespVo)) {
  85. String rateFloatFlag = ZmTransferType.getByCode(quoteRespVo.getRateFloatFlag());
  86. ruleAttrMappingVoList.add(new RuleAttrMappingVo("RateFloatFlag", rateFloatFlag == null ? "null" : rateFloatFlag));
  87. }
  88. boolean isNoLicenseFlag = false;
  89. if (carJudgeRule != null) {
  90. if (carJudgeRule.getUnitTypeCode().equals("天")) {
  91. long days = ChronoUnit.DAYS.between(registrationDate, currentDate);
  92. if (days < Integer.parseInt(carJudgeRule.getUnitTypeValue())) {
  93. isNoLicenseFlag = true;
  94. }
  95. }
  96. if (carJudgeRule.getUnitTypeCode().equals("月")) {
  97. long months = ChronoUnit.MONTHS.between(registrationDate, currentDate);
  98. if (months < Integer.parseInt(carJudgeRule.getUnitTypeValue())) {
  99. isNoLicenseFlag = true;
  100. }
  101. }
  102. }
  103. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NewAndOldCars", isNoLicenseFlag ? "1" : "0"));
  104. //车龄
  105. long between = ChronoUnit.YEARS.between(registrationDate, currentDate) + 1;
  106. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleAge", String.valueOf(between)));
  107. //发证日期
  108. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DateofIssuance", carInfo.getIssueDate()));
  109. //车长
  110. // ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleLength", carInfo.getCarLength()));
  111. //转续保 交强
  112. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqRenewalOfInsurance", insAreaCompany.getJqRenewal()));
  113. //转续保 商业
  114. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyRenewalOfInsurance", insAreaCompany.getSyRenewal()));
  115. CustomerInfoVo ownerInfo = insOrders.getOwnerinfo().toJavaObject(CustomerInfoVo.class);
  116. if (StringUtils.isBlank(ownerInfo.getProperty()) || !"0".equals(ownerInfo.getProperty())) {
  117. //车主 证件号码(前6位)
  118. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersIDNumber", ownerInfo.getIdentifyNumber()));
  119. //车主 年龄
  120. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersAge", ownerInfo.getAge()));
  121. //车主 性别
  122. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersSex", ownerInfo.getGender()
  123. .equals("男") ? "1" : "2"));
  124. //车主地址
  125. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersAddress", ownerInfo.getAddr()));
  126. // 车主生日
  127. String carOwnersBirthday = ownerInfo.getIdentifyNumber()
  128. .substring(6, 10) + "-" + ownerInfo.getIdentifyNumber()
  129. .substring(10, 12) + "-" + ownerInfo.getIdentifyNumber().substring(12, 14);
  130. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersBirthday", carOwnersBirthday));
  131. }
  132. //车主 姓名
  133. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnerName", ownerInfo.getName()));
  134. CustomerInfoVo policyHolderInfo = insOrders.getApplyinfo().toJavaObject(CustomerInfoVo.class);
  135. if (StringUtils.isBlank(policyHolderInfo.getProperty()) || !"0".equals(policyHolderInfo.getProperty())) {
  136. //投保人 证件号码(前6位)
  137. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantIDNumber", policyHolderInfo.getIdentifyNumber()));
  138. //投保人 年龄
  139. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantAge", policyHolderInfo.getAge()));
  140. //投保人 性别
  141. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantSex", policyHolderInfo.getGender()
  142. .equals("男") ? "1" : "2"));
  143. //投保人地址
  144. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantAddress", policyHolderInfo.getAddr()));
  145. // 投保人生日
  146. String applicantBirthday = policyHolderInfo.getIdentifyNumber()
  147. .substring(6, 10) + "-" + policyHolderInfo.getIdentifyNumber()
  148. .substring(10, 12) + "-" + policyHolderInfo.getIdentifyNumber().substring(12, 14);
  149. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantBirthday", applicantBirthday));
  150. }
  151. CustomerInfoVo insuredPersonInfo = insOrders.getInsureinfo().toJavaObject(CustomerInfoVo.class);
  152. if (StringUtils.isBlank(insuredPersonInfo.getProperty()) || !"0".equals(insuredPersonInfo.getProperty())) {
  153. //被保人 证件号码(前6位)
  154. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredIDNumber", insuredPersonInfo.getIdentifyNumber()));
  155. //被保人 年龄
  156. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredAge", insuredPersonInfo.getAge()));
  157. //被保人 性别
  158. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredSex", insuredPersonInfo.getGender()
  159. .equals("男") ? "1" : "2"));
  160. //被保人地址
  161. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredAddress", insuredPersonInfo.getAddr()));
  162. //被保人生日
  163. String insuredBirthday = insuredPersonInfo.getIdentifyNumber()
  164. .substring(6, 10) + "-" + insuredPersonInfo.getIdentifyNumber()
  165. .substring(10, 12) + "-" + insuredPersonInfo.getIdentifyNumber().substring(12, 14);
  166. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredBirthday", insuredBirthday));
  167. }
  168. String OPIConsistent = "0";
  169. if (StringUtils.isNotBlank(ownerInfo.getProperty())) {
  170. boolean boo = ownerInfo.getProperty()
  171. .equals(insuredPersonInfo.getProperty()) && insuredPersonInfo.getProperty()
  172. .equals(policyHolderInfo.getProperty());
  173. if (boo) {
  174. if ("0".equals(ownerInfo.getProperty())) {
  175. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  176. .equals(policyHolderInfo.getName())) &&
  177. (ownerInfo.getOrganizationCode()
  178. .equals(insuredPersonInfo.getOrganizationCode()) && insuredPersonInfo.getOrganizationCode()
  179. .equals(policyHolderInfo.getOrganizationCode()))) {
  180. OPIConsistent = "1";
  181. }
  182. } else {
  183. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  184. .equals(policyHolderInfo.getName())) &&
  185. (ownerInfo.getIdentifyNumber()
  186. .equals(insuredPersonInfo.getIdentifyNumber()) && insuredPersonInfo.getIdentifyNumber()
  187. .equals(policyHolderInfo.getIdentifyNumber()))) {
  188. OPIConsistent = "1";
  189. }
  190. }
  191. }
  192. } else {
  193. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  194. .equals(policyHolderInfo.getName())) &&
  195. (ownerInfo.getIdentifyNumber()
  196. .equals(insuredPersonInfo.getIdentifyNumber()) && insuredPersonInfo.getIdentifyNumber()
  197. .equals(policyHolderInfo.getIdentifyNumber()))) {
  198. OPIConsistent = "1";
  199. }
  200. }
  201. ruleAttrMappingVoList.add(new RuleAttrMappingVo("OPIConsistent", OPIConsistent));
  202. String PIConsistent = "0";
  203. if (StringUtils.isNotBlank(insuredPersonInfo.getProperty())) {
  204. boolean boo = insuredPersonInfo.getProperty().equals(policyHolderInfo.getProperty());
  205. if (boo) {
  206. if ("0".equals(insuredPersonInfo.getProperty())) {
  207. //投被保人是否一致
  208. if (insuredPersonInfo.getName()
  209. .equals(policyHolderInfo.getName()) && insuredPersonInfo.getOrganizationCode()
  210. .equals(policyHolderInfo.getOrganizationCode())) {
  211. PIConsistent = "1";
  212. }
  213. } else {
  214. //投被保人是否一致
  215. if (insuredPersonInfo.getName()
  216. .equals(policyHolderInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  217. .equals(policyHolderInfo.getIdentifyNumber())) {
  218. PIConsistent = "1";
  219. }
  220. }
  221. }
  222. } else {
  223. //投被保人是否一致
  224. if (insuredPersonInfo.getName().equals(policyHolderInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  225. .equals(policyHolderInfo.getIdentifyNumber())) {
  226. PIConsistent = "1";
  227. }
  228. }
  229. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PIConsistent", PIConsistent));
  230. //2024-06-20 起保日期 月份判断
  231. if (insAreaCompany.getJqStartDate() != null && !insAreaCompany.getJqStartDate().equals("")) {
  232. LocalDateTime jqStartDate = LocalDateTime.parse(insAreaCompany.getJqStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
  233. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqStartMonth", String.valueOf(jqStartDate.getMonthValue())));
  234. }
  235. if (insAreaCompany.getSyStartDate() != null && !insAreaCompany.getSyStartDate().equals("")) {
  236. LocalDateTime syStartDate = LocalDateTime.parse(insAreaCompany.getSyStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
  237. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyStartMonth", String.valueOf(syStartDate.getMonthValue())));
  238. }
  239. List<KindInfoVo> kindInfoVos = insAreaCompany.getKindinfo().toJavaList(KindInfoVo.class);
  240. //险别信息
  241. kindInfoVos.forEach(kindInfoVo -> {
  242. //机动车损失险
  243. if (InsurKind.A.getCode().equals(kindInfoVo.getKindCode())) {
  244. ruleAttrMappingVoList.add(new RuleAttrMappingVo("MotorVehicleDamageInsurance", String.valueOf(kindInfoVo.getAmount())));
  245. }
  246. //第三者责任险
  247. if (InsurKind.B.getCode().equals(kindInfoVo.getKindCode())) {
  248. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyLiabilityInsurance",
  249. String.valueOf(Double.valueOf(kindInfoVo.getAmount()).intValue())));
  250. }
  251. //司机责任险
  252. if (InsurKind.D3.getCode().equals(kindInfoVo.getKindCode())) {
  253. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverLiabilityInsurance", String.valueOf(kindInfoVo.getAmount())));
  254. }
  255. //乘客责任险
  256. if (InsurKind.D4.getCode().equals(kindInfoVo.getKindCode())) {
  257. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerLiabilityInsurance", String.valueOf(kindInfoVo.getUnitAmount())));
  258. }
  259. //车身划痕险
  260. if (InsurKind.L.getCode().equals(kindInfoVo.getKindCode())) {
  261. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarScratchInsurance", String.valueOf(kindInfoVo.getAmount())));
  262. }
  263. //绝对免赔率特约险(车损)
  264. if (InsurKind.MJ1.getCode().equals(kindInfoVo.getKindCode())) {
  265. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleDamageAbsoluteDeductibleSpecialInsurance",
  266. String.valueOf(kindInfoVo.getAmount())));
  267. }
  268. //绝对免赔率特约险(三者)
  269. if (InsurKind.MJ2.getCode().equals(kindInfoVo.getKindCode())) {
  270. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdAbsoluteDeductibleSpecialInsurance",
  271. String.valueOf(kindInfoVo.getAmount())));
  272. }
  273. //绝对免赔率特约险(司机)
  274. if (InsurKind.MJ3.getCode().equals(kindInfoVo.getKindCode())) {
  275. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAbsoluteDeductibleSpecialInsurance",
  276. String.valueOf(kindInfoVo.getAmount())));
  277. }
  278. //绝对免赔率特约险(乘客)
  279. if (InsurKind.MJ4.getCode().equals(kindInfoVo.getKindCode())) {
  280. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAbsoluteDeductibleSpecialInsurance",
  281. String.valueOf(kindInfoVo.getAmount())));
  282. }
  283. //附加医保-三者
  284. if (InsurKind.SY_FJ_YBW1.getCode().equals(kindInfoVo.getKindCode())) {
  285. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyAdditionalMedicalInsurance",
  286. String.valueOf(kindInfoVo.getAmount())));
  287. }
  288. //附加医保-座位险(乘客)
  289. if (InsurKind.SY_FJ_YBW2.getCode().equals(kindInfoVo.getKindCode())) {
  290. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAdditionalMedicalInsurance",
  291. String.valueOf(kindInfoVo.getAmount())));
  292. }
  293. //附加医保-座位险(司机)
  294. if (InsurKind.SY_FJ_YBW3.getCode().equals(kindInfoVo.getKindCode())) {
  295. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAdditionalMedicalInsurance",
  296. String.valueOf(kindInfoVo.getAmount())));
  297. }
  298. //法定节假日限额翻倍险
  299. if (InsurKind.BD.getCode().equals(kindInfoVo.getKindCode())) {
  300. ruleAttrMappingVoList.add(new RuleAttrMappingVo("LegalHolidayLimitDoublingInsurance",
  301. String.valueOf(kindInfoVo.getAmount())));
  302. }
  303. //道路救援服务特约条款
  304. if (InsurKind.TY1.getCode().equals(kindInfoVo.getKindCode())) {
  305. ruleAttrMappingVoList.add(new RuleAttrMappingVo("RoadsideAssistanceServiceSpecialClause",
  306. String.valueOf(kindInfoVo.getServiceTimes())));
  307. }
  308. //车辆安全检测特约条款
  309. if (InsurKind.TY2.getCode().equals(kindInfoVo.getKindCode())) {
  310. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleSafetyInspectionSpecialClause",
  311. String.valueOf(kindInfoVo.getServiceTimes())));
  312. }
  313. //代为驾驶服务特约条款
  314. if (InsurKind.TY3.getCode().equals(kindInfoVo.getKindCode())) {
  315. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteDrivingServiceSpecialClause",
  316. String.valueOf(kindInfoVo.getServiceTimes())));
  317. }
  318. //代为送检服务特约条款
  319. if (InsurKind.TY4.getCode().equals(kindInfoVo.getKindCode())) {
  320. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteInspectionServiceSpecialClause",
  321. String.valueOf(kindInfoVo.getServiceTimes())));
  322. }
  323. });
  324. //交强保费
  325. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryTrafficAccidentLiabilityInsurancePremium",
  326. String.valueOf(insAreaCompany.getJqpremium())));
  327. //车船税
  328. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleandVesselTax", String.valueOf(insAreaCompany.getTaxamount())));
  329. //非车险
  330. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonMotorInsurance", String.valueOf(insAreaCompany.getJypremium())));
  331. //总折扣率
  332. ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalDiscountRate", String.valueOf(insAreaCompany.getTotalAdjustRate())));
  333. //交强折扣
  334. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceDiscount", String.valueOf(insAreaCompany.getJqAdjustRate())));
  335. //商业折扣
  336. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialDiscount", String.valueOf(insAreaCompany.getSyAdjustRate())));
  337. //永安评分
  338. Optional.ofNullable(quoteRespVo)
  339. .map(quoteRespVo1 -> quoteRespVo.getYaScore())
  340. .ifPresent(x -> {
  341. ruleAttrMappingVoList.add(new RuleAttrMappingVo("YaScore", x));
  342. });
  343. //永安交强费用浮动
  344. Optional.ofNullable(quoteRespVo)
  345. .map(quoteRespVo1 -> quoteRespVo.getCifeeFloat())
  346. .ifPresent(x -> {
  347. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CifeeFloat", x));
  348. });
  349. //永安商业费用浮动
  350. Optional.ofNullable(quoteRespVo)
  351. .map(quoteRespVo1 -> quoteRespVo.getBifeeFloat())
  352. .ifPresent(x -> {
  353. ruleAttrMappingVoList.add(new RuleAttrMappingVo("BifeeFloat", x));
  354. });
  355. //数值型总评分
  356. Pattern pattern = Pattern.compile("[0-9]*");
  357. if (insAreaCompany.getScore() != null) {
  358. if (pattern.matcher(insAreaCompany.getScore()).matches()) {
  359. //数值型评分
  360. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NumericalOverallRating", String.valueOf(insAreaCompany.getScore())));
  361. } else {
  362. //字母型评分
  363. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedRating", String.valueOf(insAreaCompany.getScore())));
  364. }
  365. }
  366. //交强评分
  367. if (insAreaCompany.getJqScore() != null) {
  368. if (pattern.matcher(insAreaCompany.getJqScore()).matches()) {
  369. //数值型评分
  370. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
  371. } else {
  372. //字母型评分
  373. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqCharacterBasedRating",
  374. String.valueOf(insAreaCompany.getJqScore())));
  375. }
  376. }
  377. // ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
  378. //商业评分
  379. if (insAreaCompany.getSyScore() != null) {
  380. if (pattern.matcher(insAreaCompany.getSyScore()).matches()) {
  381. //数值型评分
  382. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialRating", String.valueOf(insAreaCompany.getSyScore())));
  383. } else {
  384. //字母型评分
  385. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyCharacterBasedRating",
  386. String.valueOf(insAreaCompany.getSyScore())));
  387. }
  388. }
  389. //交强赔付率
  390. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsurancePayoutRate", String.valueOf(insAreaCompany.getJqLossRation())));
  391. //商业赔付率
  392. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialPayoutRate", String.valueOf(insAreaCompany.getSyLossRation())));
  393. //总赔付率
  394. ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalPayoutRate", String.valueOf(insAreaCompany.getLossRation())));
  395. //太平绿黄红区
  396. ruleAttrMappingVoList.add(new RuleAttrMappingVo("GreenYellowAndRedAreas", insAreaCompany.getTpColorScore()));
  397. if (insAreaCompany.getAccidentalDriving() != null) {
  398. //非车名称
  399. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarName", insAreaCompany.getAccidentalDriving()
  400. .getRideRiskName()));
  401. //非车份数
  402. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarQuantity",
  403. String.valueOf(insAreaCompany.getAccidentalDriving().getQuantity())));
  404. }
  405. //真假单交
  406. ruleAttrMappingVoList.add(new RuleAttrMappingVo("IsDJQ", insAreaCompany.getIsDjq()));
  407. //紫金鼎然评分
  408. ruleAttrMappingVoList.add(new RuleAttrMappingVo("UbiPredictedInfoScore", insAreaCompany.getUbiPredictedInfoScore()));
  409. // 交强出险次数
  410. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqNumberOfClaims", insAreaCompany.getJqClaims() == null ? "0" : insAreaCompany.getJqClaims()));
  411. // 商业出险次数
  412. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyNumberOfClaims", insAreaCompany.getSyClaims() == null ? "0" : insAreaCompany.getSyClaims()));
  413. // 车牌地区
  414. ruleAttrMappingVoList.add(new RuleAttrMappingVo("LicenseArea", insOrders.getLicenseno().substring(0, 1)));
  415. // 系数
  416. ruleAttrMappingVoList.add(new RuleAttrMappingVo("Coefficient", getCoefficient(carInfo, insAreaCompany).toString()));
  417. // 商业是否有费用
  418. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CiMessage", (insAreaCompany.getCiMessage() == null || "".equals(insAreaCompany.getCiMessage())) ? "0" : "1"));
  419. return ruleAttrMappingVoList;
  420. }
  421. private static Float getCoefficient(CarInfoVo carInfo, InsAreaCompany insAreaCompany) {
  422. Integer seatCount = Integer.parseInt(carInfo.getSeatCount());
  423. Float coefficient = 1.00f;
  424. // ruleAttrMappingVoList.add(new RuleAttrMappingVo())
  425. //家庭自用车
  426. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  427. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_05.getCode())) {
  428. //2-5座
  429. if (seatCount >= 2 && seatCount <= 5) {
  430. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 950;
  431. }
  432. //6-9座
  433. if (seatCount >= 6 && seatCount <= 9) {
  434. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1100;
  435. }
  436. } else
  437. //非营业机关、企业
  438. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  439. (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_06.getCode()) ||
  440. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_07.getCode()))) {
  441. //2-5座
  442. if (seatCount >= 2 && seatCount <= 5) {
  443. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1000;
  444. }
  445. //6-9座
  446. if (seatCount >= 6 && seatCount <= 9) {
  447. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1130;
  448. }
  449. } else
  450. //货车
  451. if (carInfo.getCimodelclass().equals(VehicleType.VT_A1.getCode())) {
  452. //营业货运 2吨
  453. if (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_04.getCode()) &&
  454. Integer.parseInt(carInfo.getLimitLoad()) < 2000) {
  455. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1850;
  456. }
  457. //非营业货运 2吨
  458. if (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_08.getCode()) &&
  459. Integer.parseInt(carInfo.getLimitLoad()) < 2000) {
  460. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1200;
  461. }
  462. //大吨位
  463. if (Integer.parseInt(carInfo.getLimitLoad()) > 2000) {
  464. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 4480;
  465. }
  466. } else
  467. //出租车 网约车
  468. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  469. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_01.getCode())) {
  470. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1800;
  471. }
  472. return coefficient;
  473. }
  474. }