package com.eactive.eai.rms.onl.common.dao;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.eactive.eai.common.util.NullControl;
import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;
import com.eactive.eai.rms.common.datasource.DataSourceType;
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
import com.eactive.eai.rms.common.datasource.SpecifiedDataSourceExecutor;
import com.eactive.eai.rms.common.util.CommonUtil;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.MonitoringProperty;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.MonitoringPropertyId;
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
import com.eactive.eai.rms.onl.tracking.vo.DbStaticsVo;
import com.ibatis.sqlmap.client.event.RowHandler;

/**
 * <pre>
 * 1. 기능 : 대시보드에서 사용하기 위한 DB Query 서비스
 *          거래로그건수, 타임아웃건수, 에러로그 건수를 조회하여 리턴한다.
 * 2. 처리 개요 :
 *     -
 * 3. 주의사항 :
 * </pre>
 * 
 * @author : 윤영주
 * @version : $Revision: 1.12.2.3 $
 * @since : rts 1.0
 * @spring.bean id="DashboardTargetDao"
 * @spring.property name="dataSource" ref="dataSource"
 */
@Repository("DashboardTargetDao")
public class DashboardTargetDaoImpl extends SqlMapClientTemplateDao implements DashboardTargetDao {

    /**
    * Logger for this class
    */
    final Logger logger = Logger.getLogger(DashboardTargetDaoImpl.class);
    
    @Autowired
    private MonitoringPropertyService monitoringPropertyService;

