package com.uas.search.console.b2b.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * 平台里面，以供应商的角度来查看客户送货提醒
 * 
 * @author yingp
 *
 */
@Table(name = PurchaseNoticeSimpleInfo.TABLE_NAME)
@Entity
public class PurchaseNoticeSimpleInfo {

	/**
	 * 表名
	 */
	public static final String TABLE_NAME = "PURC$NOTICE";

	/**
	 * 各字段列名（也是存储索引时的field名）
	 */
	public static final String ID_FIELD = "pn_id";

	public static final String ENTERPRISE_FIELD = "pn_enuu";

	public static final String DATE_FIELD = "pn_date";

	public static final String STATUS_FIELD = "pn_status";

	public static final String VEND_FIELD = "pn_venduu";

	public static final String ORDERITEMS_FIELD = "pn_pdid";

	public static final String ISWAITING_FIELD = "is_waiting";

	public static final String END_FIELD = "pn_end";

	@Id
	@Column(name = ID_FIELD)
	private Long id;

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

	/**
	 * 企业UU
	 */
	@OneToOne
	@JoinColumn(name = ENTERPRISE_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo enterprise;

	/**
	 * 卖家企业UU
	 */
	@OneToOne
	@JoinColumn(name = VEND_FIELD, insertable = false, updatable = false)
	private EnterpriseSimpleInfo vend;

	/**
	 * 处理状态（已回复、未回复），全部发货后改为已回复
	 */
	@Column(name = STATUS_FIELD, insertable = false, updatable = false)
	private Short status;

	/**
	 * 备货状态(1--是、0--否)
	 */
	@Column(name = ISWAITING_FIELD, insertable = false, updatable = false)
	private Short waiting;

	/**
	 * 是否已结案
	 */
	@Column(name = END_FIELD)
	private Short end;

	/**
	 * 客户采购单明细
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = ORDERITEMS_FIELD, insertable = false, updatable = false, nullable = false)
	private PurchaseOrderItemSimpleInfo orderItem;

	public Long getId() {
		return id;
	}

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

	public EnterpriseSimpleInfo getVend() {
		return vend;
	}

	public void setVend(EnterpriseSimpleInfo vend) {
		this.vend = vend;
	}

	public Date getDate() {
		return date;
	}

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

	public EnterpriseSimpleInfo getEnterprise() {
		return enterprise;
	}

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

	public Short getStatus() {
		return status;
	}

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

	public Short getWaiting() {
		return waiting;
	}

	public void setWaiting(Short waiting) {
		this.waiting = waiting;
	}

	public PurchaseOrderItemSimpleInfo getOrderItem() {
		return orderItem;
	}

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

	public Short getEnd() {
		return end;
	}

	public void setEnd(Short end) {
		this.end = end;
	}

	/**
	 * 获取所有可以搜索的字段列名（索引的field名）
	 * 
	 * @return 可以搜索的字段列名
	 */
	public static List<String> getKeywordFields() {
		List<String> fields = new ArrayList<>();
		fields.add(VEND_FIELD);
		fields.add(ENTERPRISE_FIELD);
		fields.add(ORDERITEMS_FIELD);
		return fields;
	}

	@Override
	public String toString() {
		return "PurchaseNoticeSimpleInfo [id=" + id + ", date=" + date + ", enterprise=" + enterprise + ", vend=" + vend
				+ ", status=" + status + ", waiting=" + waiting + ", end=" + end + ", orderItem=" + orderItem + "]";
	}

}