package itn.let.schdlr.service.web;

import java.util.Calendar;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
import itn.let.schdlr.service.SchdlrManageService;

/**
 * 시스템 로그 요약을 위한 스케쥴링 클래스
 * @author 공통서비스개발팀 이삼섭
 * @since 2009.03.11
 * @version 1.0
 * @see
 *
 * <pre>
 * << 개정이력(Modification Information) >>
 *   
 *   수정일      수정자           수정내용
 *  -------    --------    ---------------------------
 *   2009.03.11  이삼섭          최초 생성
 *   2011.07.01  이기하          패키지 분리(sym.log -> sym.log.lgm)
 *   2011.08.31  JJY            경량환경 템플릿 커스터마이징버전 생성 
 *
 * </pre>
 */
@Service("egovSchMailSendScheduling")
public class SchMailSendScheduling extends EgovAbstractServiceImpl {

	private static final Logger LOGGER = LoggerFactory.getLogger(SchMailSendScheduling.class);
	
	@Resource(name = "SchdlrManageService")
	private SchdlrManageService schdlrManageService;

	/**
	 * 스케줄러 일정 알림 메일을 송신한다.
	 *
	 * @param
	 * @return
	 * @throws Exception
	 */
	public void schMailSend() throws Exception {
//		LOGGER.debug("@@ yu3145 egov 스케줄링 테스트1");
		
		Calendar now = Calendar.getInstance();
		int year = now.get(Calendar.YEAR);
		int month = now.get(Calendar.MONTH) + 1; // Note: zero based!
		int day = now.get(Calendar.DAY_OF_MONTH);
		int hour = now.get(Calendar.HOUR_OF_DAY);
		int minute = now.get(Calendar.MINUTE);
		now.add(Calendar.MINUTE, 1);
		int minute2 = now.get(Calendar.MINUTE);
//		int second = now.get(Calendar.SECOND);
//		int millis = now.get(Calendar.MILLISECOND);
		
		String strMonth = "" + (month < 10 ? "0" + month : month);
		String strDay = "" + (day < 10 ? "0" + day : day);
		String strHour = "" + (hour < 10 ? "0" + hour : hour);
		String strMinute = "" + (minute < 10 ? "0" + minute : minute);
		String strMinute2 = "" + (minute2 < 10 ? "0" + minute2 : minute2);
		
		String bgnDateTime = year + "-" + strMonth + "-" + strDay + " " + strHour + ":" + strMinute;
		String endDateTime = year + "-" + strMonth + "-" + strDay + " " + strHour + ":" + strMinute2;
		//LOGGER.debug("@@ 시작:" + bgnDateTime + " 종료:" + endDateTime);
		
//		bgnDateTime = "2019-11-04 22:19";
		
		schdlrManageService.schMailSend(bgnDateTime);
	}

}
