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

import java.util.List;

import com.dev.energy.server.service.pojo.DefaultBaseManager;
import com.dev.energy.server.util.LocalizedMessage;
import com.dev.swms.server.model.abstractEntity.ModelChange;
import com.dev.swms.server.model.base.Item;
import com.dev.swms.server.model.base.ItemAndMachItem;
import com.dev.swms.server.model.base.PackageUnit;
import com.dev.swms.server.service.base.ItemAndMachItemManager;

public class DefaultItemAndMachItemManager extends DefaultBaseManager implements ItemAndMachItemManager {

	@Override
	public void saveMachinScale(Long itemId,Long machItemId,double machQuantity,String description) {
		Item item =this.load(Item.class, itemId);//商品
		Item machItem=this.load(Item.class, machItemId);//加工商品
		ItemAndMachItem itemAndMachItem = new ItemAndMachItem();
		if(itemAndMachItem.isNew()){
			itemAndMachItem.setItem(item);
			itemAndMachItem.setMachItem(machItem);
			itemAndMachItem.setMachQuantity(machQuantity);
			itemAndMachItem.setDescription(description);
			this.commonDao.store(itemAndMachItem);
		}
		
	}

	@Override
	public void deleteAll(List<Long> ids) {
		for(Long id : ids){
			ItemAndMachItem itemAndMachItem =this.load(ItemAndMachItem.class, id);
			this.commonDao.delete(itemAndMachItem);
		}
		
	}

	@Override
	public void deleteAllModelChage(List<Long> ids) {
		// TODO 自动生成的方法存根
		for(Long id : ids){
			ModelChange modelChange =this.load(ModelChange.class, id);
			this.commonDao.delete(modelChange);
		}
	}


}
