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

import java.util.Set;

import com.dev.swms.server.model.base.Structure;
import com.dev.swms.server.model.base.Warehouse;
import com.dev.swms.server.model.receiving.ReceivedRecord;
import com.dev.energy.server.model.Entity;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
 * 货主转换规则主对象
 * @author  dev
 * 说明：
 *1. 带供应商属性的不允许做货主转移 
  2. 转的时候，按照新货主重新计算批次号； （可能出现信息丢失情况） 
  3. 库存日志，增加货权转出，货权转入两个类型 
  4. 日报表要准确体现 

  代码转换算法： 
  1. 配置一个转换规则，规则上设置： 货主A, 货主B ， 是否允许代码直转 
  2. 转换规则下面的挂：代码转换对照表 
  3. 如果允许代码直转， 如果没找到对照表里的信息，就看这个代码在目标货主的货品清单中是否存在， 如果有就转，如果还没有就不转 
  4. 如果不允许代码直转，就只能查表，查不到就不转
 */
public class CompanyTransRule extends Entity {
	
	private Warehouse warehouse;
	/**
	 * 货主A
	 */
	private Structure companyA;
	/**
	 * 货主B
	 */
	private Structure companyB;
	/**
	 * 货品对照表
	 */
	private Set<CompanyTransRuleDetail> details; 
	/**
	 * 是否允许代码直转
	 */
	private boolean canTrans = false;
	
	public Set<CompanyTransRuleDetail> getDetails() {
		return details;
	}
	public void setDetails(Set<CompanyTransRuleDetail> details) {
		this.details = details;
	}
	public int hashCode() {
		return new HashCodeBuilder().append(warehouse).append(companyA).append(
				companyB).toHashCode();
	}
	public boolean equals(final Object other) {
		if (!(other instanceof CompanyTransRule))
			return false;
		CompanyTransRule castOther = (CompanyTransRule) other;
		return new EqualsBuilder().append(warehouse, castOther.warehouse)
				.append(companyA, castOther.companyA).append(companyB,
						castOther.companyB).isEquals();
	}
	public Warehouse getWarehouse() {
		return warehouse;
	}
	public void setWarehouse(Warehouse warehouse) {
		this.warehouse = warehouse;
	}
	
	public boolean isCanTrans() {
		return canTrans;
	}
	public void setCanTrans(boolean canTrans) {
		this.canTrans = canTrans;
	}
	public Structure getCompanyA() {
		return companyA;
	}
	public void setCompanyA(Structure companyA) {
		this.companyA = companyA;
	}
	public Structure getCompanyB() {
		return companyB;
	}
	public void setCompanyB(Structure companyB) {
		this.companyB = companyB;
	}
	
	
}
