package com.ydtech.modules.admin.model.po; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ydtech.modules.ins.model.vo.CustomerInfoVo; import lombok.Data; import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * 车辆关联客户信息 * @TableName cust_vehicle_policy_info */ @TableName(value ="cust_vehicle_policy_info") @Data public class CustVehiclePolicyInfo implements Serializable { /** * 主键 */ @TableId private String id; /** * 客户ID */ private String custId; /** * 子订单号 */ private String subOrderNo; /** * 车辆ID */ private String vehicleId; /** * 投保人名称 */ private String applyName; /** * 投保人身份证号 */ private String applyIdentifyNumber; /** * 投保人身份证类型 */ private String applyIdentifyType; /** * 投保人地址 */ private String applyAddr; /** * 投保人年龄 */ private String applyAge; /** * 投保人性别 */ private String applyGender; /** * 投保人邮箱 */ private String applyEmail; /** * 投保人手机号 */ private String applyMobile; /** * 投保人有效时间开始 */ private Date applyIdentifyValidDate; /** * 投保人有效时间结束 */ private Date applyIdentifyValidEndDate; /** * 是否同车主 */ private Boolean applyOwnerFlag; /** * 是否同车主 */ private Boolean applyInsuranceHolderFlag; /** * 被保人名称 */ private String insureName; /** * 被保人身份证号 */ private String insureIdentifyNumber; /** * 被保人身份证类型 */ private String insureIdentifyType; /** * 被保人地址 */ private String insureAddr; /** * 被保人年齡 */ private String insureAge; /** * 被保人性別 */ private String insureGender; /** * 被保人邮箱 */ private String insureEmail; /** * 被保人手机号 */ private String insureMobile; /** * 被保人有效时间开始 */ private Date insureIdentifyValidDate; /** * 被保人有效时间结束 */ private Date insureIdentifyValidEndDate; /** * 是否同车主 */ private Boolean insureOwnerFlag; /** * 是否同车主 */ private Boolean insureInsuranceHolderFlag; /** * 车主名称 */ private String ownerName; /** * 车主身份证号 */ private String ownerIdentifyNumber; /** * 车主身份证类型 */ private String ownerIdentifyType; /** * 车主地址 */ private String ownerAddr; /** * 车主年齡 */ private String ownerAge; /** * 车主性別 */ private String ownerGender; /** * 车主邮箱 */ private String ownerEmail; /** * 车主手机号 */ private String ownerMobile; /** * 车主有效时间开始 */ private Date ownerIdentifyValidDate; /** * 车主有效时间结束 */ private Date ownerIdentifyValidEndDate; /** * 是否同车主 */ private Boolean ownerOwner; /** * 是否同车主 */ private Boolean ownerOwnerFlag; /** * 是否同车主 */ private Boolean OwnerInsuranceHolderFlag; /** * 创建人 */ private String createBy; /** * 创建时间 */ private Date createTime; /** * 修改人 */ private String updateBy; /** * 修改时间 */ private Date updateTime; /** * 是否删除 0表示未删除,1表示删除 */ private Integer delFlag; //企业车新增 /** * 固定电话 */ private String applyTel; /** * 省 */ private String applyProvince; /** * 市 */ private String applyCity; /** * 县 */ private String applyCounty; /*** * 车主类型(0:法人 1:个人(中国籍) 2: 个人(非中国籍)) */ private String applyProperty; /*** * 注册资本金 */ private String applyRegisteredCapital; /*** * 经营范围 */ private String applyScope; /*** * 联系人 */ private String applyLegalPerson; /*** * 组织机构代码 */ private String applyOrganizationCode; /** * 固定电话 */ private String insureTel; /** * 省 */ private String insureProvince; /** * 市 */ private String insureCity; /** * 县 */ private String insureCounty; /*** * 车主类型(0:法人 1:个人(中国籍) 2: 个人(非中国籍)) */ private String insureProperty; /*** * 注册资本金 */ private String insureRegisteredCapital; /*** * 经营范围 */ private String insureScope; /*** * 联系人 */ private String insureLegalPerson; /*** * 组织机构代码 */ private String insureOrganizationCode; /** * 固定电话 */ private String ownerTel; /** * 省 */ private String ownerProvince; /** * 市 */ private String ownerCity; /** * 县 */ private String ownerCounty; /*** * 车主类型(0:法人 1:个人(中国籍) 2: 个人(非中国籍)) */ private String ownerProperty; /*** * 注册资本金 */ private String ownerRegisteredCapital; /*** * 经营范围 */ private String ownerScope; /*** * 联系人 */ private String ownerLegalPerson; /*** * 组织机构代码 */ private String ownerOrganizationCode; @TableField(exist = false) private static final long serialVersionUID = 1L; public CustomerInfoVo trafferCustVehiclePolicyInfo(CustVehiclePolicyInfo custVehiclePolicyInfo, int type) { CustomerInfoVo customerInfoVo = new CustomerInfoVo(); if(type==1){ //姓名 customerInfoVo.setName(custVehiclePolicyInfo.getOwnerName()); //身份证号 customerInfoVo.setIdentifyNumber(custVehiclePolicyInfo.getOwnerIdentifyNumber()); //身份证类型 customerInfoVo.setIdentifyType(custVehiclePolicyInfo.getOwnerIdentifyType()); //地址 customerInfoVo.setAddr(custVehiclePolicyInfo.getOwnerAddr()); //年龄 customerInfoVo.setAge(getAgeByIdCard(custVehiclePolicyInfo.getOwnerIdentifyNumber())); //性别 customerInfoVo.setGender(checkGender(custVehiclePolicyInfo.getOwnerIdentifyNumber())); //邮箱 customerInfoVo.setEmail(custVehiclePolicyInfo.getOwnerEmail()); //手机号 customerInfoVo.setMobile(custVehiclePolicyInfo.getOwnerMobile()); //有效时间 Date ownerIdentifyValidDateBegin = custVehiclePolicyInfo.getOwnerIdentifyValidDate(); String ownerIdentifyValidDateBeginStr=""; if(ownerIdentifyValidDateBegin!=null){ ownerIdentifyValidDateBeginStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateBegin); } customerInfoVo.setIdentifyValidDate(ownerIdentifyValidDateBeginStr); Date ownerIdentifyValidDateEnd = custVehiclePolicyInfo.getOwnerIdentifyValidEndDate(); String ownerIdentifyValidDateEndStr=""; if(ownerIdentifyValidDateEnd!=null){ ownerIdentifyValidDateEndStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateEnd); } //有效时间 customerInfoVo.setIdentifyValidEndDate(ownerIdentifyValidDateEndStr); //同车主 customerInfoVo.setOwner(custVehiclePolicyInfo.getOwnerOwnerFlag() != null && custVehiclePolicyInfo.getOwnerOwnerFlag()); //同投保人 customerInfoVo.setInsuranceHolder(custVehiclePolicyInfo.getOwnerInsuranceHolderFlag() != null && custVehiclePolicyInfo.getOwnerInsuranceHolderFlag()); //车主相关信息 add hxl 2024-12-20 customerInfoVo.setTel(custVehiclePolicyInfo.getOwnerTel()); customerInfoVo.setOrganizationCode(custVehiclePolicyInfo.getOwnerOrganizationCode()); customerInfoVo.setProvince(custVehiclePolicyInfo.getOwnerProvince()); customerInfoVo.setCity(custVehiclePolicyInfo.getOwnerCity()); customerInfoVo.setCounty(custVehiclePolicyInfo.getOwnerCounty()); customerInfoVo.setProperty(custVehiclePolicyInfo.getOwnerProperty()); customerInfoVo.setRegisteredCapital(custVehiclePolicyInfo.getOwnerRegisteredCapital()); customerInfoVo.setScope(custVehiclePolicyInfo.getOwnerScope()); customerInfoVo.setLegalPerson(custVehiclePolicyInfo.getOwnerLegalPerson()); }else if(type ==2){ //姓名 customerInfoVo.setName(custVehiclePolicyInfo.getInsureName()); //身份证号 customerInfoVo.setIdentifyNumber(custVehiclePolicyInfo.getInsureIdentifyNumber()); //身份证类型 customerInfoVo.setIdentifyType(custVehiclePolicyInfo.getInsureIdentifyType()); //地址 customerInfoVo.setAddr(custVehiclePolicyInfo.getInsureAddr()); //年龄 customerInfoVo.setAge(getAgeByIdCard(custVehiclePolicyInfo.getInsureIdentifyNumber())); //性别 customerInfoVo.setGender(checkGender(custVehiclePolicyInfo.getInsureIdentifyNumber())); //邮箱 customerInfoVo.setEmail(custVehiclePolicyInfo.getInsureEmail()); //手机号 customerInfoVo.setMobile(custVehiclePolicyInfo.getInsureMobile()); //有效时间 Date ownerIdentifyValidDateBegin = custVehiclePolicyInfo.getInsureIdentifyValidDate(); String ownerIdentifyValidDateBeginStr=""; if(ownerIdentifyValidDateBegin!=null){ ownerIdentifyValidDateBeginStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateBegin); } customerInfoVo.setIdentifyValidDate(ownerIdentifyValidDateBeginStr); Date ownerIdentifyValidDateEnd = custVehiclePolicyInfo.getInsureIdentifyValidEndDate(); String ownerIdentifyValidDateEndStr=""; if(ownerIdentifyValidDateEnd!=null){ ownerIdentifyValidDateEndStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateEnd); } //有效时间 customerInfoVo.setIdentifyValidEndDate(ownerIdentifyValidDateEndStr); //同车主 customerInfoVo.setOwner(custVehiclePolicyInfo.getInsureOwnerFlag() != null && custVehiclePolicyInfo.getInsureOwnerFlag()); //同投保人 customerInfoVo.setInsuranceHolder(custVehiclePolicyInfo.getInsureInsuranceHolderFlag() != null && custVehiclePolicyInfo.getInsureInsuranceHolderFlag()); //车主相关信息 add hxl 2024-12-20 customerInfoVo.setTel(custVehiclePolicyInfo.getInsureTel()); customerInfoVo.setOrganizationCode(custVehiclePolicyInfo.getInsureOrganizationCode()); customerInfoVo.setProvince(custVehiclePolicyInfo.getInsureProvince()); customerInfoVo.setCity(custVehiclePolicyInfo.getInsureCity()); customerInfoVo.setCounty(custVehiclePolicyInfo.getInsureCounty()); customerInfoVo.setProperty(custVehiclePolicyInfo.getInsureProperty()); customerInfoVo.setRegisteredCapital(custVehiclePolicyInfo.getInsureRegisteredCapital()); customerInfoVo.setScope(custVehiclePolicyInfo.getInsureScope()); customerInfoVo.setLegalPerson(custVehiclePolicyInfo.getInsureLegalPerson()); }else if(type ==3){ //姓名 customerInfoVo.setName(custVehiclePolicyInfo.getApplyName()); //身份证号 customerInfoVo.setIdentifyNumber(custVehiclePolicyInfo.getApplyIdentifyNumber()); //身份证类型 customerInfoVo.setIdentifyType(custVehiclePolicyInfo.getApplyIdentifyType()); //地址 customerInfoVo.setAddr(custVehiclePolicyInfo.getApplyAddr()); //年龄 customerInfoVo.setAge(getAgeByIdCard(custVehiclePolicyInfo.getApplyIdentifyNumber())); //性别 customerInfoVo.setGender(checkGender(custVehiclePolicyInfo.getApplyIdentifyNumber())); //邮箱 customerInfoVo.setEmail(custVehiclePolicyInfo.getApplyEmail()); //手机号 customerInfoVo.setMobile(custVehiclePolicyInfo.getApplyMobile()); //有效时间 Date ownerIdentifyValidDateBegin = custVehiclePolicyInfo.getApplyIdentifyValidDate(); String ownerIdentifyValidDateBeginStr=""; if(ownerIdentifyValidDateBegin!=null){ ownerIdentifyValidDateBeginStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateBegin); } customerInfoVo.setIdentifyValidDate(ownerIdentifyValidDateBeginStr); Date ownerIdentifyValidDateEnd = custVehiclePolicyInfo.getApplyIdentifyValidEndDate(); String ownerIdentifyValidDateEndStr=""; if(ownerIdentifyValidDateEnd!=null){ ownerIdentifyValidDateEndStr = new SimpleDateFormat("yyyy-MM-dd").format(ownerIdentifyValidDateEnd); } //有效时间 customerInfoVo.setIdentifyValidEndDate(ownerIdentifyValidDateEndStr); //同车主 customerInfoVo.setOwner(custVehiclePolicyInfo.getApplyOwnerFlag() != null && custVehiclePolicyInfo.getApplyOwnerFlag()); //同投保人 customerInfoVo.setInsuranceHolder(custVehiclePolicyInfo.getApplyInsuranceHolderFlag() != null && custVehiclePolicyInfo.getApplyInsuranceHolderFlag()); //车主相关信息 add hxl 2024-12-20 customerInfoVo.setTel(custVehiclePolicyInfo.getOwnerTel()); customerInfoVo.setOrganizationCode(custVehiclePolicyInfo.getOwnerOrganizationCode()); customerInfoVo.setProvince(custVehiclePolicyInfo.getOwnerProvince()); customerInfoVo.setCity(custVehiclePolicyInfo.getOwnerCity()); customerInfoVo.setCounty(custVehiclePolicyInfo.getOwnerCounty()); customerInfoVo.setProperty(custVehiclePolicyInfo.getOwnerProperty()); customerInfoVo.setRegisteredCapital(custVehiclePolicyInfo.getOwnerRegisteredCapital()); customerInfoVo.setScope(custVehiclePolicyInfo.getOwnerScope()); //车主相关信息 add hxl 2024-12-20 customerInfoVo.setTel(custVehiclePolicyInfo.getOwnerTel()); customerInfoVo.setOrganizationCode(custVehiclePolicyInfo.getOwnerOrganizationCode()); customerInfoVo.setProvince(custVehiclePolicyInfo.getOwnerProvince()); customerInfoVo.setCity(custVehiclePolicyInfo.getOwnerCity()); customerInfoVo.setCounty(custVehiclePolicyInfo.getOwnerCounty()); customerInfoVo.setProperty(custVehiclePolicyInfo.getOwnerProperty()); customerInfoVo.setRegisteredCapital(custVehiclePolicyInfo.getOwnerRegisteredCapital()); customerInfoVo.setScope(custVehiclePolicyInfo.getOwnerScope()); customerInfoVo.setLegalPerson(custVehiclePolicyInfo.getOwnerLegalPerson()); } return customerInfoVo; } private static String farmmatSex(String sex) { if(StringUtils.isNotBlank(sex)) { if ("1".equals(sex)) { return "女"; } else if ("2".equals(sex)) { return "男"; } } return ""; } public static String getAgeByIdCard(String idCard) { // 截取身份证中的出生日期部分 String birthDateStr = idCard.substring(6, 14); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Date birthDate = sdf.parse(birthDateStr); Calendar birthCal = Calendar.getInstance(); birthCal.setTime(birthDate); Calendar currentCal = Calendar.getInstance(); int birthYear = birthCal.get(Calendar.YEAR); int currentYear = currentCal.get(Calendar.YEAR); int age = currentYear - birthYear; // 考虑生日是否已经过了 int birthMonth = birthCal.get(Calendar.MONTH); int currentMonth = currentCal.get(Calendar.MONTH); if (birthMonth > currentMonth) { age--; } else if (birthMonth == currentMonth) { int birthDay = birthCal.get(Calendar.DAY_OF_MONTH); int currentDay = currentCal.get(Calendar.DAY_OF_MONTH); if (birthDay > currentDay) { age--; } } return String.valueOf(age); } catch (Exception e) { e.printStackTrace(); return ""; } } /** * @version * @author: hxl * @Date: 2024/11/22 9:10 * @Description: 通过身份证号判断男女 */ public static String checkGender(String idCardNumber) { if (idCardNumber.length() == 18) { char genderDigit = idCardNumber.charAt(16); int genderValue = Integer.parseInt(String.valueOf(genderDigit)); if (genderValue % 2 == 0) { return "女"; } else { return "男"; } } else if (idCardNumber.length() == 15) { char genderDigit = idCardNumber.charAt(14); int genderValue = Integer.parseInt(String.valueOf(genderDigit)); if (genderValue % 2 == 0) { return "女"; } else { return "男"; } } else { return ""; } } }