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

import java.util.Set;

import com.dev.energy.server.model.Entity;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
 * 库区类
 * @author  dev
 *
 */
public class WarehouseArea extends Entity {
	private static final long serialVersionUID = 5115139409255803447L;
	/** 所属仓库 */
	private Warehouse warehouse;
	/** 库区代码 */
	private String code;
	/** 库区名称 */
	private String name;
	/** 库区说明 */
	private String description;
	/** 库区所有库位 */
	private Set<Location> locations;
	/** 是否有效 */
	private boolean disabled = false;
	/** 冷链物流---库区额定温度 */
	private double temperature;
	private int x_Pos;
	private int y_Pos;
	/** 供应商 */
	private Structure supplier;
	/** 是否不良品 */
	private boolean beReject = false;
	/**是否接收仓库*/
	private boolean beReceive= false;
	/**是否出库仓库*/
	private boolean beShip= false;
	/**制造库位耗用*/
	private boolean beZzHy= false;
	/** 工位 */
	private String gw;
	/** 待投料库位 */
	private Location hckw;
	
	
	public boolean isBeZzHy() {
		return beZzHy;
	}
	public void setBeZzHy(boolean beZzHy) {
		this.beZzHy = beZzHy;
	}
	public boolean isBeShip() {
		return beShip;
	}
	public void setBeShip(boolean beShip) {
		this.beShip = beShip;
	}
	public String getGw() {
		return gw;
	}
	public void setGw(String gw) {
		this.gw = gw;
	}
	public Location getHckw() {
		return hckw;
	}
	public void setHckw(Location hckw) {
		this.hckw = hckw;
	}
	public boolean isBeReceive() {
		return beReceive;
	}
	public void setBeReceive(boolean beReceive) {
		this.beReceive = beReceive;
	}
	public boolean isBeReject() {
		return beReject;
	}
	public void setBeReject(boolean beReject) {
		this.beReject = beReject;
	}
	public Structure getSupplier() {
		return supplier;
	}
	public void setSupplier(Structure supplier) {
		this.supplier = supplier;
	}
	public int getX_Pos() {
		return x_Pos;
	}
	public void setX_Pos(int pos) {
		x_Pos = pos;
	}
	public int getY_Pos() {
		return y_Pos;
	}
	public void setY_Pos(int pos) {
		y_Pos = pos;
	}
	public double getTemperature() {
		return temperature;
	}
	public void setTemperature(double temperature) {
		this.temperature = temperature;
	}
	public boolean isDisabled() {
		return disabled;
	}
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Warehouse getWarehouse() {
		return warehouse;
	}
	public void setWarehouse(Warehouse warehouse) {
		this.warehouse = warehouse;
	}
	public Set<Location> getLocations() {
		return locations;
	}
	public void setLocations(Set<Location> locations) {
		this.locations = locations;
	}

	public int hashCode() {
		return new HashCodeBuilder().append(warehouse).append(code)
				.toHashCode();
	}

	public boolean equals(final Object other) {
		if (!(other instanceof WarehouseArea))
			return false;
		WarehouseArea castOther = (WarehouseArea) other;
		return new EqualsBuilder().append(warehouse, castOther.getWarehouse())
				.append(code, castOther.getCode()).isEquals();
	}
	
	public boolean inUse() {
		if (this.locations == null
					|| this.locations.size() == 0) {
			return false;
		}
		for (Location location : this.locations) {
			if (!location.isDisabled()) {
				return true;
			}
		}
		return false;
	}
}
