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

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
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.validated.SaveValidated;
import com.gci.boot.common.validated.UpdateValidated;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * <p>
 * 事故信息基础表
 * </p>
 *
 * @author 2464
 * @since 2023-09-13
 */
@Data
@TableName("tb_accident_info")
@ApiModel(value = "TbAccidentInfo对象", description = "事故信息基础表")
@TableRepeat(aClass = TbAccidentInfo.class,groups = {SaveValidated.class,UpdateValidated.class})
public class TbAccidentInfo implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @ApiModelProperty("创建时间")
    private Date createTime;

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

    @ApiModelProperty("更新时间")
    private Date updateTime;

    @ApiModelProperty("更新人")
    private String updateBy;

    @ApiModelProperty("车牌号")
    @NotBlank(message = "车牌号不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @SelectQuery
    @Pattern(message = "车牌号格式错误！",regexp = "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "车牌号",orderNum = "0")
    private String plateNumber;

    @ApiModelProperty("所属项目")
    @NotBlank(message = "所属项目不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Dict(dicCode = "id",dictTable = "tb_projects",dicText = "project_name")
    @Excel(name = "所属项目",dict = "tb_projects,project_name,id",orderNum = "1")
    private String projectId;

    @ApiModelProperty("处理人")
    @NotBlank(message = "处理人不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "处理人",orderNum = "2")
    private String processedPerson;

    @ApiModelProperty("事故号")
    @Size(max = 32,message = "事故号不能超过32位字符！",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "事故号",orderNum = "3")
    @FieldRepeat(message = "事故号不能重复！")
    private String reportNumber;

    @ApiModelProperty("事故发生时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "事故发生时间不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "事故发生时间",format = "yyyy-MM-dd HH:mm:ss",orderNum = "4")
    private Date accidentTime;

    @ApiModelProperty("驾驶员")
    @Size(max = 32,message = "驾驶员名称不能超过32位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "驾驶员",orderNum = "5")
    private String driver;

    @ApiModelProperty("驾驶员证件号")
    @Size(max = 32,message = "驾驶员证件号不能超过32位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "驾驶员证件号",orderNum = "6")
    private String driverLicenseNumber;

    @ApiModelProperty("驾驶员电话")
    @Pattern(regexp = "^$|^(?:(?:\\+|00)86)?1\\d{10}$",message = "驾驶员电话格式错误!",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "驾驶员电话",orderNum = "7")
    private String driverPhoneNumber;

    @ApiModelProperty("第三方车牌号")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Pattern(message = "第三方车牌号格式错误！",regexp = "^$|^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "第三方车牌号",orderNum = "8")
    private String thirdPlateNumber;

    @ApiModelProperty("第三方保险公司")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Size(max = 32,message = "第三方保险公司不能超过32位字符！")
    @Excel(name = "第三方保险公司",orderNum = "9")
    private String thirdInsuranceCompany;

    @ApiModelProperty("第三方电话号码")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Pattern(regexp = "^$|^(?:(?:\\+|00)86)?1\\d{10}$",message = "第三方电话格式错误!",groups = {SaveValidated.class,UpdateValidated.class})
    @Excel(name = "第三方电话号码",orderNum = "10")
    private String thirdPhoneNumber;

    @ApiModelProperty("事故发生地点")
    @NotBlank(message = "事故发生地点不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Size(max = 64,message = "事故发生地点不能超过64位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "事故发生地点",orderNum = "11")
    private String accidentLocation;

    @ApiModelProperty("事故发生经过")
    @NotBlank(message = "事故发生经过不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Size(max = 512,message = "事故发生经过不能超过512位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "事故发生经过",orderNum = "12")
    private String accidentDetails;

    @ApiModelProperty("事故预估损失")
    @NotBlank(message = "事故预估损失不能为空！",groups = {SaveValidated.class, UpdateValidated.class})
    @Size(max = 512,message = "事故预估损失不能超过512位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "事故预估损失",orderNum = "13")
    private String accidentEstimatedLoss;

    @ApiModelProperty("需要更换的配件")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Size(max = 32,message = "需要更换配件描述不能超过32位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "需要更换的配件",orderNum = "14")
    private String replacedParts;

    @ApiModelProperty("事故发生类型")
    @Dict(dicCode = "accident_form")
    @Excel(name = "事故发生类型",dict = "accident_form",orderNum = "15")
    private String accidentForm;

    @ApiModelProperty("事故发生类型其他描述")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Size(max = 16,message = "事故发生类似其他描述不能超过16位字符！",groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "事故发生其他类型描述",orderNum = "16")
    private String accidentFormOther;

    @ApiModelProperty("事故类型")
    @Dict(dicCode = "accident_type")
    @Excel(name = "事故类型",dict = "accident_type",orderNum = "17")
    private String accidentType;

    @ApiModelProperty("事故伤亡类型")
    @Dict(dicCode = "accident_injury_type")
    @Excel(name = "事故伤亡类型",dict = "accident_injury_type",orderNum = "18")
    private String accidentInjuryType;

    @ApiModelProperty("初步预估责任")
    @Dict(dicCode = "liability_type")
    @Excel(name = "初步预估责任",dict = "liability_type",orderNum = "19")
    private String liabilityEstimate;

    @ApiModelProperty("初步预估性质")
    @Dict(dicCode = "nature_type")
    @Excel(name = "初步预估责任",dict = "nature_type",orderNum = "20")
    private String natureEstimate;

    @ApiModelProperty("事故现场图片")
    @Size(max = 5000,message = "事故现场图片文件名过长请修改！",groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @NotBlank(message = "事故现场图片不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @FileUrl
    private String accidentScenePhoto;

    @ApiModelProperty("事故现场视频")
    @Size(max = 5000,message = "事故现场视频文件名过长请修改！",groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String accidentSceneVideo;

    @ApiModelProperty("保险公司现场勘察报告")
    @Size(max = 5000,message = "保险公司现场勘察报告图片文件名过长请修改！",groups = {SaveValidated.class, UpdateValidated.class})
    @NotBlank(message = "保险公司现场勘察报告不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String insuranceInvestigationReport;

    @ApiModelProperty("事故损失类型")
    @Dict(dicCode = "accident_loss_type")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @Excel(name = "事故损失类型",dict = "accident_loss_type",orderNum = "21")
    private String accidentLossType;

    @ApiModelProperty("事故损失类型 前端用")
    @TableField(exist = false)
    private List<String> accidentLossTypeList;

    @ApiModelProperty("保险信息")
    @TableField(exist = false)
    @Valid
    @ExcelEntity
    private TbAccidentInsuranceInfo accidentInsuranceInfo = new TbAccidentInsuranceInfo();

    @ApiModelProperty("案件进度")
    @TableField(exist = false)
    @Valid
    @ExcelEntity
    private TbAccidentProgress accidentProgress = new TbAccidentProgress();
}
