package com.gci.boot.modules.vehicles.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.gci.boot.annotation.Query.SelectQuery;
import com.gci.boot.annotation.fileUrl.FileUrl;
import com.gci.boot.annotation.fileUrl.handle.FileUrlHandle;
import com.gci.boot.annotation.repeat.FieldRepeat;
import com.gci.boot.annotation.repeat.TableRepeat;
import com.gci.boot.common.dict.annotation.Dict;
import com.gci.boot.common.dict.excel.DictConverter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.gci.boot.common.validated.SaveValidated;
import com.gci.boot.common.validated.UpdateValidated;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.*;

/**
 * <p>
 * 出险管理
 * </p>
 *
 * @author xushuhan
 * @since 2023-09-22
 */
@Getter
@Setter
@TableName("tb_insurance_record")
@ApiModel(value = "TbInsuranceRecord对象", description = "出险管理")
@ColumnWidth(20)
@TableRepeat(aClass = TbInsuranceRecord.class,groups = {SaveValidated.class,UpdateValidated.class})
public class TbInsuranceRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @ExcelIgnore
    private String id;

    @ApiModelProperty("所属车辆")
    @ExcelProperty(value = "车牌号", converter = DictConverter.class, index = 1)
    @Dict(dictTable = "tb_vehicle", dicText = "plate_number", dicCode = "id")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @NotBlank(message = "所属车辆不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private String vehicleId;

    @ApiModelProperty("所属项目")
    @ExcelProperty(value = "所属项目", converter = DictConverter.class, index = 0)
    @Dict(dictTable = "tb_projects", dicText = "project_name", dicCode = "id")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @NotBlank(message = "所属项目不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private String projectId;

    @ApiModelProperty("车辆型号")
    //@ExcelProperty(value = "车辆型号", index = 2)
    @ExcelIgnore
    @SelectQuery
    private String vehicleModel;

    @ApiModelProperty("车辆种类")
    @Dict(dicCode = "vehicle_type")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @ExcelProperty(value = "车辆种类", converter = DictConverter.class, index = 2)
    @NotBlank(message = "车辆种类不能为空!",groups = {SaveValidated.class,UpdateValidated.class})
    private String vehicleType;

    @ApiModelProperty("出险日期")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(value = "出险日期", index = 4)
    @NotNull(message = "出险日期不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private Date insuranceDate;

    @ApiModelProperty("保险公司")
    @ExcelProperty(value = "保险公司", converter = DictConverter.class, index = 3)
    @Dict(dictTable = "tb_insurance_company_archives", dicText = "name", dicCode = "id")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @NotBlank(message = "保险公司不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private String companyId;

    @ApiModelProperty("事故号")
    @ExcelProperty(value = "事故号", index = 5)
    @NotBlank(message = "事故号不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @FieldRepeat(message = "事故号不能重复！")
    private String insuranceNo;

    @ExcelIgnore
    @ApiModelProperty("案件实际发生总金额")
    @Digits(integer = 10,fraction = 2,message = "案件实际发生总金额整数部分不能大于10位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "案件实际发生总金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "案件实际发生总金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private BigDecimal insurancePrice;

    @ApiModelProperty("处理人")
    @ExcelProperty(value = "处理人", index = 6)
    @NotBlank(message = "处理人不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    private String handleUser;

    @ApiModelProperty("处理结果")
    @ExcelProperty(value = "处理结果", converter = DictConverter.class, index = 7)
    @Dict(dicCode = "handle_status")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @NotBlank(message = "处理结果不能为空！")
    private String handleStatus;

    @ApiModelProperty("事故认定书")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String accidentUrl;

    @ApiModelProperty("赔偿协议书")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String compensateAgreementUrl;

    @ApiModelProperty("定损单")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String lossAssessmentUrl;

    @ApiModelProperty("赔偿单据")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String compensateUrl;

    @ApiModelProperty("其他")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String otherUrl;
    
    @ApiModelProperty("备注")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String remark;

    @ApiModelProperty("所属机构")
    @ExcelIgnore
    private String sysOrgCode;

    @ApiModelProperty("创建时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelIgnore
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelIgnore
    private Date updateTime;

    @ApiModelProperty("创建人")
    @ExcelIgnore
    private String createBy;

    @ApiModelProperty("更新人")
    @ExcelIgnore
    private String updateBy;
    
    @ExcelIgnore
    @ApiModelProperty("删除标志")
    private Integer delFlag;

    @ApiModelProperty("出险日期开始")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd")
    @TableField(exist = false)
    @ExcelIgnore
    private Date insuranceDateStart;

    @ApiModelProperty("出险日期结束")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd")
    @TableField(exist = false)
    @ExcelIgnore
    private Date insuranceDateEnd;

    @ApiModelProperty("来源（1后台，2小程序）")
    @ExcelIgnore
    private String sourceType;

    @ApiModelProperty("标的车损失金额")
    @Digits(integer = 9,fraction = 2,message = "标的车损失金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @NotNull(message = "标的车损失金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal vehicleLossAmount;

    @ApiModelProperty("标的车人伤金额")
    @Digits(integer = 9,fraction = 2,message = "标的车人伤金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "标的车人伤金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "标的车人伤金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal vehiclePersonalInjuryAmount;

    @ApiModelProperty("第三方物损金额")
    @Digits(integer = 9,fraction = 2,message = "第三方物损金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "第三方物损金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "第三方物损金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal thirdPropertyDamageAmount;

    @ApiModelProperty("第三方人伤金额")
    @Digits(integer = 9,fraction = 2,message = "第三方人伤金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "第三方人伤金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "第三方人伤金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal thirdPersonalInjuryAmount;

    @ApiModelProperty("预估损失总金额")
    @Digits(integer = 10,fraction = 2,message = "预估损失总金额整数部分不能大于10位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "预估损失总金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "预估损失总金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal estimatedTotalLossAmount;

    @ApiModelProperty("理赔至公司账户日期")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd")
    @NotNull(message = "理赔至公司账户日期不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private Date claimToCompanyAccountDate;

    @ApiModelProperty("理赔至公司账户金额")
    @Digits(integer = 9,fraction = 2,message = "理赔至公司账户金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "理赔至公司账户金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "理赔至公司账户金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal claimToCompanyAccountAmount;

    @ApiModelProperty("理赔至第三方账户日期")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @NotNull(message = "理赔至第三方账户日期不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private Date claimToThirdAccountDate;

    @ApiModelProperty("理赔至第三方账户金额")
    @Digits(integer = 9,fraction = 2,message = "理赔至第三方账户金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "理赔至第三方账户金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "理赔至第三方账户金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal claimToThirdAccountAmount;

    @ApiModelProperty("出险赔偿总金额")
    @Digits(integer = 10,fraction = 2,message = "出险赔偿总金额部分不能大于10位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "出险赔偿总金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "出险赔偿总金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal totalCompensationAmount;

    @ApiModelProperty("出险未赔偿金额")
    @Digits(integer = 9,fraction = 2,message = "出险未赔偿金额整数部分不能大于9位，小数部分不能大于2位",groups = {SaveValidated.class, UpdateValidated.class})
    @Min(value = 0,message = "出险未赔偿金额最小值为0！",groups = {SaveValidated.class,UpdateValidated.class})
    @NotNull(message = "出险未赔偿金额不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private BigDecimal uncompensatedAmount;

    @ApiModelProperty("事故信息主表id")
    @ExcelIgnore
    private String infoId;

}
