package cn.estsh.i3plus.pojo.mes.pcn.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @Description :产品绑定记录表
 * @Reference :
 * @Author : jack.jia
 * @CreateDate : 2019-04-02
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_PROD_BIND_RECORD", indexes = {
        @Index(columnList = "SERIAL_NUMBER"),
        @Index(columnList = "KP_SN")
})
@Api("产品绑定记录表")
public class MesProdBindRecord extends BaseBean implements Serializable {
    private static final long serialVersionUID = -4319604821328717354L;
    @Column(name = "SERIAL_NUMBER")
    @ApiParam(value = "产品条码")
    private String serialNumber;

    @Column(name = "PART_NO")
    @ApiParam("产品条码零件号")
    private String partNo;

    @Column(name = "WORK_ORDER_NO")
    @ApiParam("工单号")
    private String workOrderNo;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam(value = "工作中心")
    private String workCenterCode;

    @Column(name = "WORK_CELL_CODE")
    @ApiParam(value = "工作单元")
    private String workCellCode;

    @Column(name = "STEP_CODE")
    @ApiParam(value = "工步代码")
    private String stepCode;

    @Column(name = "ITEM_PART_NO")
    @ApiParam("原材料零件号")
    private String itemPartNo;

    @Column(name = "KP_SN")
    @ApiParam("原材料条码")
    private String kpSn;

    @Column(name = "KP_QTY")
    @ColumnDefault("0")
    @ApiParam(value = "原材料数量", example = "0")
    private Double kpQty;

    @Column(name = "SUPPLIER_CODE")
    @ApiParam("供应商")
    private String supplierCode;

    @Column(name = "LOT_NO")
    @ApiParam("关联批次")
    private String lotNo;

    @Column(name = "IS_FEED")
    @ApiParam("是否投料配置")
    private Integer isFeed;

    @Column(name = "VERSION")
    @ApiParam("版本")
    private String version;

    @Column(name = "RESULT")
    @ApiParam(value = "结果")
    private String result;

    @Column(name = "is_BIND_KEY")
    @ApiParam(value = "是否绑定关键件")
    private Integer isBindKey;

    @Column(name = "ACTION_TYPE")
    @ApiParam(value = "动作类型")
    private Integer actionType;

    public int getIsFeedVal() {
        return this.isFeed == null ? 0 : this.isFeed;
    }

    public double getQtyVal() {
        return this.kpQty == null ? 0.0d : this.kpQty;
    }
}