	/**
	 * 해당 서비스의 DB 로그에서 거래 건수를 조회하여 리턴한다.
	 * @param jndi
	 * @param schema
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getProcCount( String start, String end, String insts) throws Exception {
		int result = 0;
		try {
//        	DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(start, true));

            paramMap.put("insts", insts);
            paramMap.put("timeoutErr", CommonUtil.getTimeoutErrorCodes());
            
            return (Integer)template.queryForObject("DashboardTarget.getProcCount", paramMap);
            
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getProcCount error", e);
		}
		return result;
	}
	
	
	/**
	 * 해당 서비스의 DB TSEAISR01 거래 건수를 조회하여 리턴한다.
	 * @param jndi
	 * @param schema
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public HashMap getProcCountWithSR02(String end, String insts) throws Exception {
		HashMap<String, String> paramMap = new HashMap<String, String>();
        paramMap.put("baseYmd", end);
        paramMap.put("schemaId", insts);
		return (HashMap)template.queryForObject("DashboardTarget.getProcCountWithSR02", paramMap);
	}
	
	public List getProcCountDayWithSR02(String searchStart,String searchEnd, String insts) throws Exception {
		HashMap<String, String> paramMap = new HashMap<String, String>();
		paramMap.put("searchStart", searchStart);
        paramMap.put("searchEnd", searchEnd);
        paramMap.put("schemaId", insts);
		return template.queryForList("DashboardTarget.getProcCountDayWithSR02", paramMap);
	}
	
	public List getProcCountDateWithBJ08(String searchStart,String searchEnd, String insts) throws Exception {
		HashMap<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("searchStart", searchStart);
        paramMap.put("searchEnd", searchEnd);
        paramMap.put("schemaId", insts);
		return template.queryForList("DashboardTarget.getProcCountDateWithBJ08", paramMap);
	}
	
	public List getProcCountDateWithES01(String searchStart,String searchEnd, String insts) throws Exception {
		HashMap<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("searchStart", searchStart);
        paramMap.put("searchEnd", searchEnd);
        paramMap.put("schemaId", insts);
		return template.queryForList("DashboardTarget.getProcCountDateWithES01", paramMap);
	}
	
	
	public List getProcCountHourWithBJ08(HashMap paramMap) throws Exception {
		return template.queryForList("DashboardTarget.getProcCountHourWithBJ08", paramMap);
	}
	
	public List getProcCountHourWithES01(HashMap paramMap) throws Exception {
		return template.queryForList("DashboardTarget.getProcCountHourWithES01", paramMap);
	}
	
	public List getItsmErrorLogList(HashMap paramMap) throws Exception {
		return template.queryForList("DashboardTarget.getItsmErrorLogList", paramMap);
	}
		
	/**
	 * 해당 서비스의 DB TSEAISR01 거래 건수를 조회하여 리턴한다.
	 * @param jndi
	 * @param schema
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public List getHourProcCountWithSR02(HashMap paramMap) throws Exception {
		return template.queryForList("DashboardTarget.getHourProcCountWithSR02", paramMap);
	}
	
	/**
	 * 해당 서비스의 DB 로그에서 타임아웃 에러 건수를 조회하여 리턴한다.
	 * @param jndi
	 * @param schema
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getTimeoutCount(String start, String end, String insts) throws Exception {
		int result = 0;
		try {
//        	DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(CommonUtil.getToday(""), true));

            paramMap.put("insts", insts);
            paramMap.put("timeoutErr", CommonUtil.getTimeoutErrorCodes());
            return (Integer)template.queryForObject("DashboardTarget.getTimeoutCount", paramMap);

		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getTimeoutCount error", e);
		}
		return result;
	}

	/**
	 * 해당 서비스의 DB 로그에서 에러 건수를 조회하여 리턴한다.
	 * @param jndi
	 * @param schema
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getErrorCount(String start, String end, String insts) throws Exception {
		int result = 0;
		try {
//        	DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(CommonUtil.getToday(""), true));
            paramMap.put("insts", insts);

            // 20100108 : 영업점 테스트 를 위해서 ( 에러건수 줄이는 방안 ) => 거래통제 에러코드(RECEAIIRP070) 는 에러건수 에서 제외한다.
            // 20100108 : 영업점 테스트 를 위해서 ( 에러건수 줄이는 방안 ) => Adapter   에러(RECEAICIR002) 는 어댑터가 죽어있는데 호출되는 경우.
            // RECEAIFBR003,RECEAIFBF001,RECEAIFBF003
            paramMap.put("timeoutErr", CommonUtil.getTimeoutErrorCodes() + ",'RECEAIIRP070','RECEAICIR002','RECEAIFBR003','RECEAIFBF001','RECEAIFBF003'");
            return (Integer)template.queryForObject("DashboardTarget.getErrorCount", paramMap);
//            result = new SpecifiedDataSourceExecutor<Integer>(dt) {
//				protected Integer doExecute() throws Exception {
//	                return (Integer)template.queryForObject("DashboardTarget.getErrorCount", paramMap);
//	            }
//	        }.execute();
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getErrorCount error", e);
		}
		return result;
	}
	
	public void updatePeakTps(String key, String val) throws Exception {
		try {
			MonitoringPropertyId monitoringPropertyId = new MonitoringPropertyId("Monitoring", key);
			MonitoringProperty monitoringProperty = monitoringPropertyService
					.findById(monitoringPropertyId)
					.orElse(new MonitoringProperty());

			monitoringProperty.setId(monitoringPropertyId);
			monitoringProperty.setPrpty2Val(val);

			monitoringPropertyService.save(monitoringProperty);

		} catch (Exception e) {
			logger.error("updatePeakTps error", e);
		}
	}
	
	@Override
	public void insertPeakTpsHistory(HashMap<String, Object> paramMap) throws Exception {
		try {
        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();            
        	template.update("DashboardTarget.insertPeakTpsHistory", paramMap);
//        	new SpecifiedDataSourceExecutor<Integer>(dt) {
//				protected Integer doExecute() throws Exception {
//	                return (Integer)template.update("DashboardTarget.insertPeakTpsHistory", paramMap);
//	            }
//	        }.execute();	        
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("insertPeakTpsHistory error", e);
		}
	}
	
	@SuppressWarnings("unchecked")
	public HashMap<String, Integer> getBatchProcCountByDate(  String date ) throws Exception {

		final HashMap<String, Integer> list = new HashMap<String, Integer>();
		try {
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            //paramMap.put("schemaId", schemaName);
            paramMap.put("date", date);

	        template.queryWithRowHandler("DashboardTargetForBatch.getBatchProcCountByDate", paramMap,
			    			new RowHandler(){
		                public void handleRow(Object valueObject) {		
		        			HashMap<String, java.math.BigDecimal> value = (HashMap<String, java.math.BigDecimal>)valueObject;

		        			Iterator<String> keys = value.keySet().iterator();

		        			while( keys.hasNext()) {
		        				String key = keys.next();				
		        				list.put(key, Integer.parseInt(String.valueOf(value.get(key))));
		        				//list.put(key, value.get(key).intValue());
		        			}	
		        			
		    }});
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getBatchProcCountByDate error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public HashMap<String, Integer> getEaiBatchProcCountByDate(  String date ) throws Exception {

		final HashMap<String, Integer> list = new HashMap<String, Integer>();
		try {
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            //paramMap.put("schemaId", schemaName);
            paramMap.put("date", date);

	        template.queryWithRowHandler("DashboardTargetForBatch.getEaiBatchProcCountByDate", paramMap,
			    			new RowHandler(){
		                public void handleRow(Object valueObject) {		
		        			HashMap<String, java.math.BigDecimal> value = (HashMap<String, java.math.BigDecimal>)valueObject;

		        			Iterator<String> keys = value.keySet().iterator();

		        			while( keys.hasNext()) {
		        				String key = keys.next();
		        				list.put(key, Integer.parseInt(String.valueOf(value.get(key))));
		        				//list.put(key, value.get(key).intValue());
		        			}	
		        			
		    }});
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getEaiBatchProcCountByDate error", e);
		}
		return list;
	}
	
	/**
	 * 배치거래 건수 를 조회하여 리턴한다. - 대시보드 메인 화면의 배치건수를 표시하기 위함.
	 * @param jndi
	 * @param schema
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public HashMap<String, Integer> getBatchProcCount() throws Exception {
		final HashMap<String, Integer> list = new HashMap<String, Integer>();
		try {
			HashMap<String, String> paramMap = new HashMap<String, String>();
            //paramMap.put("schemaId", schemaName);

	        template.queryWithRowHandler("DashboardTargetForBatch.getBatchProcCount", paramMap,
			    			new RowHandler(){
		                public void handleRow(Object valueObject) {		
		        			HashMap<String, java.math.BigDecimal> value = (HashMap<String, java.math.BigDecimal>)valueObject;

		        			Iterator<String> keys = value.keySet().iterator();
		        			
		        			while( keys.hasNext()) {
		        				String key = keys.next();	
		        				list.put(key, Integer.parseInt(String.valueOf(value.get(key))));
		        				//list.put(key, value.get(key).intValue());
		        			}
		    }});
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getBatchProcCount error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public HashMap<String, Integer> getEaiBatchProcCount() throws Exception {
		final HashMap<String, Integer> list = new HashMap<String, Integer>();
		try {
			HashMap<String, String> paramMap = new HashMap<String, String>();
            //paramMap.put("schemaId", schemaName);

	        template.queryWithRowHandler("DashboardTargetForBatch.getEaiBatchProcCount", paramMap,
			    			new RowHandler(){
		                public void handleRow(Object valueObject) {		
		        			HashMap<String, java.math.BigDecimal> value = (HashMap<String, java.math.BigDecimal>)valueObject;

		        			Iterator<String> keys = value.keySet().iterator();
		        			
		        			while( keys.hasNext()) {
		        				String key = keys.next();				
		        				list.put(key, Integer.parseInt(String.valueOf(value.get(key))));
		        			}
		    }});
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getEaiBatchProcCount error", e);
		}
		return list;
	}
	
	/**
	 * 해당 서비스의 DB 로그에서 거래 건수를 조회하여 리턴한다.
	 * ( 전지점 거래테스트 - 2009.10.24 - 를 위해 만든 임시함수.)
	 * serviceNum    1:내부, 2:대외, 3:공동망
	 * @param jndi
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getProcCountBranchTest(String start, String end, String serviceNum, String insts, String commDiv) throws Exception {
		int result = 0;
		try {
        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(CommonUtil.getToday(""), true));

//            paramMap.put("schemaId", 
//            		serviceNum.equals("2") ? DataSourceTypeManager.FEP : DataSourceTypeManager.EAI	);
            paramMap.put("insts", insts);
            paramMap.put("commDiv", commDiv);
            template.queryForObject("DashboardTarget.getProcCountBranchTest", paramMap);
//            result = new SpecifiedDataSourceExecutor<Integer>(dt) {
//				protected Integer doExecute() throws Exception {
//	                return (Integer)template.queryForObject("DashboardTarget.getProcCountBranchTest", paramMap);
//	            }
//	        }.execute();
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getProcCountBranchTest error", e);
		}
		return result;
	}

	/** 해당 서비스의 DB 로그에서 타임아웃 에러 건수를 조회하여 리턴한다.
	 * ( 전지점 거래테스트 - 2009.10.24 - 를 위해 만든 임시함수.)
	 * serviceNum   1:내부, 2:대외, 3:공동망
	 * @param jndi
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getTimeoutCountBranchTest(String start, String end, String serviceNum, String insts, String commDiv) throws Exception {
		int result = 0;
		try {
        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(CommonUtil.getToday(""), true));

//            paramMap.put("schemaId", 
//          		serviceNum.equals("2") ? DataSourceTypeManager.FEP : DataSourceTypeManager.EAI	);

            paramMap.put("insts", insts);
            paramMap.put("commDiv", commDiv);
            paramMap.put("timeoutErr", CommonUtil.getTimeoutErrorCodes());
            return (Integer)template.queryForObject("DashboardTarget.getTimeoutCountBranchTest", paramMap);

		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getTimeoutCountBranchTest error", e);
		}
		return result;
	}
	
	
	/**
	 * 해당 서비스의 DB 로그에서 에러 건수를 조회하여 리턴한다.
	 * ( 전지점 거래테스트 - 2009.10.24 - 를 위해 만든 임시함수.)
	 * serviceNum = 1:내부, 2:대외, 3:공동
	 * @param jndi
	 * @param start
	 * @param end
	 * @param host
	 * @return
	 * @throws Exception
	 */
	public int getErrorCountBranchTest(String start, String end, String serviceNum, String insts, String commDiv) throws Exception {
		int result = 0;
		try {
        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("start", start);
            paramMap.put("end", end);
            paramMap.put("tableName", CommonUtil.getLogTable(CommonUtil.getToday(""), true));

//            paramMap.put("schemaId", 
//          		serviceNum.equals("2") ? DataSourceTypeManager.FEP : DataSourceTypeManager.EAI	);

            paramMap.put("insts", insts);
            paramMap.put("commDiv", commDiv);

            // 20100108 : 영업점 테스트 를 위해서 ( 에러건수 줄이는 방안 ) => 거래통제 에러코드(RECEAIIRP070) 는 에러건수 에서 제외한다.
            // 20100108 : 영업점 테스트 를 위해서 ( 에러건수 줄이는 방안 ) => Adapter   에러(RECEAICIR002) 는 어댑터가 죽어있는데 호출되는 경우.
            // RECEAIFBR003,RECEAIFBF001,RECEAIFBF003
            paramMap.put("timeoutErr", CommonUtil.getTimeoutErrorCodes() + ",'RECEAIIRP070','RECEAICIR002','RECEAIFBR003','RECEAIFBF001','RECEAIFBF003'");
            return (Integer)template.queryForObject("DashboardTarget.getErrorCountBranchTest", paramMap);

		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getErrorCountBranchTest error", e);
		}
		return result;
	}

