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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.WmsEnumUtil;
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.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description : 盘点单冻结信息
 * @Reference :
 * @Author : silliter.yuan
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_DOC_CS_DETAILS", indexes = {
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "VENDOR_NO"),
        @Index(columnList = "SN")
})
@Api("盘点单冻结信息")
public class WmsCSOrderDetails extends BaseBean {
    private static final long serialVersionUID = 1054153436116196360L;
    @Column(name = "PART_NO")
    @ApiParam("物料编码")
    public String partNo;

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

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

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

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

    @Column(name = "ORDER_NO")
    @ApiParam("订单号")
    public String orderNo;

    @Column(name = "WH_NO")
    @ApiParam("仓库代码")
    public String whNo;

    @Column(name = "ZONE_NO")
    @ApiParam("存储区编号")
    public String zoneNo;

    @Column(name = "LOCATE_NO")
    @ApiParam("库位编号")
    public String locateNo;

    @Column(name = "SN")
    @ApiParam("条码")
    public String sn;

    /**
     * 质检状态:1=未质检,10=质检中,20=质检合格,
     * 30=质检不合格,40=已退货
     */
    @Column(name = "QC_STATUS")
    @ApiParam(value = "质检状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_QC_STATUS.class,refForeignKey = "value",value = "description")
    public Integer qcStatus;

    /**
     * 条码状态:1=创建,10=已收货,20=已质检,
     * 30=已入库,40=待出库,50=已出库,
     * 60=在途,70=已隔离,80=破包,90=冻结,100=作废
     */
    @Column(name = "SN_STATUS")
    @ApiParam(value = "条码状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_STATUS.class,refForeignKey = "value",value = "description")
    public Integer snStatus;

    @Column(name = "DEST_SN_STATUS")
    @ApiParam(value = "条码状态(冻结时)", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_STATUS.class,refForeignKey = "value",value = "description")
    public Integer destSnStatus;

    /**
     * 处理状态:10=已创建,20=已盘,30=已冻结,40=已解冻,50=取消冻结 60=未盘解冻
     */
    @Column(name = "TRANS_STATUS")
    @ApiParam(value = "处理状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.CS_TRANS_STATUS.class,refForeignKey = "value",value = "description")
    public Integer transStatus;

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

    @Column(name = "LOT_NO")
    @ColumnDefault("")
    @ApiParam("收货批次")
    public String lotNo = "";

    @Transient
    @ApiParam(value = "实盘数量", example = "1")
    @AnnoOutputColumn(hidden = true)
    public Double factQty;

    @Transient
    @ApiParam(value = "差异数量", example = "1")
    @AnnoOutputColumn(hidden = true)
    public Double surplusQty;

    @Transient
    @ApiParam("目标库位编号")
    @AnnoOutputColumn(hidden = true)
    public String destLocateNo;

    @Transient
    @ApiParam("前端表格编辑使用")
    @AnnoOutputColumn(hidden = true)
    public Boolean isSet = false;

    @Transient
    @ApiParam("源单位")
    @AnnoOutputColumn(hidden = true)
    public String srcUnit;

    @Transient
    @ApiParam("存储区编号")
    @AnnoOutputColumn(hidden = true)
    public String[] zoneNos;

    /**
     * 差异类型：10：盘平，20：盘亏，30盘盈
     */
    @Transient
    @ApiParam("差异类型")
    @AnnoOutputColumn(refClass = WmsEnumUtil.INVENTORY_DIFFERENCE_TYPE.class,refForeignKey = "value",value = "description")
    public Integer differenceType;

    /**
     * 差异类型：10：盘平，20：盘亏，30盘盈
     */
    @Transient
    @ApiParam("差异集合")
    @AnnoOutputColumn(refClass = WmsEnumUtil.INVENTORY_DIFFERENCE_TYPE.class, refForeignKey = "value", value = "description")
    public List<Integer> differenceTypeList;

    public Integer getDifferenceTypeVal() {
        return this.differenceType == null ?
        -1: this.differenceType;
    }

    public Double getQty() {
        return this.qty == null ? 0 : this.qty;
    }

    public WmsCSOrderDetails(){}

    public WmsCSOrderDetails(Double qty, String partNo,String orderNo,String partName,String whNo,String zoneNo,String locateNo){
        this.qty = qty;
        this.partNo = partNo;
        this.orderNo = orderNo;
        this.partNameRdd = partName;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
    }

    public WmsCSOrderDetails(Double qty, String partNo,String orderNo,String whNo,String zoneNo,String locateNo,String partName,String sn){
        this.qty = qty;
        this.partNo = partNo;
        this.orderNo = orderNo;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
        this.partNameRdd = partName;
        this.sn = sn;
    }

    public WmsCSOrderDetails(Double qty, String partNo,String orderNo,String whNo,String zoneNo,String locateNo,String partName,String sn,Long id,String organizeCode,Integer transStatus){
        this.qty = qty;
        this.partNo = partNo;
        this.orderNo = orderNo;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
        this.partNameRdd = partName;
        this.sn = sn;
        this.id = id;
        this.organizeCode = organizeCode;
        this.transStatus = transStatus;
    }
    public WmsCSOrderDetails(String partNo,String partNameRdd,String unit, String orderNo, String organizeCode,double qty) {
        this.partNo=partNo;
        this.partNameRdd = partNameRdd;
        this.unit = unit;
        this.orderNo = orderNo;
        this.organizeCode = organizeCode;
        this.qty=qty;
    }

    public WmsCSOrderDetails (String orderNo, String partNo,String partNameRdd, String locateNo, double qty, double factQty){
    	this.orderNo=orderNo;
        this.partNo=partNo;
        this.partNameRdd=partNameRdd;
        this.qty=qty;
        this.factQty=factQty;
        this.locateNo=locateNo;
    }

    public WmsCSOrderDetails(String partNo,String partNameRdd) {
        this.partNo=partNo;
        this.partNameRdd = partNameRdd;
    }
}
