RuleAttrMappingVo.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. if (Objects.nonNull(quoteRespVo)) {
  90. if (quoteRespVo.getPricingCoefficient() != null) {
  91. if("".equals(quoteRespVo.getPricingCoefficient())){
  92. quoteRespVo.setPricingCoefficient("0");
  93. }
  94. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PricingCoefficient", quoteRespVo.getPricingCoefficient()));
  95. }
  96. }
  97. // 判断是否是进口车
  98. ruleAttrMappingVoList.add(new RuleAttrMappingVo("IsImportedCar", isImportedCar));
  99. // 中煤不浮动原因
  100. if (Objects.nonNull(quoteRespVo)) {
  101. String rateFloatFlag = ZmTransferType.getByCode(quoteRespVo.getRateFloatFlag());
  102. ruleAttrMappingVoList.add(new RuleAttrMappingVo("RateFloatFlag", rateFloatFlag == null ? "null" : rateFloatFlag));
  103. }
  104. boolean isNoLicenseFlag = false;
  105. if (carJudgeRule != null) {
  106. if (carJudgeRule.getUnitTypeCode().equals("天")) {
  107. long days = ChronoUnit.DAYS.between(registrationDate, currentDate);
  108. if (days < Integer.parseInt(carJudgeRule.getUnitTypeValue())) {
  109. isNoLicenseFlag = true;
  110. }
  111. }
  112. if (carJudgeRule.getUnitTypeCode().equals("月")) {
  113. long months = ChronoUnit.MONTHS.between(registrationDate, currentDate);
  114. if (months < Integer.parseInt(carJudgeRule.getUnitTypeValue())) {
  115. isNoLicenseFlag = true;
  116. }
  117. }
  118. }
  119. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NewAndOldCars", isNoLicenseFlag ? "1" : "0"));
  120. //车龄
  121. long between = ChronoUnit.YEARS.between(registrationDate, currentDate) + 1;
  122. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleAge", String.valueOf(between)));
  123. //发证日期
  124. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DateofIssuance", carInfo.getIssueDate()));
  125. // 初登日期是否与发证日期一致
  126. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SameDate", carInfo.getRegisterDate().equals(carInfo.getIssueDate()) ? "1" : "0"));
  127. //车长
  128. // ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleLength", carInfo.getCarLength()));
  129. //转续保 交强
  130. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqRenewalOfInsurance", insAreaCompany.getJqRenewal()));
  131. //转续保 商业
  132. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyRenewalOfInsurance", insAreaCompany.getSyRenewal()));
  133. CustomerInfoVo ownerInfo = insOrders.getOwnerinfo().toJavaObject(CustomerInfoVo.class);
  134. if (StringUtils.isBlank(ownerInfo.getProperty()) || !"0".equals(ownerInfo.getProperty())) {
  135. //车主 证件号码(前6位)
  136. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersIDNumber", ownerInfo.getIdentifyNumber()));
  137. //车主 年龄
  138. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersAge", ownerInfo.getAge()));
  139. //车主 性别
  140. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersSex", ownerInfo.getGender()
  141. .equals("男") ? "1" : "2"));
  142. //车主地址
  143. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersAddress", ownerInfo.getAddr()));
  144. // 车主生日
  145. String carOwnersBirthday = ownerInfo.getIdentifyNumber()
  146. .substring(6, 10) + "-" + ownerInfo.getIdentifyNumber()
  147. .substring(10, 12) + "-" + ownerInfo.getIdentifyNumber().substring(12, 14);
  148. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnersBirthday", carOwnersBirthday));
  149. }
  150. //车主 姓名
  151. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarOwnerName", ownerInfo.getName()));
  152. CustomerInfoVo policyHolderInfo = insOrders.getApplyinfo().toJavaObject(CustomerInfoVo.class);
  153. if (StringUtils.isBlank(policyHolderInfo.getProperty()) || !"0".equals(policyHolderInfo.getProperty())) {
  154. //投保人 证件号码(前6位)
  155. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantIDNumber", policyHolderInfo.getIdentifyNumber()));
  156. //投保人 年龄
  157. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantAge", policyHolderInfo.getAge()));
  158. //投保人 性别
  159. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantSex", policyHolderInfo.getGender()
  160. .equals("男") ? "1" : "2"));
  161. //投保人地址
  162. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantAddress", policyHolderInfo.getAddr()));
  163. // 投保人生日
  164. String applicantBirthday = policyHolderInfo.getIdentifyNumber()
  165. .substring(6, 10) + "-" + policyHolderInfo.getIdentifyNumber()
  166. .substring(10, 12) + "-" + policyHolderInfo.getIdentifyNumber().substring(12, 14);
  167. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ApplicantBirthday", applicantBirthday));
  168. }
  169. CustomerInfoVo insuredPersonInfo = insOrders.getInsureinfo().toJavaObject(CustomerInfoVo.class);
  170. if (StringUtils.isBlank(insuredPersonInfo.getProperty()) || !"0".equals(insuredPersonInfo.getProperty())) {
  171. //被保人 证件号码(前6位)
  172. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredIDNumber", insuredPersonInfo.getIdentifyNumber()));
  173. //被保人 年龄
  174. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredAge", insuredPersonInfo.getAge()));
  175. //被保人 性别
  176. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredSex", insuredPersonInfo.getGender()
  177. .equals("男") ? "1" : "2"));
  178. //被保人地址
  179. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredAddress", insuredPersonInfo.getAddr()));
  180. //被保人生日
  181. String insuredBirthday = insuredPersonInfo.getIdentifyNumber()
  182. .substring(6, 10) + "-" + insuredPersonInfo.getIdentifyNumber()
  183. .substring(10, 12) + "-" + insuredPersonInfo.getIdentifyNumber().substring(12, 14);
  184. ruleAttrMappingVoList.add(new RuleAttrMappingVo("InsuredBirthday", insuredBirthday));
  185. }
  186. String OPIConsistent = "0";
  187. if (StringUtils.isNotBlank(ownerInfo.getProperty())) {
  188. boolean boo = ownerInfo.getProperty()
  189. .equals(insuredPersonInfo.getProperty()) && insuredPersonInfo.getProperty()
  190. .equals(policyHolderInfo.getProperty());
  191. if (boo) {
  192. if ("0".equals(ownerInfo.getProperty())) {
  193. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  194. .equals(policyHolderInfo.getName())) &&
  195. (ownerInfo.getOrganizationCode()
  196. .equals(insuredPersonInfo.getOrganizationCode()) && insuredPersonInfo.getOrganizationCode()
  197. .equals(policyHolderInfo.getOrganizationCode()))) {
  198. OPIConsistent = "1";
  199. }
  200. } else {
  201. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  202. .equals(policyHolderInfo.getName())) &&
  203. (ownerInfo.getIdentifyNumber()
  204. .equals(insuredPersonInfo.getIdentifyNumber()) && insuredPersonInfo.getIdentifyNumber()
  205. .equals(policyHolderInfo.getIdentifyNumber()))) {
  206. OPIConsistent = "1";
  207. }
  208. }
  209. }
  210. } else {
  211. if ((ownerInfo.getName().equals(insuredPersonInfo.getName()) && insuredPersonInfo.getName()
  212. .equals(policyHolderInfo.getName())) &&
  213. (ownerInfo.getIdentifyNumber()
  214. .equals(insuredPersonInfo.getIdentifyNumber()) && insuredPersonInfo.getIdentifyNumber()
  215. .equals(policyHolderInfo.getIdentifyNumber()))) {
  216. OPIConsistent = "1";
  217. }
  218. }
  219. ruleAttrMappingVoList.add(new RuleAttrMappingVo("OPIConsistent", OPIConsistent));
  220. String PIConsistent = "0";
  221. if (StringUtils.isNotBlank(insuredPersonInfo.getProperty())) {
  222. boolean boo = insuredPersonInfo.getProperty().equals(policyHolderInfo.getProperty());
  223. if (boo) {
  224. if ("0".equals(insuredPersonInfo.getProperty())) {
  225. //投被保人是否一致
  226. if (insuredPersonInfo.getName()
  227. .equals(policyHolderInfo.getName()) && insuredPersonInfo.getOrganizationCode()
  228. .equals(policyHolderInfo.getOrganizationCode())) {
  229. PIConsistent = "1";
  230. }
  231. } else {
  232. //投被保人是否一致
  233. if (insuredPersonInfo.getName()
  234. .equals(policyHolderInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  235. .equals(policyHolderInfo.getIdentifyNumber())) {
  236. PIConsistent = "1";
  237. }
  238. }
  239. }
  240. } else {
  241. //投被保人是否一致
  242. if (insuredPersonInfo.getName().equals(policyHolderInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  243. .equals(policyHolderInfo.getIdentifyNumber())) {
  244. PIConsistent = "1";
  245. }
  246. }
  247. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PIConsistent", PIConsistent));
  248. // 车被保人是否一致
  249. String CIConsistent = "0";
  250. if (StringUtils.isNotBlank(ownerInfo.getProperty())) {
  251. boolean boo = ownerInfo.getProperty().equals(insuredPersonInfo.getProperty());
  252. if (boo) {
  253. if ("0".equals(insuredPersonInfo.getProperty())) {
  254. //车被保人是否一致
  255. if (insuredPersonInfo.getName()
  256. .equals(ownerInfo.getName()) && insuredPersonInfo.getOrganizationCode()
  257. .equals(ownerInfo.getOrganizationCode())) {
  258. CIConsistent = "1";
  259. }
  260. } else {
  261. //车被保人是否一致
  262. if (insuredPersonInfo.getName()
  263. .equals(ownerInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  264. .equals(ownerInfo.getIdentifyNumber())) {
  265. CIConsistent = "1";
  266. }
  267. }
  268. }
  269. } else {
  270. //投被保人是否一致
  271. if (insuredPersonInfo.getName().equals(ownerInfo.getName()) && insuredPersonInfo.getIdentifyNumber()
  272. .equals(ownerInfo.getIdentifyNumber())) {
  273. CIConsistent = "1";
  274. }
  275. }
  276. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CIConsistent", CIConsistent));
  277. //2024-06-20 起保日期 月份判断
  278. if (insAreaCompany.getJqStartDate() != null && !insAreaCompany.getJqStartDate().equals("")) {
  279. LocalDateTime jqStartDate = LocalDateTime.parse(insAreaCompany.getJqStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
  280. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqStartMonth", String.valueOf(jqStartDate.getMonthValue())));
  281. }
  282. if (insAreaCompany.getSyStartDate() != null && !insAreaCompany.getSyStartDate().equals("")) {
  283. LocalDateTime syStartDate = LocalDateTime.parse(insAreaCompany.getSyStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
  284. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyStartMonth", String.valueOf(syStartDate.getMonthValue())));
  285. }
  286. List<KindInfoVo> kindInfoVos = insAreaCompany.getKindinfo().toJavaList(KindInfoVo.class);
  287. //险别信息
  288. kindInfoVos.forEach(kindInfoVo -> {
  289. //机动车损失险
  290. if (InsurKind.A.getCode().equals(kindInfoVo.getKindCode())) {
  291. ruleAttrMappingVoList.add(new RuleAttrMappingVo("MotorVehicleDamageInsurance", String.valueOf(kindInfoVo.getAmount())));
  292. }
  293. //第三者责任险
  294. if (InsurKind.B.getCode().equals(kindInfoVo.getKindCode())) {
  295. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyLiabilityInsurance",
  296. String.valueOf(Double.valueOf(kindInfoVo.getAmount()).intValue())));
  297. }
  298. //司机责任险
  299. if (InsurKind.D3.getCode().equals(kindInfoVo.getKindCode())) {
  300. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverLiabilityInsurance", String.valueOf(kindInfoVo.getAmount())));
  301. }
  302. //乘客责任险
  303. if (InsurKind.D4.getCode().equals(kindInfoVo.getKindCode())) {
  304. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerLiabilityInsurance", String.valueOf(kindInfoVo.getUnitAmount())));
  305. }
  306. //车身划痕险
  307. if (InsurKind.L.getCode().equals(kindInfoVo.getKindCode())) {
  308. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CarScratchInsurance", String.valueOf(kindInfoVo.getAmount())));
  309. }
  310. //绝对免赔率特约险(车损)
  311. if (InsurKind.MJ1.getCode().equals(kindInfoVo.getKindCode())) {
  312. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleDamageAbsoluteDeductibleSpecialInsurance",
  313. String.valueOf(kindInfoVo.getAmount())));
  314. }
  315. //绝对免赔率特约险(三者)
  316. if (InsurKind.MJ2.getCode().equals(kindInfoVo.getKindCode())) {
  317. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdAbsoluteDeductibleSpecialInsurance",
  318. String.valueOf(kindInfoVo.getAmount())));
  319. }
  320. //绝对免赔率特约险(司机)
  321. if (InsurKind.MJ3.getCode().equals(kindInfoVo.getKindCode())) {
  322. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAbsoluteDeductibleSpecialInsurance",
  323. String.valueOf(kindInfoVo.getAmount())));
  324. }
  325. //绝对免赔率特约险(乘客)
  326. if (InsurKind.MJ4.getCode().equals(kindInfoVo.getKindCode())) {
  327. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAbsoluteDeductibleSpecialInsurance",
  328. String.valueOf(kindInfoVo.getAmount())));
  329. }
  330. //附加医保-三者
  331. if (InsurKind.SY_FJ_YBW1.getCode().equals(kindInfoVo.getKindCode())) {
  332. ruleAttrMappingVoList.add(new RuleAttrMappingVo("ThirdPartyAdditionalMedicalInsurance",
  333. String.valueOf(kindInfoVo.getAmount())));
  334. }
  335. //附加医保-座位险(乘客)
  336. if (InsurKind.SY_FJ_YBW2.getCode().equals(kindInfoVo.getKindCode())) {
  337. ruleAttrMappingVoList.add(new RuleAttrMappingVo("PassengerAdditionalMedicalInsurance",
  338. String.valueOf(kindInfoVo.getAmount())));
  339. }
  340. //附加医保-座位险(司机)
  341. if (InsurKind.SY_FJ_YBW3.getCode().equals(kindInfoVo.getKindCode())) {
  342. ruleAttrMappingVoList.add(new RuleAttrMappingVo("DriverAdditionalMedicalInsurance",
  343. String.valueOf(kindInfoVo.getAmount())));
  344. }
  345. //法定节假日限额翻倍险
  346. if (InsurKind.BD.getCode().equals(kindInfoVo.getKindCode())) {
  347. ruleAttrMappingVoList.add(new RuleAttrMappingVo("LegalHolidayLimitDoublingInsurance",
  348. String.valueOf(kindInfoVo.getAmount())));
  349. }
  350. //道路救援服务特约条款
  351. if (InsurKind.TY1.getCode().equals(kindInfoVo.getKindCode())) {
  352. ruleAttrMappingVoList.add(new RuleAttrMappingVo("RoadsideAssistanceServiceSpecialClause",
  353. String.valueOf(kindInfoVo.getServiceTimes())));
  354. }
  355. //车辆安全检测特约条款
  356. if (InsurKind.TY2.getCode().equals(kindInfoVo.getKindCode())) {
  357. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleSafetyInspectionSpecialClause",
  358. String.valueOf(kindInfoVo.getServiceTimes())));
  359. }
  360. //代为驾驶服务特约条款
  361. if (InsurKind.TY3.getCode().equals(kindInfoVo.getKindCode())) {
  362. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteDrivingServiceSpecialClause",
  363. String.valueOf(kindInfoVo.getServiceTimes())));
  364. }
  365. //代为送检服务特约条款
  366. if (InsurKind.TY4.getCode().equals(kindInfoVo.getKindCode())) {
  367. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SubstituteInspectionServiceSpecialClause",
  368. String.valueOf(kindInfoVo.getServiceTimes())));
  369. }
  370. });
  371. //交强保费
  372. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryTrafficAccidentLiabilityInsurancePremium",
  373. String.valueOf(insAreaCompany.getJqpremium())));
  374. //车船税
  375. ruleAttrMappingVoList.add(new RuleAttrMappingVo("VehicleandVesselTax", String.valueOf(insAreaCompany.getTaxamount())));
  376. //非车险
  377. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonMotorInsurance", String.valueOf(insAreaCompany.getJypremium())));
  378. //总折扣率
  379. ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalDiscountRate", String.valueOf(insAreaCompany.getTotalAdjustRate())));
  380. //交强折扣
  381. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceDiscount", String.valueOf(insAreaCompany.getJqAdjustRate())));
  382. //商业折扣
  383. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialDiscount", String.valueOf(insAreaCompany.getSyAdjustRate())));
  384. //永安评分
  385. Optional.ofNullable(quoteRespVo)
  386. .map(quoteRespVo1 -> quoteRespVo.getYaScore())
  387. .ifPresent(x -> {
  388. ruleAttrMappingVoList.add(new RuleAttrMappingVo("YaScore", x));
  389. });
  390. //永安交强费用浮动
  391. Optional.ofNullable(quoteRespVo)
  392. .map(quoteRespVo1 -> quoteRespVo.getCifeeFloat())
  393. .ifPresent(x -> {
  394. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CifeeFloat", x));
  395. });
  396. // 华农评分分组
  397. Optional.ofNullable(quoteRespVo)
  398. .map(quoteRespVo1 -> quoteRespVo.getMarkGroup())
  399. .ifPresent(x -> {
  400. ruleAttrMappingVoList.add(new RuleAttrMappingVo("MarkGroup", x));
  401. });
  402. //永安商业费用浮动
  403. Optional.ofNullable(insAreaCompany)
  404. .map(InsAreaCompany::getBifeeFloat)
  405. .ifPresent(x -> {
  406. ruleAttrMappingVoList.add(new RuleAttrMappingVo("BifeeFloat", x));
  407. });
  408. // 向阳花评分 阳光
  409. Optional.ofNullable(insAreaCompany)
  410. .map(InsAreaCompany::getXyhGrade)
  411. .map(String::valueOf)
  412. .ifPresent(x -> ruleAttrMappingVoList.add(new RuleAttrMappingVo("XyhGrade", x)));
  413. // 红黄蓝车系 阳光
  414. Optional.ofNullable(insAreaCompany)
  415. .map(InsAreaCompany::getSeriesTypeActualName)
  416. .map(String::valueOf)
  417. .ifPresent(x -> ruleAttrMappingVoList.add(new RuleAttrMappingVo("SeriesTypeActualName", x)));
  418. //数值型总评分
  419. Pattern pattern = Pattern.compile("\\d+(\\.\\d+)?");
  420. if (insAreaCompany.getScore() != null) {
  421. if (pattern.matcher(insAreaCompany.getScore()).matches()) {
  422. //数值型评分
  423. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NumericalOverallRating", String.valueOf(insAreaCompany.getScore())));
  424. } else {
  425. //字母型评分
  426. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CharacterBasedRating", String.valueOf(insAreaCompany.getScore())));
  427. }
  428. }
  429. //交强评分
  430. if (insAreaCompany.getJqScore() != null) {
  431. if (pattern.matcher(insAreaCompany.getJqScore()).matches()) {
  432. //数值型评分
  433. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
  434. } else {
  435. //字母型评分
  436. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqCharacterBasedRating",
  437. String.valueOf(insAreaCompany.getJqScore())));
  438. }
  439. }
  440. // ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsuranceRating", String.valueOf(insAreaCompany.getJqScore())));
  441. //商业评分
  442. if (insAreaCompany.getSyScore() != null) {
  443. if (pattern.matcher(insAreaCompany.getSyScore()).matches()) {
  444. //数值型评分
  445. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialRating", String.valueOf(insAreaCompany.getSyScore())));
  446. } else {
  447. //字母型评分
  448. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyCharacterBasedRating",
  449. String.valueOf(insAreaCompany.getSyScore())));
  450. }
  451. }
  452. //交强赔付率
  453. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CompulsoryInsurancePayoutRate", String.valueOf(insAreaCompany.getJqLossRation())));
  454. //商业赔付率
  455. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CommercialPayoutRate", String.valueOf(insAreaCompany.getSyLossRation())));
  456. //总赔付率
  457. ruleAttrMappingVoList.add(new RuleAttrMappingVo("TotalPayoutRate", String.valueOf(insAreaCompany.getLossRation())));
  458. //太平绿黄红区
  459. ruleAttrMappingVoList.add(new RuleAttrMappingVo("GreenYellowAndRedAreas", insAreaCompany.getTpColorScore()));
  460. if (insAreaCompany.getApiType() == 2) {
  461. if (insAreaCompany.getAccidentInfo() != null && !insAreaCompany.getAccidentInfo().isEmpty()) {
  462. //非车名称
  463. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarName", ((JSONObject) insAreaCompany.getAccidentInfo().get(0)).getString("projectName")));
  464. //非车份数
  465. Integer quantity = ((JSONObject) insAreaCompany.getAccidentInfo().get(0)).getInteger("quantity");
  466. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarQuantity",
  467. String.valueOf(quantity)));
  468. }
  469. }else if(insAreaCompany.getApiType() == 1){
  470. if (Objects.nonNull(insAreaCompany.getAccidentalDriving())){
  471. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarName", insAreaCompany.getAccidentalDriving().getRideRiskName()));
  472. ruleAttrMappingVoList.add(new RuleAttrMappingVo("NonCarQuantity", String.valueOf(insAreaCompany.getAccidentalDriving().getQuantity())));
  473. }
  474. }
  475. //真假单交
  476. ruleAttrMappingVoList.add(new RuleAttrMappingVo("IsDJQ", insAreaCompany.getIsDjq()));
  477. //紫金鼎然评分
  478. ruleAttrMappingVoList.add(new RuleAttrMappingVo("UbiPredictedInfoScore", insAreaCompany.getUbiPredictedInfoScore()));
  479. // 交强出险次数
  480. ruleAttrMappingVoList.add(new RuleAttrMappingVo("JqNumberOfClaims", insAreaCompany.getJqClaims() == null ? "0" : insAreaCompany.getJqClaims()));
  481. // 商业出险次数
  482. ruleAttrMappingVoList.add(new RuleAttrMappingVo("SyNumberOfClaims", insAreaCompany.getSyClaims() == null ? "0" : insAreaCompany.getSyClaims()));
  483. // 车牌地区
  484. ruleAttrMappingVoList.add(new RuleAttrMappingVo("LicenseArea", insOrders.getLicenseno().substring(0, 1)));
  485. // 系数
  486. ruleAttrMappingVoList.add(new RuleAttrMappingVo("Coefficient", getCoefficient(carInfo, insAreaCompany).toString()));
  487. // 商业是否有费用
  488. ruleAttrMappingVoList.add(new RuleAttrMappingVo("CiMessage", (insAreaCompany.getCiMessage() == null || "".equals(insAreaCompany.getCiMessage())) ? "0" : "1"));
  489. return ruleAttrMappingVoList;
  490. }
  491. private static Float getCoefficient(CarInfoVo carInfo, InsAreaCompany insAreaCompany) {
  492. Integer seatCount = Integer.parseInt(carInfo.getSeatCount());
  493. Float coefficient = 1.00f;
  494. // ruleAttrMappingVoList.add(new RuleAttrMappingVo())
  495. //家庭自用车
  496. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  497. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_05.getCode())) {
  498. //2-5座
  499. if (seatCount >= 2 && seatCount <= 5) {
  500. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 950;
  501. }
  502. //6-9座
  503. if (seatCount >= 6 && seatCount <= 9) {
  504. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1100;
  505. }
  506. } else
  507. //非营业机关、企业
  508. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  509. (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_06.getCode()) ||
  510. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_07.getCode()))) {
  511. //2-5座
  512. if (seatCount >= 2 && seatCount <= 5) {
  513. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1000;
  514. }
  515. //6-9座
  516. if (seatCount >= 6 && seatCount <= 9) {
  517. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1130;
  518. }
  519. } else
  520. //货车
  521. if (carInfo.getCimodelclass().equals(VehicleType.VT_A1.getCode())) {
  522. //营业货运 2吨
  523. if (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_04.getCode()) &&
  524. Integer.parseInt(carInfo.getLimitLoad()) < 2000) {
  525. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1850;
  526. }
  527. //非营业货运 2吨
  528. if (carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_08.getCode()) &&
  529. Integer.parseInt(carInfo.getLimitLoad()) < 2000) {
  530. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1200;
  531. }
  532. //大吨位
  533. if (Integer.parseInt(carInfo.getLimitLoad()) > 2000) {
  534. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 4480;
  535. }
  536. } else
  537. //出租车 网约车
  538. if (carInfo.getCimodelclass().equals(VehicleType.VT_A0.getCode()) &&
  539. carInfo.getVehicleUse().equals(TypeVehicleMapping.TM_01.getCode())) {
  540. coefficient = Float.parseFloat(insAreaCompany.getJqpremium().toString()) / 1800;
  541. }
  542. return coefficient;
  543. }
  544. }