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", indexes = {
        @Index(columnList = "CUST_FLAG_NO"),
        @Index(columnList = "ORGANIZE_CODE"),
        @Index(columnList = "ORDER_NO")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = {"ORGANIZE_CODE", "ORDER_NO"})
})
@Api("生产队列主表")
public class MesQueueOrder extends BaseBean implements Serializable {
    private static final long serialVersionUID = -7459452106180601417L;

    @Column(name = "ORDER_NO", nullable = false)
    @ApiParam("主队列编号")
    private String orderNo;

    @Column(name = "VIN_CODE")
    @ApiParam("Vin")
    private String vinCode;

    @Column(name = "CUST_FLAG_NO")
    @ApiParam("客户标识号")
    private String custFlagNo;

    @Column(name = "PROD_CFG_CODE")
    @ApiParam("产品配置代码")
    private String prodCfgCode;

    @Column(name = "PROD_CFG_NAME_RDD")
    @ApiParam("产品配置名称")
    private String prodCfgNameRdd;

    @Column(name = "SEQ", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("排序")
    private Double seq;

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

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

    @Column(name = "CUST_PROD_LINE_CODE")
    @ApiParam("客户产线代码")
    private String custProdLineCode;

    @Column(name = "AREA_CODE")
    @ApiParam("区域代码")
    private String areaCode;

    @Column(name = "IS_LOCK")
    @ApiParam("锁定标识")
    private Integer isLock;

    @Column(name = "CUST_CODE")
    @ApiParam("客户代码")
    private String custCode;

    @Column(name = "WORK_TYPE")
    @ApiParam("工单类型")
    private String workType;

    @Column(name = "QUEUE_TYPE")
    @ApiParam("队列类型")
    private Integer queueType;

    @Column(name = "PG_CODE")
    @ApiParam("生产组代码")
    private String pgCode;

    @Column(name = "JIT_LOT_NO")
    @ApiParam("JIT队列批次")
    private String jitLotNo;

    @Column(name = "JIT_ACTUAL_NO")
    @ApiParam("客户JIT队列编号")
    private String jitActualNo;

    @Column(name = "PROD_CFG_TYPE_CODE")
    @ApiParam("项目代码")
    private String prodCfgTypeCode;

    @Column(name = "MODEL_YEAR")
    @ApiParam("年度型")
    private String modelYear;

    @Column(name = "GRADE_CODE")
    @ApiParam("等级代码")
    private String gradeCode;

    @Column(name = "JIT_SEQ")
    @ApiParam("JIT排序号")
    private String jitSeq;

    @Column(name = "SPECIAL_FLAG")
    @ApiParam("特殊标识")
    private Integer specialFlag;

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

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

    @Transient
    @ApiParam("起始车号")
    private String custFlagNoStart;

    @Transient
    @ApiParam("截至车号")
    private String custFlagNoEnd;

    @Transient
    @ApiParam("工单类型名称")
    private String workTypeName;

    @Transient
    @ApiParam("锁定标识名称")
    private String isLockName;

    @Transient
    @ApiParam("队列类型名称")
    private String queueTypeName;

    @Transient
    @ApiParam("产品颜色")
    private String colorName;

    @Transient
    @ApiParam("零件号")
    private String partNo;

    @Transient
    @ApiParam("零件名称")
    private String partNameRdd;

    @Transient
    @ApiParam("箱数")
    private Integer boxQty;

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

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

    @Transient
    @ApiParam("数量")
    private Double qty;

    @Transient
    @ApiParam("已生产数量")
    private Double finsihQty;

    public MesQueueOrder(){}

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

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

    public MesQueueOrder(Double seq, String partNo, String partNameRdd,Integer boxQty,
                               Integer queueType,Integer status,String createUser,
                         String createDatetime,String modifyUser,String modifyDatetime,String workType,String orderNo) {
        this.seq = seq;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.boxQty = boxQty;
        this.queueType = queueType;
        this.status = status;
        this.createUser = createUser;
        this.createDatetime = createDatetime;
        this.modifyUser = modifyUser;
        this.modifyDatetime = modifyDatetime;
        this.workType = workType;
        this.orderNo = orderNo;
    }
    public MesQueueOrder(Long id, Double seq, String partNo, String partNameRdd,Integer boxQty,
                               Integer queueType,Integer status,String createUser,
                         String createDatetime,String modifyUser,String modifyDatetime,String workType,String orderNo,
                         String workCenterCode, String workCellCode, Double qty, Double finsihQty) {
        this.id = id;
        this.seq = seq;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.boxQty = boxQty;
        this.queueType = queueType;
        this.status = status;
        this.createUser = createUser;
        this.createDatetime = createDatetime;
        this.modifyUser = modifyUser;
        this.modifyDatetime = modifyDatetime;
        this.workType = workType;
        this.orderNo = orderNo;
        this.workCenterCode = workCenterCode;
        this.workCellCode = workCellCode;
        this.qty = qty;
        this.finsihQty = finsihQty;
    }

}
