Subversion Repositories SmartDukaan

Rev

Rev 37482 | 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.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 com.spice.profitmandi.service.integrations.icicilombard.IciciLombardService;
import com.spice.profitmandi.service.integrations.icicilombard.model.LastTransactionsResponseModel;
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.time.YearMonth;
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 BatchScheduledTasks batchScheduledTasks;

    @Autowired
    private ScheduledTasksTest scheduledTasksTest;

    @Autowired
    private AbmReportSender abmReportSender;

    @Autowired
    private LeadSyncRunner leadSyncRunner;

    @Autowired
    private Reconciliation reconciliation;

    @Autowired
    private RunOnceTasks runOnceTasks;

    @Autowired
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;

    @Autowired
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;

//    @Autowired
//    private IciciLombardService iciciLombardService;

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

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

        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);
        }

    }

    /** Daily 00:20: re-index models whose hot-deal window opened today or closed yesterday. */
    @Scheduled(cron = "0 20 0 * * *")
    public void syncHotDealFlags() throws Exception {
        try {
            scheduledTasks.syncHotDealFlags();
        } catch (Exception e) {
            log.error("syncHotDealFlags failed", e);
        }
    }

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

        scheduledTasks.reconcileRecharge();

    }

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

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

        scheduledTasks.processRechargeCashback();

    }

    @Scheduled(cron = "0 0 6 * * *")
    public void sendPartnerInvestmentDetails() throws Exception {
        scheduledTasks.sendPartnerInvestmentDetails();
        long secs = (new Date().getTime()) / 1000;
        log.info("sendPartnerInvestmentDetails" + LocalDateTime.now());

    }

    // Monthly margins CN dry-run at 06:00 on the 1st. dryRun=true forces the harmless dev path
    // (no IRN, no PDF, no DB persist, no partner mail) even on prod. The real pipeline is run
    // manually via `--sendCreditNote --live`.
    @Scheduled(cron = "0 0 6 1 * ?")
    public void monthlyMarginsCnDryRun() throws Exception {

        scheduledTasks.sendCreditNote(YearMonth.now().minusMonths(1), true);

    }

    @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 {

        scheduledTasks.sendIndentTertiary();

    }

    @Scheduled(cron = "0 0 6 * * *")
    public void checkPartnerActiveStoreByStatus() throws Exception {

        scheduledTasks.checkPartnerActiveStore();

    }

    @Scheduled(cron = "0 30 23 * * *")
    public void updatePartnerActivationTypeByMonthlySale() throws Exception {

        scheduledTasks.updatePartnerActivationTypeByMonthlySale();

    }

    // 23:45 — after updatePartnerActivationTypeByMonthlySale (23:30), so the
    // REVIVAL agenda mirror reads today's activation_type state.
    @Scheduled(cron = "0 45 23 * * *")
    public void updatePjpAgendaInstances() throws Exception {

        scheduledTasks.updatePjpAgendaInstances();

    }

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

        scheduledTasks.sendAgeingReport();

    }

    @Scheduled(cron = "0 0 11 * * *")
    public void escalateTicket() throws Exception {
        log.info("escalate ticket");
        ticketRelatedScheduledTask.escalateTicket();

    }

    @Scheduled(cron = "0 0 11 * * *")
    public void alertTicketToUser() throws Exception {
        log.info("alert for ticket");

        ticketRelatedScheduledTask.alertforTicket();

    }

    /**
     * Hits ICICI Lombard "Get Last Twenty Five Transactions" twice a day (14:00 and 22:00 IST)
     * to log our CDBG account's current available balance + last 25 transactions.
     * First iteration: log-only so we can eyeball the response format. Persisting / alerting
     * on balance drops can be added once we agree on the shape.
     */
   /* @Scheduled(cron = "0 0 14,22 * * *")
    public void fetchIciciCdBalance() throws Exception {
        log.info("Fetching ICICI CD balance");
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
        propertiesDetails.put("fetchIciciCdBalance", "0");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);

        try {
            LastTransactionsResponseModel response = iciciLombardService.getLastTwentyFiveTransactions(null);
            log.info("ICICI CD balance response: {}", response);
            if (response != null
                    && response.getTransactionsDetails() != null
                    && !response.getTransactionsDetails().isEmpty()) {
                LastTransactionsResponseModel.TransactionDetail latest = response.getTransactionsDetails().get(0);
                log.info("ICICI CD current available balance = {} (as of {} — status: {})",
                        latest.getAvailableBalance(),
                        latest.getEffectiveDate(),
                        latest.getStatus());
                log.info("ICICI CD last 25 transactions -> {}", response.getTransactionsDetails());
            } else {
                log.warn("ICICI returned empty transactions_details. status={}, statusMessage={}, message={}",
                        response == null ? null : response.getStatus(),
                        response == null ? null : response.getStatusMessage(),
                        response == null ? null : response.getMessage());
            }
        } catch (Exception e) {
            log.error("Failed to fetch ICICI CD balance", e);
        }

        propertiesDetails.put("fetchIciciCdBalance", "1");
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
    }*/

    //@Scheduled(cron = "0 0 14,18,23 ? * *")
    public void dailySaleNotification() throws Exception {
        log.info("daily send Notification");

        scheduledTasks.sendDailySalesNotificationToPartner(null);

    }

    /*
     * @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 {

        scheduledTasks.processActivation();

    }

    // 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");

        scheduledTasks.sendNotification();
        log.info("send Notification Done");

    }

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

        scheduledTasks.checkRazorPayPaymentStatus();

    }

    @Scheduled(fixedDelay = 5 * 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 {

        scheduledTasks.attachToffeeInvoices();

    }

    // REMOVED: ticketClosed() scheduler - now handled by TicketRelatedScheduledTask.autoCloseResolvedTickets()
    // which uses 8 working days instead of 7 calendar days and runs as part of processAllTicketTasks()

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

        scheduledTasks.checkfocusedModelInPartnerStock();

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

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

        scheduledTasks.notifyLead();

        // scheduledTasks.notifyVisits();
    }

    // No longer scheduled
    // @Scheduled(cron = "0 0 1 * * *")
    public void fetchImeiActivation() throws Throwable {

        runOnceTasks.fetchImeiActivation(0);

    }

    @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());

        scheduledTasks.checkValidateReferral();

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

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

        scheduledTasks.partnerProblemAlert();

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

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

        onBoardingRelatedSchelduleTask.onboardingEventDelays();

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

    @Scheduled(cron = "0 30 10 * * *")
    public void sendStockDeliveredTrainingNotification() {
        log.info("sendStockDeliveredTrainingNotification startTime " + LocalDateTime.now());
        onBoardingRelatedSchelduleTask.sendStockDeliveredTrainingNotification();
        log.info("sendStockDeliveredTrainingNotification endTime " + LocalDateTime.now());
    }

    @Scheduled(cron = "0 0 9 * * ?")
    public void sendDelayAlertEmail() {
        log.info("sendDelayAlertEmail startTime " + LocalDateTime.now());
        onBoardingRelatedSchelduleTask.sendDelayAlertEmail();
        log.info("sendDelayAlertEmail endTime " + LocalDateTime.now());
    }

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

        onBoardingRelatedSchelduleTask.brandingAlert();

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

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

        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();

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

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

        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();

        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 = 5 * 60 * 1000)
    public void fetchPartnerStat() throws Throwable {
        scheduledTasks.fetchParnterStats();
    }

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

        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
        long secs = (new Date().getTime()) / 1000;
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());

    }

    /**
     * Vivo: one full pass a day, then nothing until tomorrow.
     *
     * Was two parallel jobs every 5 minutes capped at 50 and 10 imeis, which never
     * finished a pass over a 9,510-row pool and retried a failed lookup five minutes
     * later instead of the next day. Vivo stays on its own schedule and its own thread:
     * it is direct HTTP plus the captcha solver, no ChromeDriver, so it does not
     * contend for the resource the oppo/realme pass is rationing.
     *
     * ~9,510 imeis at roughly 2.5s each is about 6.6 hours.
     */
    @Scheduled(cron = "0 15 0 * * *")
    public void vivoImeiActivation() throws Throwable {
        log.info("startTimevivoImeiActivation" + LocalDateTime.now());

        scheduledTasks.checkImeiActivation();

        log.info("endTimevivoImeiActivation" + LocalDateTime.now());

    }

    /**
     * Itel activation from Carlcare, Transsion's own after-sales endpoint. 50 imeis every 5
     * minutes, which spreads the work over the whole day rather than bursting: 14,400 lookups a
     * day against a pending pool of ~10,400.
     *
     * The 5-minute cadence is safe here in a way it was not for vivo, whose comment below records
     * why that pattern ran away: there, a failed lookup wrote no row, so createTimestamp was not
     * bumped and the same imei was eligible again five minutes later. This service stamps the row
     * on EVERY outcome, failures included, so each tick advances past the imeis it asked about
     * and a failure costs one retry tomorrow rather than one every five minutes.
     *
     * It is one plain signed GET per imei -- no captcha solver, no ChromeDriver -- so it does not
     * contend with the oppo/realme pass. Both this and the 23:00 DCR pull write Itel rows and
     * need no coordination: the pool query returns only imeis whose activationTimestamp is still
     * null, so whatever one has filled has already left the other's pool.
     */
    @Scheduled(fixedDelay = 5 * 60 * 1000)
    public void carlcareImeiActivation() throws Throwable {
        scheduledTasks.checkCarlcareImeiActivation();
    }

    @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();

    }

    // Sales-hierarchy target snapshot — runs 10 minutes after RBM targets so
    // today's rbm_targets rows are guaranteed present for the roll-up.
    @Scheduled(cron = "0 10 7 * * *")
    public void setSalesTodayTargets() throws Throwable {
        log.info("sales today targets startTime {}", LocalDateTime.now());

        scheduledTasks.persistSalesTodayTargets();

    }

    // Sales-hierarchy achievement snapshot — independent of the target chain;
    // rolls up live order ACH so it can run any time after orders settle.
    // Kept aligned with RBM achievement time (21:00).
    @Scheduled(cron = "0 10 21 * * *")
    public void setSalesTodayAchievements() throws Throwable {
        log.info("sales today achievement startTime {}", LocalDateTime.now());

        scheduledTasks.persistSalesTodayAchievements();

    }

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

        scheduledTasks.reviewNonSdBuyingBrand();

    }

    @Autowired
    private StandAlone standAlone;

    @Autowired
    OrderTrackingService orderTrackingService;

    // ONE thread, ONE full pass a day, for oppo and realme together.
    //
    // This replaces four @Scheduled jobs (oppo and realme x secondary and tertiary,
    // every 5 minutes), and it supersedes the r37447 / r37448 / r37449 argument about
    // how many ChromeDrivers to run. That argument was about the wrong variable.
    //
    // The revert in r37449 was sized on lookups ATTEMPTED per day, and the re-merge that
    // followed blamed the resulting collapse on CPU contention pushing the captcha
    // render past the element waits. The logs do not support contention:
    //
    //   29 Aug        imeis   canvas timeouts   captcha ok   distinct imeis   asks each
    //   oppo          4,350                 0       ~100%            4,238        1.03
    //   realme        4,524             3,390         19%            1,004        4.50
    //
    // Same box, same six cores, same driver count, same captcha vendor, load average
    // 0.9 -- and oppo took ZERO timeouts in all 24 hours, including the 15:00-23:00
    // window in which realme solved nothing at all. Realme's own canvas wait is 15s
    // against oppo's 8s, so the LONGER wait is the one expiring.
    //
    // What realme's timeout rate actually tracks is its own daily request volume, and
    // it resets at midnight: 920/day -> 0.3%, 3,467/day -> 28%, 4,524/day -> 75%. That
    // is realme.com declining to serve the widget, not a busy box.
    //
    // The 4.5 asks per imei is why it ran away. A failed lookup never reaches
    // dateMap.put, so no row is written, so createTimestamp is not bumped, so the same
    // imei was eligible again five minutes later -- more requests hardened the block,
    // which caused more failures, which caused more requests. A snapshotted daily pass
    // bounds that by construction: a failure costs one retry tomorrow, never one in
    // five minutes, however the far end behaves.
    //
    // Judge this change on dates written, not on timeout count.
    @Scheduled(cron = "0 30 0 * * *")
    public void oppoRealmeImeiActivation() throws Throwable {
        log.info("startTimeOppoRealmeImeiActivation {}", LocalDateTime.now());

        standAlone.checkBrowserImeiActivation();

        log.info("endTimeOppoRealmeImeiActivation {}", LocalDateTime.now());
    }

    @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 {

        log.info("startTime" + LocalDateTime.now());
        orderTrackingService.markDelhiveryOrderDelivered();

        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 * * MON")  // Every Monday at 9:00 AM
    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 {
        batchScheduledTasks.updatePartnerLimitWithBatch();
    }

    @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 {
        batchScheduledTasks.reprocessPriceDropsWithBatch();
    }

    @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 22,16 * * *")
    public void dailyTrackingReport() throws Throwable {
        log.info("Running daily employee tracking cron at 10: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();
    }

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

    @Scheduled(cron = "0 0 0 * * *")
    public void syncProductsToShopify() throws Exception {
        scheduledTasks.syncProductsToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
    }

    @Scheduled(cron = "0 0 6,18 * * *")
    public void syncInventoryToShopify() throws Exception {
        scheduledTasks.syncInventoryToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
    }

    @Autowired
    private WarehouseStockReconciliation warehouseStockReconciliation;

    @Scheduled(cron = "0 30 5 * * *")
    public void reconcileInventorySnapshot() throws Exception {
        log.info("reconcileInventorySnapshot");
        warehouseStockReconciliation.reconcile();
    }

    @Autowired
    private PartnerIdentityIntegrityMonitor partnerIdentityIntegrityMonitor;

    @Scheduled(cron = "0 0 7 * * *")
    public void partnerIdentityIntegrityMonitor() throws Exception {
        log.info("partnerIdentityIntegrityMonitor");
        partnerIdentityIntegrityMonitor.monitor();
    }
}