package cn.estsh.i3plus.pojo.mes.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"),
        @Index(columnList = "CREATE_DATE_TIME"),
        @Index(columnList = "MODIFY_DATE_TIME"),
        @Index(columnList = "ITEM_PART_NO")
})
@Api("产品绑定记录表")
public class MesProdBindRecord extends BaseBean implements Serializable {
    private static final long serialVersionUID = -6984193022328810942L;

    // 联合唯一索引必须加:, nullable = false
    @Column(name = "SERIAL_NUMBER", nullable = false)
    @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", nullable = false)
    @ApiParam("原材料条码")
    private String kpSn;

    @Column(name = "KP_QTY", columnDefinition = "decimal(18,8)")
    @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;

    @Transient
    @ApiParam(value = "是否绑定关键件名称")
    private String isBindKeyName;

    @Transient
    @ApiParam(value = "动作类型名称")
    private String actionTypeName;

    @Transient
    @ApiParam("产品条码零件名称")
    private String partName;

    @Column(name = "ITEM_PART_NAME")
    @ApiParam("原材料零件名称")
    private String itemPartName;

    @Transient
    @ApiParam("生产队列号")
    private String orderNo;

    @Transient
    @ApiParam("产品条码")
    private String productSn;


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

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