package com.eactive.eai.rms.onl.statistics.eaisvcname.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.eactive.eai.rms.common.spring.BaseController;
import com.eactive.eai.rms.onl.statistics.eaisvcname.service.EaiSvcNameErrTopTenService;
import com.eactive.eai.rms.onl.statistics.eaisvcname.vo.StatisticsForm;


/**
 * <pre>
 *     1. 기능 : EAI서비스명 의 장애 발생 상위 TOP 10 통계 화면의 컨트롤러 
 * </pre>
 * 
 * @author : music75
 * @version : $Revision: 1.4 $
 * @since : rts 1.0
 */
@Controller
public class EaiSvcNameErrTopTenController extends BaseController  {

	@Autowired
	@Qualifier("eaiSvcNameErrTopTenService")
	private	EaiSvcNameErrTopTenService eaiSvcNameErrTopTenService;

	@RequestMapping("/statistics/eaisvcname/eaiSvcNameErrTopTen.do")
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		//
		StatisticsForm statisticsForm = new StatisticsForm();

		statisticsForm.setStartDate(request.getParameter("startDate"));
		statisticsForm.setEndDate(request.getParameter("endDate"));

//		try {
//			findErrEaiSvcNameTopTenData(statisticsForm, request, response);
//		} catch (BizException be) {
//			//be.printStackTrace();
//			logger.error("[BIZ ERROR]");
//			((HttpGauceResponse) response).addException(be);
//		} catch (SysException se) {
//			//se.printStackTrace();
//			logger.error("[SYS ERROR]");
//			((HttpGauceResponse) response).addException(se);
//		} catch (Exception e) {
//			//e.printStackTrace();
//			logger.error("[SYS ERROR]");
//			((HttpGauceResponse) response).addException(e);
//		}
		return null;
	}

	private void findErrEaiSvcNameTopTenData(StatisticsForm statisticsForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception {


		List listData = eaiSvcNameErrTopTenService.getFindErrEaiSvcNameTopTenData(statisticsForm);

//		GauceInputStream gis = null;
//		GauceOutputStream gos = null;
//		
//		//
//		try {
//			gis = ((HttpGauceRequest) request).getGauceInputStream();
//			gos = ((HttpGauceResponse) response).getGauceOutputStream();
//
//			GauceDataSet dataSet = gis.read("ds_01");
//
//			// 그리드 데이터셋 메핑
//			EaiSvcNameErrTopTenVO vo = new EaiSvcNameErrTopTenVO();
//
//			for (int i = 0; i < listData.size(); i++) {
//				vo = (EaiSvcNameErrTopTenVO) listData.get(i);
//				dataSet.put("Order", i+1+"", 2,
//						GauceDataColumn.TB_STRING);
//				dataSet.put("EaiSvcName", vo.getEaiSvcName(), 30,
//						GauceDataColumn.TB_STRING);
//				dataSet.put("EaiSvcDesc", vo.getEaiSvcDesc(), 250,
//						GauceDataColumn.TB_STRING);
//				dataSet.put("ErrNoitm", vo.getErrNoitm(), 15,
//						GauceDataColumn.TB_INT);
//				dataSet.heap();
//			}
//
//			gos.write(dataSet);
//		} catch (IOException e) {
//			//
//			logger.error("[GAUCE SEND ERROR]");
//			//e.printStackTrace();
//			throw new SysException("[GAUCE SEND ERROR]", e); // 에러발생
//		}finally{
//			if (gos != null)
//			{
//				try
//				{
//					gos.close();
//				}
//				catch (Exception e)
//				{
//					gos = null;
//				}
//			}
//		}
	}
}
