package com.eactive.eai.rms.onl.statistics.etc.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.vo.StatisticsForm;
import com.eactive.eai.rms.onl.statistics.etc.service.ResponseTimeHourlyService;

/**
 * <pre>
 *     1. 기능 : 시간대별 응답시간 통계 화면의 컨트롤러
 * </pre>
 *
 * @author : music75
 * @version : $Revision: 1.6 $
 * @since : rts 1.0
 */
@Controller
public class ResponseTimeHourlyController extends BaseController  {

	@Autowired
	@Qualifier("responseTimeHourlyService")
	private ResponseTimeHourlyService responseTimeHourlyService ;

	@RequestMapping("/statistics/etc/responseTimeHourly.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 {
//			findResponseTimeHourlyData(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 findResponseTimeHourlyData(StatisticsForm statisticsForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception {


		List dailyData = responseTimeHourlyService
				.getFindResponseTimeHourlyData(statisticsForm);

//		GauceInputStream gis = null;
//		GauceOutputStream gos = null;
//
//		//
//		try {
//			gis = ((HttpGauceRequest) request)
//					.getGauceInputStream();
//			gos = ((HttpGauceResponse) response)
//					.getGauceOutputStream();
//
//			GauceDataSet dataSet = gis.read("ds_01");
//
//			// 그리드 데이터셋 메핑
//			ResponseTimeHourlyVO vo = new ResponseTimeHourlyVO();
//
//			for (int i = 0; i < dailyData.size(); i++) {
//				vo = (ResponseTimeHourlyVO) dailyData.get(i);
//
//				dataSet.put("EAISvcDesc", vo.getEaiSvcDesc(), 200,
//						GauceDataColumn.TB_STRING);
//				dataSet.put("EAISvcName", vo.getEaiSvcName(), 30,
//						GauceDataColumn.TB_STRING);
//				dataSet.put("HhRspnsAvgVal0", vo.getHhRspnsAvgVal0(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal1", vo.getHhRspnsAvgVal1(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal2", vo.getHhRspnsAvgVal2(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal3", vo.getHhRspnsAvgVal3(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal4", vo.getHhRspnsAvgVal4(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal5", vo.getHhRspnsAvgVal5(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal6", vo.getHhRspnsAvgVal6(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal7", vo.getHhRspnsAvgVal7(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal8", vo.getHhRspnsAvgVal8(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal9", vo.getHhRspnsAvgVal9(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal10", vo.getHhRspnsAvgVal10(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal11", vo.getHhRspnsAvgVal11(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal12", vo.getHhRspnsAvgVal12(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal13", vo.getHhRspnsAvgVal13(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal14", vo.getHhRspnsAvgVal14(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal15", vo.getHhRspnsAvgVal15(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal16", vo.getHhRspnsAvgVal16(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal17", vo.getHhRspnsAvgVal17(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal18", vo.getHhRspnsAvgVal18(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal19", vo.getHhRspnsAvgVal19(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal20", vo.getHhRspnsAvgVal20(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal21", vo.getHhRspnsAvgVal21(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal22", vo.getHhRspnsAvgVal22(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsAvgVal23", vo.getHhRspnsAvgVal23(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal0", vo.getHhRspnsMaxVal0(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal1", vo.getHhRspnsMaxVal1(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal2", vo.getHhRspnsMaxVal2(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal3", vo.getHhRspnsMaxVal3(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal4", vo.getHhRspnsMaxVal4(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal5", vo.getHhRspnsMaxVal5(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal6", vo.getHhRspnsMaxVal6(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal7", vo.getHhRspnsMaxVal7(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal8", vo.getHhRspnsMaxVal8(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal9", vo.getHhRspnsMaxVal9(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal10", vo.getHhRspnsMaxVal10(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal11", vo.getHhRspnsMaxVal11(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal12", vo.getHhRspnsMaxVal12(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal13", vo.getHhRspnsMaxVal13(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal14", vo.getHhRspnsMaxVal14(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal15", vo.getHhRspnsMaxVal15(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal16", vo.getHhRspnsMaxVal16(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal17", vo.getHhRspnsMaxVal17(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal18", vo.getHhRspnsMaxVal18(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal19", vo.getHhRspnsMaxVal19(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal20", vo.getHhRspnsMaxVal20(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal21", vo.getHhRspnsMaxVal21(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal22", vo.getHhRspnsMaxVal22(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//				dataSet.put("HhRspnsMaxVal23", vo.getHhRspnsMaxVal23(), 4.3,
//						GauceDataColumn.TB_DECIMAL);
//
//				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;
//				}
//			}
//		}
	}
}
