package com.bankaudit.util;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.bankaudit.rest.process.service.EmailService;
import com.bankaudit.service.GeneralParameterService;

@Configuration
@Component 
public class SchedularJob {
	
	@Autowired
	EmailService emailservice;
	
	@Autowired
	GeneralParameterService generalParameterService;
	
	@Autowired
    private Environment environment;

	//@Scheduled(fixedDelay = 10000)
	//@Scheduled(cron = "0 30 2 ? * *")
	@Scheduled(cron = "${schedule.interval.cron}")
	public void runJob() throws Exception{	     	
		Date now = new Date();
		int legalEntityCode=4;
		System.out.println("==============================> " +"${schedule.interval.cron}" +" ==> "+ now);
		//System.out.println("==============================> " + now);
		Map map=generalParameterService.getGeneralParameterKeyValue(legalEntityCode, null, null, "", "", null, null);  //legalEntityCode, modCode, language, key1, key2, value, maker
		emailservice.sendEmailForInspectionNotification(legalEntityCode);
		emailservice.sendEmailForInspection2ndNotification(legalEntityCode);
		
		
	}

}
