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_PRODUCE_SN", indexes = {
        @Index(columnList = "PRODUCT_SN"),
        @Index(columnList = "CREATE_DATE_TIME")
}, uniqueConstraints = {
        @UniqueConstraint(columnNames = {"ORGANIZE_CODE", "SERIAL_NUMBER"})
}
)
@Api("产品条码表")
public class MesProduceSn extends BaseBean implements Serializable {

    private static final long serialVersionUID = 6641051790330191326L;

    @Column(name = "SERIAL_NUMBER", nullable = false)
    @ApiParam("过程条码")
    private String serialNumber;

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

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

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

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

    @Column(name = "QC_STATUS")
    @ApiParam("质量状态")
    private Integer qcStatus;

    @Column(name = "SN_STATUS")
    @ApiParam("条码状态")
    private Integer snStatus;

    @Column(name = "PRINT_COUNT")
    @ApiParam("打印次数")
    private Integer printCount;

    @Column(name = "PRINT_STATUS")
    @ApiParam("打印状态")
    private Integer printStatus;

    @Column(name = "WORK_CENTER_CODE")
    @ApiParam("生产线")
    private String workCenterCode;

    @Column(name = "WORK_CELL_CODE")
    @ApiParam("工位")
    private String workCellCode;

    @Column(name = "ROUTE_CODE")
    @ApiParam("流程代码")
    private String routeCode;

    @Column(name = "PROCESS_CODE")
    @ApiParam("工序代码")
    private String processCode;

    @Column(name = "NEXT_PROCESS_CODE")
    @ApiParam("下一工序代码")
    private String nextProcessCode;

    @Column(name = "IN_WC_TIME")
    @ApiParam("进产线时间")
    private String inWorkCenterTime;

    @Column(name = "OUT_WC_TIME")
    @ApiParam("出产线时间")
    private String outWorkCenterTime;

    @Column(name = "SHIPPING_TIME")
    @ApiParam("发运时间")
    private String shippingTime;

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

    @Column(name = "CUST_SN")
    @ApiParam("客户条码")
    private String custSn;

    @Column(name = "CUST_PART_NO")
    @ApiParam("客户零件号")
    private String custPartNo;

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

    @Column(name = "SN_TYPE")
    @ApiParam("条码类型 10=正常 20=首检件")
    private Integer snType;

    @Column(name = "TRAY_NO")
    @ApiParam("托盘号")
    private String trayNo;
//
//    @Version
//    @Column(name = "LOCK_VERSION")
//    @ApiParam(value = "乐观锁", example = "1")
//    public transient Integer lockVersion;

    @Transient
    @ApiParam("返回信息")
    private String resultMsg;

    @Column(name = "OPERATE_TYPE")
    @ApiParam("操作类型")
    private Integer operateType;

    @Transient
    @ApiParam("下线时间开始")
    private String outWorkCenterTimeStart;

    @Transient
    @ApiParam("下线时间截止")
    private String outWorkCenterTimeEnd;

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

    public int getQcStatusVal() {
        return this.qcStatus == null ? 0 : this.qcStatus;
    }

    public int getSnStatusVal() {
        return this.snStatus == null ? 0 : this.snStatus;
    }

    public int getPrintCountVal() {
        return this.printCount == null ? 0 : this.printCount;
    }

    public int getPrintStatusVal() {
        return this.printStatus == null ? 0 : this.printStatus;
    }

    public int getSnTypeVal() {
        return this.snType == null ? 0 : this.snType;
    }

    @Override
    public String toString() {
        return "MesProduceSn{" +
                "serialNumber='" + serialNumber + '\'' +
                ", partNo='" + partNo + '\'' +
                ", partNameRdd='" + partNameRdd + '\'' +
                ", qty=" + qty +
                ", qcStatus=" + qcStatus +
                ", snStatus=" + snStatus +
                ", printCount=" + printCount +
                ", printStatus=" + printStatus +
                ", workCenterCode='" + workCenterCode + '\'' +
                ", workCellCode='" + workCellCode + '\'' +
                ", routeCode='" + routeCode + '\'' +
                ", processCode='" + processCode + '\'' +
                ", nextProcessCode='" + nextProcessCode + '\'' +
                ", inWorkCenterTime='" + inWorkCenterTime + '\'' +
                ", outWorkCenterTime='" + outWorkCenterTime + '\'' +
                ", shippingTime='" + shippingTime + '\'' +
                ", workOrderNo='" + workOrderNo + '\'' +
                ", custSn='" + custSn + '\'' +
                ", custPartNo='" + custPartNo + '\'' +
                ", snType=" + snType +
                ", trayNo='" + trayNo + '\'' +
                ", resultMsg='" + resultMsg + '\'' +
                ", operateType=" + operateType +
                ", outWorkCenterTimeStart='" + outWorkCenterTimeStart + '\'' +
                ", outWorkCenterTimeEnd='" + outWorkCenterTimeEnd + '\'' +
                '}';
    }
}
