package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import org.codehaus.jackson.annotate.JsonIgnore;

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

/**
 * 平台里面，以供应商的角度来查看采购询价单明细
 * 
 * @author yingp
 *
 */
@Table(name = "purc$inquiryitems")
@Entity
public class PurchaseInquiryItemTemp {

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

	/**
	 * 来源（买家ERP采购询价明细）的ID
	 */
	@Column(name = "id_sourceid", updatable = false)
	private Long sourceId;

	/**
	 * 序号
	 */
	@Column(name = "id_number")
	private Short number;

	/**
	 * 询价单
	 */
	@Column(name = "id_inid", nullable = false)
	private Long inId;

    /**
     * 询价单
     */
	@Transient
	private PurchaseInquiryTemp inquiry;

	/**
	 * 买家采购员UU
	 */
	@Column(name = "id_useruu")
	private Long userUU;

	/**
	 * 联系人姓名
	 */
	@Column(name = "id_username")
	private String userName;

	/**
	 * 联系人电话
	 */
	@Column(name = "id_usertel")
	private String userTel;

	/**
	 * 联系人编号
	 */
	@Column(name = "id_usercode")
	private String userCode;

	@Column(name = "id_prid")
	private Long productId;

	/**
	 * 币种
	 */
	@Column(name = "id_currency")
	private String currency;

	/**
	 * 税率
	 */
	@Column(name = "id_taxrate")
	private Float taxrate;

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

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

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

	/**
	 * （买家预先提供的）有效期始
	 */
	@Column(name = "id_fromdate")
	private Date fromDate;

	/**
	 * （买家预先提供的）有效期止
	 */
	@Column(name = "id_todate")
	private Date toDate;

	/**
	 * （卖家报的）有效期始
	 */
	@Column(name = "id_vendfromdate")
	private Date vendFromDate;

	/**
	 * （卖家报的）有效期止
	 */
	@Column(name = "id_vendtodate")
	private Date vendToDate;

	/**
	 * （卖家报的）最小订购量
	 */
	@Column(name = "id_minorderqty")
	private Double minOrderQty;

	/**
	 * （卖家报的）最小包装量
	 */
	@Column(name = "id_minpackqty")
	private Double minPackQty;

	/**
	 * （卖家报的）物料品牌
	 */
	@Column(name = "id_brand")
	private String brand;

	/**
	 * （卖家报的）供应商物料编号
	 */
	@Column(name = "id_vendorprodcode")
	private String vendorprodcode;

	/**
	 * （卖家报的）交货周期（天数）
	 */
	@Column(name = "id_leadtime")
	private Long leadtime;

