package com.uas.platform.b2b.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.alibaba.fastjson.annotation.JSONField;
import com.uas.platform.core.model.Constant;

/**
 * 委外变更单明细
 * 
 * @author suntg
 * @since 2015年8月6日下午2:57:52
 */
@Table(name = "make$changeitems")
@Entity
public class MakeOrderChangeItem {

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

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

	/**
	 * 变更单供应商UU
	 */
	@Column(name = "mcd_venduu")
	private Long vendUU;

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

	/**
	 * 采购订单变更单
	 */
	@ManyToOne(cascade = CascadeType.ALL, optional = true)
	@JoinColumn(name = "mcd_pcid", nullable = false)
	private MakeOrderChange orderChange;

	/**
	 * 委外加工单ID
	 */
	@Column(name = "mcd_maid")
	private Long orderId;

	/**
	 * 委外加工单编号
	 */
	@Column(name = "mcd_macode")
	private String orderCode;

	/**
	 * 生产的物料
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "mcd_prid", insertable = false, updatable = false)
	private Product product;

	/**
	 * 生产物料id
	 */
	@Column(name = "mcd_prid")
	private Long productId;

	/**
	 * 新数量
	 */
	@Column(name = "mcd_newqty")
	private Double newQty;

	/**
	 * 原数量
	 */
	@Column(name = "mcd_oldqty")
	private Double oldQty;

	/**
	 * 新加工单价
	 */
	@Column(name = "mcd_newprice")
	private Double newPrice;

	/**
	 * 原加工单价
	 */
	@Column(name = "mcd_oldprice")
	private Double oldPrice;

	/**
	 * 录入日期
	 */
	@Column(name = "mcd_date")
	private Date date;
	/**
	 * 新计划开工日期
	 */
	@Column(name = "mcd_newcommence")
	private Date newCommence;

	/**
	 * 原计划开工日期
	 */
	@Column(name = "mcd_oldcommence")
	private Date oldCommence;

	/**
	 * 新计划完工日期
	 */
	@Column(name = "mcd_newcomplete")
	private Date newComplete;

	/**
	 * 原计划完工日期
	 */
	@Column(name = "mcd_oldcomplete")
	private Date oldComplete;

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

	/**
	 * 变更原因
	 */
	@Column(name = "mcd_reason")
	private String reason;

	/**
	 * 变更单传到卖方ERP的状态
	 */
	@Column(name = "mcd_sendstatus")
	private Short sendStatus;

	/**
	 * 状态（未回复、已回复）
	 */
	@Column(name = "mcd_status")
	private Short status;

	/**
	 * 卖家是否同意了买家的变更请求(1,0)
	 */
	@Column(name = "mcd_agreed")
	private Short agreed;

	/**
	 * 不需要供应商确认(1,0)
	 */
	@Column(name = "mcd_unneedreply")
	private Short unNeedReply;

	/**
	 * 回复备注
	 */
	@Column(name = "mcd_replyremark")
	private String replyRemark;

	/**
	 * 回复人
	 */
	@Column(name = "mcd_replyman")
	private String replyMan;

	/**
	 * 回复时间
	 */
	@Column(name = "mcd_replydate")
	private Date replyDate;

	/**
	 * 从平台上回复的内容回传到卖方ERP的状态
	 */
	@Column(name = "mcd_replybackstatus")
	private Short replyBackStatus;

	/**
	 * 回复内容传到买方ERP的状态
	 */
	@Column(name = "mcd_replysendstatus")
	private Short replySendStatus;

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

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

	/**
	 * 新税率
	 */
	@Column(name = "mcd_newtaxrate")
	private Float newtaxrate;

	public Long getId() {
		return id;
	}

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

	public Short getNumber() {
		return number;
	}

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

	public Double getNewQty() {
		return newQty;
	}

	public void setNewQty(Double newQty) {
		this.newQty = newQty;
	}

	public Double getNewPrice() {
		return newPrice;
	}

	public void setNewPrice(Double newPrice) {
		this.newPrice = newPrice;
	}

	public String getRemark() {
		return remark;
	}

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

	public Double getOldQty() {
		return oldQty;
	}

	public void setOldQty(Double oldQty) {
		this.oldQty = oldQty;
	}

	public Double getOldPrice() {
		return oldPrice;
	}

	public void setOldPrice(Double oldPrice) {
		this.oldPrice = oldPrice;
	}

	public MakeOrderChange getOrderChange() {
		return orderChange;
	}

	public void setOrderChange(MakeOrderChange orderChange) {
		this.orderChange = orderChange;
	}

	public Long getOrderId() {
		return orderId;
	}

	public void setOrderId(Long orderId) {
		this.orderId = orderId;
	}

	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Date getDate() {
		return date;
	}

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

	public Date getNewCommence() {
		return newCommence;
	}

	public void setNewCommence(Date newCommence) {
		this.newCommence = newCommence;
	}

	public Date getOldCommence() {
		return oldCommence;
	}

	public void setOldCommence(Date oldCommence) {
		this.oldCommence = oldCommence;
	}

	public Date getNewComplete() {
		return newComplete;
	}

	public void setNewComplete(Date newComplete) {
		this.newComplete = newComplete;
	}

	public Date getOldComplete() {
		return oldComplete;
	}

	public void setOldComplete(Date oldComplete) {
		this.oldComplete = oldComplete;
	}

	public Short getSendStatus() {
		return sendStatus;
	}

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

	public Short getStatus() {
		return status;
	}

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

	public Short getAgreed() {
		return agreed;
	}

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

	public Short getUnNeedReply() {
		return unNeedReply;
	}

	public void setUnNeedReply(Short unNeedReply) {
		this.unNeedReply = unNeedReply;
	}

	public String getReplyRemark() {
		return replyRemark;
	}

	public void setReplyRemark(String replyRemark) {
		this.replyRemark = replyRemark;
	}

	public Short getReplyBackStatus() {
		return replyBackStatus;
	}

	public void setReplyBackStatus(Short replyBackStatus) {
		this.replyBackStatus = replyBackStatus;
	}

	public Short getReplySendStatus() {
		return replySendStatus;
	}

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

	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 Long getProductId() {
		return productId;
	}

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

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Date getReplyDate() {
		return replyDate;
	}

	public void setReplyDate(Date replyDate) {
		this.replyDate = replyDate;
	}

	public String getReplyMan() {
		return replyMan;
	}

	public void setReplyMan(String replyMan) {
		this.replyMan = replyMan;
	}

	public Date getErpDate() {
		return erpDate;
	}

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

	@JsonIgnore
	@JSONField(serialize = false)
	public boolean isAgreed() {
		return this.agreed != null && Constant.YES == this.agreed;
	}

	/**
	 * 处理详情
	 * 
	 * @return
	 */
	public String replyDescription() {
		return isAgreed() ? "同意变更" : "不同意变更";
	}

	public Float getTaxrate() {
		return taxrate;
	}

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

	public Float getNewtaxrate() {
		return newtaxrate;
	}

	public void setNewtaxrate(Float newtaxrate) {
		this.newtaxrate = newtaxrate;
	}

}
