/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sg.managementcenter.materialInventory.service;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.managementcenter.materialInventory.entity.MaterialInventory;
import com.jeeplus.modules.sg.managementcenter.materialInventory.entity.MaterialRequisition;
import com.jeeplus.modules.sg.managementcenter.materialInventory.mapper.MaterialInventoryMapper;
import com.jeeplus.modules.sg.managementcenter.project.entity.PickingRequisition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class MaterialInventoryService extends CrudService<MaterialInventoryMapper, MaterialInventory> {
	@Autowired
	private MaterialInventoryMapper materialInventoryMapper;

	public MaterialInventory get(String id) {
		return super.get(id);
	}
	
	public List<MaterialInventory> findList(MaterialInventory materialInventory) {
		return super.findList(materialInventory);
	}
	
	public Page<MaterialInventory> findPage(Page<MaterialInventory> page, MaterialInventory materialInventory) {
		return super.findPage(page, materialInventory);
	}
	
	@Transactional(readOnly = false)
	public void save(MaterialInventory materialInventory) {
		super.save(materialInventory);
	}
	
	@Transactional(readOnly = false)
	public void delete(MaterialInventory materialInventory) {
		super.delete(materialInventory);
	}

	@Transactional(readOnly = false)
	public void saveList(List<MaterialInventory> list) {
		for(MaterialInventory materialInventory : list){
			materialInventory.preInsert();
		}
		materialInventoryMapper.insertList(list);
	}

	/**
	 * 根据领料单数据对象列表获取对应库存对象列表
	 * @param list
	 * @return
	 */
	public List<MaterialInventory> findByList(List<MaterialRequisition> list){
		return materialInventoryMapper.findByList(list);
	}

//	//根据物料编码查找库存信息
//	public List<MaterialInventory> findByListPicking(List<PickingRequisition> list){
//		return materialInventoryMapper.findListInventory(list);
//	}
}