package com.dev.swms.server.service.base.pojo;

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

import com.dev.energy.server.service.pojo.DefaultBaseManager;
import com.dev.energy.server.web.security.UserHolder;
import com.dev.swms.server.model.inventory.Stock;
import com.dev.swms.server.service.base.StockManager;

public class DefaultStockManager extends DefaultBaseManager implements StockManager{
	
	/**添加托盘*/
	@Override
	public void saveStock(Stock stock) {
		if(stock.isNew()) {
			stock.setEnabled(false);
			stock.setCreatPeople(UserHolder.getUser().getName());
			stock.setCreatDate(new Date());
		}
		commonDao.store(stock);
	}
	
	/**删除托盘*/
	@Override
	public void deleteStock(List<Long> ids) {
		for(Long id : ids) {
			Stock stock = this.load(Stock.class, id);
			this.delete(stock);
		}
		
	}

	/**失效*/
	@Override
	public void StockInvalid(List<Long> ids) {
		for(Long id : ids) {
			Stock stock = this.load(Stock.class, id);
			stock.setEnabled(true);
		}
		
	}
	
	/**恢复*/
	@Override
	public void Stockrestore(List<Long> ids) {
		for(Long id : ids) {
			Stock stock = this.load(Stock.class, id);
			stock.setEnabled(false);
		}
		
	}

}
