package cn.estsh.i3plus.pojo.wms.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.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 javax.persistence.Version;
import java.util.List;
import java.util.Map;

/**
 * @Description : 库存信息
 * @Reference :
 * @Author : jessica.chen
 * @CreateDate : 2018-11-02 11:06
 * @Modify:
 **/
@Data
@Entity
@Table(name = "WMS_STOCK_QUAN", indexes = {
        @Index(columnList = "WH_NO"),
        @Index(columnList = "ZONE_NO"),
        @Index(columnList = "LOCATE_NO")
})
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value = "库存信息", description = "库存信息")
public class WmsStockQuan extends BaseBean {

    private static final long serialVersionUID = -1761371963373124790L;
    @Column(name = "WH_NO")
    @ApiParam(value = "仓库代码")
    private String whNo;

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

    @Column(name = "LOCATE_NO")
    @ApiParam(value = "库位代码")
    private String locateNo;

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

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

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

    @Column(name = "CUST_NO")
    @ApiParam(value = "客户编码")
    private String custNo;

    @Transient
    @ApiParam(value = "项目代码")
    private String prodCfgTypeCode;

    @Transient
    @ApiParam(value = "含0库存显示")
    private Boolean includeZeroStock = false;

    @Transient
    @ApiParam(value = "无差异库存显示")
    private Boolean showNoDiffStock = false;

    @Transient
    @ColumnDefault("0")
    @ApiParam(value = "库存数量总和")
    private Double sumQty;

    @Transient
    @ApiParam(value = "库位信息")
    private WmsLocate wmsLocate;


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

