package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * 平台里面，以供应商的角度来查看客户打样申请
 * 
 * @author suntg
 *
 */
@Table(name = "purc$proofing")
@Entity
public class PurchaseProofing implements Serializable {

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 2147648497108840786L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "purc$proofing_gen")
	@SequenceGenerator(name = "purc$proofing_gen", sequenceName = "purc$proofing_seq", allocationSize = 1)
	@Column(name = "pp_id")
	private Long id;

	/**
	 * 所属企业UU(买方)
	 */
	@Column(name = "pp_enuu")
	private Long enUU;

	/**
	 * 企业（买方）
	 */
	@OneToOne(cascade = { CascadeType.MERGE })
	@JoinColumn(name = "pp_enuu", insertable = false, updatable = false)
	private Enterprise enterprise;
	
	/**
	 * 买方申请人uu
	 */
	@Column(name = "pp_useruu")
	private Long userUU;
	
	/**
	 * 买方申请人
	 */
	@OneToOne(cascade = { CascadeType.MERGE })
	@JoinColumn(name = "pp_useruu", insertable = false, updatable = false)
	private User user;

	/**
	 * 流水号
	 */
	@Column(name = "pp_code")
	private String code;

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

	/**
	 * 录入人
	 */
	@Column(name = "pp_recorder")
	private String recorder;

	/**
	 * 物料(买方物料)
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "pp_prid", insertable = false, updatable = false)
	private Product product;

	@Column(name = "pp_prid")
	private Long productId;
	
	/**
	 * 是否收费
	 */
	@Column(name = "pp_ischarge")
	private String isCharge;

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

	/**
	 * 环保要求
	 */
	@Column(name = "pp_envrequiry")
	private String envrequiry;

	/**
	 * 备注
	 */
	@Column(name = "pp_remark")
	private String remark;
	
	/**
	 * 使用范围
	 */
	@Column(name = "pp_scope")
	private String scope;

	/**
	 * 打样申请明细
	 */
	@OneToMany(mappedBy = "proofing", cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@OrderBy("number")
	private Set<PurchaseProofingItem> proofingItems;

	/**
	 * 附件ID
	 */
	@Column(name = "pp_attach")
	private String attach;

	public Long getId() {
		return id;
	}

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

	public Long getEnUU() {
		return enUU;
	}

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

	public Enterprise getEnterprise() {
		return enterprise;
	}

	public void setEnterprise(Enterprise enterprise) {
		this.enterprise = enterprise;
	}

	public Long getUserUU() {
		return userUU;
	}

	public void setUserUU(Long userUU) {
		this.userUU = userUU;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	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 String getRecorder() {
		return recorder;
	}

	public void setRecorder(String recorder) {
		this.recorder = recorder;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Long getProductId() {
		return productId;
	}

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

	public String getIsCharge() {
		return isCharge;
	}

	public void setIsCharge(String isCharge) {
		this.isCharge = isCharge;
	}

	public Date getDelivery() {
		return delivery;
	}

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

	public String getEnvrequiry() {
		return envrequiry;
	}

	public void setEnvrequiry(String envrequiry) {
		this.envrequiry = envrequiry;
	}

	public String getRemark() {
		return remark;
	}

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

	public String getScope() {
		return scope;
	}

	public void setScope(String scope) {
		this.scope = scope;
	}
	
	@JsonIgnore
	public Set<PurchaseProofingItem> getProofingItems() {
		return proofingItems;
	}

	public void setProofingItems(Set<PurchaseProofingItem> proofingItems) {
		this.proofingItems = proofingItems;
	}

	public String getAttach() {
		return attach;
	}

	public void setAttach(String attach) {
		this.attach = attach;
	}

	

}