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

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
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.gci.boot.annotation.Query.SelectQuery;
import com.gci.boot.annotation.repeat.FieldRepeat;
import com.gci.boot.annotation.repeat.TableRepeat;
import com.gci.boot.common.config.CancelConverter;
import com.gci.boot.common.dict.annotation.Dict;
import com.gci.boot.common.dict.excel.DictConverter;
import com.gci.boot.common.validated.SaveValidated;
import com.gci.boot.common.validated.UpdateValidated;
import com.gci.boot.modules.vehicles.vo.AttachmentDetailVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@TableName("tb_upkeep_plan")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "保养计划表", description = "保养计划表")
@TableRepeat(aClass = TbUpkeepPlan.class,groups = {SaveValidated.class, UpdateValidated.class})
public class TbUpkeepPlan implements Serializable {

    private static final long serialVersionUID = 1L;

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

    //1-未审核，2-审核通过，3-审核未通过，4-已作废, 5-已归档
    @ApiModelProperty("审核状态")
    @Dict(dicCode = "upkeep_audit_status")
    @ExcelProperty(value = "状态",index = 7,converter = DictConverter.class)
    @ColumnWidth(value = 15)
    @SelectQuery
    private String auditStatus;

    @ApiModelProperty("流程状态")
    @ExcelIgnore
    private Integer flowStatus;

    @ApiModelProperty("流程节点")
    @ExcelIgnore
    private Integer flowNode;

    @ApiModelProperty("工单号")
    @ExcelIgnore
    private String orderNo;

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

    @ApiModelProperty("项目名称")
    @ExcelIgnore
    private String projectName;

    @ApiModelProperty("车牌号")
    @NotBlank(message = "车牌号不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelProperty(value = "车牌号",index = 1)
    @ColumnWidth(value = 20)
    @SelectQuery
    private String plateNumber;

    @ApiModelProperty("交车时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ExcelIgnore
    private Date deliveryTime;

    @ApiModelProperty("车架号")
    @ExcelIgnore
    private String frameNumber;

    @ApiModelProperty("车辆种类")
    @Dict(dicCode = "vehicle_type")
    @ExcelProperty(value = "车辆种类",index = 2,converter = DictConverter.class)
    @ColumnWidth(value = 15)
    @SelectQuery
    private String vehicleType;

    @ApiModelProperty("车辆型号")
    @ExcelIgnore
    private String vehicleModel;

    @ApiModelProperty("车辆品牌")
    @Dict(dicCode = "vehicle_brand")
    @ExcelIgnore
    private String vehicleBrand;

    @ApiModelProperty("车辆识别代码（VIN码）")
    @ExcelIgnore
    private String vinCode;

    @ApiModelProperty("发动机号码")
    @ExcelIgnore
    private String engineNumber;

    @ApiModelProperty("上次保养时间")
    @NotNull(message = "上次保养时间不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(value = "上次保养时间",index = 3)
    @ColumnWidth(value = 20)
    private Date lastTime;

    @ApiModelProperty("上次保养里程")
    @NotNull(message = "上次保养里程不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Range(min = 0, max = 99999999, message = "上次保养里程在[0,99999999]之间!",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelProperty(value = "上次保养里程(KM)",index = 4)
    @ColumnWidth(value = 20)
    private Integer lastMileage;

    @ApiModelProperty("预计保养时间")
    @NotNull(message = "预计保养时间不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(value = "预计保养时间",index = 5)
    @ColumnWidth(value = 20)
    private Date predictTime;

    @ApiModelProperty("预计保养里程")
    @NotNull(message = "预计保养里程不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Range(min = 0, max = 99999999, message = "预计保养里程在[0,99999999]之间!",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelProperty(value = "预计保养里程(KM)",index = 6)
    @ColumnWidth(value = 20)
    private Integer predictMileage;

    @ApiModelProperty("保养内容")
    @NotBlank(message = "保养内容不能为空！",groups = {SaveValidated.class,UpdateValidated.class})
    @Length(max = 250,message = "保养内容长度不能超过250位",groups = {SaveValidated.class,UpdateValidated.class})
    @ExcelIgnore
    private String content;

    @ApiModelProperty("附件/照片JSON")
    @ExcelIgnore
    private String attachmentJson;

    @ApiModelProperty("附件/照片列表")
    @TableField(exist = false)
    @ExcelIgnore
    private List<AttachmentDetailVO> attachmentList;

    @ApiModelProperty("作废意见")
    @ExcelIgnore
    private String cancelIdea;

    @ApiModelProperty("作废人")
    @ExcelIgnore
    private String cancelPeople;

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

    @ApiModelProperty("生成类型 1-自动，2-手动")
    @Dict(dicCode = "upkeep_plan_save_type")
    @ExcelIgnore
    private Integer saveType;

    @ApiModelProperty("规则id")
    @ExcelIgnore
    private String ruleId;
    @ApiModelProperty("生成批次")
    @ExcelIgnore
    private Integer createNo;

    /**实际保养开始*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    @ExcelIgnore
    private Date startTime;

    /**实际保养结束*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    @ExcelIgnore
    private Date endTime;

    /**实际保养里程*/
    @ApiModelProperty("实际保养里程")
    @ExcelIgnore
    private Integer realMileage;

    /**计划生成日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "计划生成日期")
    @com.alibaba.excel.annotation.format.DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty(value = "计划生成日期",index = 8)
    @ColumnWidth(value = 30)
    private Date planSaveTime;
    @ApiModelProperty("保存类型 1-数据录入，，2-走流程的")
    @ExcelIgnore
    private Integer addType;

    /**所属机构*/
    @ApiModelProperty(value = "所属部门")
    @ExcelIgnore
    private String sysOrgCode;
    /**创建日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    @ExcelIgnore
    private Date createTime;
    /**更新日期*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    @ExcelIgnore
    private Date updateTime;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    @ExcelIgnore
    private String createBy;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    @ExcelIgnore
    private String updateBy;


    @Dict(dicCode = "overdue_status")
    @ApiModelProperty("逾期状态")
    @TableField(exist = false)
    @ExcelProperty(value = "逾期状态",index = 9,converter = DictConverter.class)
    @ColumnWidth(value = 15)
    private String overdueStatus;
    @ApiModelProperty("逾期天数")
    @TableField(exist = false)
    @ExcelProperty(value = "逾期天数",index = 10)
    @ColumnWidth(value = 15)
    private String overdueDay;
    //查看按钮 1-有 2-没有
    @ExcelIgnore
    @TableField(exist = false)
    private Integer checkButton;
    // 作废按钮 1-有 2-没有
    @ExcelIgnore
    @TableField(exist = false)
    private Integer deleteButton;
    //编辑按钮 1-有 2-没有
    @ExcelIgnore
    @TableField(exist = false)
    private Integer editButton;
    // 审核按钮 1-有 2-没有
    @ExcelIgnore
    @TableField(exist = false)
    private Integer auditButton;
    // 用户类型 1-司机，2-维修厂，3-司机&维修厂，4-维保管理员，5-维保领导，6-维保管理员&维保领导
    @ExcelIgnore
    @TableField(exist = false)
    private String userType;

}
