package com.dev.swms.server.service.receiving;

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

import org.springframework.transaction.annotation.Transactional;

import com.dev.swms.server.model.inventory.InventoryApplyDetail;
import com.dev.swms.server.model.inventory.Stock;
import com.dev.swms.server.model.inventory.Task;
import com.dev.swms.server.model.receiving.MoveDoc;
import com.dev.swms.server.model.receiving.MoveDocDetail;
import com.dev.swms.server.model.receiving.MoveObject;
import com.dev.swms.server.model.shipping.Label;
import com.dev.energy.server.service.BaseManager;

@Transactional(readOnly = true)
public interface MoveDocManager extends BaseManager {
	/**
	 * 取消上架分配(批量上架单同时取消分配)
	 */
	@Transactional
	void unallocate(List<Long> moveDocIds);

	/**
	 * 整单移位确认
	 */
	@Transactional
	void moveTo(Long moveDocId,Long workId);
	
	/**
	 * 单一Task移位确认
	 * @param task 移位任务
	 * @param workId 移位人
	 * @param dstLocId 目标库位
	 * @param packageUnitId 移位包装
	 * @param expectedQuantity 包装数量
	 */
	@Transactional
	void taskMove(Task task, Long workId, Long dstLocId, Long packageUnitId, double expectedQuantity);
	
	/**
	 * 单一Task移位确认
	 * @param task
	 * @param workId
	 */
	@Transactional
	void moveTo(Task task, Long workId);

	/**
	 * 保存手工新增的移位计划
	 */
	@Transactional
	void storeMoveLP(MoveDoc moveDoc);
	
	/**
	 * @param ids 自动生成批量移位计划
	 */
	@Transactional
	void moveBatchInventory(List<Long> ids);
	
	/**
	 * 手工新增移位明细
	 */
	@Transactional
	void addMoveLPDetail(Long moveDocId, Long inventoryId, Long destLocationId, 
			Long packageUnitId, Double quantity);
	
	/**
	 * 手工添加库存移位
	 */
	@Transactional
	void addMoveLPDetails(Long moveDocId, Map invs);
	
	/**
	 * 手工修改移位明细
	 */
	@Transactional
	void editMoveLPDetail(Long moveDocId, MoveDocDetail moveDocDetail);
	
	/**
	 * 删除手工移位明细
	 */
	@Transactional
	void deleteMoveLPDetails(Long moveDocId, List<Long> moveDocDetailIds);
	
	/**
	 * 反激活手工移位计划
	 * @param moveDocIds
	 */
	@Transactional
	void inactiveMoveDoc(List<Long> moveDocIds);
	
	/**
	 * 取消移位单
	 */
	@Transactional
	void cancel(List<Long> moveDocIds);
	
	/**
	 * 删除移位单
	 */
	@Transactional
	void deleteMoveDoc(List<Long> moveDocIds);
	
	/**
	 * 自动创建库内补货单
	 */
	@Transactional
	void autoSupplyDoc();
	
	/**
	 * 自动创建补货申请单
	 * */
	@Transactional
	void autoCreateApplyDoc();
	
	/**
	 * 向受理仓库发送补货申请单
	 * */
	@Transactional
	void sendApplyDoc(List<Long> ids);
	
	/**
	 * 根据补货申请单内容创建发货单
	 * */
	@Transactional
	void createPickTicketByApplyDoc(List<Long> ids);
	
	/**
	 * 取消补货申请单
	 * */
	@Transactional
	void cancelApplyDoc(List<Long> ids);
	
	/**
	 * 反激活库内补货单
	 * @param moveDocIds
	 */
	@Transactional
	void inactiveSupplyDoc(List<Long> moveDocIds);
	
	/**
	 * 关闭库内补货单
	 * */
	@Transactional
	void closeSupplyDoc(List<Long> moveDocIds);
	
	/**
	 * 删除库内补货单
	 * */
	@Transactional
	void deleteSupplyDoc(List<Long> moveDocIds);
	
	/**
	 * 根据itemCode查找匹配的第一条明细记录（For RF）
	 * @param moveDocId
	 * @param itemCode
	 * @return
	 */
	MoveDocDetail getMoveDocDetailByItem(Long moveDocId, String itemCode);

	/**
	 * 根据itemKey查找匹配的第一条明细记录（For RF）
	 * @param moveDocId
	 * @param itemCode
	 * @return
	 */
	MoveDocDetail getMoveDocDetailByItemKey(Long moveDocId, Long itemKeyId);

	String getExpectedQuantityByTask(Map map);
	
	/**
	 * 删除库间补货申请明细
	 * @param applyDocId
	 * @param applyDetailIds
	 */
	@Transactional
	void removeInventoryApplyDetails(Long applyDocId, List<Long> applyDetailIds);
	
	/**
	 * 修改库间补货单明细
	 * @param applyDocId
	 * @param detail
	 */
	@Transactional
	void addInventoryApplyDetail(Long applyDocId, InventoryApplyDetail detail);
	
	/**
	 * 手工分配上架计划
	 * @param detail
	 * @param packageUnitId 包装单位ID
	 * @param moveQUantity(包装数量)
	 */
	@Transactional
	void manualMoveDetail(MoveDocDetail detail, Long packageUnitId,Double caseQty,Double puQty,Stock srcLp);
	/**
	 * 手工分配上架计划
	 */
	@Transactional
	void manualMoveDetail(MoveDocDetail detail, Long packageUnitId, Double caseQty,Double puQty);
	@Transactional
	void manualMoveDetail(Long moveDocId, Map maps);
	
	@Transactional
	void deletePutAway(List<Long> ids) ;
	
	String getPlanQuantityByDetail(Map map);
	
	int getCaseQty(Map map);
	
	int getPuQty(Map map);
	
	int getsjQty(Map map);
	
	//上架确认
	@Transactional
	void putawayConfirm(MoveDocDetail detail, Long dstLocId,Long moveDocId);

		@Transactional
		void storeLabel(Label l);
		@Transactional
		void deleteLabel(List<Long> ids);
		
		@Transactional
		void addLabelDetails(Long LabelId, Map invs);
		
		@Transactional
		void inactiveLabel(List<Long> ids);
		
		
		/**
		 * @author  dev
		 * 删除回单影像
		 */
		@Transactional
		void deleteSignFile(List<Long> ids);
		//货权转移添加
		@Transactional
		void addMoveTransDetails(Long moveObjectId, Map invs);
		//货权转移移除
		@Transactional
		void deleteMoveTransDetails(Long moveObjectId, List<Long> moveObjectDetailIds);
		@Transactional
		void storeMoveTrans(MoveObject moveObject);
		
		@Transactional
		void deleteMoveTrans(List<Long> moveObjectIds);
		
		
}