    @Column(name = "FAIL_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "不合格数量")
    private Double failQty;

    @Column(name = "HOLD_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "隔离数量")
    private Double holdQty;

    @Column(name = "QC_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "质检中数量")
    private Double qcQty;

    @Column(name = "RIN_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "待入库数量")
    private Double rinQty;

    @Column(name = "FREEZE_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "冻结数量")
    private Double freezeQty;

    @Column(name = "CONSIGN_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "寄售数量")
    private Double consignQty;

    @Column(name = "LOCK_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "锁定数量")
    private Double lockQty;

    @Column(name = "SCRAP_QTY", columnDefinition = "decimal(18,8) default 0", nullable = false)
    @ApiParam(value = "报废数量")
    private Double scrapQty;

    @Version
    @Column(name = "LOCK_VERSION", columnDefinition = "int default 0")
    @ApiParam(value = "乐观锁", defaultValue = "0")
    public Integer lockVersion;

    @Transient
    @ApiParam(value = "总数量")
    private Double totalQty;

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

    @Transient
    @ApiParam(value = "箱数")
    private Integer boxQty;

    @Transient
    @ApiParam(value = "零件数")
    private Double partQty;

    @Transient
    @ApiParam(value = "处理中数量")
    private Double transQty;

    @Transient
    @ApiParam(value = "ERP库存地")
    private String areaNo;

    @Transient
    @ApiParam(value = "存储区集合")
    private List<String> zoneList;

    @Transient
    @ApiParam(value = "移动单条码集合")
    private List<WmsMoveSn> wmsMoveSnList;

    @Transient
    @ApiParam(value = "快照时间")
    private String snapshotTime;

    @Transient
    private Integer isSnapshot;


    @Transient
    @ApiParam(value = "应有数量")
    private Double theoryQty;

    @Transient
    @ApiParam(value = "差异数量MAP")
    private Map<String, Map<String,Double>> differenceQtyMap;


    public Integer getIsSnapshot() {
        return this.isSnapshot == null ? 0 : this.isSnapshot;
    }

    public String getAreaNo() {
        return areaNo;
    }

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

    public Double getFailQtyVal() {
        return this.failQty == null ? 0 : this.failQty;
    }

    public Double getHoldQtyVal() {
        return this.holdQty == null ? 0 : this.holdQty;
    }

    public Double getQcQtyVal() {
        return this.qcQty == null ? 0 : this.qcQty;
    }

    public Double getRinQtyVal() {
        return this.rinQty == null ? 0 : this.rinQty;
    }

    public Double getFreezeQtyVal() {
        return this.freezeQty == null ? 0 : this.freezeQty;
    }

    public Double getConsignQtyVal() {
        return this.consignQty == null ? 0 : this.consignQty;
    }

    public Double getLockQtyVal() {
        return this.lockQty == null ? 0 : this.lockQty;
    }

    public Double getScrapQtyVal() {
        return this.scrapQty == null ? 0 : this.scrapQty;
    }

    public Double getTotalVal() {
        return this.totalQty == null ? 0 : this.totalQty;
    }

    public Double getPartQtyVal() {
        return this.partQty == null ? 0 : this.partQty;
    }

    public Integer getBoxQtyVal() {
        return this.boxQty == null ? 0 : this.boxQty;
    }


    public Integer getLockVersion() {
        return this.lockVersion == null ? 0 : this.lockVersion;
    }


    public WmsStockQuan() {
    }

    public WmsStockQuan(String whNo, String zoneNo, String unit, String partNo, String partName,
                        Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty,
                        Double consignQty, Double lockQty, Double sumQty, String prodCfgTypeCode, String prodCfgTypeName, Double scrapQty) {
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.partNo = partNo;
        this.partNameRdd = partName;
        this.unit = unit;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.sumQty = sumQty;
        this.prodCfgTypeCode = prodCfgTypeCode;
        this.prodCfgTypeName = prodCfgTypeName;
        this.scrapQty = scrapQty;
    }

    public WmsStockQuan(String organizeCode, String whNo, String zoneNo, String unit, String partNo, String partName,
                        Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty,
                        Double consignQty, Double lockQty, Double totalQty, String prodCfgTypeCode, String prodCfgTypeName, Double scrapQty) {
        this.organizeCode = organizeCode;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.unit = unit;
        this.partNo = partNo;
        this.partNameRdd = partName;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.totalQty = totalQty;
        this.prodCfgTypeCode = prodCfgTypeCode;
        this.prodCfgTypeName = prodCfgTypeName;
        this.scrapQty = scrapQty;
    }
    public WmsStockQuan(Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty, Double consignQty, Double lockQty, Double scrapQty) {
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.scrapQty = scrapQty;
    }

    public WmsStockQuan(String locateNo, Integer boxQty, Double partQty, String partNo, String partNameRdd, String unit,
                        Double sumQty, Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty, Double consignQty, Double lockQty, Double scrapQty) {
        this.locateNo = locateNo;
        this.boxQty = boxQty;
        this.partQty = partQty;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.unit = unit;
        this.sumQty = sumQty;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.scrapQty = scrapQty;
    }

    public WmsStockQuan(String whNo, String zoneNo, String locateNo, Integer boxQty, Double partQty, String partNo, String partNameRdd, String unit,
                        Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty, Double consignQty, Double lockQty, Double scrapQty) {
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.locateNo = locateNo;
        this.boxQty = boxQty;
        this.partQty = partQty;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.unit = unit;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.scrapQty = scrapQty;
        this.totalQty = qty + failQty + holdQty + qcQty + rinQty + freezeQty + consignQty + lockQty + scrapQty;
    }

    public WmsStockQuan(String organizeCode, String whNo, String zoneNo, String unit, String partNo, String partName,
                        Double qty, Double failQty, Double holdQty, Double qcQty, Double rinQty, Double freezeQty,
                        Double consignQty, Double lockQty, Double totalQty, String prodCfgTypeCode, String prodCfgTypeName, Double scrapQty, String areaNo) {
        this.organizeCode = organizeCode;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.unit = unit;
        this.partNo = partNo;
        this.partNameRdd = partName;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.totalQty = totalQty;
        this.prodCfgTypeCode = prodCfgTypeCode;
        this.prodCfgTypeName = prodCfgTypeName;
        this.scrapQty = scrapQty;
        this.areaNo = areaNo;
    }

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