package com.uas.platform.b2b.model;

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

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

/**
 * 委外变更单（主表，变更信息在明细表）
 * 
 * @author suntg
 * @since 2015年8月6日下午2:18:11
 */
@Table(name = "make$changes")
@Entity
public class MakeOrderChange implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

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

	/**
	 * 采购变更单所属企业UU
	 */
	@Column(name = "mc_enuu")
	private Long enUU;

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

	/**
	 * 变更单买方用户UU（订单中的数据）
	 */
	@Column(name = "mc_useruu")
	private Long userUU;

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

	/**
	 * 录入人
	 */
	@Column(name = "mc_recorder")
	private String recorder;

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

	/**
	 * 审核人
	 */
	@Column(name = "mc_auditman")
	private String auditMan;

	/**
	 * 审核日期
	 */
	@Column(name = "mc_auditdate")
	private Date auditDate;

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

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

	/**
	 * 对应的erpid
	 * 
	 * @return
	 */
	@Column(name = "mc_erpid")
	private Long erpId;

	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 String getCode() {
		return code;
	}

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

	public String getRecorder() {
		return recorder;
	}

	public void setRecorder(String recorder) {
		this.recorder = recorder;
	}

	public Date getDate() {
		return date;
	}

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

	public String getRemark() {
		return remark;
	}

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

	@JsonIgnore
	@JSONField(serialize = false)
	public Set<MakeOrderChangeItem> getOrderChangeItems() {
		return orderChangeItems;
	}

	public void setOrderChangeItems(Set<MakeOrderChangeItem> orderChangeItems) {
		this.orderChangeItems = orderChangeItems;
	}

	public EnterpriseInfo getEnterprise() {
		return enterprise;
	}

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

	public Long getUserUU() {
		return userUU;
	}

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

	public String getAuditMan() {
		return auditMan;
	}

	public void setAuditMan(String auditMan) {
		this.auditMan = auditMan;
	}

	public Date getAuditDate() {
		return auditDate;
	}

	public void setAuditDate(Date auditDate) {
		this.auditDate = auditDate;
	}

	public Long getErpId() {
		return erpId;
	}

	public void setErpId(Long erpId) {
		this.erpId = erpId;
	}

}
