RuleAttrMappingVo.java 30 KB

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