package com.eactive.eai.rms.onl.manage.sna.lugroup;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.eactive.eai.rms.common.base.BaseService;

@Service("luGroupService")
public class LuGroupService extends BaseService{
	
	@Autowired
	@Qualifier("luGroupDao")
	private LuGroupDao dao;
	
	
	public HashMap selectList(int startNum,int endNum, String searchAdptrGstatSevrName , String searchAdptrGroupName) throws Exception {
		HashMap paramMap = new HashMap();
		
		//검색 조건 
		paramMap.put("searchAdptrGstatSevrName", searchAdptrGstatSevrName);
		paramMap.put("searchAdptrGroupName", searchAdptrGroupName);
		// 전체 목록수 얻기
		int totalCount = dao.selectListCount(paramMap);

		paramMap.put("startNum" , startNum);// 시작 record
		paramMap.put("endNum"   , endNum);// 끝 record

		List<HashMap<String, Object>> list = dao.selectList(paramMap);
		
		HashMap map = new HashMap();

		map.put("totalCount", totalCount);

		map.put("list", list);

		return map;
	}
	
	public HashMap selectDetail(String adptrGstatSevrName,String adptrGroupName,String luGroupName) throws Exception { 
		HashMap paramMap = new HashMap();
		paramMap.put("adptrGstatSevrName", adptrGstatSevrName);
		paramMap.put("adptrGroupName", adptrGroupName);
		paramMap.put("luGroupName", luGroupName);
		
		HashMap resultMap = dao.selectDetail( paramMap);

		return resultMap;

	}
	
	public List<Map<String, Object>> selectSnaHostList(HashMap paramMap)throws Exception {
    	return dao.selectSnaHostList(paramMap);
    }  
	
	 public List<Map<String, Object>> selectSnaGroupList()throws Exception {
    	HashMap<String, Object> paramMap = new HashMap<String, Object>();
    	return dao.selectSnaGroupList(paramMap);
    }  
	 
	public List<Map<String, Object>> selectSnaAdapterList()throws Exception {
    	HashMap<String, Object> paramMap = new HashMap<String, Object>();
    	return dao.selectSnaAdapterList(paramMap);
	}  
	
	public List<Map<String, Object>> selectLuGroupShortNameList()throws Exception {
    	HashMap<String, Object> paramMap = new HashMap<String, Object>();
    	return dao.selectLuGroupShortNameList(paramMap);
	}  
	
	public List<Map<String, Object>> selectLuGroupList(HashMap paramMap)throws Exception {
    	return dao.selectLuGroupList(paramMap);
	}  
	
	public int selectLuGroupCnt(HashMap paramMap) throws Exception{
		return dao.selectLuGroupCnt(paramMap);
	}
		
	public void insert(HashMap paramMap) throws Exception {
		dao.insert(paramMap);
		dao.updateInfo(paramMap);
		
	}
	
	public void update(HashMap paramMap) throws Exception {
		dao.update(paramMap);
		dao.updateInfo(paramMap);
	}
	
	public void delete(HashMap paramMap) throws Exception {
		dao.delete(paramMap);
		dao.deleteInfo(paramMap);
	}	
	
	public HashMap selectListToExcel(HashMap<String, Object> paramMap ) throws Exception {

		List list = dao.selectListToExcel(paramMap);
		
		for(int i=0;i<list.size();i++){
			HashMap tmp = (HashMap) list.get(i);
			String rowNo = tmp.get("ROWNO").toString();
			String softlinkportno = tmp.get("SOFTLINKPORTNO").toString();
			String wcasesscnt = tmp.get("WCASESSCNT").toString();
			String svctoutval = tmp.get("SVCTOUTVAL").toString();
			String bkupautocnvsnyn = tmp.get("BKUPAUTOCNVSNYN").toString();
			String bkupcnvsnbaseobstclrt = tmp.get("BKUPCNVSNBASEOBSTCLRT").toString();
			
			tmp.put("ROWNO", String.valueOf(rowNo));
			tmp.put("SOFTLINKPORTNO", String.valueOf(softlinkportno));
			tmp.put("WCASESSCNT", String.valueOf(wcasesscnt));
			tmp.put("SVCTOUTVAL", String.valueOf(svctoutval));
			tmp.put("BKUPAUTOCNVSNYN", String.valueOf(bkupautocnvsnyn));
			tmp.put("BKUPCNVSNBASEOBSTCLRT", String.valueOf(bkupcnvsnbaseobstclrt));
		}
		

		HashMap map = new HashMap();

		map.put("list", list);

		return map;
	}

}
