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

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
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 : jimmy.zeng
 * @CreateDate : 2018-11-01 16:22
 * @Modify:
 **/
@Data
@Entity
@Table(name="WMS_TRANS_RCD")
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value="仓库交易归档表",description = "仓库交易归档表")
public class WmsTransRcd extends BaseBean{

    private static final long serialVersionUID = 5996005499842022226L;
    @Column(name="ORDER_NO")
    @ApiParam(value ="单据编号")
    private String orderNo;

    @Column(name="SN")
    @ApiParam(value ="箱条码")
    private String sn;

    @Column(name="PART_ID")
    @ApiParam(value ="零件id",example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long partId;

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

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

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

    @Column(name="QTY", columnDefinition = "decimal(18,8)", nullable = false)
    @ColumnDefault("0")
    @ApiParam(value ="需求数")
    private Double qty;

    @Column(name="TRANS_CODE")
    @ApiParam(value ="交易类型")
    private String transCode;

    @Column(name="DATASOURCE")
    @ApiParam(value ="数据来源", example = "1")
    private Integer dataSource;

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

    @Column(name="LOC_ID")
    @ApiParam(value ="库位id",example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long locId;

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

    @Column(name="GROUP_ID")
    @ApiParam(value ="分组id",example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long groupId;

    @Transient
    @ApiParam(value ="库存数", example = "0")
    private Double qit;


    public Long getLocId() {
        if(locId != null) {
            return locId.longValue();
        }else{
            return locId;
        }
    }

    public Long getPartId() {
        if(partId != null) {
            return partId.longValue();
        }else{
            return partId;
        }
    }
}
