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


import com.sw.mes.base.factory.init.entity.Device;
import com.sw.mes.base.factory.material.entity.MaterialModel;
import com.sw.mes.base.factory.material.entity.MaterialType;
import com.sw.mes.base.factory.material.entity.Unit;
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.math.BigDecimal;
import java.util.Date;

/**
 * 辅料属性
 */
@Data
@Entity
@Table(name = "zhxx_accessory_material")
@DynamicUpdate
@DynamicInsert
public class AccessoryMaterial {

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

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

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

    /**
     * 热场名称
     */
    @Column(nullable = false, length = 50)
    private String name;

    /**
     * 热场编码
     */
    @Column(length = 130)
    private String codes;

    /**
     * 单位
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "unit_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Unit unit;

    /**
     * 物料模型
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "material_model_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MaterialModel materialModel;

    /**
     * 物料类型
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "model_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MaterialType model;

    /**
     * 设备类型
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "device_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Device device;

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

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

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

    /**
     * 规格
     */
    @Column(length = 130)
    private String specification;

    /**
     * 创建人
     */
    @Column(length = 50)
    private String createUser;

    @Column
    private Integer createUserId;

    /**
     * 创建时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;

    /**
     * 供应商
     */
    @Column
    private String supplier;

    /**
     * 单价
     */
    @Column
    private BigDecimal unitPrice;

    /**
     * 尺寸
     */
    @Column
    private String dimensions;

    /**
     * 权重值
     */
    @Column
    private String weightValue;
    /**
     * 寿命单位
     */
    @Column
    private String unitOfLife;
    /**
     * 备注
     */
    @Column
    private String remarks;
    /**
     * 提前预警量
     */
    @Column
    private String earlyWarningQuantity;
    public AccessoryMaterial() {}

    public AccessoryMaterial(Long id) {
        this.id = id;
    }

}