	/**
	 * 거래 통계 집계 테이블에서 최대,최소 일자를 구한다.
	 * @param jndi
	 * @param hostName
	 * @return
	 * @throws Exception
	 */
	 public HashMap<String, String> getMinMaxDate(String hostName ) throws Exception {
		 HashMap<String, String> result = new HashMap<String, String>();
		try {
        	DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("hostName", hostName);
            HashMap<String, java.math.BigDecimal> value = new SpecifiedDataSourceExecutor<HashMap<String, java.math.BigDecimal>>(dt) {
	            @SuppressWarnings("unchecked")
				protected HashMap<String, java.math.BigDecimal> doExecute() throws Exception {
	                return (HashMap<String, java.math.BigDecimal>)template.queryForObject("DashboardTarget.getMinMaxTime", paramMap);
	            }
	        }.execute();
	        result.put("minTime", (value.get("minTime")).toString());
	        result.put("maxTime", (value.get("maxTime")).toString());
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getMinMaxDate error", e);
		}
		return result;
	 }
	 
	 /**
	  * 거래 통계 집계 테이블에서 최대,최소 시간을 구한다.
	  * @param jndi
	  * @param baseDate
	  * @param hostName
	  * @return
	  * @throws Exception
	  */
	 public HashMap<String, String> getMinMaxTime(String baseDate, String hostName ) throws Exception {
		 HashMap<String, String> result = new HashMap<String, String>();
		try {
        	DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("baseDate", baseDate);
            paramMap.put("hostName", hostName);
            return (HashMap<String, String>)template.queryForList("DashboardTarget.getMinMaxTime", paramMap);

		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("getMinMaxTime error", e);
		}
		return result;
	 }
	 
