package com.uas.platform.b2b.model;

import com.uas.platform.core.model.Constant;
import com.uas.platform.core.model.Status;

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

/**
 * 平台里面，以供应商的角度来查看客户送货提醒
 * 
 * @author yingp
 *
 */
@Table(name = "purc$notice", indexes = {
        @Index(name = "unique_enuu_sourceid", columnList = "pn_enuu,pn_sourceid", unique = true)
})
@Entity
public class PurchaseNotice implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "pn_id")
	private Long id;

	/**
	 * 来源系统的送货提醒ID
	 */
	@Column(name = "pn_sourceid")
	private Long sourceId;

	/**
	 * 送货提醒单所属企业UU
	 */
	@Column(name = "pn_enuu")
	private Long enUU;

	/**
	 * 卖家企业UU
	 */
	@Column(name = "pn_venduu")
	private Long vendUU;

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

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

	/**
	 * 已发货数
	 */
	@Column(name = "pn_endqty")
	private Double endQty;

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

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

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

	/**
	 * 客户采购单明细
	 */
	@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumn(name = "pn_pdid", insertable = false, updatable = false)
	private PurchaseOrderItem orderItem;

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

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

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

	/**
	 * 结案状态是否已传输到卖家ERP的情况
	 */
	@Column(name = "pn_endstatus")
	private Short endStatus;

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

	/**
	 * 是否需要等待发货描述
	 */
	@Transient
	private String needWaiting;

	/**
	 * 物料最小包装数
	 */
	@Column(name = "pn_minpackqty")
	private Double minPackQty;

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

	public Long getId() {
		return id;
	}

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

	public Long getSourceId() {
		return sourceId;
	}

	public void setSourceId(Long sourceId) {
		this.sourceId = sourceId;
	}

	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 Double getQty() {
		return qty;
	}

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

	public Double getEndQty() {
		return endQty;
	}

	public void setEndQty(Double endQty) {
		this.endQty = endQty;
	}

	public Date getDate() {
		return date;
	}

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

	public Date getDelivery() {
		return delivery;
	}

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

	public String getRemark() {
		return remark;
	}

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

	public PurchaseOrderItem getOrderItem() {
		return orderItem;
	}

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

	public Short getSendStatus() {
		return sendStatus;
	}

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

	public Short getEnd() {
		return end;
	}

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

	public Short getEndStatus() {
		return endStatus;
	}

	public void setEndStatus(Short endStatus) {
		this.endStatus = endStatus;
	}

	public Short getStatus() {
		return status;
	}

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

	public Long getOrderItemId() {
		return orderItemId;
	}

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

	public Short getWaiting() {
		return waiting;
	}

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

	public Double getMinPackQty() {
		return minPackQty;
	}

	public void setMinPackQty(Double minPackQty) {
		this.minPackQty = minPackQty;
	}

	public Date getErpDate() {
		return erpDate;
	}

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

	public String getNeedWaiting() {
		if (this.waiting == Constant.YES && this.status == Status.NOT_REPLY.value()) {
            return "需要";
        } else if (this.waiting == Constant.NO && this.status == Status.NOT_REPLY.value()) {
            return "不需要";
        } else {
            return "";
        }
	}

	public void setNeedWaiting(String needWaiting) {
		this.needWaiting = needWaiting;
	}

}