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

import cn.estsh.i3plus.pojo.wms.bean.WmsLocate;
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.util.List;

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

    private static final long serialVersionUID = 8335719859185712904L;

    @Column(name="SNAPSHOT_TIME")
    @ApiParam("快照时间")
    public String snapshotTime;

    @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
    @ColumnDefault("0")
    @ApiParam(value = "库存数量总和")
    private Double sumQty;

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


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

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

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

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

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

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

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

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

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

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

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

    @Transient
    @ApiParam(value = "箱数", example = "-1")
    private Integer boxQty;

    @Transient
    @ApiParam(value = "零件数", example = "-1")
    private Double partQty;

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

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

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


    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 WmsStockQuanSnapshot() {
    }

    public WmsStockQuanSnapshot(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,String snapshotTime) {
        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.prodCfgTypeCode = prodCfgTypeCode;
        this.prodCfgTypeName = prodCfgTypeName;
        this.scrapQty = scrapQty;
        this.snapshotTime =snapshotTime;
    }

    public WmsStockQuanSnapshot(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 WmsStockQuanSnapshot(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 WmsStockQuanSnapshot(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;
    }
}
