/**
 * 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 com.sw.mes.base.factory.material.entity.MaterialModel;
import com.sw.mes.core.annotation.Jinko;
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.sw.mes.base.factory.product.entity.ProductModel;

import lombok.Data;

/**
 * @Author
 * @Description：
 * @Date: Create in
 * @Modified By:
 */
@Data
@Entity
@Table(name = "plan_production_order")
@DynamicUpdate
@DynamicInsert
public class ProductionOrder {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
 
    /**
     * GUID,PLNATID+DATE+TIME+流水
     */
    @Column(length = 80)
    private String tid;

    /**
     * SAP char(12)
     * SAP中最多12位
     * 订单编号
     */
    @Column
    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;

    /**
     * Sales Order
     * 销售订单行号
     */
    @Column(length = 40)
    private String kdpos;

    /**
     * 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
     * 订单状态  REL/TECO/DLFL
     */
    @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;
    /**
     * 工厂模式id
     */
    @Column
    private Integer factoryId;
    /**
     *
     */
    @Column(length = 19)
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;

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

    @Jinko(value = "针对晶科修改物料主数据绑定订单",author = "liru")
    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action= NotFoundAction.IGNORE)
    @JoinColumn(name = "material_model_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MaterialModel materialModel;

    /**
     * 研发唯一标识
     */
    @Column(length=20)
    private String rdonlylogo;

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

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

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

    /**
     * 电阻类型
     */
    @Column
    private String resistanceType;

    /**
     * 方棒边长范围
     */
    @Column(length = 50)
    private String sideLengthRange;


    @ApiModelProperty(value = "车间")
    private String workShop;

    @ApiModelProperty(value = "溯源标识")
    private String fromMark;

    @ApiModelProperty(value = "基地")
    private String baseMark;

    @ApiModelProperty(value = "方棒订单号")
    private String fbOrderNo;

    @ApiModelProperty(value = "部门编码")
    private String deptCode;

    @ApiModelProperty(value = "erp订单单号")
    private String erpOrderNo;

    @ApiModelProperty(value = "erp订单详情id")
    private String modid;

    @ApiModelProperty(value = "工单类型描述")
    private String auarttxt;
    @ApiModelProperty(value = "组合号")
    private String zCollectNo;
    @ApiModelProperty(value = "组合行号")
    private String zCollectItm;
    @ApiModelProperty(value = "安装孔距")
    private String zeinr;
    @ApiModelProperty(value = "技术文件编号")
    private String zjswjbh;
    @ApiModelProperty(value = "名称1")
    private String name1;
    @ApiModelProperty(value = "目的地国家")
    private String zzlandd;
    @ApiModelProperty(value = "工序号")
    private String vornr;
    @ApiModelProperty(value = "特征名称")
    private String atnam;
    @ApiModelProperty(value = "特性描述")
    private String tbez;
    @ApiModelProperty(value = "特性值")
    private String atwrt;
    @ApiModelProperty(value = "特性值文本")
    private String atwtb;

    //对应绑定物料信息
    @Column
    private String wgbez;
    @Column
    private String mtbez;
    @Column
    private String vtext;
    @Column
    private String matkl;
    @Column
    private String brgew;
    @Column
    private String ntgew;
    @Column
    private String laeng;
    @Column
    private String breit;
    @Column
    private String hoehe;
    //工作中心类别 20240105新增
    @Column
    private String zarbplLb;
    //外发标识 20240106新增
    @Column
    private String zwfFlag;
    //销售订单行需求数量
    private String netGamng;
    
    
    private String bezei;
    
    private String zzcountry;


    /**
     * 设备类别(1:单晶, 3:刀刨, 4:截断, 5:其他)
     */
    @Column
    private Integer category;


    @ApiModelProperty(value = "生产工作类型:数据字典中配置 圆棒,方棒,截断..... FactoryModelWorkTypeEnum")
    private Integer workType;
    
    /**拉晶工单定向标识**/
    private String zorientationind;

    /**
     * 是否被排程 0未被排程，1已被排程
     */
    @Column
    private Integer scheduled = 0;


    public ProductionOrder() {
    }

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

}
