package com.uas.platform.b2b.model;

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;

/**
 * 平台里面，以供应商的角度来查看采购订单 <br>
 * 级联采购明细
 * 
 * @author yingp
 * 
 */
@Table(name = "purc$orders")
@Entity
public class PurchaseOrderAll {

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

	/**
	 * 采购企业UU
	 */
	@Column(name = "pu_enuu")
	private Long enUU;

	/**
	 * 采购企业
	 */
	@OneToOne(cascade = { CascadeType.MERGE })
	@JoinColumn(name = "pu_enuu", insertable = false, updatable = false)
	private Enterprise enterprise;

	/**
	 * 采购单所属采购员
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "pu_useruu", insertable = false, updatable = false)
	private User user;

	/**
	 * 采购单所属采购员UU
	 */
	@Column(name = "pu_useruu")
	private Long userUU;

	/**
	 * 采购单号
	 */
	@Column(name = "pu_code")
	private String code;

	/**
	 * 采购类型
	 */
	@Column(name = "pu_type")
	private String type;

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

	/**
	 * 录单人
	 */
	@Column(name = "pu_recorder")
	private String recorder;

	/**
	 * 审核人
	 */
	@Column(name = "pu_auditor")
	private String auditor;

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

	/**
	 * 供应商联系人UU
	 */
	@Column(name = "pu_venduseruu")
	private Long vendUserUU;

	/**
	 * 收货地址
	 */
	@Column(name = "pu_shipaddress")
	private String shipAddress;

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

	/**
	 * 付款币种
	 */
	@Column(name = "pu_currency")
	private String currency;

	/**
	 * 汇率
	 */
	@Column(name = "pu_rate")
	private Float rate;

	/**
	 * 付款方式
	 */
	@Column(name = "pu_payments")
	private String payments;

	/**
	 * 处理状态（已回复、未回复），全部回复后改为已回复
	 */
	@Column(name = "pu_status")
	private Short status;

	/**
	 * 从平台传到供应商ERP的状态
	 */
	@Column(name = "pu_sendstatus")
	private Short sendStatus;

	/**
	 * 采购单明细
	 */
	@OneToMany(mappedBy = "order", cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@OrderBy("number")
	private Set<PurchaseOrderAllItem> orderItems;

	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 User getUser() {
		return user;
	}

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

	public Long getUserUU() {
		return userUU;
	}

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

	public String getCode() {
		return code;
	}

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

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	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 String getAuditor() {
		return auditor;
	}

	public void setAuditor(String auditor) {
		this.auditor = auditor;
	}

	public Long getVendUU() {
		return vendUU;
	}

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

	public Long getVendUserUU() {
		return vendUserUU;
	}

	public void setVendUserUU(Long vendUserUU) {
		this.vendUserUU = vendUserUU;
	}

	public String getShipAddress() {
		return shipAddress;
	}

	public void setShipAddress(String shipAddress) {
		this.shipAddress = shipAddress;
	}

	public String getRemark() {
		return remark;
	}

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

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public Float getRate() {
		return rate;
	}

	public void setRate(Float rate) {
		this.rate = rate;
	}

	public String getPayments() {
		return payments;
	}

	public void setPayments(String payments) {
		this.payments = payments;
	}

	public Short getStatus() {
		return status;
	}

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

	public Short getSendStatus() {
		return sendStatus;
	}

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

	public Set<PurchaseOrderAllItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(Set<PurchaseOrderAllItem> orderItems) {
		this.orderItems = orderItems;
	}
}
