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

import java.math.BigDecimal;
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 org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.sw.mes.base.factory.product.entity.FbProductModel;

import lombok.Data;

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

    /**
     * GUID,PLNATID+DATE+TIME+流水
     */
    @Column(length = 80)
    private String tid;

    /**
     * SAP char(12)
     * SAP中最多12位
     * 订单编号
     */
    @Column(length = 12)
    private String aufnr;

    /**
     * FAB Name
     * 工厂编码
     */
    @Column(length = 40)
    private String werks;

    /**
     * need to sync with SAP
     * 需要与SAP一致
     * 订单类型
     */
    @Column(length = 40)
    private String auart;

    /**
     * Product ID
     * 产品料号
     */
    @Column(length = 18)
    private String matnr;

    /**
     * 数量
     */
    @Column(length = 19)
    private BigDecimal menge;

    /**
     * 单位
     */
    @Column(length = 30)
    private String meins;

    /**
     * 1 ~ 9，业务可能调整
     */
    @Column(length = 20)
    private String aprio;

    /**
     * Null, Reserve
     * 空白，保留字段
     */
    @Column(length = 40)
    private String customerid;

    /**
     * Sales Order
     * 销售订单信息
     */
    @Column(length = 40)
    private String salesorder;

    /**
     * Owner
     * 负责人
     */
    @Column(length = 40)
    private String ownerengineer;

    /**
     * Plan End Date
     * 计划结束时间
     */
    @Column(length = 20)
    private Date gltrp;

    /**
     * Plan Start Date
     * 计划开始时间
     */
    @Column(length = 20)
    private Date gstrp;

    /**
     * ORDER STATUS
     * 订单状态
     */
    @Column(length = 40)
    private String status;

    /**
     * Comment
     * 订单备注
     */
    @Column(length = 255)
    private String comment;

    /**
     * 保税号
     */
    @Column(length = 30)
    private String bonded;

    /**
     * 研发项目编号
     */
    @Column(length = 20)
    private String rdNum;

    /**
     * 晶体板块用来标注特殊圆棒或方棒的字段
     */
    @Column(length = 20)
    private String rdInd;

    /**
     * 预留字段
     */
    @Column(length = 40)
    private String field1;

    /**
     * 预留字段
     */
    @Column(length = 40)
    private String field2;

    /**
     * 预留字段
     */
    @Column(length = 40)
    private String field3;

    /**
     * 预留字段
     */
    @Column(length = 40)
    private String field4;

    /**
     * 预留字段
     */
    @Column(length = 40)
    private String field5;

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

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

    /**
     * 加工能力编码
     */
    @Column(length=10)
    private Integer capacityKfinfoId;

    /**
     * 是否生产
     */
    private Boolean productionStatus;

    public FbProductionOrder() {
    }

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