package com.eactive.eai.rms.ext.eims;

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

import org.springframework.stereotype.Repository;

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


@Repository("eimsSyncDao")
@SuppressWarnings("unchecked")
public class EIMSSyncDao extends SqlMapClientTemplateDao {

	public List<Map<String, Object>> selectHS04(HashMap param) throws Exception {
		return (List<Map<String, Object>>)template.queryForList("EIMSSync.selectHS04", param);
	}
	public void deleteHS04(HashMap<String,Object> std) {
		template.delete("EIMSSync.deleteHS04", std);
	}	
	public void deleteHS05(HashMap<String,Object> std) {
		template.delete("EIMSSync.deleteHS05", std);
	}	
	public void insertHS04(HashMap<String,Object> std) {
		template.insert("EIMSSync.insertHS04", std);
	}	
	public void insertHS05(HashMap<String,Object> std) {
		template.insert("EIMSSync.insertHS05", std);
	}	
	public void mergeHE01(HashMap<String,Object> vo) {
		template.insert("EIMSSync.mergeHE01", vo);
	}
	public void mergeHE02(HashMap<String,Object> vo) { 
		template.insert("EIMSSync.mergeHE02", vo);
	}
	public Map<String, String> selectAdapterForNickName(Map param) throws Exception {
		List<Map<String,String>> list= (List<Map<String,String>>) template.queryForList("EIMSSync.selectAdapterForNickName", param);
		if (list == null || list.size() ==0){
			return new HashMap<String,String>();
		}else if (list.size() == 1){
			return list.get(0);
		}else {
			String nickName = (String)param.get("adptrNickName");
			throw new Exception("중복된 nickname("+nickName+")이 존재 합니다.EAI 담당자에게 문의 하세요.");
		}

	}
	public Map<String,String> selectHS05(Map param) throws Exception {
		List<Map<String, String>> list = (List<Map<String, String>>)template.queryForList("EIMSSync.selectHS05", param);
		Map<String,String> results = new HashMap<String,String>();
		for(Map<String,String> map : list){
			String key = map.get("BZWKSVCKEYNAME") + "," + map.get("COLUMNNAME");
			results.put(key, map.get("COLUMNVALUE"));
		}
		return results;
	}
	public List<String> selectTransformListForEaiSvcName(HashMap<String,Object> vo) { 
		return (List<String>)template.queryForList("EIMSSync.selectTransformListForEaiSvcName", vo);
	}
	public List<String> selectBzwkSvcKeyNameForEaiSvcName(HashMap<String,Object> vo) { 
		return (List<String>)template.queryForList("EIMSSync.selectBzwkSvcKeyNameForEaiSvcName", vo);
	}
	public void deleteHe02SvcPrcssNo(HashMap<String,Object> vo) {
		template.delete("EIMSSync.deleteHe02SvcPrcssNo", vo);
	}	
	public int selecAppIsYn(HashMap<String,Object> vo) { 
		return (Integer) template.queryForObject("EIMSSync.selecAppIsYn", vo);
	}
	public List<String> selectHS04ForBzwkSvcKeyName(HashMap<String,Object> vo) { 
		return (List<String>)template.queryForList("EIMSSync.selectHS04ForBzwkSvcKeyName", vo);
	}
	public List<String> selectInterfaceForSameLayout(HashMap<String,Object> vo) { 
		return (List<String>)template.queryForList("EIMSSync.selectInterfaceForSameLayout", vo);
	}

}
