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

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

import org.springframework.transaction.annotation.Transactional;

import com.dev.swms.server.model.rules.WaveRule;
import com.dev.swms.server.model.shipping.MachiningDetail;
import com.dev.swms.server.model.shipping.Prewave;
import com.dev.swms.server.model.shipping.WaveDoc;
import com.dev.swms.server.model.shipping.WaveDocItem;
import com.dev.energy.server.service.BaseManager;

public interface WaveDocManager extends BaseManager {
	
	/**
	 * 创建波次
	 */
	@Transactional
	void createWaveDoc();
	
	/**
	 * 创建波次作业单
	 * baseDate:基准时间
	 */
	@Transactional
	void createWaveDoc(Date baseDate);
	
	/**
	 * 指定备货库位
	 * @param waveDoc
	 */
	@Transactional
	void savePrepareGoodsLoc(WaveDoc waveDoc);
	/**
	 * 生效
	 * @param waveDocIds
	 */
	@Transactional
	void activeWaveDoc(List<Long> waveDocIds);
	
	/**
	 * 失效
	 * @param waveDocIds
	 */
	@Transactional
	void inactiveWaveDoc(List<Long> waveDocIds);
	
	/**
	 * 删除波次作业单
	 * @param waveDocIds
	 */
	@Transactional
	void deleteWaveDoc(List<Long> waveDocIds);
	
	/**
	 * 往波次作业单中添加拣货单
	 * @param waveDocId
	 * @param pickTicketIds
	 */
	@Transactional
	void addPickTicketsToWaveDoc(Long waveDocId,List<Long> pickTicketIds);
	
	/**
	 * 从波次作业单中删除拣货单
	 * @param waveDocId
	 * @param pickTicketIds
	 */
	@Transactional
	void deletePickTicketsFromWaveDoc(Long waveDocId,List<Long> pickTicketIds);
	
	/**
	 * 取消分配
	 * @param waveDocIds
	 */
	@Transactional
	void unallocate(List<Long> waveDocIds);
	
	/**
	 * 手工分配所选波次作业
	 * @param waveDocId
	 * @param waveDocDetailIds
	 */
//	@Transactional
//	void autoAllocate(Long waveDocId,	List<Long> waveDocDetailIds);
	
	/**
	 * 手工部份分配
	 * @param waveDocDetailId
	 * @param inventories
	 */
//	@Transactional
//	void manualAllocate(Long waveDocDetailId, Map inventories);
	
	/**
	 * 手工取消波次作业单分配
	 * @param waveDocId
	 * @param tasks
	 */
//	@Transactional
//	void unallocate(Long waveDocId, Map tasks);
	
	/**
	 * 整单拣货
	 * @param waveDocId
	 * @param workerId
	 */
	@Transactional
	void pickConfirmForPickAll(Long waveDocId,Long workerId);
	
	/**
	 * 单一收货与分配一致
	 * @param taskId
	 * @param pickedQuantity
	 * @param workerId
	 */
	@Transactional
	void pickConfirm(Long taskId, double pickedQuantity, Long workerId);
	
	@Transactional
	void afterPickConfirm(List<Long> ids);
	
	/**
	 * 选库位单一收货
	 * @param taskId
	 * @param srcLocId
	 * @param lp
	 * @param lot
	 * @param packageUnitId
	 * @param pickedQuantity
	 * @param workerId
	 */
	@Transactional
	void pickConfirm(Long taskId, Long srcLocId, String lp, String lot, Long packageUnitId,
			double pickedQuantity, Long workerId );
	
	/**
	 * 关闭波次作业单
	 * @param waveDocIds
	 */
	@Transactional
	void closeWaveDocsByIds(List<Long> waveDocIds);
	
	/**
	 * 波次自动分单
	 * @param waveDocId
	 */
	@Transactional
	void autoDisForWave(Long waveDocId);
	
	/**
	 * 批量自动分单
	 * @param pickTicketIds
	 */
	@Transactional
	void autoDisForPickticket(List<Long> pickTicketIds,Long waveDocId);
	
	/**
	 * 强制波次自动分单
	 * @param waveDocId
	 */
	@Transactional
	void mustDisForWave(Long waveDocId);
	
	/**
	 * 强制批量自动分单
	 * @param pickTicketIds
	 */
	@Transactional
	void mustDisForPickticket(List<Long> pickTicketIds,Long waveDocId);
	
	/**
	 * 取消分单(整个波次取消分单)
	 * @param ids
	 */
	@Transactional
	void cancelSplitWaveDoc(Long waveDocId);
	/**
	 * 取消分单(按照选择的捡货单取消分单)
	 * @param ids
	 */
	@Transactional
	void cancelSplitForPickticket(List<Long> ids ,Long waveDocId);
	
	@Transactional
	Map init_WD_INFO(Map params);

	@Transactional
	Map init_WDD_INFO(Map params);
	
	@Transactional
	Map init_WDAL_INFO(Map params);
	
	@Transactional
	Map init_WDALD_INFO(Map params);
	
//	按策略分配波次
	@Transactional
	Map auto_WD_Allocate(Map params);
//	对已分配的波次取消分配	
	@Transactional
	Map cancell_WD_Allocate(Map clientParams);
//	对波次明细手工分配指定库存的数量
	@Transactional
	Map manual_WD_Allocate(Map clientParams);
	
	@Transactional
	void operatingArrangement(List<Long> ids);
	
	//手工创建波次
	@Transactional
	void manualcreateWaveDoc(Long sid,WaveDoc waveDoc);
	
	@Transactional
	void savePickTicketsToWaveDoc(Long waveDocId,List<Long> ids);
	
	//移除
	@Transactional
	void removePickTicketsToWaveDoc(Long waveDocId,List<Long> ids);
	
	//添加
	@Transactional
	void saveWaveDoc(Long waveDocId,List<Long> ids);
	
	@Transactional
	void removeWaveDoc(Long waveDocId,List<Long> ids);
	
	@Transactional
	void addMachiningDetail(MachiningDetail md,Long waveDocId);
	
	@Transactional
	void deleteMachiningDetail(List<Long> ids);
	
	@Transactional
	void effectiveMachiningDetail(List<Long> ids);
	
	@Transactional
	void abateMachiningDetail(List<Long> ids);
	
	@Transactional
	void saveWaveDocItem(Long id,WaveDocItem waveDocItem);
	
	@Transactional
	void deleteWaveDocItem(Long id,List<Long> ids);
	
}
