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 javax.persistence.Version;

/**
 * @Description : 库存移动单条码信息
 * @Reference :
 * @Author : silliter.yuan
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_MOVE_SN", indexes = {
        @Index(columnList = "PART_NO"),
        @Index(columnList = "ORDER_NO"),
        @Index(columnList = "ITEM_STATUS"),
        @Index(columnList = "SN"),
        @Index(columnList = "VENDOR_NO"),
        @Index(columnList = "PACKAGE_NO"),
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("库存移动单条码信息")
public class WmsMoveSn extends BaseBean {

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

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

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

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

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

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

    @Column(name = "CSN")
    @ApiParam("客户条码")
    public String csn;

    /**
     * 状态:1=创建,10=待处理,20=已处理
     */
    @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("备注")
    public String remark;


    @Column(name = "LOT_NO")
    @ApiParam("批次编号")
    public String lotNo;

    @Column(name = "LEFT_CODE")
    @ApiParam(value = "生产批次")
    private String leftCode = "";


    @Column(name = "PACKAGE_NO")
    @ApiParam("容器编号")
    public String packAgeNo;

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

    @Column(name = "SRC_WH_NO")
    @ApiParam("源仓库代码")
    public String srcWhNo;

    @Column(name = "SRC_ZONE_NO")
    @ApiParam("源存储区代码")
    public String srcZoneNo;

    @Column(name = "SRC_LOCATE_NO")
    @ApiParam("源库位代码")
    public String srcLocateNo;

    @Column(name = "DEST_WH_NO")
    @ApiParam("目标仓库代码")
    public String destWhNo;

    @Column(name = "DEST_ZONE_NO")
    @ApiParam("目标存储区代码")
    public String destZoneNo;

    @Column(name = "DEST_LOCATE_NO")
    @ApiParam("目标库位代码")
    public String destLocateNo;

    @ApiParam("待上架箱数")
    @Transient
    private Long waitingCounts;

    @ApiParam("已上架箱数")
    @Transient
    private Long finishedCounts;

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

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

    @Column(name = "SRC_QC_STATUS")
    @ApiParam(value = "源质量状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_QC_STATUS.class, refForeignKey = "value", value = "description")
    public Integer srcQcStatus;

    @Column(name = "SRC_SN_STATUS")
    @ApiParam(value = "源条码状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_STATUS.class, refForeignKey = "value", value = "description")
    public Integer srcSnStatus;

    @Column(name = "DEST_QC_STATUS")
    @ApiParam(value = "目的质量状态", example = "1")
    @AnnoOutputColumn(refClass = WmsEnumUtil.STOCK_SN_QC_STATUS.class, refForeignKey = "value", value = "description")
    public Integer descQcStatus;

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

    @Column(name = "DATE_CODE")
    @ApiParam("生产日期")
    public String dateCode;

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

    @Column(name = "VENDOR_NO")
    @ApiParam("供应商编号")
    private String vendorNo;

    @Column(name = "srcSn")
    @ApiParam("原条码")
    private String srcSn;

    @Column(name = "SERIAl_SN")
    @ApiParam("产品条码")
    public String serialSn;

    @Transient
    @ApiParam("客户编号")
    public String custNo;

    @Transient
    @ApiParam("业务类型编码")
    @AnnoOutputColumn(refClass = WmsEnumUtil.OUT_MOVEMENT_BUSI_TYPE.class, refForeignKey = "value", value = "description")
    private Integer busiTypeCode;

    @Transient
    @ApiParam(value = "交易类型代码")
    private String transTypeCode;

    @Transient
    @ApiParam("关联单号")
    public String refSrc;

    @Transient
    @ApiParam("erp库存地")
    private String ZoneNo;

    @Transient
    @ApiParam("交易类型名称")
    private String transTypeName;

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

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

    @Transient
    private Integer isSnapshot;

    @Column(name = "CONSIGNATION")
    @ApiParam("是否寄售 1-是 2-否")
    private Integer consignation;

    @Transient
    @ApiParam("收货物料编码")
    public String rcPartNo;

    @Transient
    @ApiParam("发运物料编码")
    public String outPartNo;

    @Transient
    @ApiParam("发运单据")
    public String outRefSrc;

    @Transient
    @ApiParam("收货单据")
    public String rcRefSrc;

    @Transient
    @ApiParam("发运条码")
    public String outSn;

    @Transient
    @ApiParam("收货条码")
    public String rcSn;

    @Transient
    @ApiParam("发运单位")
    public String outUnit;

    @Transient
    @ApiParam("收货单位")
    public String rcUnit;

    @Transient
    @ApiParam("发运数量")
    public Double outQty;

    @Transient
    @ApiParam("收货数量")
    public Double rcQty;

    @Transient
    @ApiParam("委外发运时间")
    public String outDatetime;

    @Transient
    @ApiParam("委外收货时间")
    public String rcDatetime;

    @Transient
    @ApiParam("条码数量")
    public Integer snCount;

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

    public WmsMoveSn() {
    }

    public Long getWaitingCounts() {
        return waitingCounts == null ? 0L : this.waitingCounts;
    }

    public Long getFinishedCounts() {
        return finishedCounts == null ? 0L : this.finishedCounts;
    }

    public WmsMoveSn(String partNo, String lotNo, Double qty) {
        this.partNo = partNo;
        this.lotNo = lotNo;
        this.qty = qty;
    }

    public WmsMoveSn(String partNo, String partNameRdd, Double destQty, Integer busiTypeCode, String transTypeCode, String refSrc) {
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.destQty = destQty;
        this.busiTypeCode = busiTypeCode;
        this.transTypeCode = transTypeCode;
        this.refSrc = refSrc;
    }
    public WmsMoveSn(String partNo, String partNameRdd, Double destQty, String transTypeCode, String refSrc) {
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.destQty = destQty;
        this.transTypeCode = transTypeCode;
        this.refSrc = refSrc;
    }

    public WmsMoveSn(String partNo, String srcLocateNo, String destLocateNo, String createUser, String createDatetime, String transTypeName, Double destQty) {
        this.partNo = partNo;
        this.srcLocateNo = srcLocateNo;
        this.destLocateNo = destLocateNo;
        this.createUser = createUser;
        this.createDatetime = createDatetime;
        this.transTypeName = transTypeName;
        this.destQty = destQty;
    }

    public WmsMoveSn(String organizeCode, String orderNo, Integer item, String partNo, String partNameRdd,
                     String transTypeCode, String transTypeName, Integer itemStatus, String unit, String srcLocateNo, String destLocateNo, Double srcQty, Double destQty, Integer srcQcStatus, Integer descQcStatus, Integer srcSnStatus,
                     Integer destSnStatus, String lotNo, String dateCode, String refSrc, String destZoneNo, String destWhNo, Integer busiTypeCode, String sn,
                     String createUser, String createDatetime, String modifyDatetime, String modifyUser) {
        this.organizeCode = organizeCode;
        this.orderNo = orderNo;
        this.item = item;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.transTypeCode = transTypeCode;
        this.transTypeName = transTypeName;
        this.itemStatus = itemStatus;
        this.unit = unit;
        this.srcLocateNo = srcLocateNo;
        this.destLocateNo = destLocateNo;
        this.srcQty = srcQty;
        this.srcQty = srcQty;
        this.destQty = destQty;
        this.srcQcStatus = srcQcStatus;
        this.descQcStatus = descQcStatus;
        this.srcSnStatus = srcSnStatus;
        this.destSnStatus = destSnStatus;
        this.lotNo = lotNo;
        this.dateCode = dateCode;
        this.refSrc = refSrc;
        this.destZoneNo = destZoneNo;
        this.destWhNo = destWhNo;
        this.busiTypeCode = busiTypeCode;
        this.sn = sn;
        this.createUser = createUser;
        this.createDatetime = createDatetime;
        this.modifyDatetime = modifyDatetime;
        this.modifyUser = modifyUser;
    }

    public WmsMoveSn(String organizeCode, String orderNo, Integer item, String partNo, String partNameRdd,
                     String transTypeCode, String transTypeName, Integer itemStatus, String unit, String srcLocateNo, String destLocateNo, Double srcQty, Double destQty, Integer srcQcStatus, Integer descQcStatus, Integer srcSnStatus,
                     Integer destSnStatus, String lotNo, String dateCode, String leftCode, String refSrc, String destZoneNo, String destWhNo, Integer busiTypeCode, String sn,
                     String createUser, String createDatetime, String modifyDatetime, String modifyUser) {
        this.organizeCode = organizeCode;
        this.orderNo = orderNo;
        this.item = item;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.transTypeCode = transTypeCode;
        this.transTypeName = transTypeName;
        this.itemStatus = itemStatus;
        this.unit = unit;
        this.srcLocateNo = srcLocateNo;
        this.destLocateNo = destLocateNo;
        this.srcQty = srcQty;
        this.srcQty = srcQty;
        this.destQty = destQty;
        this.srcQcStatus = srcQcStatus;
        this.descQcStatus = descQcStatus;
        this.srcSnStatus = srcSnStatus;
        this.destSnStatus = destSnStatus;
        this.lotNo = lotNo;
        this.dateCode = dateCode;
        this.leftCode = leftCode;
        this.refSrc = refSrc;
        this.destZoneNo = destZoneNo;
        this.destWhNo = destWhNo;
        this.busiTypeCode = busiTypeCode;
        this.sn = sn;
        this.createUser = createUser;
        this.createDatetime = createDatetime;
        this.modifyDatetime = modifyDatetime;
        this.modifyUser = modifyUser;
    }

    public WmsMoveSn(Long id,String organizeCode,String vendorNo,String rcPartNo,String outPartNo, Double destQty) {
        this.id = id;
        this.organizeCode = organizeCode;
        this.vendorNo = vendorNo;
        this.rcPartNo = rcPartNo;
        this.outPartNo = outPartNo;
        this.destQty = destQty;
    }

    public WmsMoveSn(Long id,String organizeCode,String outRefSrc,String rcRefSrc,String outSn,String rcSn,
                     String outPartNo,String rcPartNo,String outUnit,String rcUnit, Double outQty ,Double rcQty,
                     String outDatetime,String rcDatetime ,String vendorNo, String modifyUser,String modifyDatetime) {
        this.id = id;
        this.organizeCode = organizeCode;
        this.outRefSrc = outRefSrc;
        this.rcRefSrc = rcRefSrc;
        this.outSn = outSn;
        this.rcSn = rcSn;
        this.outPartNo = outPartNo;
        this.rcPartNo = rcPartNo;
        this.outUnit = outUnit;
        this.rcUnit = rcUnit;
        this.outQty = outQty;
        this.rcQty = rcQty;
        this.outDatetime = outDatetime;
        this.rcDatetime = rcDatetime;
        this.vendorNo = vendorNo;
        this.modifyUser = modifyUser;
        this.modifyDatetime = modifyDatetime;
    }

    public WmsMoveSn(String partNo, String partNameRdd,String sn,String vendorNo,String custNo,String srcLocateNo,String destLocateNo,String srcZoneNo,
                     Double srcQty,Double destQty,String orderNo,String srcWhNo, Integer srcQcStatus ,Integer descQcStatus,
                     Integer srcSnStatus,Integer destSnStatus ) {
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.sn = sn;
        this.vendorNo = vendorNo;
        this.custNo = custNo;
        this.srcLocateNo = srcLocateNo;
        this.destLocateNo = destLocateNo;
        this.srcZoneNo = srcZoneNo;
        this.srcQty = srcQty;
        this.destQty = destQty;
        this.orderNo = orderNo;
        this.srcWhNo = srcWhNo;
        this.srcQcStatus = srcQcStatus;
        this.descQcStatus = descQcStatus;
        this.srcSnStatus = srcSnStatus;
        this.destSnStatus = destSnStatus;;
    }


    public WmsMoveSn(String sn, String refSrc,String transTypeCode, String transTypeName, Integer itemStatus) {
        this.sn = sn;
        this.refSrc = refSrc;
        this.transTypeCode = transTypeCode;
        this.transTypeName = transTypeName;
        this.itemStatus = itemStatus;
    }

    public WmsMoveSn(Integer snCount, String createDatetime) {
        this.snCount = snCount;
        this.createDatetime = createDatetime;
    }
}
