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

import cn.estsh.i3plus.pojo.base.annotation.DynamicField;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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.*;

/**
 * @Description : 库存交易条码信息 （移库类的交易需要记录2笔交易数据，正负各一笔）
 * @Reference :
 * @Author : silliter.yuan
 * @CreateDate : 2018-11-06 15:58
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "WMS_TRANS_QUAN", indexes = {
        @Index(columnList = "WH_NO"),
        @Index(columnList = "ZONE_NO"),
        @Index(columnList = "LOCATE_NO"),
        @Index(columnList = "REF_SRC"),
        @Index(columnList = "ORGANIZE_CODE")
})
@Api("库存交易信息")
public class WmsTransQuan extends BaseBean {

    private static final long serialVersionUID = -7379945456037422449L;
    @Column(name = "TRANS_NO")
    @ApiParam(value = "事务编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String transNo;

    @Column(name = "WH_NO")
    @ApiParam(value = "仓库代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
dataSrc ="cn.estsh.i3plus.pojo.wms.bean.WareHouse",
            searchColumnName = "code,name",listColumnName = "code,name", explicitColumnName = "code")
    private String whNo;

    @Column(name = "ZONE_NO")
    @ApiParam(value = "存储区编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
dataSrc ="cn.estsh.i3plus.pojo.wms.bean.WmsZones",
            searchColumnName = "zoneNo,zoneName",listColumnName = "zoneNo,zoneName", explicitColumnName = "zoneNo")
    private String zoneNo;

    @Column(name = "LOCATE_NO")
    @ApiParam(value = "库位编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
dataSrc ="cn.estsh.i3plus.pojo.wms.bean.WmsLocate",
            searchColumnName = "locateNo,locateName",listColumnName = "locateNo,locateName", explicitColumnName = "locateNo")
    private String locateNo;

    @Column(name = "PART_NO")
    @ApiParam(value = "物料编码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST,  getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsPart",
            searchColumnName = "partNo,partName", listColumnName = "partNo,partName", explicitColumnName = "partNo")
    private String partNo;

    @Column(name = "PART_NAME_RDD")
    @ApiParam(value = "物料名称")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2,  getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.WmsPart",
            searchColumnName = "partNo,partName", listColumnName = "partNo,partName", explicitColumnName = "partName")
    private String partNameRdd;

    @Column(name = "UNIT")
    @ApiParam(value = "单位")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String unit;

    @Column(name = "TRANS_STATUS")
    @ApiParam(value = "状态", example = "10")
    private Integer transStatus;

    @Column(name = "REF_TYPE")
    @ApiParam(value = "关联单据类型")
    private String refType;

    @Column(name = "BUSI_TYPE")
    @ApiParam(value = "业务类型", example = "10")
    private Integer busiType;

    @Column(name = "REF_SRC")
    @ApiParam(value = "关联单号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String refSrc;

    @Column(name = "TRANS_CODE")
    @ApiParam(value = "交易代码")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String transCode;

    @Column(name = "MOVE_NO")
    @ApiParam(value = "库存移动单号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String moveNo;

    @Column(name = "VENDOR_NO")
    @ApiParam(value = "供应商编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.BasVendor",
            searchColumnName = "vendorNo,vendorName", listColumnName = "vendorNo,vendorName", explicitColumnName = "vendorNo")
    private String vendorNo;

    @Column(name = "CUST_NO")
    @ApiParam(value = "客户编号")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.LIST, isRequire = 2, getValWay = CommonEnumUtil.DYNAMIC_FIELD_GET_WAY.OBJ,
            dataSrc = "cn.estsh.i3plus.pojo.wms.bean.BasCustomer",
            searchColumnName = "custNo,custDesc", listColumnName = "custNo,custDesc", explicitColumnName = "custNo")
    private String custNo;

    @Column(name = "ERROR_MESSAGE")
    @ApiParam(value = "错误信息")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String errorMessage;

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

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

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

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

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

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

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

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

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

    @Column(name="TRANS_TYPE_NAME")
    @ApiParam(value ="交易名称")
    @DynamicField(webFieldType = CommonEnumUtil.FIELD_TYPE.TEXT)
    private String transTypeName;

    /*@Transient
    @ApiParam("交易类型")
    private String transTypeName;*/

    @Transient
    @ApiParam("仓库名称")
    private String warehouseName;

    @Transient
    @ApiParam("存储区名称")
    private String zoneName;

    @Transient
    @ApiParam("库存地代码")
    private String areaNo;

    public WmsTransQuan(){}

    public WmsTransQuan(String organizeCode,String partNo,String partNameRdd,String transCode,String unit,String whNo,String zoneNo,
                        Double qty,Double failQty,Double holdQty,Double scrapQty,Double qcQty,Double rinQty,
                        Double freezeQty,Double consignQty,Double lockQty,String createUser,String createDatetime){
        this.organizeCode = organizeCode;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        this.transCode = transCode;
        this.unit = unit;
        this.whNo = whNo;
        this.zoneNo = zoneNo;
        this.qty = qty;
        this.failQty = failQty;
        this.holdQty = holdQty;
        this.scrapQty = scrapQty;
        this.qcQty = qcQty;
        this.rinQty = rinQty;
        this.freezeQty = freezeQty;
        this.consignQty = consignQty;
        this.lockQty = lockQty;
        this.createUser = createUser;
        this.createDatetime = createDatetime;

    }


    public WmsTransQuan(Integer transStatus){
        this.transStatus = transStatus;
    }
}