	/**
	 * 分段报价明细
	 */
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "ir_idid")
	@OrderBy("lapQty")
	private Set<PurchaseInquiryReply> replies;

	/**
	 * {未回复、已回复}
	 */
	@Column(name = "id_status")
	private Short status;

	/**
	 * (针对卖家的)询价传输状态{待上传、已下载}
	 */
	@Column(name = "id_sendstatus")
	private Short sendStatus;

	/**
	 * (针对买家的)报价信息传输状态{待上传、已下载}
	 */
	@Column(name = "id_backstatus")
	private Short backStatus;

	/**
	 * (针对卖家的)报价信息传输状态{待上传、已下载}
	 */
	@Column(name = "id_replysendstatus")
	private Short replySendStatus;

	/**
	 * 是否采纳
	 */
	@Column(name = "id_agreed")
	private Short agreed;

	/**
	 * (针对卖家的)是否采纳信息传输状态{待上传、已下载}
	 */
	@Column(name = "id_decidestatus")
	private Short decideStatus;

	/**
	 * (针对卖家的)作废信息传输状态{待上传、已下载}
	 */
	@Column(name = "id_invalidstatus")
	private Short invalidStatus;

	/**
	 * 是否买家已设置分段数
	 */
	@Column(name = "id_custlap")
	private Short custLap;

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

	/**
	 * 录入时间(取主表日期字段)
	 *
	 * @return
	 */
	@Column(name = "id_date", insertable = false, updatable = false)
	private Date date;

	/**
	 * search项目进行单据是否已过期时实际根据主表中enddate与当前时间的比较获取，但是数据库无字段会报“标识符无效”的错误
	 * 所以建立此字段，但是此字段不会赋值。
	 *   在建立索引时，overdue的值加入到了invalid（已失效）的判断条件中，所以此字段的值无实际意义，
	 *   UAS询价单提交或反提交时，更新此字段，来使询价单明细更新触发器生效，更新询价单明细索引，
	 *   才能使未过期未报价已提交单据进入失效列表，未过期未报价反提交单据从已失效列表回到待报价列表。
	 *
	 *   （1为已提交， 0为被反提交， null为未提交）
	 */
	@Column(name = "id_overdue", insertable = false, updatable = false)
	private Short overdue;

	/**
	 * 报价是否已过期  根据vendToDate与当前时间的比较获取，但是数据库无字段会报“标识符无效”的错误
	 * 所以建立此字段，此字段在视图中赋值。
	 *
	 */
	@Column(name = "id_invalid", insertable = false, updatable = false)
	private Short invalid;

	/**
	 * 应用来源ERP、B2B
	 */
	@Column(name = "id_sourceapp")
	private String sourceApp;

	/**
	 * 需求数量
	 */
	@Column(name = "id_needquantity")
	private Double needquantity;

    /**
     * erp传输状态
     *
     * <pre>erp发出数据传输请求时，赋给状态，完成后更新状态</pre>
     *
     * 1、 传输完成<br>
     * 0、 正在传输
     *
     */
	@Column(name = "id_erpstatus")
    private Short erpstatus;

	/**
	 * 询价种类
	 */
	@Column(name = "id_kind")
	private String kind;

	public Long getId() {
		return id;
	}

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

	@JsonIgnore
	@JSONField(serialize = false)
	public Long getSourceId() {
		return sourceId;
	}

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

	public Short getNumber() {
		return number;
	}

	public void setNumber(Short number) {
		this.number = number;
	}

	public Long getInId() {
		return inId;
	}

	public void setInId(Long inId) {
		this.inId = inId;
	}

    public PurchaseInquiryTemp getInquiry() {
        return inquiry;
    }

    public void setInquiry(PurchaseInquiryTemp inquiry) {
        this.inquiry = inquiry;
    }

    public Long getUserUU() {
		return userUU;
	}

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

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserTel() {
		return userTel;
	}

	public void setUserTel(String userTel) {
		this.userTel = userTel;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public Long getProductId() {
		return productId;
	}

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

	public String getCurrency() {
		return currency;
	}

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

	public Float getTaxrate() {
		return taxrate;
	}

	public void setTaxrate(Float taxrate) {
		this.taxrate = taxrate;
	}

	public String getRemark() {
		return remark;
	}

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

	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 Date getFromDate() {
		return fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public Date getToDate() {
		return toDate;
	}

	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}

	public Date getVendFromDate() {
		return vendFromDate;
	}

	public void setVendFromDate(Date vendFromDate) {
		this.vendFromDate = vendFromDate;
	}

	public Date getVendToDate() {
		return vendToDate;
	}

	public void setVendToDate(Date vendToDate) {
		this.vendToDate = vendToDate;
	}

	public Double getMinOrderQty() {
		return minOrderQty;
	}

	public void setMinOrderQty(Double minOrderQty) {
		this.minOrderQty = minOrderQty;
	}

	public Double getMinPackQty() {
		return minPackQty;
	}

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

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getVendorprodcode() {
		return vendorprodcode;
	}

	public void setVendorprodcode(String vendorprodcode) {
		this.vendorprodcode = vendorprodcode;
	}

	public Long getLeadtime() {
		return leadtime;
	}

	public void setLeadtime(Long leadtime) {
		this.leadtime = leadtime;
	}

	public Set<PurchaseInquiryReply> getReplies() {
		return replies;
	}

	public void setReplies(Set<PurchaseInquiryReply> replies) {
		this.replies = replies;
	}

	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 Short getBackStatus() {
		return backStatus;
	}

	public void setBackStatus(Short backStatus) {
		this.backStatus = backStatus;
	}

	public Short getReplySendStatus() {
		return replySendStatus;
	}

	public void setReplySendStatus(Short replySendStatus) {
		this.replySendStatus = replySendStatus;
	}

	public Short getAgreed() {
		return agreed;
	}

	public void setAgreed(Short agreed) {
		this.agreed = agreed;
	}

	public Short getDecideStatus() {
		return decideStatus;
	}

	public void setDecideStatus(Short decideStatus) {
		this.decideStatus = decideStatus;
	}

	public Short getInvalidStatus() {
		return invalidStatus;
	}

	public void setInvalidStatus(Short invalidStatus) {
		this.invalidStatus = invalidStatus;
	}

	public Short getCustLap() {
		return custLap;
	}

	public void setCustLap(Short custLap) {
		this.custLap = custLap;
	}

	public Date getErpDate() {
		return erpDate;
	}

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

	public Date getDate() {
		return date;
	}

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

	public Short getOverdue() {
		return overdue;
	}

	public void setOverdue(Short overdue) {
		this.overdue = overdue;
	}

	public Short getInvalid() {
		return invalid;
	}

	public void setInvalid(Short invalid) {
		this.invalid = invalid;
	}

	public String getSourceApp() {
		return sourceApp;
	}

	public void setSourceApp(String sourceApp) {
		this.sourceApp = sourceApp;
	}

	public Double getNeedquantity() {
		return needquantity;
	}

	public void setNeedquantity(Double needquantity) {
		this.needquantity = needquantity;
	}

	public Short getErpstatus() {
		return erpstatus;
	}

	public void setErpstatus(Short erpstatus) {
		this.erpstatus = erpstatus;
	}

	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}
}
