package com.sw.mes.yb.accessory.entity;


import com.sw.mes.base.factory.init.entity.Equipment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.util.Date;

/**
 * 设备辅料信息
 */
@Data
@Entity
@Table(name = "zhxx_equipment_accessory")
@DynamicUpdate
@DynamicInsert
public class EquipmentAccessory {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * wms发料信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "out_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private AccessoryMaterialOut accessoryMaterialOut;

    /**
     * 物料编号(热场条码（唯一）)
     */
    @Column
    private String goodsCode;

//    /** 辅料类型字典名称 **/
//    @Column(name = "accessory_type_name", length = 80)
//    private String accessoryTypeName;
//
//    /** 辅料类型字典值 **/
//    @Column(length = 80, name = "accessory_type_value")
//    private String accessoryTypeValue;

    /**
     * 辅料信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "material_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private AccessoryMaterial material;

    /**
     * 设备状态信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "equipment_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Equipment equipment;

    /**
     * 设备编号
     */
    @Column(length = 80)
    private String deviceNo;

    /**
     * 是否预警
     */
    @Column(length=0)
    private Boolean warning;

    /**
     * 预警时间
     */
    @Column(length = 18)
    private Double warnTime;

    /**
     * 使用周期(总的使用时间)
     */
    @Column(length = 18)
    private Double useLife;

    /**
     * 有效运行时间   (有效运行时间是实时的，可以通过EquipmentAccessoryServiceImpl.getDetail(id)获取)
     */
    @Column(length = 18)
    private Double useTime;

    /**
     * 已使用时间    (已使用时间是实时的，可以通过EquipmentAccessoryServiceImpl.getDetail(id)获取)
     */
    @Column(length = 18)
    private Double usedTime;

    /**
     * 单位
     */
    @Column(length = 40)
    private String unitName;

    /**
     * 更新/创建人
     */
    @Column(length = 50)
    private String operateUser;

    @Column
    private Integer operateUserId;

    /**
     * 更新时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date operateDate;

    /**
     * 预警时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date warningDate;

    /**
     * 厂家
     */
    @Column
    private String factory;

    /**
     * 申请人
     */
    @Column(length = 40)
    private String applyUser;

    /**
     * 申请时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date applyDate;

    /**
     * 绑定状态（已绑定1 ； 未绑定0）(已废弃)
     */
    @Column(length = 2)
    private Integer bind;

    @Column(length = 2)
    private Integer deleted;

    /**
     * 数量
     */
    @Column(length = 11)
    private Integer num;

    /**
     * "是否开启-更换-对调按钮" 1为开启  0为关闭
     */
    @Column(length = 2)
    private Integer buttonStatus;

    /**
     * 是否开启申请按钮  1为开启  0为关闭
     */
    @Column(length = 2)
    private Integer applyButton;

    @Column(length = 64)
    private String batchNo;

    /**
     * 刻码
     */
    @Column
    private String engraving;

    /**
     * 碳毡
     */
    @Column
    private String carbonFelt;

    /**
     * 辅料类型
     */
    @Column
    private String accessoryType;

    /**
     * 备注
     */
    @Column
    private String remark;
}
