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

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

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.common.dict.annotation.Dict;
import com.gci.boot.common.dict.excel.DictConverter;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.simpleframework.xml.core.Validate;

/**
 * <p>
 * 车辆验收
 * </p>
 *
 * @author xushuhan
 * @since 2023-09-11
 */
@Getter
@Setter
@TableName("tb_vehicle_check")
@ApiModel(value = "TbVehicleCheck对象", description = "车辆验收")
@ColumnWidth(20)
public class TbVehicleCheck implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("所属项目")
    @ExcelIgnore
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dictTable = "tb_projects", dicText = "project_name", dicCode = "id")
    private String projectId;

    @ApiModelProperty("所属合同")
    @ExcelProperty(value = "所属合同", converter = DictConverter.class, index = 0)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dictTable = "tb_contract", dicText = "name", dicCode = "id")
    private String contractId;

    @ApiModelProperty("车辆种类")
    @ExcelProperty(value = "车辆种类", converter = DictConverter.class, index = 3)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dicCode = "vehicle_type")
    private String vehicleType;

    @ApiModelProperty("模板")
    @ExcelProperty(value = "模板名称", converter = DictConverter.class, index = 1)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dictTable = "tb_vehicle_check_template", dicText = "name", dicCode = "id")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String templateId;

    @ApiModelProperty("交车人")
    @ExcelProperty(value = "交车人", index = 7)
    private String sentVehicleUser;

    @ApiModelProperty("验收人id")
    @ExcelProperty(value = "验收人", converter = DictConverter.class, index = 8)
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id")
    private String checkUserId;

    @ApiModelProperty("验收人")
    @ExcelIgnore
    private String checkUserName;

    @ApiModelProperty("接收人id")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id")
    @ExcelIgnore
    //@ExcelProperty(value = "接收人", converter = DictConverter.class, index = 9)
    private String acceptUserId;

    @ApiModelProperty("接收人")
    @ExcelIgnore
    private String acceptUserName;

    @ApiModelProperty("验收时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(value = "验收日期", index = 6)
    private Date checkTime;
    
    @ApiModelProperty("初登日期")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Date registrationTime;

    @ApiModelProperty("验收地址")
    @ExcelIgnore
    private String checkAddress;

    @ApiModelProperty("验收结果(0不合格，1合格)")
    @Dict(dicCode = "check_status")
    @ExcelProperty(value = "验收结果", converter = DictConverter.class, index = 5)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String checkStatus;

    @ApiModelProperty("验收结论")
    @ExcelIgnore
    private String remark;

    @ApiModelProperty("验收单")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String ckeckUrl;

    @ApiModelProperty("保函")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String ensureUrl;

    @ApiModelProperty("其他")
    @ExcelIgnore
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String otherUrl;

    @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;

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

    @ApiModelProperty("验收类型")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @ExcelIgnore
    @Dict(dicCode = "check_type")
    private String checkType;

    @ApiModelProperty("交车人id")
    //@ExcelProperty(value = "交车人", converter = DictConverter.class, index = 6)
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "id")
    @ExcelIgnore
    private String sentVehicleUserId;

    @ApiModelProperty("来源（1后台，2小程序）")
    @ExcelIgnore
    private String sourceType;
    
    @ApiModelProperty("租赁交车id")
    @ExcelIgnore
    private String parentId;
    
    @ApiModelProperty("状态（0待提交，1已提交）")
    @ExcelIgnore
    @Dict(dicCode = "edit_status")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String status;
    
    @ApiModelProperty("收车状态（0未交车，0.5未收车,1已收车）")
    @ExcelIgnore
    @Dict(dicCode = "receive_status")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String receiveStatus;

    //验收项目
    @TableField(exist = false)
    @ExcelIgnore
    private String projectNames;
    
    //车辆信息
    //车牌号列表
    @TableField(exist = false)
    @ExcelProperty(value = "车辆信息", index = 2)
    private String plateNumbers;

    @TableField(exist = false)
    @ExcelIgnore
    @Validate
    private List<TbVehicleCheckDetail> vehicleList;
    
    @TableField(exist = false)
    @ExcelIgnore
    private List<TbVehicleCheckProject> projectList;
    
    //租赁收车
    @TableField(exist = false)
    @ExcelIgnore
    private TbVehicleCheck children;
    
    //未处理违章数
    @TableField(exist = false)
    @ExcelIgnore
    private Integer violationCount = 0;
    
    //未处理事故数
    @TableField(exist = false)
    @ExcelIgnore
    private Integer accidentInfoCount = 0;

    @TableField(exist = false)
    @ExcelIgnore
    private String frameNumber;

    @TableField(exist = false)
    @ExcelIgnore
    private String plateNumber;

    //车架号列表
    @TableField(exist = false)
    @ExcelIgnore
    private String frameNumbers;

    //车辆数
    @TableField(exist = false)
    @ExcelProperty(value = "车辆数量", index = 4)
    private Integer vehicleCount = 0;
}
