package com.uas.platform.b2b.model;

import com.uas.platform.core.model.Status;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 这张表用来记录ERP订单上传过程中未存在的物料信息
 *
 * Created by hejq on 2018-03-14.
 */
@Table(name = "erp$products")
@Entity
public class NotExistProduct implements Serializable {

    /**
     * default serialVersionUID
     */
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "pr_id")
    private Long id;

    /**
     * 物料编号
     */
    @Column(name = "pr_code")
    private String code;

    /**
     * 企业
     */
    @Column(name = "pr_enuu")
    private Long enuu;

    /**
     * 下载状态<br>
     *     <pro>
     *         203: 已下载， 202 未下载
     *     </pro>
     */
    @Column(name = "pr_status")
    private Integer status;

    /**
     * 单据日期
     */
    @Column(name = "pr_date")
    private Date date;

    /**
     * 物料来源，哪个单据发现的
     */
    @Column(name = "pr_source")
    private String source;

    /**
     * 单据编号
     */
    @Column(name = "pr_sourcecode")
    private String sourceCode;

    /**
     * 明细序号
     */
    @Column(name = "pr_detno")
    private Short detno = 0;

    /**
     * 标识符，能通过异常查询出来
     */
    @Column(name = "pr_sign")
    private String sign;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Long getEnuu() {
        return enuu;
    }

    public void setEnuu(Long enuu) {
        this.enuu = enuu;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getSourceCode() {
        return sourceCode;
    }

    public void setSourceCode(String sourceCode) {
        this.sourceCode = sourceCode;
    }

    public Short getDetno() {
        return detno;
    }

    public void setDetno(Short detno) {
        this.detno = detno;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public NotExistProduct() {

    }

    /**
     * 新构建记录不存在物料信息实体
     *
     * @param code 物料编号
     * @param enUU 企业UU
     * @param source 来源
     * @param sourceCode 来源编号
     * @param detno 如果是明细，存序号，默认为0
     * @param sign 标记，能通过异常查询出来
     */
    public NotExistProduct(String code, Long enUU, String source, String sourceCode, Short detno, String sign) {
        this.code = code;
        this.enuu = enUU;
        this.source = source;
        this.sourceCode = sourceCode;
        this.date = new Date(System.currentTimeMillis());
        this.status = Status.NOT_UPLOAD.value();
        this.detno = detno;
        this.sign = sign;
    }

}
