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.alibaba.excel.annotation.write.style.ContentLoopMerge;
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.annotation.repeat.FieldRepeat;
import com.gci.boot.annotation.repeat.TableRepeat;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

/**
 * <p>
 * 合同档案
 * </p>
 *
 * @author xushuhan
 * @since 2023-09-01
 */
@Getter
@Setter
@TableName("tb_contract")
@ApiModel(value = "TbContract对象", description = "合同档案")
@TableRepeat(aClass = TbContract.class,groups = {SaveValidated.class,UpdateValidated.class})
/*@ContentRowHeight(10)
@HeadRowHeight(20)*/
@ColumnWidth(20)
public class TbContract implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("所属项目")
    @ExcelProperty(value = "所属项目", converter = DictConverter.class, index = 0)
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @Dict(dictTable = "tb_projects", dicText = "project_name", dicCode = "id")
    private String projectId;

    @ApiModelProperty("合同名称")
    @SelectQuery
    @ExcelProperty(value = "合同名称", index = 2)
    private String name;

    @ApiModelProperty("合同编号")
    @SelectQuery
    @FieldRepeat(message = "合同编号不能重复!")
    @ExcelProperty(value = "合同编号", index = 3)
    private String contractNo;

    @ApiModelProperty("合同类型（客户租赁合同、保险合同、维修合同、车辆采购合同、定制件采购合同、耗材采购合同、资产评估合同、法人尽调合同）")
    @ExcelProperty(value = "合同类型", converter = DictConverter.class, index = 1)
    @Dict(dicCode = "contract_type")
    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    private String contractType;

    @ApiModelProperty("签约方（客户档案（客户租赁合同）、维修厂档案（维修合同）、车辆供应商档案（车辆采购合同）、保险档案（保险合同），其填文本）")
    @ExcelIgnore
    private String signingId;

    @ApiModelProperty("签约时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    //@DateTimeFormat("yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(value = "签约时间", index = 6,format="yyyy-MM-dd")
    private Date signingTime;

    @ApiModelProperty("合同总价（含税）")
    @ExcelIgnore
    private Double totalPrice;

    @ApiModelProperty("合同总价（不含税）")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Double totalPriceNoTax;

    @ApiModelProperty("增值税率")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Double addedTaxRate;

    @ApiModelProperty("增值税")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Double addedTax;

    @ApiModelProperty("生效时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @ExcelProperty(value = "生效时间", index = 7)
    private Date startTime;

    @ApiModelProperty("终止时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat("yyyy-MM-dd")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @ExcelProperty(value = "失效时间", index = 8)
    private Date endTime;

    @ApiModelProperty("备注")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String remark;

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

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

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

    @ApiModelProperty("更新人")
    @Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
    @ExcelProperty(value = "更新人",converter = DictConverter.class)
    private String updateBy;

    @ApiModelProperty("更新时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty("合同文件")
    @ExcelIgnore
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    @JsonDeserialize(using = FileUrlHandle.class)
    @FileUrl
    private String fileUrl;

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

    @ExcelIgnore
    @Length(max = 256,groups = {SaveValidated.class,UpdateValidated.class},message = "货物名称长度不能超过256")
    @ApiModelProperty("货物名称")
    private String goodsName;

    //车辆数
    @ExcelIgnore
    private Integer vehicleCount;

    @SelectQuery
    @ExcelProperty(value = "签约方", index = 4)
    private String signingName;

    @SelectQuery(Type = SelectQuery.SelectType.EQ)
    @ExcelProperty(value = "状态", converter = DictConverter.class, index = 5)
    @Dict(dicCode = "contrack_status")
    private String status;

    @ExcelIgnore
    @TableField(exist = false)
    @ApiModelProperty("车型明细")
    private List<TbContractVehicle> vehicleDetails;

    @ExcelIgnore
    @ApiModelProperty("车辆明细")
    @TableField(exist = false)
    List<TbVehicleCheckDetail> vehicleList;

}
