package com.chinaitop.depot.intelligent.ventilation.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.chinaitop.depot.intelligent.ventilation.mapper.DataKcglKcswDefaultMapper;
import com.chinaitop.depot.intelligent.ventilation.model.DataKcglKcswDefault;
import com.chinaitop.depot.intelligent.ventilation.model.DataKcglKcswDefaultExample;
import com.chinaitop.depot.intelligent.ventilation.model.DataKcglKcswDefaultExample.Criteria;
import com.chinaitop.depot.intelligent.ventilation.service.KcswService;

@Service
public class KcswServiceImpl implements KcswService{

	@Resource
	private DataKcglKcswDefaultMapper dataKcglKcswDefaultMapper;

	
	/**
	 * 根据orgId查询库存数量
	 */
	@Override
	public List<DataKcglKcswDefault> queryKcData(Integer orgId, String houseId, String warehouseId) {
		// TODO Auto-generated method stub
		DataKcglKcswDefaultExample example = new DataKcglKcswDefaultExample();
        Criteria createCriteria = example.createCriteria();
        if(warehouseId!=null && warehouseId.equals("0")){//油料(仓房号和货位号是一样的)(品种是油的，7031,7036)
        	if(orgId!=null){
        		createCriteria.andUnitidEqualTo(String.valueOf(orgId));
        	}
        	if(houseId!=null){
        		createCriteria.andChEqualTo(houseId);
        	}
        	createCriteria.andPzBetween("7031", "7036");
        }else{//粮食的
        	if(orgId!=null){
        		createCriteria.andUnitidEqualTo(String.valueOf(orgId));
        	}
        	if(houseId!=null){
        		createCriteria.andChEqualTo(houseId);
        	}
        	if(warehouseId!=null){
        		createCriteria.andHwhEqualTo(warehouseId);
        	}
        }
		return dataKcglKcswDefaultMapper.selectByExample(example);
	}

	
}