	 /**
	  * 거래 통계 집계 테이블에 데이터를 추가한다.
	  * @param jndi
	  * @param vo
	  * @return
	  * @throws Exception
	  */
	 public int insertTradeStatics( final DbStaticsVo vo ) throws Exception{
		 int result = 0;
			try {
	        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();
				return (Integer)template.insert("DashboardTarget.insertTradeStatics", vo);

			} catch (Exception e) {
				//e.printStackTrace();
				logger.error("insertTradeStatics error", e);
			}
			return result;		 
	 }
	 
	 public HashMap<String, String> sumTradeStatics(String eaiMoniJobDstcd
			                                , String eaiMoniSvcDstcd, String statcYmd, String hostName ) throws Exception {
		final HashMap<String, String> result = new HashMap<String, String>();
		try {
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("eaiMoniJobDstcd", eaiMoniJobDstcd);
            paramMap.put("eaiMoniSvcDstcd", eaiMoniSvcDstcd);
            paramMap.put("statcYmd", statcYmd);
            paramMap.put("hostName", hostName);

	        template.queryWithRowHandler("DashboardTarget.sumTradeStatics", paramMap,
			    			new RowHandler(){
		        		@SuppressWarnings("unchecked")
		                public void handleRow(Object valueObject) {		
		        			HashMap<String,Object> values = (HashMap<String,Object>)valueObject;
		        			result.put("maxTime",    (String)values.get("maxTime"));
		        			result.put("sumProc",    ((java.math.BigDecimal)values.get("sumProc")).toString());
		        			result.put("sumTimeout", ((java.math.BigDecimal)values.get("sumTimeout")).toString());
		        			result.put("sumError",   ((java.math.BigDecimal)values.get("sumError")).toString());
		        			result.put("maxTps",     ((java.math.BigDecimal)values.get("maxTps")).toString());
		    }});
		} catch (Exception e) {
			logger.error("sumTradeStatics Error", e);
			//e.printStackTrace();
			
		}
		return result;		 
	 }

