package cn.estsh.i3plus.pojo.wms.bean;

import cn.estsh.i3plus.pojo.base.annotation.DynamicField;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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.*;

/**
 * @Description : PO条码表
 * @Reference :
 * @Author : hansen.ke
 * @CreateDate : 2018-11-28 15:20
 * @Modify:
 *  2018-12-10 10:39:46 Test
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="WMS_DOC_PO_SN", indexes = {
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "PART_NO"),
        @Index(columnList = "SN_1D"),
        @Index(columnList = "SN_2D"),
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("PO条码信息")
public class WmsPoSn extends BaseBean {

    private static final long serialVersionUID = -5493787929463992199L;
    @Column(name="ORDER_NO")
    @ApiParam("订单号")
    public String orderNo;

    @Column(name="ITEM")
    @ApiParam("行号")
    public String item;

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

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

    @Column(name="QTY", columnDefinition = "decimal(18,8)", nullable = false)
    @ColumnDefault("0")
    @ApiParam(value = "数量", example = "0")
    public Double qty;


    @Column(name="UNIT")
    @ApiParam("单位")
    public String unit;

    /**
     * 状态:10 = 创建，20 = 已打印，30 = 已收货
     */
    @Column(name="SN_STATUS")
    @ApiParam(value = "状态", example = "10")
    public Integer snStatus;
    /**
     * 质量:10-合格 20-不合格 30-隔离 40-报废
     */
    @Column(name="QC_STATUS")
    @ApiParam(value = "质量状态", example = "10")
    public Integer qcStatus;

    @Column(name="PACKAGE")
    @ApiParam("包装名称")
    public String packAge;

    @Column(name="SN_1D")
    @ApiParam("一维条码")
    public String snOneBarCode;

    @Column(name="SN_2D")
    @ApiParam("二维条码")
    public String snTwoBarCode;

    @Column(name="GROUP_NO")
    @ApiParam("组条码")
    public String groupNo;

    @Column(name="REC_QTY", columnDefinition = "decimal(18,8)", nullable = false)
    @ColumnDefault("0")
    @ApiParam(value = "收货数量", example = "0")
    public Double recQty;

    @Column(name = "ERP_AREA_NO_ADD")
    @ApiParam("默认收货库存地")
    private String erpAreaNoAdd;

    @Column(name = "VENDOR_NO")
    @ApiParam(value = "供应商编码")
    public String vendorNo;

//    @Column(name = "DATE_CODE", nullable = false)
//    @ApiParam(value = "供应商生产批次")
//    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
//    public String dateCode = "";

    @ApiParam(value = "供应商名称")
    @Transient
    public String vendorNameRdd;

    @ApiParam(value = "项目名称")
    @Transient
    public String prodCfgTypeName;

    @ApiParam(value = "标签编号")
    @Transient
    public String labelNo;

    @ApiParam(value = "送货批号")
    @Transient
    public String lotNo;

    @Column(name = "DATE_CODE", nullable = false)
    @ApiParam(value = "供应商生产日期")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    public String dateCode;

    @Transient
    @ApiParam(value = "订单号")
    public String refSrc;

    @Transient
    @ApiParam(value = "条码")
    public String sn;

    @Transient
    @ApiParam(value = "工厂名称")
    public String organizeName;

    @Transient
    @ApiParam(value = "最早收货时间")
    public String earliestReceTime;

    @Transient
    @ApiParam(value = "最晚收货时间")
    public String latestReceTime;

    @Column(name = "FIX_LOT_NO")
    @ApiParam(value = "特殊批次")
    private String fixLotNo = "";

    @Transient
    @ApiParam("父层级packcode对应的可回用零件号")
    private String parentReturnPart;

    @Transient
    @ApiParam(value = "生产批次")
    private String leftCode = "";

    @Transient
    @ApiParam("erp单号")
    private String erpSrcNo;

    @Transient
    @ApiParam("仓库")
    private String whNo;

    @Transient
    @ApiParam("汇总数量")
    private Double sumQty;

    @Transient
    @ApiParam("物料库位")
    private String partLocateNo;

    @Transient
    @ApiParam("备注1")
    private String remark1;

    @Transient
    @ApiParam("备注2")
    private String remark2;

    public WmsPoSn(){}

    public WmsPoSn(String orderNo,String earliestReceTime,String latestReceTime){
        this.orderNo = orderNo;
        this.earliestReceTime = earliestReceTime;
        this.latestReceTime = latestReceTime;
    }

    public WmsPoSn(String orderNo,String erpSrcNo,String item,String partNo,String lotNo,String dateCode,String whNo,
                   String createDatetime,Double sumQty){
        this.orderNo = orderNo;
        this.erpSrcNo = erpSrcNo;
        this.item = item;
        this.partNo = partNo;
        this.lotNo = lotNo;
        this.dateCode = dateCode;
        this.whNo = whNo;
        this.createDatetime = createDatetime;
        this.sumQty = sumQty;
    }
}
