package com.uas.platform.b2b.model;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.OptimisticLockType;
import org.hibernate.annotations.OptimisticLocking;

import javax.persistence.*;
import java.util.*;

/**
 * 只保存采购明细
 */
@Table(name = "purc$orderitems")
@Entity
@OptimisticLocking(type = OptimisticLockType.ALL)
@DynamicUpdate(value = true)
public class SaleOrderItem {

	@Id
	@Column(name = "pd_id")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	/**
	 * 序号
	 */
	@Column(name = "pd_number")
	private Short number;

	/**
	 * 采购订单id
	 */
	@Column(name = "pd_puid")
	private Long puId;

	/**
	 * 产品ID
	 */
	@Column(name = "pd_prid")
	private Long productId;

	/**
	 * 产品的附件
	 */
	@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
	@JoinTable(name = "purc$prod$attach", joinColumns = @JoinColumn(name = "pd_id", referencedColumnName = "pd_id"), inverseJoinColumns = @JoinColumn(name="at_id", referencedColumnName = "at_id"))
	private Set<Attach> attachs;

	/**
	 * 数量
	 */
	@Column(name = "pd_qty")
	private Double qty;

	/**
	 * 备注
	 */
	@Column(name = "pd_remark")
	private String remark;

	/**
	 * 送货工厂
	 */
	@Column(name = "pd_factory")
	private String factory;

	/**
	 * 供应商规格
	 */
	@Column(name = "pd_vendspec")
	private String vendspec;

	/**
	 * 含税单价
	 */
	@Column(name = "pd_price")
	private Double price;

	/**
	 * 税率
	 */
	@Column(name = "pd_taxrate")
	private Float taxrate;

	/**
	 * 交货日期
	 */
	@Column(name = "pd_delivery")
	private Date delivery;

	/**
	 * 虚拟列，不可修改，自动根据qty, replyqty生成值<br>
	 * 处理状态（已回复、未回复），全部回复后改为已回复
	 */
	@Column(name = "pd_status")
	private Short status;

    /**
     * 备品数量
     */
    @Column(name = "pd_beipin")
    private Integer beipin;

	/**
	 * erp传入时间
	 */
	@Column(name = "pd_erpdate")
	private Date erpDate;

	public Long getId() {
		return id;
	}

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

	public Short getNumber() {
		return number;
	}

	public void setNumber(Short number) {
		this.number = number;
	}

	public Long getPuId() {
		return puId;
	}

	public void setPuId(Long puId) {
		this.puId = puId;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public Set<Attach> getAttachs() {
		return attachs;
	}

	public void setAttachs(Set<Attach> attachs) {
		this.attachs = attachs;
	}

	public Double getQty() {
		return qty;
	}

	public void setQty(Double qty) {
		this.qty = qty;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getFactory() {
		return factory;
	}

	public void setFactory(String factory) {
		this.factory = factory;
	}

	public String getVendspec() {
		return vendspec;
	}

	public void setVendspec(String vendspec) {
		this.vendspec = vendspec;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Float getTaxrate() {
		return taxrate;
	}

	public void setTaxrate(Float taxrate) {
		this.taxrate = taxrate;
	}

	public Date getDelivery() {
		return delivery;
	}

	public void setDelivery(Date delivery) {
		this.delivery = delivery;
	}

	public Short getStatus() {
		return status;
	}

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

    public Integer getBeipin() {
        return beipin;
    }

    public void setBeipin(Integer beipin) {
        this.beipin = beipin;
    }

	public Date getErpDate() {
		return erpDate;
	}

	public void setErpDate(Date erpDate) {
		this.erpDate = erpDate;
	}
}
