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

import java.util.Date;

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

import com.dev.swms.server.model.base.ItemKey;
import com.dev.swms.server.model.base.Location;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.model.base.Worker;
import com.dev.energy.server.model.Entity;

public class TaskLog extends Entity {
	private static final long serialVersionUID = -1619061812790559494L;
	/** 关联作业任务 */
	private Task task;
	/** 作业人员 */
	private Worker worker;
	/** 作业时间	 */
	private Date recordTime;
	/** 源库位	 */
	private Location srcLoc;
	/**	目标库位	 */
	private Location dstLoc;
	/**	源托盘	 */
	private Stock srcLP;
	/** 源托盘号 */
	private String srcLPCode;
	/**	目标托盘	 */
	private Stock dstLP;
	/** 目标托盘号 */
	private String dstLPCode;
	/** 货品批次属性	 */
	private ItemKey itemKey;
	/** 存货日期 */
	private Date storageDate;
	/** SOI */
	private String SOI;
	/** 库存状态 */
	private String inventoryStatus;
	/**	包装单位	 */
	private PackageUnit packageUnit;
	/** 移位数量（包装数量）	 */
	private double movedQuantity;
	/** 加入bol数量 */
	private double bolQuantity;
	/** 拆分数量	 */
	private double splitQuantity;
	/** 发运数量	 */
	private double shipQuantity;
	/** 描述 */
	private String description;
	/** 退拣标志 */
	private boolean bePickBack = false;
	
	private String barCode;//条形码
	
	private double weight;//收货重量
	
	private double volume;//体积
	
	/** 线边接收数量	 */
	private double xbQuantity;
	
	/** 发货时间 */
	private Date fhDate;
	/** 发货 */
	private String fhBy;
	
	/** 收料日期 */
	private Date slDate;
	/** 收料人 */
	private String slBy;
	
	
	public Date getFhDate() {
		return fhDate;
	}

	public void setFhDate(Date fhDate) {
		this.fhDate = fhDate;
	}

	public String getFhBy() {
		return fhBy;
	}

	public void setFhBy(String fhBy) {
		this.fhBy = fhBy;
	}

	public Date getSlDate() {
		return slDate;
	}

	public void setSlDate(Date slDate) {
		this.slDate = slDate;
	}

	public String getSlBy() {
		return slBy;
	}

	public void setSlBy(String slBy) {
		this.slBy = slBy;
	}

	public double getXbQuantity() {
		return xbQuantity;
	}

	public void setXbQuantity(double xbQuantity) {
		this.xbQuantity = xbQuantity;
	}

	public String getBarCode() {
		return barCode;
	}

	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}

	public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	public double getVolume() {
		return volume;
	}

	public void setVolume(double volume) {
		this.volume = volume;
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof TaskLog))
			return false;
		TaskLog castOther = (TaskLog) other;
		return new EqualsBuilder().append(task, castOther.getTask())
				.append(worker,	castOther.getWorker())
				.append(recordTime, castOther.getRecordTime())
				.append(srcLoc, castOther.getSrcLoc())
				.append(dstLoc,	castOther.getDstLoc())
				.append(srcLP, castOther.getSrcLP())
				.append(srcLPCode, castOther.getSrcLPCode())
				.append(dstLP, castOther.getDstLP())
				.append(dstLPCode, castOther.getDstLPCode())
				.append(itemKey, castOther.getItemKey())
				.append(storageDate, castOther.getStorageDate())
				.append(SOI, castOther.getSOI())
				.append(inventoryStatus, castOther.getInventoryStatus())
				.append(packageUnit, castOther.getPackageUnit())
				.isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(task).append(worker).append(
				recordTime).append(srcLoc).append(dstLoc).append(srcLP).append(
				srcLPCode).append(dstLP).append(dstLPCode).append(itemKey)
				.append(storageDate).append(SOI).append(inventoryStatus)
				.append(packageUnit).toHashCode();
	}

	protected TaskLog() {
		super();
	}
	
	public String getSrcLPCode() {
		return srcLPCode;
	}

	public void setSrcLPCode(String srcLPCode) {
		this.srcLPCode = srcLPCode;
	}

	public String getDstLPCode() {
		return dstLPCode;
	}

	public void setDstLPCode(String dstLPCode) {
		this.dstLPCode = dstLPCode;
	}

	public boolean isBePickBack() {
		return bePickBack;
	}

	public void setBePickBack(boolean bePickBack) {
		this.bePickBack = bePickBack;
	}

	public double getSplitQuantity() {
		return splitQuantity;
	}

	public void setSplitQuantity(double splitQuantity) {
		this.splitQuantity = splitQuantity;
	}

	public double getShipQuantity() {
		return shipQuantity;
	}

	public void setShipQuantity(double shipQuantity) {
		this.shipQuantity = shipQuantity;
	}

	public String getInventoryStatus() {
		return inventoryStatus;
	}

	public void setInventoryStatus(String inventoryStatus) {
		this.inventoryStatus = inventoryStatus;
	}

	public Date getStorageDate() {
		return storageDate;
	}

	public void setStorageDate(Date storageDate) {
		this.storageDate = storageDate;
	}

	public String getSOI() {
		return SOI;
	}

	public void setSOI(String soi) {
		SOI = soi;
	}

	public double getBolQuantity() {
		return bolQuantity;
	}

	public void setBolQuantity(double bolQuantity) {
		this.bolQuantity = bolQuantity;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Location getDstLoc() {
		return dstLoc;
	}

	public void setDstLoc(Location dstLoc) {
		this.dstLoc = dstLoc;
	}

	public Stock getDstLP() {
		return dstLP;
	}

	public void setDstLP(Stock dstLP) {
		this.dstLP = dstLP;
	}

	public ItemKey getItemKey() {
		return itemKey;
	}

	public void setItemKey(ItemKey itemKey) {
		this.itemKey = itemKey;
	}

	public double getMovedQuantity() {
		return movedQuantity;
	}

	public void setMovedQuantity(double movedQuantity) {
		this.movedQuantity = movedQuantity;
	}

	public PackageUnit getPackageUnit() {
		return packageUnit;
	}

	public void setPackageUnit(PackageUnit packageUnit) {
		this.packageUnit = packageUnit;
	}

	public Date getRecordTime() {
		return recordTime;
	}

	public void setRecordTime(Date recordTime) {
		this.recordTime = recordTime;
	}

	public Location getSrcLoc() {
		return srcLoc;
	}

	public void setSrcLoc(Location srcLoc) {
		this.srcLoc = srcLoc;
	}

	public Stock getSrcLP() {
		return srcLP;
	}

	public void setSrcLP(Stock srcLP) {
		this.srcLP = srcLP;
	}

	public Task getTask() {
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	public Worker getWorker() {
		return worker;
	}

	public void setWorker(Worker worker) {
		this.worker = worker;
	}

	public void pickBack(Double quantity) {
		this.movedQuantity -= quantity;
		
		if(this.movedQuantity==0){
			this.setBePickBack(true);
		}	
		task.pickBak(quantity);
		
	}
}
