/**
 * There are <a href="https://github.com/ketayao/keta-custom">keta-custom</a> code generation
 */
package com.sw.mes.yb.plan.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sw.mes.base.factory.init.entity.MachineCapacityInfo;
import com.sw.mes.base.factory.product.entity.ProductModel;

import lombok.Data;

/**
 * @Author
 * @Description：
 * @Date: Create in
 * @Modified By:
 */
@Data
@Entity
@Table(name = "plan_production_schedule")
@DynamicUpdate
@DynamicInsert
public class ProductionSchedule {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 炉次id
     */
    @Column(length = 10)
    private Long lotId;

    /**
     * 炉次号
     */
    @Column(length = 32)
    private String lotNo;

    /**
     * 工单编号
     */
    @Column(length = 32)
    private String code;

    /**
     * 设备id
     */
    @Column(length = 10)
    private Long deviceId;

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


    /**
     * 产品信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "product_model_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private ProductModel productModel;

    /**
     * 订单信息
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "production_order_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private ProductionOrder productionOrder;

    /**
     * 加工能力信息
     **/
    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "capacity_info_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MachineCapacityInfo capacityInfo;


    /**
     * 任务状态(0：即将开始,1：进行中,2：已完成,3：已取消,4：待备料,5：已备料)
     */
    @Column(nullable = false, length = 0)
    private Integer status;

    /**
     * 状态信息
     */
    @Column(length = 200)
    private String statusInfo;

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

    /**
     * 完成时间
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date closeTime;

    /**
     * 数量
     */
    @Column(length = 10)
    private Integer count;

    /**
     * 创建人id
     */
    @Column(length = 10)
    private Integer createUserId;

    /**
     * 创建人
     */
    @Column(length = 32)
    private String createUserName;

    /**
     * 炉台类型【0:默认；0-常规;2-研发;】
     */
    @Column(nullable = false, length = 3)
    private Integer furnaceType;

    /**
     * 产品类别
     */
    @Column(length=10)
    private String productType;


    /**
     * 炉内切换订单
     */
    @Column(length=10)
    private Boolean witchOrder;


    @ApiModelProperty(value = "发料编码")
    String deliveryNo;

    public ProductionSchedule() {
    }

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