	 /**
	  * 대시보드 에서 사용하는 거래통계 집계 테이블 데이터를 0으로 초기화 함으로써, 대시보드의 거래건수를 0으로 초기화 한다.
	  * @param jndi
	  * @param statcYmd
	  * @param statcHMS
	  * @throws Exception
	  */
	 public void resetTradeStatics( String statcYmd, String statcHMS ) throws Exception {
		try {
        	//DataSourceType dt = DataSourceContextHolder.getDataSourceType();
            final HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("statcYmd", statcYmd);
            paramMap.put("statcHMS", statcHMS);
            template.update("DashboardTarget.resetTradeStatics", paramMap);

		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("resetTradeStatics error", e);
		}					 
	 }
	 
	 
	 public HashMap<String,String> selectEAISevrDstcd( ) throws Exception {
	 	final HashMap<String,String> ret = new HashMap<String,String>();
        try {
		 	final HashMap<String, String> paramMap = new HashMap<String, String>();
            		 	
		 	DataSourceType dataSourceType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
			DataSourceContextHolder.setDataSourceType(dataSourceType);
			
			paramMap.put("schemaId", dataSourceType.getSchema());

	        template.queryWithRowHandler("DashboardTarget.selectEAISevrDstcd", paramMap,
			    			new RowHandler(){
		        		@SuppressWarnings("unchecked")
		                public void handleRow(Object valueObject) {
		
		        			HashMap<String,String> rowMap = (HashMap<String,String>)valueObject;
		
							ret.put( NullControl.trimSpace(rowMap.get("EAISvcName")).trim(),
									 NullControl.trimSpace(rowMap.get("schema")).trim());
		    }});       
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error("selectEAISevrDstcd error", e);
		}
        
        return ret;
	 }

	 @Override
	 public List<HashMap<String, String>> getEaiBatchErrorList(HashMap<String, String> paramMap) {
		 return template.queryForList("DashboardTarget.getEaiBatchErrorList", paramMap);
	 }

	 @Override
	 public List<HashMap<String, String>> getFepBatchErrorList(HashMap<String, String> paramMap) {
		 return template.queryForList("DashboardTarget.getFepBatchErrorList", paramMap);
	 }

//	 /**
//	  * 일괄전송의 IP, PORT 정보를 리턴한다.
//	  * @return
//	  */
//	 public Map<String, String> getEaiBatchServerIpList( String schemaName ) {
//
//	    final HashMap<String, String> retList = new HashMap<>();
//		
//        try {
//			HashMap<String, String> paramMap = new HashMap<String, String>();
//            paramMap.put("schemaId", schemaName);
//    		
//	        template.queryWithRowHandler("DashboardTargetForBatch.getEaiBatchServerIpList", paramMap,
//			    			new RowHandler(){
//		        		@SuppressWarnings({ "unchecked", "null" })
//		                public void handleRow(Object valueObject) {		
//		        			retList.putAll((HashMap<String,String>)valueObject);
//		    }});
//		} catch (Exception e) {
//			//e.printStackTrace();
//			logger.error("getEaiBatchServerIpList error", e);
//		}
//        return retList;
//	}
}
