Subversion Repositories SmartDukaan

Rev

Rev 35326 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.smartdukaan.cron.scheduled;

import com.smartdukaan.cron.migrations.RunOnceTasks;
import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
import com.smartdukaan.cron.properties.WriteToPropertiesFile;
import com.smartdukaan.cron.scheduled.ambreports.AbmReportSender;
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
import com.smartdukaan.cron.scheduled.ordertracking.OrderTrackingService;
import com.smartdukaan.cron.scheduled.purchaseorder.POScheduler;
import com.spice.profitmandi.common.model.ProfitMandiConstants;
import com.spice.profitmandi.dao.service.PurSaleService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.LinkedHashMap;

@Component
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
public class ScheduledSkeleton {

    private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);

    @Autowired
    private ScheduledTasks scheduledTasks;

    @Autowired
    private ScheduledTasksTest scheduledTasksTest;

    @Autowired
    private AbmReportSender abmReportSender;

    @Autowired
    private LeadSyncRunner leadSyncRunner;

    @Autowired
    private Reconciliation reconciliation;

    @Autowired
    private RunOnceTasks runOnceTasks;

    @Autowired
    NagiosMonitorTasks nagiosMonitorTasks;

    @Autowired
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;

    @Autowired
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;

    @Autowired
    private WriteToPropertiesFile writeToPropertiesFile;

    String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";

    @Scheduled(cron = "0 0 2 * * *")
    public void processDailySchemes() throws Exception {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("processDailySchemes", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        int maxMinusDays = 5;
        int currentDayOfMonth = LocalDate.now().getDayOfMonth();
        int minusDays = currentDayOfMonth > maxMinusDays ? maxMinusDays : currentDayOfMonth - 1;
        if (minusDays > 0) {
            scheduledTasks.processScheme(LocalDateTime.now().minusDays(minusDays), LocalDateTime.now(), false);
        }
        propertiesDetails.put("processDailySchemes", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 15 0 * * *")
    public void runOnceTasks() throws Exception {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("runOnceTasks", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.reconcileRecharge();

        propertiesDetails.put("runOnceTasks", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
    }

    /*
     * @Scheduled(cron = "0 0 8 * * *") public void mailDashboardScreenshots()
     * throws Exception { runOnceTasks.mailDashboardScreenshots(); }
     */

    @Scheduled(cron = "0 05 0 1,16 * ?")
    public void processRechargeCashback() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("processRechargeCashback", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        scheduledTasks.processRechargeCashback();

        propertiesDetails.put("processRechargeCashback", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 6 * * *")
    public void sendPartnerInvestmentDetails() throws Exception {
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("sendPartnerInvestmentDetails", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        scheduledTasks.sendPartnerInvestmentDetails();
        long secs = (new Date().getTime()) / 1000;
        log.info("sendPartnerInvestmentDetails" + LocalDateTime.now());

        propertiesDetails.put("investmentDate", Long.toString(secs));
        propertiesDetails.put("sendPartnerInvestmentDetails", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 30 6 * * *")
    public void generateBiReport() throws Exception {
        scheduledTasksTest.generateBiReport();
    }
    @Scheduled(cron = "0 30 4 * * *")
    public void createFofoSmartCartSuggestion() throws Exception {
        scheduledTasksTest.createFofoSmartCartSuggestion();
    }
    @Scheduled(cron = "0 0 6,22 * * *")
    public void sendAbmSmartCartReport() throws Exception {
        abmReportSender.sendAbmSmartCartReport();
    }

    @Scheduled(cron = "0 0 10,15,17 * * *")
    public void sendIndentTertiaryReport() throws Exception {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("sendIndentTertiaryReport", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.sendIndentTertiary();

        propertiesDetails.put("sendIndentTertiaryReport", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 6 * * *")
    public void checkPartnerActiveStoreByStatus() throws Exception {
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("checkPartnerActiveStoreByStatus", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.checkPartnerActiveStore();
        propertiesDetails.put("checkPartnerActiveStoreByStatus", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    // @Scheduled(cron = "0 0 8 * * *")
    public void sendStockAgeingReport() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("sendStockAgeingReport", "0");

        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.sendAgeingReport();

        propertiesDetails.put("sendStockAgeingReport", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 11 * * *")
    public void escalateTicket() throws Exception {
        log.info("escalate ticket");
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("escalateTicket", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        ticketRelatedScheduledTask.escalateTicket();

        propertiesDetails.put("escalateTicket", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 11 * * *")
    public void alertTicketToUser() throws Exception {
        log.info("alert for ticket");
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("alertTicketToUser", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        ticketRelatedScheduledTask.alertforTicket();
        propertiesDetails.put("alertTicketToUser", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    //@Scheduled(cron = "0 0 14,18,23 ? * *")
    public void dailySaleNotification() throws Exception {
        log.info("daily send Notification");
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("dailySaleNotification", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.sendDailySalesNotificationToPartner(null);

        propertiesDetails.put("dailySaleNotification", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    /*
     * @Scheduled(cron = "0 0 6 * * *") public void dailyReconciliation() throws
     * Exception { reconciliation.dailyReconciliation(); }
     */

    @Scheduled(cron = "0 0 1 * * *")
    public void selectFinServiceFollowUpDateByCurrDate() throws Exception {
        log.info("selectFinServiceFollowUpDateByCurrDate");
        scheduledTasks.selectFinServiceFollowUpDateByCurrDate(LocalDate.now());

    }

    @Scheduled(cron = "0 0 4 * * *")
    public void processActivation() throws Exception {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("processActivation", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.processActivation();

        propertiesDetails.put("processActivation", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    // TODO: Change it back to first of every month
    // @Scheduled(cron = "0 0 1 1 * *")
    @Scheduled(cron = "0 0 1 2 * *")
    public void rollOutUpgardedMargins() throws Exception {
        scheduledTasks.rollOutUpgardedMarginsNextMonth(null);

    }

    @Scheduled(fixedDelay = 60 * 1000)
    public void sendNotification() throws Throwable {

        log.info("send Notification");
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("sendNotification", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.sendNotification();
        propertiesDetails.put("sendNotification", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        log.info("send Notification Done");

    }

    //@Scheduled(cron = "0 */15 * * * *")
    public void checkRazorPayPaymentStatus() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("checkRazorPayPaymentStatus", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.checkRazorPayPaymentStatus();
        propertiesDetails.put("checkRazorPayPaymentStatus", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(fixedDelay = 2 * 1000)
    //@Scheduled(cron = "0 5 23 * * *")
    public void updateIrnsToInvoices() throws Throwable {
        runOnceTasks.updateIrnsToInvoices();
    }

    // No longer needed
    // @Scheduled(cron = "0 */10 * * * *")
    public void attachToffeeInvoices() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("attachToffeeInvoices", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.attachToffeeInvoices();

        propertiesDetails.put("attachToffeeInvoices", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 5 * * *")
    public void ticketClosed() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("ticketClosed", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.ticketClosed();

        propertiesDetails.put("ticketClosed", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 8 * * *")
    public void checkfocusedModelInPartnerStock() throws Throwable {
        log.info("startTime" + LocalDateTime.now());

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("checkfocusedModelInPartnerStock", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.checkfocusedModelInPartnerStock();
        propertiesDetails.put("checkfocusedModelInPartnerStock", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    @Scheduled(cron = "0 0 8,10,12,14,16,18,20 * * *")
    public void notifyLead() throws Throwable {

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("notifyLead", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.notifyLead();

        propertiesDetails.put("notifyLead", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        // scheduledTasks.notifyVisits();
    }

    // No longer scheduled
    // @Scheduled(cron = "0 0 1 * * *")
    public void fetchImeiActivation() throws Throwable {
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("fetchImeiActivation", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        runOnceTasks.fetchImeiActivation(0);

        propertiesDetails.put("fetchImeiActivation", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 7 * * *")
    //Send all lead owners the report for scheduled followups missed
    public void sendUnscheduledFollowUpMail() throws Exception {
        scheduledTasks.sendUnscheduledFollowUpMail();
    }

    @Scheduled(cron = "0 0 1 * * *")
    public void checkValidateReferral() throws Throwable {
        log.info("startTime" + LocalDateTime.now());
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("checkValidateReferral", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.checkValidateReferral();

        propertiesDetails.put("checkValidateReferral", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    // @Scheduled(cron = "0 0 8 * * *")
    public void partnerProblemAlert() throws Throwable {
        log.info("startTime" + LocalDateTime.now());
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("partnerProblemAlert", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.partnerProblemAlert();
        propertiesDetails.put("partnerProblemAlert", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    /*
     * @Scheduled(cron = "0 30 10 * * MON-SAT") public void
     * sendMorningAttendanceAlert() throws Throwable { log.info("startTime" +
     * LocalDateTime.now()); LinkedHashMap<String, String> propertiesDetails = new
     * LinkedHashMap<>(); propertiesDetails.put("sendMorningAttendanceAlert", "0");
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
     * nagiosCronPropertiesFile);
     *
     * scheduledTasks.sendAttendanceMorningAlert();
     * propertiesDetails.put("sendMorningAttendanceAlert", "1");
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
     * nagiosCronPropertiesFile);
     *
     * log.info("endTime" + LocalDateTime.now()); }
     *
     * @Scheduled(cron = "0 30 20 * * MON-SAT") public void
     * sendEveningAttendanceAlert() throws Throwable { log.info("startTime" +
     * LocalDateTime.now()); LinkedHashMap<String, String> propertiesDetails = new
     * LinkedHashMap<>(); propertiesDetails.put("sendEveningAttendanceAlert", "0");
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
     * nagiosCronPropertiesFile);
     *
     * scheduledTasks.sendAttendanceEveningAlert();
     * propertiesDetails.put("sendEveningAttendanceAlert", "1");
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
     * nagiosCronPropertiesFile);
     *
     * log.info("endTime" + LocalDateTime.now()); }
     */

    @Scheduled(cron = "0 0 10 * * *")
    public void onboardingEventDelays() throws Throwable {
        log.info("startTime" + LocalDateTime.now());

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("onboardingEventDelays", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        onBoardingRelatedSchelduleTask.onboardingEventDelays();

        propertiesDetails.put("onboardingEventDelays", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    @Scheduled(cron = "0 0 8 * * *")
    public void brandingAlert() throws Throwable {
        log.info("startTime" + LocalDateTime.now());
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("brandingAlert", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        onBoardingRelatedSchelduleTask.brandingAlert();
        propertiesDetails.put("brandingAlert", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

//    @Scheduled(cron = "0 0 8 * * *")
//    public void advancePaymentPendingAlert() throws Throwable {
//        log.info("startTime" + LocalDateTime.now());
//
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
//        propertiesDetails.put("advancePaymentPendingAlert", "0");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
//        onBoardingRelatedSchelduleTask.advancePaymentPendingAlert();
//        propertiesDetails.put("advancePaymentPendingAlert", "1");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
//        log.info("endTime" + LocalDateTime.now());
//    }

    @Scheduled(cron = "0 0 8 * * *")
    public void fullPaymentPendingAlert() throws Throwable {
        log.info("startTime" + LocalDateTime.now());

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("fullPaymentPendingAlert", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();

        propertiesDetails.put("fullPaymentPendingAlert", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

//    @Scheduled(cron = "0 0 9 * * *")
//    public void advancePaymentPendinglegalAlert() throws Throwable {
//        log.info("startTime" + LocalDateTime.now());
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
//        propertiesDetails.put("advancePaymentPendinglegalAlert", "0");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
////        onBoardingRelatedSchelduleTask.advancePaymentPendinglegalAlert();
//
//        propertiesDetails.put("advancePaymentPendinglegalAlert", "1");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
//        log.info("endTime" + LocalDateTime.now());
//    }

    @Scheduled(cron = "0 */5 * * * *")
    public void onBoardingCompleteEventEmail() throws Throwable {
        log.info("startTime" + LocalDateTime.now());
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("onBoardingCompleteEventEmail", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();
        propertiesDetails.put("onBoardingCompleteEventEmail", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    @Scheduled(cron = "0 */5 * * * *")
    public void updateSaholicCISTable() throws Throwable {
        log.info("updateSaholicCISTable startTime" + LocalDateTime.now());
        runOnceTasks.updateSaholicCISTable();
        log.info("updateSaholicCISTable endTime" + LocalDateTime.now());
    }

    @Autowired
    PurSaleService purSaleService;

    @Scheduled(cron = "0 0 6,22 * * ?")
    public void send10DaysEgedStockReport() throws Throwable {
        log.info("moreThen10DaysEgedStockReport startTime" + LocalDateTime.now());
        scheduledTasks.send10OrMoreOlderStockReport();
        log.info("moreThen10DaysEgedStockReport endTime" + LocalDateTime.now());
    }

    @Scheduled(fixedDelay = 30 * 60 * 1000, initialDelay = 15 * 60 * 1000)
    public void fetchPartnerStat() throws Throwable {
        scheduledTasks.fetchParnterStats();
    }

//    @Scheduled(cron = "0 0 9 * * *")
//    public void storeTimelinePromoterPending() throws Throwable {
//        log.info("startTime" + LocalDateTime.now());
//
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
//        propertiesDetails.put("storeTimelinePromoterPending", "0");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
////        onBoardingRelatedSchelduleTask.storeTimelinePromoterPending();
//        propertiesDetails.put("storeTimelinePromoterPending", "1");
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
//
//        log.info("endTime" + LocalDateTime.now());
//    }

    //@Scheduled(cron = "0 0 23 * * *")
    public void checkItelImeiActivationNew() throws Throwable {
        log.info("startTime" + LocalDate.now());

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("checkItelImeiActivationNew", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
        long secs = (new Date().getTime()) / 1000;
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());
        propertiesDetails.put("checkItelImeiActivationNew", "1");
        propertiesDetails.put("itelDate", Long.toString(secs));
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }


    @Scheduled(fixedDelay = 60 * 1000)
    public void vivoImeiActivation() throws Throwable {
        log.info("startTimevivoImeiActivation" + LocalDateTime.now());

        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("vivoImeiActivation", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        scheduledTasks.checkImeiActivation();
        long secs = (new Date().getTime()) / 1000;
        log.info("endTimevivoImeiActivation" + LocalDateTime.now());
        propertiesDetails.put("vivoImeiActivation", "1");

        propertiesDetails.put("vivoDate", Long.toString(secs));
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

    }

    @Scheduled(cron = "0 0 8 * * *")
    public void reviewUncontactablePartner() throws Throwable {
        log.info("startTime" + LocalDateTime.now());

        scheduledTasks.reviewUncontactablePartner();

    }

    @Scheduled(cron = "0 0 7 * * *")
    public void setMovementWiseRbmTodayTargets() throws Throwable {
        log.info("today targets startTime {}", LocalDateTime.now());

        scheduledTasks.persistRbmTodayTargets();

    }

    @Scheduled(cron = "0 0 21 * * *")
    public void setMovementWiseRbmTodayAchievements() throws Throwable {
        log.info("today achievement startTime {}", LocalDateTime.now());

        scheduledTasks.persistRbmTodayAchievements();

    }

    @Scheduled(cron = "0 0 8 * * *")
    public void reviewNonSdBuyingBrand() throws Throwable {
        log.info("startTime" + LocalDateTime.now());

        scheduledTasks.reviewNonSdBuyingBrand();

    }

    @Autowired
    private StandAlone standAlone;

    @Autowired
    OrderTrackingService orderTrackingService;

    @Scheduled(fixedDelay = 60 * 1000)
    public void oppo() throws Throwable {
        standAlone.checkOppoImeiStatus();
    }

    @Scheduled(fixedDelay = 60 * 1000)
    public void realme() throws Throwable {
        standAlone.checkRealmeImeiStatus();
    }

    @Scheduled(cron = "0 0 * * * *")
    public void markBlueDartOrderDelivered() throws Throwable {
        log.info("startTime" + LocalDateTime.now());
        orderTrackingService.markBlueDartOrderDelivered();
        log.info("endTime" + LocalDateTime.now());
    }

    @Scheduled(cron = "0 15 * * * *")
    public void markDelhiveryOrderDelivered() throws Throwable {
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("markDelhiveryOrderDelivered", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("startTime" + LocalDateTime.now());
        orderTrackingService.markDelhiveryOrderDelivered();
        propertiesDetails.put("markDelhiveryOrderDelivered", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        log.info("endTime" + LocalDateTime.now());
    }

    @Scheduled(cron = "0 0 4 * * *")
    public void processPriceDrop() throws Throwable {
        scheduledTasks.processPriceDrop();
    }

    @Scheduled(cron = "0 0 0 * * *")
    public void calculateInterestAccured() throws Throwable {
        scheduledTasks.loanSettlement();
        scheduledTasks.calculateInterestAccured();
    }

    //  @Scheduled(cron = "0 */5 2-22 * * *")
    @Scheduled(fixedDelay = 1 * 60 * 1000)
    //@Scheduled(cron = "0 0 23 * * *")
    public void loanSettlement() throws Throwable {
        LocalTime now = LocalTime.now();
        LocalTime start = LocalTime.of(9, 0);
        LocalTime end = LocalTime.of(23, 0);

        if (now.isBefore(start) || now.isAfter(end)) {
            System.out.println("Task skipped during restricted hours: " + now);
        } else {
            scheduledTasks.loanSettlement();
            System.out.println("Task executed at " + now);
        }
    }

    @Scheduled(cron = "0 */15 * * * *")
    public void ccAvenueSettlement() throws Throwable {
        scheduledTasks.settleCCAvePayments();
    }

    @Scheduled(cron = "0 0 6 * * *")
    public void dailyLoanAlert() throws Throwable {
        scheduledTasks.dailyLoanAlert();
    }

    @Scheduled(cron = "0 0 11 * * *")
    public void groupHidCatalogsByWeeks() throws Throwable {
        scheduledTasks.groupHidCatalogsByWeeks();
    }

    @Scheduled(cron = "0 0 9 * * *")
    public void sendFeebackSalesAndRbm() throws Throwable {
        scheduledTasksTest.sendRbmFeedbackSummaryEmail();
        scheduledTasksTest.sendSalesFeedbackSummaryEmail();
    }

    //Look out for imeis that have activation pending based of sale and mark create new SIO out of them
    @Scheduled(cron = "0 0 1 * * *")
    public void processActivatedImeisForSchemes() throws Throwable {
        scheduledTasks.processActivatedImeisForSchemes();
    }

    //On every fifth update deductions
    @Scheduled(cron = "0 30 6 5 * ?")
    public void processSidbiDeductions() throws Throwable {
        scheduledTasks.processSidbiDeductions();
    }

    //Dont reset it for now as proposed by TV
    //@Scheduled(cron = "0 30 6 4 * ?")
    public void resetHardLimit() throws Throwable {
        scheduledTasks.resetHardLimit();
    }

    @Scheduled(cron = "0 0/20 * * * *")
    public void updatePartnerLimit() throws Throwable {
        scheduledTasks.updatePartnerLimit();
    }

    @Scheduled(cron = "0 0 9,14,18 * * *")
    public void createOpeningStockPartyWise() throws Throwable {
        scheduledTasks.createOpeningStockPartyWise();
    }


    //Loans due/overdue/default notifications sent to parnters
    @Scheduled(cron = "0 0 11 * * *")
    public void sendMailWhatsAppAfterLoanDueDate() throws Throwable {
        scheduledTasks.sendMailWhatsAppAfterLoanDueDate();
    }

    @Scheduled(cron = "0 0 8 * * *")
    public void alertForDueDate() throws Throwable {
        scheduledTasks.alertForDueDate();
    }

    @Scheduled(cron = "0 0 4,21 * * *")
    public void notifyLoanDueDateCross() throws Throwable {
        scheduledTasks.notifyLoanDueDateCross();
    }

    @Scheduled(cron = "0 0 4,21 * * *")
    public void notifyDefaultLoans() throws Throwable {
        scheduledTasks.notifyDefaultLoans();
    }

   // @Scheduled(cron = "0 0 23 * * *")
    public void hygineAlertForInternalTeam() throws Throwable {
        scheduledTasks.hygineAlertForInternalTeam();

    }

    @Scheduled(cron = "0 0 23 * * *")
    public void hygineAlertForPartner() throws Throwable {
        scheduledTasks.hygineAlertForPartner();

    }

    @Scheduled(cron = "0 0 0 * * MON")
    public void monthlyTargetForPartner() throws Throwable {
        scheduledTasks.monthlyTargetForPartner();

    }

    @Scheduled(cron = "0 0 0 * * MON")
    public void monthlyTargetForInternalTeam() throws Throwable {
        scheduledTasks.monthlyTargetForInternalTeam();

    }

    @Scheduled(cron = "0 0 6 * * *")
    public void sendSamsungRebilling() throws Throwable {
        scheduledTasks.sendMailForSamsungRebilling();
    }

    @Scheduled(cron = "0 10 8 * * *")
    public void sendMailForAgeingAlert() throws Throwable {
        scheduledTasks.sendMailForAgeingAlert();
    }


    @Scheduled(cron = "0 0 8 * * *")
    public void sendFilteredRetailerPerformance() throws Throwable {
        scheduledTasks.sendFilteredRetailerPerformance();
    }

    @Scheduled(cron = "0 0 0 * * MON")
    public void findAllLiveDemoBrandItemsByBillingDate() throws Throwable {
        scheduledTasks.findAllLiveDemoBrandItemsByBillingDate();
    }

    @Scheduled(cron = "0 10 6 * * *")
    public void findTodayPocoBillingItems() throws Throwable {
        scheduledTasks.findTodayPocoBillingItems();
    }


    @Scheduled(cron = "0 0 12 * * *")
    public void rejectPriceDropsOfApprovedImeis() throws Throwable {
        scheduledTasks.rejectPriceDropsOfApprovedImeis();
    }

    @Autowired
    POScheduler poScheduler;

    @Scheduled(cron = "0 0 1 * * *")
    public void autoClosePO() {
        poScheduler.autoClosePurchaseOrders();
    }
    /*
     * @Scheduled(cron = "0 0 9 * * *") public void onBoardingDocumentsPending()
     * throws Throwable { log.info("startTime" + LocalDateTime.now());
     * onBoardingRelatedSchelduleTask.onBoardingDocumentsPending();
     * log.info("endTime" + LocalDateTime.now()); }
     */

    @Scheduled(cron = "0 50 23 * * *")
    public void bidConfirmation() throws Throwable {
        log.info("running bid cron at 23:50PM");
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.YESTERDAY);
    }

    @Scheduled(cron = "0 0 19 * * *")
    public void processLiquidationBids() throws Throwable {
        log.info("running bid cron at 07:00PM");
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
    }

    @Scheduled(cron = "0 30 21 * * *")
    public void bidPurchaseOrder() throws Throwable {
        log.info("running bid cron at 09:30PM");
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
    }

    /*@Scheduled(cron = "0 0 12 * * *")
    public void processCashDiscount() throws Throwable {
        scheduledTasks.processCashDiscount();
    }*/


    @Scheduled(cron = "0 0 9,17 * * *")
    public void bidConsolidatedMessage() throws Throwable {
        log.info("Running bid cron at 09:00 AM or 05:00 PM");
        runOnceTasks.consolidatedBiddingMessage();
    }

    @Scheduled(cron = "0 0 8 * * *")
    public void yesterdayTrackingReport() throws Throwable {
        log.info("Running yesterday employee tracking cron at 08:00 AM");
        runOnceTasks.yesterdayTrackingReport();
    }

    @Scheduled(cron = "0 10 8 * * *")
    public void partnerCreditExposureReport() throws Throwable {
        log.info("Running yesterday employee tracking cron at 08:00 AM");
        runOnceTasks.sendCreditExposureReport();
    }

    @Scheduled(cron = "0 0 21,16 * * *")
    public void dailyTrackingReport() throws Throwable {
        log.info("Running daily employee tracking cron at 09:00 PM and 04:00 PM");
        runOnceTasks.dailyTrackingReport();
    }

    @Scheduled(cron = "0 0 0 1 1,4,7,10 *")
    public void sendUpdateMobileBrandMarketShareQuaterlyMail() throws Throwable {
        log.info("Running Marketshare update remined quaterly");
        scheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail();
    }

    @Scheduled(cron = "0 0 * * * *")
    public void checkRewardsEligibility() throws Throwable {
        log.info("Running Rewards Disburse daily");
        runOnceTasks.checkRewardsEligibility();
    }

    @Scheduled(cron="0 0 20 * * *")
    public void sendTrialExpiry() {
        scheduledTasks.sendTrialExpiry();
    }
}