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.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

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

/**
 * @Description:
 * @Reference:
 * @Author: Crish
 * @CreateDate:2019-04-16-17:36
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_QUEUE_ORDER_DETAIL", indexes = {
        @Index(columnList = "ORDER_NO")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = {"ORGANIZE_CODE", "ORDER_NO", "PART_NO"})
}
)
@Api("生产队列明细")
public class MesQueueOrderDetail extends BaseBean implements Serializable {
    private static final long serialVersionUID = 1548933241804083457L;
    @Column(name = "ORDER_NO", nullable = false)
    @ApiParam("主队列编号")
    private String orderNo;

    @Column(name = "PART_NO", nullable = false)
    @ApiParam("物料号")
    private String partNo;

    @Column(name = "PART_NAME_RDD")
    @ApiParam("物料名称")
    private String partNameRdd;

    @Column(name = "SERIAL_NUMBER")
    @ApiParam("产品条码")
    private String serialNumber;

    @Column(name = "SEQ")
    @ApiParam("队列明细序号")
    private Double seq;

    @Column(name = "QTY")
    @ApiParam("数量")
    private Double qty;

    @Column(name = "STATUS")
    @ApiParam("状态")
    private Integer status;

    @Column(name = "WORK_TYPE")
    @ApiParam("生产类型")
    private String workType;

    @Column(name = "PRODUCE_CATEGORY_CODE")
    @ApiParam("产品类型代码")
    private String produceCategoryCode;

    @Column(name = "PRODUCE_CATEGORY_NAME_RDD")
    @ApiParam("产品类型名称")
    private String produceCategoryNameRdd;

    @Transient
    @ApiParam("队列序号")
    private Double queueSeq;

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

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

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

    public int getStatusVal() {
        return this.status == null ? 0 : this.status;
    }

    public MesQueueOrderDetail() {
    }

    public MesQueueOrderDetail(Double queueSeq, Double seq, String serialNumber) {
        this.queueSeq = queueSeq;
        this.seq = seq;
        this.serialNumber = serialNumber;
    }
}
