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: 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"),
        @Index(columnList = "SERIAL_NUMBER"),
        @Index(columnList = "QUEUE_GROUP_NO"),
        @Index(columnList = "PRODUCE_CATEGORY_CODE")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = {"ORGANIZE_CODE", "ORDER_NO", "PART_NO", "PRODUCE_CATEGORY_CODE"})
})
@Api("生产队列明细")
public class MesQueueOrderDetail extends BaseBean implements Serializable {
    private static final long serialVersionUID = 7840873844253353896L;

    @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", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("队列明细序号")
    private Double seq;

    @Column(name = "QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("数量")
    private Double qty;

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

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

    @Column(name = "PRODUCE_CATEGORY_CODE", nullable = false)
    @ApiParam("产品位置")
    private String produceCategoryCode;

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

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

    @Column(name = "QUEUE_GROUP_NO")
    @ApiParam("分组队列编号")
    private String queueGroupNo;

    @Column(name = "GROUP_NO")
    @ApiParam("组内编号")
    private Integer groupNo;

    @Column(name = "IS_GROUP_PRINTED")
    @ApiParam("料架是否已打印")
    private Integer isGroupPrinted = 2;

    @Column(name = "PRODUCE_COLOR")
    @ApiParam("产品颜色")
    private String produceColor;

    @Column(name = "PRODUCE_COLOR_CODE")
    @ApiParam("产品颜色代码")
    private String produceColorCode;

    @Column(name = "OPTION_CODE")
    @ApiParam("选项代码")
    private String optionCode;

    @Column(name = "ASSY_NO")
    @ApiParam("组件编号")
    private String assyNo;

    @Column(name = "FORMULA_CONTENT")
    @ApiParam("配方内容")
    private String formulaContent;

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

    @Column(name = "FINSIH_QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("已生产数量")
    private Double finsihQty;

    @Column(name = "GROUP_SIDE")
    @ApiParam("料架摆放位置")
    private String groupSide;

    @Column(name = "GROUP_SEQ")
    @ApiParam("分组序号")
    private String groupSeq;

    @Column(name = "PRODUCT_SN")
    @ApiParam("产品条码")
    private String productSn;

    @Column(name = "IS_EMPTY")
    @ApiParam("是否放空")
    private Integer isEmpty;

    @Column(name = "JIS_BACKFLUSH_STATUS")
    @ApiParam("回冲标识")
    private String jisBackflushStatus;

    @Transient
    @ApiParam("Vin")
    private String vinCode;

    @Transient
    @ApiParam("条码状态")
    private Integer snStatus;

    @Transient
    @ApiParam("开始时间")
    private String startTime;

    @Transient
    @ApiParam("结束时间")
    private String endTime;

    @Transient
    @ApiParam("过程标签模板")
    private String processLabelTemplate;

    @Transient
    @ApiParam("产品标签模板")
    private String prodLabelTemplate;

    @Transient
    @ApiParam("等级代码")
    private String gradeCode;

    @Transient
    @ApiParam("标志值集合")
    private String flagValueList;

    @Transient
    @ApiParam("质量标志值")
    private String qcFlagValue;

    @Transient
    @ApiParam("3C认证编码")
    private String cccCode;

    @Transient
    @ApiParam("条码标签描述")
    private String labelDesc;

    @Transient
    @ApiParam("打印时间")
    private String printTime;

    @Transient
    @ApiParam("年度型")
    private String modelYear;

    @Transient
    @ApiParam("主队列状态")
    private Integer masterStatus;

    @Transient
    @ApiParam("队列类型")
    private Integer queueType;

    @Transient
    @ApiParam("等级名称")
    private String gradeName;

    @Transient
    @ApiParam("客户产线代码")
    private String custProdLineCode;

    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 double getFinsihQtyVal() {
        return this.finsihQty == null ? 0.0d : this.finsihQty;
    }

    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;
    }

    public MesQueueOrderDetail(String orderNo, String vinCode, String partNo, String partNameRdd, String produceCategoryCode,
                               Integer status, String serialNumber, Double seq, Integer isGroupPrinted, String createDatetime,
                               String processLabelTemplate, String prodLabelTemplate,String optionCode,String produceColor,
                               String gradeCode,String assyNo,Integer queueType) {
        this.orderNo = orderNo;
        this.vinCode = vinCode;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.produceCategoryCode = produceCategoryCode;
        this.status = status;
        this.serialNumber = serialNumber;
        this.seq = seq;
        this.isGroupPrinted = isGroupPrinted;
        this.createDatetime = createDatetime;
        this.processLabelTemplate = processLabelTemplate;
        this.prodLabelTemplate = prodLabelTemplate;
        this.optionCode = optionCode;
        this.produceColor = produceColor;
        this.gradeCode = gradeCode;
        this.assyNo = assyNo;
        this.queueType = queueType;
    }
}
