package com.dev.swms.server.service.picking.allocate;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.dev.swms.server.model.abstractEntity.AbstractMoveDoc;
import com.dev.swms.server.model.abstractEntity.AbstractMoveDocDetail;
import com.dev.swms.server.model.base.BillType;
import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.LotInfo;
import com.dev.swms.server.model.base.Structure;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.model.inventory.ProcessDocBOMDetail;
import com.dev.swms.server.model.rules.PickItemRule;
import com.dev.swms.server.model.shipping.PickTicketDetail;
import com.dev.energy.server.service.BaseManager;

/**
 * @author  dev
 */
@Transactional(readOnly = true)
public interface AutoAllocator extends BaseManager {
	/**
	 * 预分配
	 * @param pickTicketDetails
	 */
	@Transactional
	String preAllocate(List<Long> pickTicketId);
	/**
	 * 预分配
	 * @param pickTicketDetails
	 */
	@Transactional
	void preAllocate(Collection<PickTicketDetail> pickTicketDetails);
	
	@Transactional
	 void prePlanAllocate(Collection<PickTicketDetail> pickTicketDetails);

	/**
	 * 预分配
	 * @param detail 发货单明细
	 * @param quantity 待预分配数量
	 */
	@Transactional
	void preAllocate(PickTicketDetail detail, Double quantity,String Type);
	/**
	 * 预分配
	 * @param detail 发货单明细
	 * @param quantity 待预分配数量
	 */
	@Transactional
    void preAllocate(PickTicketDetail d, Double quantity); 

	/**
	 * 取消预分配
	 * @param pickTicketDetails
	 */
	@Transactional
	void unPreAllocate(Collection<PickTicketDetail> pickTicketDetails);

	/**
	 * 取消预分配
	 * @param detail 发货单明细
	 * @param quantity 待取消预分配数量
	 */
	@Transactional
	void unPreAllocate(PickTicketDetail detail, Double quantity);
	
	/**
	 * 查找拣货规则
	 * @param company
	 * @param billType
	 * @param itemPickType
	 * @param item
	 * @param packageUnit
	 * @param lotInfo
	 * @param quantity
	 * @param abcType
	 * @return
	 */
	List<PickItemRule> getPickItemRules(Structure company,BillType billType,String itemPickType,
			Item item,PackageUnit packageUnit,LotInfo lotInfo,double quantity,String abcType);
    
	/**
	 * 反激活补货计划
	 * @param moveDoc
	 * @return
	 */
	@Transactional
	void unallocate(AbstractMoveDoc moveDoc);
	
	@Transactional
	void unallocate(AbstractMoveDoc moveDoc,List<PickTicketDetail> details);
	
	/**
	 * 库内加工作为单子件明细预分配
	 * @param bomDetail
	 * @param quantity
	 */
	@Transactional
	void preAllocate(ProcessDocBOMDetail bomDetail, Double quantity);
	
	/**
	 * 库内加工作为单子件明细取消预分配
	 * @param bomDetail
	 * @param quantity
	 */
	@Transactional
	void unPreAllocate(ProcessDocBOMDetail bomDetail, Double quantity);

	/**
	 * 手工拣货分配
	 * @param pickTicketDetail
	 * @param inventories
	 */
	@Transactional
	void manualAllocate(AbstractMoveDocDetail moveDocDetail, Map inventories);

	/**
	 * 根据类型自动拣货分配(确保同一仓库单进程)
	 * @param ids
	 * @param type
	 */
	@Transactional
	String allocate(Long pickTicketId, Long waveDocId, Long moveDocId, Collection<AbstractMoveDocDetail> details);
	
}
