package com.cim.idm.mwmsextend.materialshiprequest.service;

import java.util.ArrayList;
import java.util.List;

import com.cim.idm.framework.IDMFrameServiceProxy;

public class MaterialShipRequestServiceUtil {

	public String getMaterialShiprequestByUndoID(String UndoID)throws Exception
	{
		try{
	
			String sql = "SELECT DISTINCT SHIPREQUESTNAME FROM BS_MATERIALPACKINGUNDOINFO WHERE UNDOID=? ";
		
			Object[] args = {UndoID};

	    	//String result = String.valueOf(IDMFrameServiceProxy.getSqlTemplate().queryByCursor(sql, args));
			//List result = IDMFrameServiceProxy.getSqlTemplate().getJdbcTemplate().queryForList(sql, bindSet);
              String result = IDMFrameServiceProxy.getSqlTemplate().queryForObject(sql, String.class, args);
			return result;
		}
		catch(Exception e){e.printStackTrace();
		throw e;}
	}
	
	public String getMESMaterialShiprequestByUndoID(String UndoID)throws Exception
	{
		try{
	
			String sql = "SELECT DISTINCT RECEIVEREQUESTNAME FROM BS_MATERIALPACKINGUNDOINFO WHERE UNDOID=? ";
		
			Object[] args = {UndoID};

	    	//String result = String.valueOf(IDMFrameServiceProxy.getSqlTemplate().queryByCursor(sql, args));
			//List result = IDMFrameServiceProxy.getSqlTemplate().getJdbcTemplate().queryForList(sql, bindSet);
              String result = IDMFrameServiceProxy.getSqlTemplate().queryForObject(sql, String.class, args);
			return result;
		}
		catch(Exception e){e.printStackTrace();
		throw e;}
	}
	
	public List<String> getMaterialShiprequestList(String UndoID){
		String sql = "SELECT DISTINCT SHIPREQUESTNAME FROM BS_MATERIALPACKINGUNDOINFO WHERE UNDOID=? ";
		Object[] bindSet = new Object[] { UndoID };
	String[][]	result= IDMFrameServiceProxy.getSqlTemplate().queryForStringArray(sql, bindSet);
		//List result = IDMFrameServiceProxy.getSqlTemplate().getJdbcTemplate().queryForList(sql, bindSet);

	List<String> returnValue = new ArrayList<String>();
	
	for (String[] row : result)
		returnValue.add(row[0].toString());
	
	return returnValue;
		
	}
}
