package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;

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

/**
 * 模具明细
 */
@Table(name = "purc$inquirymoulditems")
@Entity
public class PurchaseInquiryMouldItem {

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

	/**
	 * 单据编号
	 */
	@Column(name = "imi_code")
	private String code;

	/**
	 * 序号
	 */
	@Column(name = "imi_detno")
	private Short detno;

	/**
	 * 询价单
	 */
	@ManyToOne(cascade = CascadeType.ALL, optional = true)
	@JoinColumn(name = "imi_imid", nullable = false)
	private PurchaseInquiryMould inquiryMould;

	/**
	 * 模具编号
	 */
	@Column(name = "imi_pscode")
	private String psCode;

	/**
	 * 模具名称
	 */
	@Column(name = "imi_psname")
	private String psName;

	/**
	 * 模具类型
	 */
	@Column(name = "imi_pstype")
	private String psType;

	/**
	 * 价格（单品价格显示）
	 */
	@Column(name = "imi_price")
	private Double price;

	/**
	 * 报价（历史显示）
	 */
	@Column(name = "imi_reply")
	private Double reply;

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

	/**
	 * 模具报价模具明细ID
	 */
	@Column(name = "imi_pddid")
	private Long pddId;

	/**
	 * erp sourceId
	 */
	@Column(name = "imi_erpsourceid")
	private Long erpSourceId;
	
	
	/**
	 * 模具报价
	 */
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "mr_imiid")
	@OrderBy("replyDate desc")
	private Set<PurchaseInquiryMouldReply> replies;

	/**
	 * 模具物料明细
	 * 
	 */
	@OneToMany(mappedBy = "inquiryMouldItem", cascade = { CascadeType.REFRESH, CascadeType.PERSIST,
			CascadeType.REMOVE, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@OrderBy("detno")
	private Set<PurchaseInquiryMouldDetail> inquiryMouldDetails;

	public Long getId() {
		return id;
	}

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

	public String getCode() {
		return code;
	}

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

	public Short getDetno() {
		return detno;
	}

	public void setDetno(Short detno) {
		this.detno = detno;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public PurchaseInquiryMould getInquiryMould() {
		return inquiryMould;
	}

	public void setInquiryMould(PurchaseInquiryMould inquiryMould) {
		this.inquiryMould = inquiryMould;
	}

	public String getPsCode() {
		return psCode;
	}

	public void setPsCode(String psCode) {
		this.psCode = psCode;
	}

	public String getPsName() {
		return psName;
	}

	public void setPsName(String psName) {
		this.psName = psName;
	}

	public String getPsType() {
		return psType;
	}

	public void setPsType(String psType) {
		this.psType = psType;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Double getReply() {
		return reply;
	}

	public void setReply(Double reply) {
		this.reply = reply;
	}

	public String getRemark() {
		return remark;
	}

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

	public Long getPddId() {
		return pddId;
	}

	public void setPddId(Long pddId) {
		this.pddId = pddId;
	}

	public Long getErpSourceId() {
		return erpSourceId;
	}

	public void setErpSourceId(Long erpSourceId) {
		this.erpSourceId = erpSourceId;
	}
	

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

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

	public Set<PurchaseInquiryMouldDetail> getInquiryMouldDetails() {
		return inquiryMouldDetails;
	}

	public void setInquiryMouldDetails(Set<PurchaseInquiryMouldDetail> inquiryMouldDetails) {
		this.inquiryMouldDetails = inquiryMouldDetails;
	}

}
