package com.eactive.eai.rms.onl.transaction.trackingchart;

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;

/**
* 1. 기능 : 코드정보를 관리하는 코드 정보 테이블에 대한 Data Access Object 이다. 
*         업무데이터로 부터 아래와 같은 특정 필드를 추출하기 위한 어댑터 정보 테이블에
*         대한 Data Access Object 이다.
* 2. 처리 개요 :  코드 정보 테이블에 대한 Create, Read, Update, Delete 를 처리한다.
*
* 3. 주의사항
*
* @author  :
* @version : v 1.0.0
* @see : CodeManQuery.java
* @since   :
*/
@Repository
public class TrackingChartDao extends SqlMapClientTemplateDao {

    /**
     * Default Logger
     */

    
	// CODE GROUP LIST
    public List selectCodeGroupList(HashMap param) throws Exception {
    	return template.queryForList("CodeMan.selectCodeGroupList", param);
    }
    public List<Map<String, Object>> selectPopList(HashMap param) throws Exception {
    	return (List<Map<String, Object>>)template.queryForList("DbTrackingChart.selectSubList", param);
    } 
	public int selectPopListCount(HashMap<String, Object> param) throws Exception {

		int totalcnt = (Integer)template.queryForObject("DbTrackingChart.selectSubListCount", param);

    	return totalcnt;
    }	  
	public HashMap<String, Object>  selectDetail(String eaiSvcName) throws Exception {
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("eaiSvcName", eaiSvcName);
		
     	List detailList  = template.queryForList("DbTrackingChart.selectDetail" , param);
		HashMap detail = new HashMap();
		String bzwkSvcKeyName = "";
		if(detailList.size()>0){
			for(int i=0; i<detailList.size(); i++){
				detail = (HashMap)detailList.get(i);
				if(i==0){
					bzwkSvcKeyName+=detail.get("BZWKSVCKEYNAME");
				}else{
					bzwkSvcKeyName+=","+detail.get("BZWKSVCKEYNAME");
				}
				detail.put("BZWKSVCKEYNAME",bzwkSvcKeyName);
			}
			return detail;
		}else{
			return  (HashMap<String,Object>) template.queryForObject("DbTrackingChart.selectDetail" , param);
		}
			
    }
    public List<Map<String, Object>> selectSharedTrans(HashMap param) throws Exception {
    	return (List<Map<String, Object>>)template.queryForList("DbTrackingChart.selectSharedTrans", param);
    } 
	
	// Transform 
	public void updateTransfromEaiSvcName(HashMap map) {
        this.template.update("DbTrackingChart.updateTransfromEaiSvcName",map);
    }   
 
    public void insertTransform(HashMap map) {
        this.template.insert("DbTrackingChart.insertTransform",map);
    }  
    
    public void insertTransformSourceResult(HashMap map) {
        this.template.insert("DbTrackingChart.insertTransformSourceResult",map);
    }   
    public void deleteTransform(HashMap map) {
        this.template.delete("DbTrackingChart.deleteTransform",map);
    }

    public void deleteTransformSourceResult(HashMap map) {
        this.template.delete("DbTrackingChart.deleteTransformSourceResult",map);
    }
    public void insertTransformItem(HashMap map) {
        this.template.insert("DbTrackingChart.insertTransformItem",map);
    }   
    public void deleteTransformItem(HashMap map) {
        this.template.delete("DbTrackingChart.deleteTransformItem",map);

    }
}
