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.Table;
import javax.persistence.Transient;

/**
 * @Description : 盘点实盘信息
 * @Reference :
 * @Author : silliter.yuan
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="WMS_DOC_CS_FACTTRANS")
@Api("盘点实盘信息")
public class WmsCSFactTrans extends BaseBean {

    private static final long serialVersionUID = 4187069750607177519L;
    @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="PART_NO")
    @ApiParam("物料代码")
    public String partNo;

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

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

    @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="FACT_QTY", columnDefinition = "decimal(18,8)")
    @ColumnDefault("0")
    @ApiParam(value = "实盘数量", example = "0")
    public Double factQty;

    /**
     * 状态:1=创建,10=已处理
     */
    @Column(name="ITEM_STATUS")
    @ApiParam(value = "状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.MOVE_ORDER_STATUS.class,refForeignKey = "value",value = "description")
    public Integer itemStatus;

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

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

    @Column
    @AnnoOutputColumn(hidden = true)
    @ApiParam("源库位编号")
    public String srcLocateNo;

    @Column
    @AnnoOutputColumn(hidden = true)
    @ApiParam("源存储区编号")
    public String srcZoneNo;

    @Column
    @AnnoOutputColumn(hidden = true)
    @ApiParam("源仓库编号")
    public String srcWhNo;

    @Column
    @AnnoOutputColumn(hidden = true)
    @ApiParam("是否范围内")
    public Integer isScope;

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

    @Transient
    @AnnoOutputColumn(hidden = true)
    @ApiParam(value = "实盘箱数", example = "1")
    public Long countBoxQty;

    @Transient
    @AnnoOutputColumn(hidden = true)
    @ApiParam(value = "物料数量", example = "1")
    public Double sumPartQty;

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

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

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

    @Transient
    @AnnoOutputColumn(hidden = true)
    @ApiParam("行号")
    private String item;

    public WmsCSFactTrans(){}

    public Integer getIsScopeVal() {
        return isScope== null ? 0 : this.isScope.intValue();
    }

    public WmsCSFactTrans(Double factQty, String partNo){
        if(factQty == null) {
            this.factQty = 0d;
        }else{
            this.factQty = factQty;
        }
        this.partNo = partNo;
    }

    public WmsCSFactTrans(String orderNo, String whNo, String zoneNo, String locateNo,Double factQty, String partNo, String partNameRdd, String sn, Double qty, String unit, String srcLocateNo, String srcZoneNo, String srcWhNo) {
        this.orderNo = orderNo;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
        this.factQty = factQty;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.sn = sn;
        this.qty = qty;
        this.unit = unit;
        this.srcLocateNo = srcLocateNo;
        this.srcZoneNo = srcZoneNo;
        this.srcWhNo = srcWhNo;
    }

    public WmsCSFactTrans(String orderNo, String whNo, String zoneNo, String locateNo,Double factQty, String partNo, String partNameRdd, String sn, Double qty, String unit, String srcLocateNo, String srcZoneNo, String srcWhNo,String vendorNo) {
        this.orderNo = orderNo;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
        this.factQty = factQty;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.sn = sn;
        this.qty = qty;
        this.unit = unit;
        this.srcLocateNo = srcLocateNo;
        this.srcZoneNo = srcZoneNo;
        this.srcWhNo = srcWhNo;
        this.vendorNo= vendorNo;
    }
    public WmsCSFactTrans(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 WmsCSFactTrans(Long countBoxQty,Double sumPartQty,String zoneNo, String partNo, String partNameRdd) {
        this.countBoxQty = countBoxQty;
        this.sumPartQty = sumPartQty;
        this.zoneNo = zoneNo;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;

    }



}
