package com.dev.swms.server.model.inventory;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.dev.energy.server.model.DomainModel;

public class ProductInventory extends DomainModel {
	/** 仓库编码 */
	private String warehouse;
	/** 客户编码 */
	private String customer;
	/** 货品编码 */
	private String product;
	/** 批次号(生产) */
	private String lot;
	/** 库存数量(MU) */
	private double quantity;
	/** 唯一键(仓库编码|货品编码|批次号) */
	private String unicode;
	
	protected ProductInventory() {
		
	}
	
	public ProductInventory(String warehouse, String customer, String product,
			String lot, double quantity) {
		super();
		this.warehouse = warehouse;
		this.customer = customer;
		this.product = product;
		this.lot = lot;
		this.quantity = quantity;
		this.unicode = this.warehouse + "|" + this.customer + "|"  
				+ this.product + (this.lot == null ? "" : ("|" + this.lot));
	}
	
	public String getWarehouse() {
		return warehouse;
	}
	public void setWarehouse(String warehouse) {
		this.warehouse = warehouse;
	}
	public String getCustomer() {
		return customer;
	}
	public void setCustomer(String customer) {
		this.customer = customer;
	}
	public String getProduct() {
		return product;
	}
	public void setProduct(String product) {
		this.product = product;
	}
	public String getLot() {
		return lot;
	}
	public void setLot(String lot) {
		this.lot = lot;
	}
	public double getQuantity() {
		return quantity;
	}
	public void setQuantity(double quantity) {
		this.quantity = quantity;
	}
	public String getUnicode() {
		return unicode;
	}
	public void setUnicode(String unicode) {
		this.unicode = unicode;
	}
	
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ProductInventory))
			return false;
		ProductInventory castOther = (ProductInventory) other;
		return new EqualsBuilder().append(unicode, castOther.unicode)
				.isEquals();
	}
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(unicode).toHashCode();
	}
	
}
