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

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

import org.springframework.transaction.annotation.Transactional;

import com.dev.swms.server.model.rules.AbcTypeCountRule;
import com.dev.swms.server.model.rules.CompanyTransRule;
import com.dev.swms.server.model.rules.CompanyTransRuleDetail;
import com.dev.swms.server.model.rules.CompanyWorkRule;
import com.dev.swms.server.model.rules.CustomerWorkRule;
import com.dev.swms.server.model.rules.ItemStorageRule;
import com.dev.swms.server.model.rules.ItemSupplyRule;
import com.dev.swms.server.model.rules.PresentSaleRule;
import com.dev.energy.server.service.BaseManager;

@Transactional(readOnly = true)
public interface RuleManager extends BaseManager {
	/**
	 * 定义货品存放规则
	 * @param itemStorageRule
	 */
	@Transactional
	void storeItemStorageRule(ItemStorageRule itemStorageRule);

	/**
	 * 删除货品存放规则
	 * @param ids
	 */
	@Transactional
	void deleteItemStorageRules(List<Long> ids);
	/**
	 * 删除批次规则
	 * @param putawayRuleDetailIds
	 */
	@Transactional
	void deleteLotRules(List<Long> lotRuleIds);
	/**
	 * 定义补货规则
	 * @param itemStorageRule
	 */
	@Transactional
	void storeItemSupplyRule(ItemSupplyRule itemSupplyRule);
	/**
	 * 删除补货规则
	 * @param ids
	 */
	@Transactional
	void deleteItemSupplyRules(List<Long> ids);
	
	/**
	 * 仓库货品存货规则中的各种分类定义
	 * @param itemStorageRuleIds
	 * @param referTo（PUTAWAY-上架分类 PICK-拣货分类）
	 * @param method 设置方式
	 * @param type 自定义分类名称
	 */
	@Transactional
	void setItemStorageType(List<Long> itemStorageRuleIds, String referTo, String method, String type);

	/**
	 * 设置货品ABC分类
	 * @param itemStorageRule
	 */
	@Transactional
	void setABCTypeCountRule(ItemStorageRule itemStorageRule);
	
	/**
	 * 安全库存定义
	 * @param itemStorageRule
	 */
	@Transactional
	void storeItemSafeRule(List<Long> ids,Long warehouseId,String minStock,String maxStock);
	
	/**
	 * 删除ABC规则
	 * @param ids
	 */
	@Transactional
	void deleteAbcTypeCountRule(List<Long> ids);
	
	/**
	 * 保存ABC规则
	 * @param itemStorageRule
	 */
	@Transactional
	void saveAbcTypeCountRule(AbcTypeCountRule abcTypeCountRule);
	
	@Transactional
	void setBigTypePutaway(List<Long> ids);
	
	@Transactional
	void setMiddleTypePutaway(List<Long> ids);
	
	@Transactional
	void setSmallTypePutaway(List<Long> ids);
	
	@Transactional
	void setBigTypePick(List<Long> ids);
	
	@Transactional
	void setMiddleTypePick(List<Long> ids);
	
	@Transactional
	void setSmallTypePick(List<Long> ids);
	
	@Transactional
	void storeCompanyTransRule(CompanyTransRule rule);
	@Transactional
	void deleteCompanyTransRule(List<Long> ids);
	@Transactional
	void deleteCompanyTransRuleDetail(Long ruleId,List<Long> ids);
	@Transactional
	void storeCompanyTransRuleDetail(Long ruleId,CompanyTransRuleDetail companyTransRuleDetail);
	@Transactional
	void storePresentSaleRule(PresentSaleRule psr,Double Qty,Double presentQty);
	@Transactional
	void deletePresentSalrRules(List<Long> ids);
	
	@Transactional
	void deleteCompanyWorkRuls(List<Long> ids);
	@Transactional
	void saveCompanyWorkRule(CompanyWorkRule rule);
	
	@Transactional
	void deleteCustomerWorkRuls(List<Long> ids);
	@Transactional
	void saveCustomerWorkRule(CustomerWorkRule rule);
	
	/**
	 * 对当前仓库按货品初始化货品作业分类资料（只增补货品作业分类中没有的货品）
	 */
	@Transactional
	void initItemStorageRule();
	
	/**
	 * 对指定货主的当前仓库货品按统计结果调整原ABC分类
	 * @param companyId
	 */
	@Transactional
	void adjustAbcType(Long companyId);
	
	/**
	 * 对指定货主指定时间范围内的货物流转情况进行分析，并设置对应货品的ABC统计分类
	 * @param companyId
	 * @param beginDate
	 * @param endDate
	 */
	@Transactional
	void analyzeAbcType(Long companyId, Date beginDate, Date endDate);
}
