package com.style24.batch.biz.job.statistics;

import com.gagaframework.web.util.GagaDateUtil;
import com.style24.batch.biz.job.TsbAbstractJob;
import com.style24.batch.biz.service.TsbStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 시간대별주문통계
 *
 * @author swkim
 * @since 2021.05.17
 */
@Component
@Slf4j
public class TsbDateTimeOrderStaticsJob extends TsbAbstractJob<String, String, String> {

	@Autowired
	private TsbStatisticsService statisticsService;

	@Override
	public String read() throws Exception {
		return "OK";
	}

	@Override
	public String process(String result) throws Exception {

		// 기간
		/*String startDay = "20210101";
		String endDay = "20210831";
		int days = GagaDateUtil.getOffsetDays(endDay, startDay) + 1;

		System.out.println("term === " + days);

		for (int i=0; i<days; i++) {
			String currDay = GagaDateUtil.getOffsetDate(startDay, i, "yyyyMMdd");
			System.out.println(currDay);

			statisticsService.createOrderDateTime(currDay);
		}*/

		/*String toDay = GagaDateUtil.getToday();
		String currDay = GagaDateUtil.getOffsetDate(toDay, -1, "yyyyMMdd");

		statisticsService.createOrderDateTime(currDay);*/

		return result;
	}

	@Override
	public String write(String result) throws Exception {
		return result;
	}

	@Override
	public void notify(String result) throws Exception {
		// Do nothing
	}
}
