package com.uas.platform.b2b.model;

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

/**
 * 买家MRB单
 * 
 * @author suntg
 *
 */
@Table(name = "purc$MRB", indexes = {
		@Index(name = "unique_enuu_code", columnList = "pm_enuu,pm_code", unique = true),
		@Index(name = "pm_enuu_index", columnList = "pm_enuu"),
		@Index(name = "pm_venduu_index", columnList = "pm_venduu")
})
@Entity
public class PurchaseMRB implements Serializable {

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

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

	/**
	 * 单号
	 */
	@Column(name = "pm_code")
	private String code;

	/**
	 * 日期
	 */
	@Column(name = "pm_date")
	private Date date;

	/**
	 * 验收单 所属企业(买家)UU
	 */
	@Column(name = "pm_enuu")
	private Long enUU;

	/**
	 * 供应商企业UU
	 */
	@Column(name = "pm_venduu")
	private Long vendUU;

	/**
	 * 采购订单明细
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "pm_pdid", insertable = false, updatable = false)
	private PurchaseOrderItem orderItem;

	@Column(name = "pm_pdid")
	private Long orderItemId;

	/**
	 * 不良品入库单
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "pm_pbid", insertable = false, updatable = false)
	private PurchaseBadIn badIn;

	@Column(name = "pm_pbid")
	private Long badInId;

	/**
	 * 来料数量
	 */
	@Column(name = "pm_inqty")
	private Double inQty;

	/**
	 * 检验数量
	 */
	@Column(name = "pm_checkqty")
	private Double checkQty;

	/**
	 * 不合格数量
	 */
	@Column(name = "pm_ngqty")
	private Double ngQty;

	/**
	 * 合格数量
	 */
	@Column(name = "pm_okqty")
	private Double okQty;

	/**
	 * 判定结果
	 */
	@Column(name = "pm_result")
	private String result;

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

	/**
	 * 收货单号
	 */
	@Column(name = "pm_sendcode")
	private String sendCode;

	/**
	 * 来料日期
	 */
	@Column(name = "pm_indate")
	private Date inDate;

	/**
	 * （对卖家）传输状态
	 */
	@Column(name = "pm_sendstatus")
	private Short sendStatus;

	/**
	 * 检验明细
	 */
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "pmci_pmid")
	@OrderBy("number")
	private Set<PurchaseMRBCheckItem> checkItems;

	/**
	 * 项目明细
	 */
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "pmji_pmid")
	@OrderBy("number")
	private Set<PurchaseMRBProjectItem> projectItems;

	/**
	 * 保存erp数据传入的时间
	 */
	@Column(name = "pmji_erpdate")
	private Date erpDate;

	/**
	 * erpid
	 * 
	 * @return
	 */
	@Column(name = "pmji_erpid")
	private Long erpId;

	/**
	 * 附件
	 */
	@OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
	@JoinTable(name="purc$MRBattach", joinColumns = @JoinColumn(name = "pm_id", referencedColumnName = "pm_id"), inverseJoinColumns = @JoinColumn(name="at_id", referencedColumnName = "at_id"))
	private Set<Attach> attaches;

	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 Date getDate() {
		return date;
	}

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

	public Long getEnUU() {
		return enUU;
	}

	public void setEnUU(Long enUU) {
		this.enUU = enUU;
	}

	public Long getVendUU() {
		return vendUU;
	}

	public void setVendUU(Long vendUU) {
		this.vendUU = vendUU;
	}

	public PurchaseOrderItem getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(PurchaseOrderItem orderItem) {
		this.orderItem = orderItem;
	}

	public Long getOrderItemId() {
		return orderItemId;
	}

	public void setOrderItemId(Long orderItemId) {
		this.orderItemId = orderItemId;
	}

	public PurchaseBadIn getBadIn() {
		return badIn;
	}

	public void setBadIn(PurchaseBadIn badIn) {
		this.badIn = badIn;
	}

	public Long getBadInId() {
		return badInId;
	}

	public void setBadInId(Long badInId) {
		this.badInId = badInId;
	}

	public Double getInQty() {
		return inQty;
	}

	public void setInQty(Double inQty) {
		this.inQty = inQty;
	}

	public Double getCheckQty() {
		return checkQty;
	}

	public void setCheckQty(Double checkQty) {
		this.checkQty = checkQty;
	}

	public Double getNgQty() {
		return ngQty;
	}

	public void setNgQty(Double ngQty) {
		this.ngQty = ngQty;
	}

	public Double getOkQty() {
		return okQty;
	}

	public void setOkQty(Double okQty) {
		this.okQty = okQty;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getRemark() {
		return remark;
	}

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

	public String getSendCode() {
		return sendCode;
	}

	public void setSendCode(String sendCode) {
		this.sendCode = sendCode;
	}

	public Date getInDate() {
		return inDate;
	}

	public void setInDate(Date inDate) {
		this.inDate = inDate;
	}

	public Set<PurchaseMRBCheckItem> getCheckItems() {
		return checkItems;
	}

	public void setCheckItems(Set<PurchaseMRBCheckItem> checkItems) {
		this.checkItems = checkItems;
	}

	public Set<PurchaseMRBProjectItem> getProjectItems() {
		return projectItems;
	}

	public void setProjectItems(Set<PurchaseMRBProjectItem> projectItems) {
		this.projectItems = projectItems;
	}

	public Short getSendStatus() {
		return sendStatus;
	}

	public void setSendStatus(Short sendStatus) {
		this.sendStatus = sendStatus;
	}

	public Date getErpDate() {
		return erpDate;
	}

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

	public Long getErpId() {
		return erpId;
	}

	public void setErpId(Long erpId) {
		this.erpId = erpId;
	}

	public Set<Attach> getAttaches() {
		return attaches;
	}

	public void setAttaches(Set<Attach> attaches) {
		this.attaches = attaches;
	}
}
