package com.eactive.eai.rms.bat.monitoring.inter;

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.bat.common.base.BatBaseService;
import com.eactive.eai.rms.bat.manage.rule.inter.BatInterfaceDao;

@Service("batInterfaceMonitorService")
public class BatInterfaceMonitorService extends BatBaseService {

	@Autowired
	@Qualifier("batInterfaceMonitorDao")
	private BatInterfaceMonitorDao dao;
	
	@Autowired
	@Qualifier("batInterfaceDao")
	private BatInterfaceDao interfaceDao;
	
	public HashMap<String, Object> selectList(int startNum,int endNum, HashMap<String,Object> paramap) throws Exception {
 
		// 전체 목록수 얻기
		int totalCount = dao.selectListCount(paramap);

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

		List<Map<String, Object>> list = dao.selectList(paramap);

		HashMap<String, Object> map = new HashMap<String, Object>();

		map.put("totalCount", totalCount);

		map.put("list", list);

		return map;
	}	
	
	public HashMap<String, Object> selectDetail(String bjobDmndMsgID) throws Exception {

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("bjobDmndMsgID", bjobDmndMsgID);

		HashMap<String, Object>   detail   = dao.selectDetail(paramMap);
		paramMap.put("intfId", detail.get("INTFID"));
		
		List<Map<String, Object>> listDB   = interfaceDao.dbAdapterList(paramMap);
		List<Map<String, Object>> listFile = interfaceDao.fileAdapterList(paramMap);
		List<Map<String, Object>> listDBLog   = dao.dbAdapterLogList(paramMap);
		List<Map<String, Object>> listFileLog = dao.fileAdapterLogList(paramMap);

		HashMap<String, Object> map = new HashMap<String, Object>();

		map.put("detail"   , detail);
		map.put("listDB"   , listDB);
		map.put("listFile" , listFile);
		map.put("listDBLog" , listDBLog);
		map.put("listFileLog" , listFileLog);

		return map;

	}	
}
