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

import cn.afterturn.easypoi.excel.annotation.Excel;

import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.baomidou.mybatisplus.annotation.*;

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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
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.ImportValidated;
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.constraints.*;

/**
 * <p>
 * 年检信息表
 * </p>
 *
 * @author 2464
 * @since 2023-09-20
 */
@Data
@TableName("tb_annual_inspection_info")
@ApiModel(value = "TbAnnualInspectionInfo对象", description = "年检信息表")
@TableRepeat(aClass = TbAnnualInspectionInfo.class,
    groups = {SaveValidated.class, UpdateValidated.class})
public class TbAnnualInspectionInfo implements Serializable, IExcelModel, IExcelDataModel {

    private static final long serialVersionUID = 1L;

    @JsonPropertyDescription("id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotBlank(message = "id不能为空！", groups = {UpdateValidated.class})
    private String id;

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

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

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

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

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

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

    @JsonPropertyDescription("所属项目")
    @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 = "0")
    private String projectId;

    @JsonPropertyDescription("处理人")
    @NotBlank(message = "处理人不能为空！", groups = {SaveValidated.class, UpdateValidated.class})
    @Size(max = 32, message = "处理人不能超过32位字符！", groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "处理人", orderNum = "2")
    private String processedPerson;

    @JsonPropertyDescription("办理日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "办理日期不能为空！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @PastOrPresent(message = "办理日期必须为当天或过去的时间！", groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "办理日期", format = "yyyy-MM-dd", orderNum = "3")
    private Date handlingDate;

    @JsonPropertyDescription("年检有效期")
    @NotNull(message = "年检有效期不能为空！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Future(message = "年检有效期必须为将来的时间！", groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "年检有效期", format = "yyyy-MM-dd", orderNum = "4")
    private Date validityPeriod;

    @JsonPropertyDescription("年检地点")
    @Size(max = 64, message = "年检地点不能超过64位字符！",
        groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Excel(name = "年检地点", orderNum = "5")
    private String location;

    @JsonPropertyDescription("年检人员")
    @Excel(name = "年检人员",orderNum = "5")
    @Size(max = 32, message = "年检人员不能超过32位字符！",
            groups = {SaveValidated.class, UpdateValidated.class})
    private String personnel;

    @JsonPropertyDescription("年检项目")
    @Excel(name = "年检项目",orderNum = "5")
    @Size(max = 32, message = "年检项目不能超过32位字符！",
            groups = {SaveValidated.class, UpdateValidated.class})
    private String items;

    @JsonPropertyDescription("备注")
    @Size(max = 500, message = "备注不能超过500位字符！", groups = {SaveValidated.class, UpdateValidated.class})
    @Excel(name = "备注", orderNum = "6")
    private String remark;

    @JsonPropertyDescription("检测费")
    @Digits(integer = 9, fraction = 2, message = "检测费金额整数部分不能大于9位，小数部分不能大于2位",
        groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Min(value = 0, message = "检测费最小值为0！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @NotNull(message = "检测费不能为空！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Excel(name = "检测费", orderNum = "7")
    private BigDecimal testingFee;

    @JsonPropertyDescription("手续费")
    @Digits(integer = 9, fraction = 2, message = "手续费金额整数部分不能大于9位，小数部分不能大于2位",
        groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Min(value = 0, message = "手续费最小值为0！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @NotNull(message = "手续费不能为空！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Excel(name = "手续费", orderNum = "8")
    private BigDecimal serviceFee;

    @JsonPropertyDescription("杂费")
    @Digits(integer = 9, fraction = 2, message = "杂费金额整数部分不能大于9位，小数部分不能大于2位",
        groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Min(value = 0, message = "杂费最小值为0！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @NotNull(message = "杂费不能为空！", groups = {SaveValidated.class, UpdateValidated.class, ImportValidated.class})
    @Excel(name = "杂费", orderNum = "9")
    private BigDecimal miscellaneousFee;

    @JsonPropertyDescription("费用合计")
    @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})
    @Excel(name = "费用合计", orderNum = "10")
    private BigDecimal totalFee;

    @JsonPropertyDescription("行驶证")
    @Size(max = 5000, message = "行驶证图片文件名过长请修改！", groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String drivingLicense;

    @JsonPropertyDescription("车辆合格标")
    @Size(max = 5000, message = "车辆合格标图片文件名过长请修改！", groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String vehicleQualificationMark;

    @JsonPropertyDescription("年检费用明细表")
    @Size(max = 5000, message = "年检费用明细表图片文件名过长请修改！", groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String detailsTable;

    @JsonPropertyDescription("其他")
    @Size(max = 5000, message = "其他图片文件名过长请修改！", groups = {SaveValidated.class, UpdateValidated.class})
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String other;

    @ApiModelProperty("来源（1车辆档案，2采购交车）")
    @ExcelIgnore
    private String sourceType;

    @Dict(dicCode = "vehicle_type")
    @TableField(exist = false)
    @JsonPropertyDescription("车辆种类")
    @Excel(name = "车辆种类", dict = "vehicle_type", orderNum = "2")
    private String vehicleType;

    @JsonPropertyDescription("逾期类型")
    @TableField(exist = false)
    @Dict(dicCode = "overdue_type")
    @Excel(name = "逾期类型", dict = "overdue_type", orderNum = "11")
    private String overdueType;

    @JsonPropertyDescription("将要逾期天数")
    @TableField(exist = false)
    @Excel(name = "将要逾期天数", orderNum = "12")
    private Integer daysToOverdue = 0;

    @JsonPropertyDescription("逾期天数")
    @TableField(exist = false)
    @Excel(name = "逾期天数", orderNum = "13")
    private Integer overdueDays = 0;

    @JsonPropertyDescription("天数")
    @TableField(exist = false)
    private Integer days;

    @JsonPropertyDescription("违章未处理数")
    @TableField(exist = false)
    private Integer violationCount;

    @JsonPropertyDescription("事故未处理数")
    @TableField(exist = false)
    private Integer accidentCount;

    @ApiModelProperty("删除标志")
    private Integer delFlag;

    @TableField(exist = false)
    private int rowNum;

    @TableField(exist = false)
    @Excel(name = "错误信息",width = 20)
    private String errorMsg;

    @Override
    public Integer getRowNum() {
        return rowNum;
    }

    @Override
    public void setRowNum(Integer integer) {
        this.rowNum = integer;
    }

    @Override
    public String getErrorMsg() {
        return errorMsg;
    }

    @Override
    public void setErrorMsg(String s) {
        this.errorMsg = s;
    }
}
