package cn.estsh.i3plus.ext.mes.pojo.bean;

import cn.estsh.i3plus.ext.mes.pojo.util.MesExtEnumUtil;
import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
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;

/**
 * @author yumingxing
 * @version 1.0
 * @date 2021/1/29 13:58
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "MES_OQC_CHECK", indexes = {
        @Index(columnList = "OQC_NO"),
        @Index(columnList = "WORK_CENTER_CODE"),
        @Index(columnList = "PART_NO"),
        @Index(columnList = "WORK_ORDER_NO"),
        @Index(columnList = "WORK_TIME"),
        @Index(columnList = "CHECK_TIME"),
        @Index(columnList = "WORK_TIME,PART_NO"),
        @Index(columnList = "CHECK_TIME,PART_NO"),
        @Index(columnList = "CHECK_TIME,WORK_CENTER_CODE"),
        @Index(columnList = "CHECK_TIME,CHECK_RESULT"),
        @Index(columnList = "CHECK_TIME,WORK_CENTER_CODE,CHECK_RESULT"),
        @Index(columnList = "WORK_ORDER_NO,SHIFT_CODE,WORK_TIME"),
        @Index(columnList = "WORK_ORDER_NO,SHIFT_CODE,WORK_TIME,PACKAGE_NO")
})
@Api("MES_出货检验单主表")
public class MesOqcCheck extends BaseBean implements Serializable {

    private static final long serialVersionUID = 5638814501089899420L;

    @Column(name = "OQC_NO")
    @ApiParam("单据号")
    private String oqcNo;

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

    @Column(name = "WORK_ORDER_TYPE")
    @ApiParam("工单类型")
    private Integer workOrderType;

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

    @Column(name = "PACKAGE_NO")
    @ApiParam("包装条码")
    private String packageNo;

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

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

    @Column(name = "SN_TYPE")
    @ApiParam("扫描条码类型:产品条码=10,包装条码=20")
    private String snType;

    @Column(name = "OQC_TYPE")
    @ApiParam("检测方式")
    @AnnoOutputColumn(refClass = MesExtEnumUtil.OQC_TYPE.class, refForeignKey = "value", value = "description")
    private Integer oqcType;

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

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

    @Column(
            name = "OQC_Qty",
            columnDefinition = "decimal(18,8)"
    )
    @ColumnDefault("0")
    @ApiParam("检测数量")
    private Double oqcQty;

    @Column(name = "WORK_TIME")
    @ApiParam("生产日期")
    private String workTime;

    @Column(name = "SHIFT_CODE")
    @ApiParam("班次代码")
    private String shiftCode;

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

    @Column(name = "DUTY_DIFF")
    @ApiParam("原因区分")
    private String dutyDiff;

    @Column(name = "CHECK_RESULT")
    @ApiParam("检验结果")
    @AnnoOutputColumn(refClass = MesExtEnumUtil.OQC_CHECK_RESULT.class, refForeignKey = "value",
            value = "description", hidden = true)
    private Integer checkResult;

    @Column(name = "CHECK_USER")
    @ApiParam("检验人")
    private String checkUser;

    @Column(name = "CHECK_TIME")
    @ApiParam("检验时间")
    private String checkTime;

    @Column(name = "REMARK")
    @ApiParam("备注")
    private String remark;

    //----BU-----
    @Column(name = "SPOT_CHECK_QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam("抽检数量")
    private Double spotCheckQty;

    @Column(name = "OQC_NO_TYPE")
    @ApiParam("检验单类型")
    @AnnoOutputColumn(refClass = MesExtEnumUtil.OQC_CHECK_TYPE.class, refForeignKey = "value", value = "description")
    private Integer oqcNoType;

    @Column(name = "CATEGORY_CODE3")
    @ApiParam("产品类别")
    private String categoryCode3;

    @Column(name = "BADNESS_TYPE_CODE")
    @ApiParam("不良类型代码")
    private String badnessTypeCode;

    @Column(name = "BADNESS_CLASSIFY_CODE")
    @ApiParam("不良分类代码")
    private String badnessClassifyCode;

    @Column(name = "BADNESS_CLASSIFY_DETAIL_CODE")
    @ApiParam("不良分类明细代码")
    private String badnessClassifyDetailCode;

    @Column(name = "BADNESS_CLASSIFY_DETAIL_NAME")
    @ApiParam("不良分类明细名称")
    private String badnessClassifyDetailName;

    @Column(name = "SYSTEM_SYNC_STATUS")
    @ColumnDefault("2")
    @ApiParam("系统同步标志 MES-PCN互相同步用")
    public Integer systemSyncStatus = 2;

}
