package com.jasamedika.medifirst2000.asynctask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.jasamedika.medifirst2000.asynctask.timer.TargetSkorDokterTimer;
//import com.jasamedika.medifirst2000.asynctask.timer.TargetSkorDokterTimer;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IkiDanRemunerasiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.TargetSkorDokterVO;

/**
 * @author salmanoe
 * @since Dec 29, 2021
 */
@Component
public class TargetSkorDokterGenerating extends LocaleController<TargetSkorDokterVO> {

	private final static Logger LOGGER = LoggerFactory.getLogger(TargetSkorDokterGenerating.class);

	@Autowired
	private IkiDanRemunerasiService remunerasiService;

	public TargetSkorDokterGenerating() {
//		int the1st = 1;
//		int at0hrs = 0;
//		TargetSkorDokterTimer.schedule(new Runnable() {
//			@Override
//			public void run() {
//				try {
//					LOGGER.info("Task Target Skor Dokter : Running Task Target Skor Dokter");
//					generateTargetSkorDokter();
//				} catch (Exception ex) {
//					LOGGER.error("Task Target Skor Dokter : Task Target Skor Dokter " + ex.getMessage());
//				} finally {
//					LOGGER.info("Task Target Skor Dokter : Finishing Target Skor Dokter");
//				}
//			}
//		}, the1st, at0hrs);
	}

//	@Async
	public void generateTargetSkorDokter() {
		try {
			if (CommonUtil.isNotNullOrEmpty(remunerasiService)) {
				LOGGER.info("Task Target Skor Dokter : Running Check/Generate Target Skor Dokter");
				remunerasiService.autoSaveTargetCapaianLayananJamKerja();
			} else {
				LOGGER.warn("Task Target Skor Dokter : Undefined service");
			}
		} catch (Exception ex) {
			LOGGER.error("Task Target Skor Dokter : Check/Generate Target Skor Dokter " + ex.getMessage());
		} finally {
			LOGGER.info("Task Target Skor Dokter : Finishing Check/Generate Target Skor Dokter");
		}
	}

}
