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.repeat.TableRepeat;
import com.gci.boot.common.config.CancelConverter;
import com.gci.boot.common.dict.annotation.Dict;
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.springframework.format.annotation.DateTimeFormat;

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

@Data
@TableName("tb_upkeep_bill")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "保养台账表", description = "保养台账表")
@TableRepeat(aClass = TbUpkeepRule.class,groups = {SaveValidated.class, UpdateValidated.class})
public class TbUpkeepBill 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")
    private String auditStatus;

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

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

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

    @ApiModelProperty("所属项目")
    @Dict(dicCode = "id",dictTable = "tb_projects",dicText = "project_name")
    private String projectId;

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

    @ApiModelProperty("车牌号")
    private String plateNumber;

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

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

    @ApiModelProperty("车辆种类")
    @Dict(dicCode = "vehicle_type")
    private String vehicleType;

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

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

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

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

    @ApiModelProperty("上次保养时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date lastTime;

    @ApiModelProperty("上次保养里程")
    private Integer lastMileage;

    @ApiModelProperty("预计保养时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date predictTime;

    @ApiModelProperty("预计保养里程")
    private Integer predictMileage;

    @ApiModelProperty("保养内容")
    private String content;

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

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

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

    @ApiModelProperty("作废人")
    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-手动")
    private Integer saveType;

    @ApiModelProperty("规则id")
    private String ruleId;
    @ApiModelProperty("生成批次")
    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("实际保养里程")
    private Integer realMileage;

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


    @Dict(dicCode = "overdue_status")
    @ApiModelProperty("逾期状态")
    @TableField(exist = false)
    private String overdueStatus;
    @ApiModelProperty("逾期天数")
    @TableField(exist = false)
    private String overdueDay;

    /**所属机构*/
    @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;
//    /**作废标志--默认0-正常，1-作废*/
//    @ApiModelProperty(value = "作废标志")
//    @ExcelProperty(value = "数据状态", converter = CancelConverter.class)
//    @ColumnWidth(value = 15)
//    private Integer cancelFlag;

}
