Subversion Repositories SmartDukaan

Rev

Rev 37499 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23756 amit.gupta 1
package com.smartdukaan.cron.scheduled;
2
 
30049 amit.gupta 3
import com.smartdukaan.cron.migrations.RunOnceTasks;
34948 ranu 4
import com.smartdukaan.cron.scheduled.ambreports.AbmReportSender;
30049 amit.gupta 5
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
32832 amit.gupta 6
import com.smartdukaan.cron.scheduled.ordertracking.OrderTrackingService;
32907 amit.gupta 7
import com.smartdukaan.cron.scheduled.purchaseorder.POScheduler;
34443 vikas.jang 8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
34241 tejus.loha 9
import com.spice.profitmandi.dao.service.PurSaleService;
37499 ranu 10
import com.spice.profitmandi.service.integrations.icicilombard.IciciLombardService;
11
import com.spice.profitmandi.service.integrations.icicilombard.model.LastTransactionsResponseModel;
23756 amit.gupta 12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.scheduling.annotation.Scheduled;
16
import org.springframework.stereotype.Component;
17
 
30049 amit.gupta 18
import java.time.LocalDate;
19
import java.time.LocalDateTime;
34756 amit.gupta 20
import java.time.LocalTime;
36993 amit 21
import java.time.YearMonth;
30049 amit.gupta 22
import java.util.Date;
37499 ranu 23
import java.util.LinkedHashMap;
23756 amit.gupta 24
 
25
@Component
30887 amit.gupta 26
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
23756 amit.gupta 27
public class ScheduledSkeleton {
23794 govind 28
 
32048 tejbeer 29
    private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);
23756 amit.gupta 30
 
32048 tejbeer 31
    @Autowired
32
    private ScheduledTasks scheduledTasks;
28205 tejbeer 33
 
32048 tejbeer 34
    @Autowired
36361 amit 35
    private BatchScheduledTasks batchScheduledTasks;
36
 
37
    @Autowired
34321 ranu 38
    private ScheduledTasksTest scheduledTasksTest;
39
 
40
    @Autowired
34948 ranu 41
    private AbmReportSender abmReportSender;
42
 
43
    @Autowired
32048 tejbeer 44
    private LeadSyncRunner leadSyncRunner;
24841 govind 45
 
32048 tejbeer 46
    @Autowired
47
    private Reconciliation reconciliation;
25822 amit.gupta 48
 
32048 tejbeer 49
    @Autowired
50
    private RunOnceTasks runOnceTasks;
23756 amit.gupta 51
 
32048 tejbeer 52
    @Autowired
53
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;
24841 govind 54
 
32048 tejbeer 55
    @Autowired
56
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;
28921 tejbeer 57
 
37499 ranu 58
//    @Autowired
59
//    private IciciLombardService iciciLombardService;
60
 
61
    String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";
62
 
32048 tejbeer 63
    @Scheduled(cron = "0 0 2 * * *")
64
    public void processDailySchemes() throws Exception {
29757 tejbeer 65
 
32048 tejbeer 66
        int maxMinusDays = 5;
67
        int currentDayOfMonth = LocalDate.now().getDayOfMonth();
68
        int minusDays = currentDayOfMonth > maxMinusDays ? maxMinusDays : currentDayOfMonth - 1;
69
        if (minusDays > 0) {
70
            scheduledTasks.processScheme(LocalDateTime.now().minusDays(minusDays), LocalDateTime.now(), false);
71
        }
29673 manish 72
 
32048 tejbeer 73
    }
24841 govind 74
 
37292 amit 75
    /** Daily 00:20: re-index models whose hot-deal window opened today or closed yesterday. */
37258 amit 76
    @Scheduled(cron = "0 20 0 * * *")
77
    public void syncHotDealFlags() throws Exception {
78
        try {
79
            scheduledTasks.syncHotDealFlags();
80
        } catch (Exception e) {
81
            log.error("syncHotDealFlags failed", e);
82
        }
83
    }
84
 
32048 tejbeer 85
    @Scheduled(cron = "0 15 0 * * *")
86
    public void runOnceTasks() throws Exception {
29757 tejbeer 87
 
32048 tejbeer 88
        scheduledTasks.reconcileRecharge();
29757 tejbeer 89
 
32048 tejbeer 90
    }
25822 amit.gupta 91
 
32048 tejbeer 92
    /*
93
     * @Scheduled(cron = "0 0 8 * * *") public void mailDashboardScreenshots()
94
     * throws Exception { runOnceTasks.mailDashboardScreenshots(); }
95
     */
25721 tejbeer 96
 
32048 tejbeer 97
    @Scheduled(cron = "0 05 0 1,16 * ?")
98
    public void processRechargeCashback() throws Throwable {
29673 manish 99
 
32048 tejbeer 100
        scheduledTasks.processRechargeCashback();
29673 manish 101
 
32048 tejbeer 102
    }
23794 govind 103
 
32048 tejbeer 104
    @Scheduled(cron = "0 0 6 * * *")
105
    public void sendPartnerInvestmentDetails() throws Exception {
106
        scheduledTasks.sendPartnerInvestmentDetails();
107
        long secs = (new Date().getTime()) / 1000;
108
        log.info("sendPartnerInvestmentDetails" + LocalDateTime.now());
29757 tejbeer 109
 
32048 tejbeer 110
    }
28921 tejbeer 111
 
36993 amit 112
    // Monthly margins CN dry-run at 06:00 on the 1st. dryRun=true forces the harmless dev path
113
    // (no IRN, no PDF, no DB persist, no partner mail) even on prod. The real pipeline is run
114
    // manually via `--sendCreditNote --live`.
115
    @Scheduled(cron = "0 0 6 1 * ?")
116
    public void monthlyMarginsCnDryRun() throws Exception {
117
 
118
        scheduledTasks.sendCreditNote(YearMonth.now().minusMonths(1), true);
119
 
120
    }
121
 
37234 vikas 122
    @Scheduled(cron = "0 30 6 * * *")
34648 ranu 123
    public void generateBiReport() throws Exception {
124
        scheduledTasksTest.generateBiReport();
125
    }
34939 ranu 126
    @Scheduled(cron = "0 30 4 * * *")
127
    public void createFofoSmartCartSuggestion() throws Exception {
128
        scheduledTasksTest.createFofoSmartCartSuggestion();
129
    }
35980 amit 130
    /*@Scheduled(cron = "0 0 6,22 * * *")
34948 ranu 131
    public void sendAbmSmartCartReport() throws Exception {
132
        abmReportSender.sendAbmSmartCartReport();
35980 amit 133
    }*/
34648 ranu 134
 
32048 tejbeer 135
    @Scheduled(cron = "0 0 10,15,17 * * *")
136
    public void sendIndentTertiaryReport() throws Exception {
29757 tejbeer 137
 
32048 tejbeer 138
        scheduledTasks.sendIndentTertiary();
29757 tejbeer 139
 
32048 tejbeer 140
    }
28921 tejbeer 141
 
32048 tejbeer 142
    @Scheduled(cron = "0 0 6 * * *")
143
    public void checkPartnerActiveStoreByStatus() throws Exception {
29673 manish 144
 
32048 tejbeer 145
        scheduledTasks.checkPartnerActiveStore();
29673 manish 146
 
32048 tejbeer 147
    }
26790 tejbeer 148
 
37040 ranu 149
    @Scheduled(cron = "0 30 23 * * *")
150
    public void updatePartnerActivationTypeByMonthlySale() throws Exception {
151
 
152
        scheduledTasks.updatePartnerActivationTypeByMonthlySale();
153
 
154
    }
155
 
37172 amit 156
    // 23:45 — after updatePartnerActivationTypeByMonthlySale (23:30), so the
157
    // REVIVAL agenda mirror reads today's activation_type state.
158
    @Scheduled(cron = "0 45 23 * * *")
159
    public void updatePjpAgendaInstances() throws Exception {
160
 
161
        scheduledTasks.updatePjpAgendaInstances();
162
 
163
    }
164
 
32048 tejbeer 165
    // @Scheduled(cron = "0 0 8 * * *")
166
    public void sendStockAgeingReport() throws Throwable {
29757 tejbeer 167
 
32048 tejbeer 168
        scheduledTasks.sendAgeingReport();
29757 tejbeer 169
 
32048 tejbeer 170
    }
24131 govind 171
 
32048 tejbeer 172
    @Scheduled(cron = "0 0 11 * * *")
173
    public void escalateTicket() throws Exception {
174
        log.info("escalate ticket");
175
        ticketRelatedScheduledTask.escalateTicket();
29757 tejbeer 176
 
32048 tejbeer 177
    }
24841 govind 178
 
32048 tejbeer 179
    @Scheduled(cron = "0 0 11 * * *")
180
    public void alertTicketToUser() throws Exception {
181
        log.info("alert for ticket");
29673 manish 182
 
32048 tejbeer 183
        ticketRelatedScheduledTask.alertforTicket();
29673 manish 184
 
32048 tejbeer 185
    }
24841 govind 186
 
37499 ranu 187
    /**
188
     * Hits ICICI Lombard "Get Last Twenty Five Transactions" twice a day (14:00 and 22:00 IST)
189
     * to log our CDBG account's current available balance + last 25 transactions.
190
     * First iteration: log-only so we can eyeball the response format. Persisting / alerting
191
     * on balance drops can be added once we agree on the shape.
192
     */
193
   /* @Scheduled(cron = "0 0 14,22 * * *")
194
    public void fetchIciciCdBalance() throws Exception {
195
        log.info("Fetching ICICI CD balance");
196
        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
197
        propertiesDetails.put("fetchIciciCdBalance", "0");
198
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
199
 
200
        try {
201
            LastTransactionsResponseModel response = iciciLombardService.getLastTwentyFiveTransactions(null);
202
            log.info("ICICI CD balance response: {}", response);
203
            if (response != null
204
                    && response.getTransactionsDetails() != null
205
                    && !response.getTransactionsDetails().isEmpty()) {
206
                LastTransactionsResponseModel.TransactionDetail latest = response.getTransactionsDetails().get(0);
207
                log.info("ICICI CD current available balance = {} (as of {} — status: {})",
208
                        latest.getAvailableBalance(),
209
                        latest.getEffectiveDate(),
210
                        latest.getStatus());
211
                log.info("ICICI CD last 25 transactions -> {}", response.getTransactionsDetails());
212
            } else {
213
                log.warn("ICICI returned empty transactions_details. status={}, statusMessage={}, message={}",
214
                        response == null ? null : response.getStatus(),
215
                        response == null ? null : response.getStatusMessage(),
216
                        response == null ? null : response.getMessage());
217
            }
218
        } catch (Exception e) {
219
            log.error("Failed to fetch ICICI CD balance", e);
220
        }
221
 
222
        propertiesDetails.put("fetchIciciCdBalance", "1");
223
        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
224
    }*/
225
 
34904 ranu 226
    //@Scheduled(cron = "0 0 14,18,23 ? * *")
32048 tejbeer 227
    public void dailySaleNotification() throws Exception {
228
        log.info("daily send Notification");
29673 manish 229
 
32048 tejbeer 230
        scheduledTasks.sendDailySalesNotificationToPartner(null);
29757 tejbeer 231
 
32048 tejbeer 232
    }
24841 govind 233
 
32048 tejbeer 234
    /*
235
     * @Scheduled(cron = "0 0 6 * * *") public void dailyReconciliation() throws
236
     * Exception { reconciliation.dailyReconciliation(); }
237
     */
28205 tejbeer 238
 
32048 tejbeer 239
    @Scheduled(cron = "0 0 1 * * *")
240
    public void selectFinServiceFollowUpDateByCurrDate() throws Exception {
241
        log.info("selectFinServiceFollowUpDateByCurrDate");
242
        scheduledTasks.selectFinServiceFollowUpDateByCurrDate(LocalDate.now());
30049 amit.gupta 243
 
32048 tejbeer 244
    }
30049 amit.gupta 245
 
32165 amit.gupta 246
    @Scheduled(cron = "0 0 4 * * *")
32048 tejbeer 247
    public void processActivation() throws Exception {
29757 tejbeer 248
 
32048 tejbeer 249
        scheduledTasks.processActivation();
29757 tejbeer 250
 
32048 tejbeer 251
    }
25721 tejbeer 252
 
32048 tejbeer 253
    // TODO: Change it back to first of every month
254
    // @Scheduled(cron = "0 0 1 1 * *")
255
    @Scheduled(cron = "0 0 1 2 * *")
256
    public void rollOutUpgardedMargins() throws Exception {
35522 amit 257
        scheduledTasks.rollOutUpgardedMarginsNextMonth(null);
30788 amit.gupta 258
 
32048 tejbeer 259
    }
30788 amit.gupta 260
 
34241 tejus.loha 261
    @Scheduled(fixedDelay = 60 * 1000)
32048 tejbeer 262
    public void sendNotification() throws Throwable {
29757 tejbeer 263
 
32048 tejbeer 264
        log.info("send Notification");
29673 manish 265
 
32048 tejbeer 266
        scheduledTasks.sendNotification();
267
        log.info("send Notification Done");
29673 manish 268
 
32048 tejbeer 269
    }
28205 tejbeer 270
 
34669 amit.gupta 271
    //@Scheduled(cron = "0 */15 * * * *")
32048 tejbeer 272
    public void checkRazorPayPaymentStatus() throws Throwable {
29757 tejbeer 273
 
32048 tejbeer 274
        scheduledTasks.checkRazorPayPaymentStatus();
29673 manish 275
 
32048 tejbeer 276
    }
28377 tejbeer 277
 
36292 amit 278
    @Scheduled(fixedDelay = 5 * 1000)
33426 amit.gupta 279
    //@Scheduled(cron = "0 5 23 * * *")
32048 tejbeer 280
    public void updateIrnsToInvoices() throws Throwable {
281
        runOnceTasks.updateIrnsToInvoices();
282
    }
31612 tejbeer 283
 
32048 tejbeer 284
    // No longer needed
285
    // @Scheduled(cron = "0 */10 * * * *")
286
    public void attachToffeeInvoices() throws Throwable {
29757 tejbeer 287
 
32048 tejbeer 288
        scheduledTasks.attachToffeeInvoices();
29757 tejbeer 289
 
32048 tejbeer 290
    }
24841 govind 291
 
35568 amit 292
    // REMOVED: ticketClosed() scheduler - now handled by TicketRelatedScheduledTask.autoCloseResolvedTickets()
293
    // which uses 8 working days instead of 7 calendar days and runs as part of processAllTicketTasks()
26283 tejbeer 294
 
32048 tejbeer 295
    @Scheduled(cron = "0 0 8 * * *")
296
    public void checkfocusedModelInPartnerStock() throws Throwable {
297
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 298
 
32048 tejbeer 299
        scheduledTasks.checkfocusedModelInPartnerStock();
25721 tejbeer 300
 
32048 tejbeer 301
        log.info("endTime" + LocalDateTime.now());
302
    }
28205 tejbeer 303
 
32048 tejbeer 304
    @Scheduled(cron = "0 0 8,10,12,14,16,18,20 * * *")
305
    public void notifyLead() throws Throwable {
29757 tejbeer 306
 
32048 tejbeer 307
        scheduledTasks.notifyLead();
29757 tejbeer 308
 
32048 tejbeer 309
        // scheduledTasks.notifyVisits();
310
    }
25721 tejbeer 311
 
32048 tejbeer 312
    // No longer scheduled
313
    // @Scheduled(cron = "0 0 1 * * *")
314
    public void fetchImeiActivation() throws Throwable {
29673 manish 315
 
32048 tejbeer 316
        runOnceTasks.fetchImeiActivation(0);
29757 tejbeer 317
 
32048 tejbeer 318
    }
26790 tejbeer 319
 
32411 amit.gupta 320
    @Scheduled(cron = "0 0 7 * * *")
321
    //Send all lead owners the report for scheduled followups missed
322
    public void sendUnscheduledFollowUpMail() throws Exception {
323
        scheduledTasks.sendUnscheduledFollowUpMail();
324
    }
325
 
32048 tejbeer 326
    @Scheduled(cron = "0 0 1 * * *")
327
    public void checkValidateReferral() throws Throwable {
328
        log.info("startTime" + LocalDateTime.now());
29673 manish 329
 
32048 tejbeer 330
        scheduledTasks.checkValidateReferral();
29757 tejbeer 331
 
32048 tejbeer 332
        log.info("endTime" + LocalDateTime.now());
333
    }
26790 tejbeer 334
 
32048 tejbeer 335
    // @Scheduled(cron = "0 0 8 * * *")
336
    public void partnerProblemAlert() throws Throwable {
337
        log.info("startTime" + LocalDateTime.now());
29673 manish 338
 
32048 tejbeer 339
        scheduledTasks.partnerProblemAlert();
29673 manish 340
 
32048 tejbeer 341
        log.info("endTime" + LocalDateTime.now());
342
    }
28921 tejbeer 343
 
35109 ranu 344
    @Scheduled(cron = "0 0 10 * * *")
32048 tejbeer 345
    public void onboardingEventDelays() throws Throwable {
346
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 347
 
32048 tejbeer 348
        onBoardingRelatedSchelduleTask.onboardingEventDelays();
29757 tejbeer 349
 
32048 tejbeer 350
        log.info("endTime" + LocalDateTime.now());
351
    }
28921 tejbeer 352
 
36065 aman 353
    @Scheduled(cron = "0 30 10 * * *")
354
    public void sendStockDeliveredTrainingNotification() {
355
        log.info("sendStockDeliveredTrainingNotification startTime " + LocalDateTime.now());
356
        onBoardingRelatedSchelduleTask.sendStockDeliveredTrainingNotification();
357
        log.info("sendStockDeliveredTrainingNotification endTime " + LocalDateTime.now());
358
    }
359
 
36003 aman 360
    @Scheduled(cron = "0 0 9 * * ?")
361
    public void sendDelayAlertEmail() {
362
        log.info("sendDelayAlertEmail startTime " + LocalDateTime.now());
363
        onBoardingRelatedSchelduleTask.sendDelayAlertEmail();
364
        log.info("sendDelayAlertEmail endTime " + LocalDateTime.now());
365
    }
366
 
32048 tejbeer 367
    @Scheduled(cron = "0 0 8 * * *")
368
    public void brandingAlert() throws Throwable {
369
        log.info("startTime" + LocalDateTime.now());
29673 manish 370
 
32048 tejbeer 371
        onBoardingRelatedSchelduleTask.brandingAlert();
29673 manish 372
 
32048 tejbeer 373
        log.info("endTime" + LocalDateTime.now());
374
    }
28921 tejbeer 375
 
32048 tejbeer 376
    @Scheduled(cron = "0 0 8 * * *")
377
    public void fullPaymentPendingAlert() throws Throwable {
378
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 379
 
32048 tejbeer 380
        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();
29757 tejbeer 381
 
32048 tejbeer 382
        log.info("endTime" + LocalDateTime.now());
383
    }
28921 tejbeer 384
 
32048 tejbeer 385
    @Scheduled(cron = "0 */5 * * * *")
386
    public void onBoardingCompleteEventEmail() throws Throwable {
387
        log.info("startTime" + LocalDateTime.now());
29673 manish 388
 
32048 tejbeer 389
        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();
29673 manish 390
 
32048 tejbeer 391
        log.info("endTime" + LocalDateTime.now());
392
    }
29040 tejbeer 393
 
32048 tejbeer 394
    @Scheduled(cron = "0 */5 * * * *")
395
    public void updateSaholicCISTable() throws Throwable {
396
        log.info("updateSaholicCISTable startTime" + LocalDateTime.now());
397
        runOnceTasks.updateSaholicCISTable();
398
        log.info("updateSaholicCISTable endTime" + LocalDateTime.now());
399
    }
30667 amit.gupta 400
 
34241 tejus.loha 401
    @Autowired
402
    PurSaleService purSaleService;
403
 
35133 ranu 404
    @Scheduled(cron = "0 0 6,22 * * ?")
34241 tejus.loha 405
    public void send10DaysEgedStockReport() throws Throwable {
34275 tejus.loha 406
        log.info("moreThen10DaysEgedStockReport startTime" + LocalDateTime.now());
407
        scheduledTasks.send10OrMoreOlderStockReport();
408
        log.info("moreThen10DaysEgedStockReport endTime" + LocalDateTime.now());
34241 tejus.loha 409
    }
410
 
35616 amit 411
    @Scheduled(fixedDelay = 5 * 60 * 1000)
32048 tejbeer 412
    public void fetchPartnerStat() throws Throwable {
413
        scheduledTasks.fetchParnterStats();
414
    }
30390 amit.gupta 415
 
37472 amit 416
    @Scheduled(cron = "0 0 23 * * *")
32214 jai.hind 417
    public void checkItelImeiActivationNew() throws Throwable {
418
        log.info("startTime" + LocalDate.now());
419
 
420
        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
421
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
422
        long secs = (new Date().getTime()) / 1000;
423
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());
424
 
425
    }
426
 
37472 amit 427
    /**
428
     * Vivo: one full pass a day, then nothing until tomorrow.
429
     *
430
     * Was two parallel jobs every 5 minutes capped at 50 and 10 imeis, which never
431
     * finished a pass over a 9,510-row pool and retried a failed lookup five minutes
432
     * later instead of the next day. Vivo stays on its own schedule and its own thread:
433
     * it is direct HTTP plus the captcha solver, no ChromeDriver, so it does not
434
     * contend for the resource the oppo/realme pass is rationing.
435
     *
436
     * ~9,510 imeis at roughly 2.5s each is about 6.6 hours.
437
     */
37565 amit 438
    // One chunk of 250 every 20 seconds until the day's pool is empty, then idle ticks
439
    // until midnight. Was a single 00:15 pass; the method name is kept so the
440
    // cron_job_* series and anything keyed on it stay continuous.
441
    //
442
    // The 20s cadence is not a throttle -- vivo is 0.24s an imei and does not rate-limit
443
    // us. It is what makes progress durable: the old pass held one thread for its whole
444
    // run and kept its position nowhere else, so a restart mid-pass forfeited the rest.
445
    @Scheduled(fixedDelay = 20 * 1000)
32048 tejbeer 446
    public void vivoImeiActivation() throws Throwable {
447
        scheduledTasks.checkImeiActivation();
448
    }
29255 tejbeer 449
 
37482 amit 450
    /**
451
     * Itel activation from Carlcare, Transsion's own after-sales endpoint. 50 imeis every 5
452
     * minutes, which spreads the work over the whole day rather than bursting: 14,400 lookups a
453
     * day against a pending pool of ~10,400.
454
     *
455
     * The 5-minute cadence is safe here in a way it was not for vivo, whose comment below records
456
     * why that pattern ran away: there, a failed lookup wrote no row, so createTimestamp was not
457
     * bumped and the same imei was eligible again five minutes later. This service stamps the row
458
     * on EVERY outcome, failures included, so each tick advances past the imeis it asked about
459
     * and a failure costs one retry tomorrow rather than one every five minutes.
460
     *
461
     * It is one plain signed GET per imei -- no captcha solver, no ChromeDriver -- so it does not
462
     * contend with the oppo/realme pass. Both this and the 23:00 DCR pull write Itel rows and
463
     * need no coordination: the pool query returns only imeis whose activationTimestamp is still
464
     * null, so whatever one has filled has already left the other's pool.
465
     */
466
    @Scheduled(fixedDelay = 5 * 60 * 1000)
467
    public void carlcareImeiActivation() throws Throwable {
468
        scheduledTasks.checkCarlcareImeiActivation();
469
    }
470
 
32048 tejbeer 471
    @Scheduled(cron = "0 0 8 * * *")
472
    public void reviewUncontactablePartner() throws Throwable {
473
        log.info("startTime" + LocalDateTime.now());
30421 tejbeer 474
 
32048 tejbeer 475
        scheduledTasks.reviewUncontactablePartner();
30421 tejbeer 476
 
32048 tejbeer 477
    }
30421 tejbeer 478
 
33928 ranu 479
    @Scheduled(cron = "0 0 7 * * *")
480
    public void setMovementWiseRbmTodayTargets() throws Throwable {
34669 amit.gupta 481
        log.info("today targets startTime {}", LocalDateTime.now());
33928 ranu 482
 
483
        scheduledTasks.persistRbmTodayTargets();
484
 
485
    }
486
 
33986 ranu 487
    @Scheduled(cron = "0 0 21 * * *")
488
    public void setMovementWiseRbmTodayAchievements() throws Throwable {
34669 amit.gupta 489
        log.info("today achievement startTime {}", LocalDateTime.now());
33986 ranu 490
 
491
        scheduledTasks.persistRbmTodayAchievements();
492
 
493
    }
494
 
37499 ranu 495
    // Sales-hierarchy target snapshot — runs 10 minutes after RBM targets so
496
    // today's rbm_targets rows are guaranteed present for the roll-up.
497
    @Scheduled(cron = "0 10 7 * * *")
498
    public void setSalesTodayTargets() throws Throwable {
499
        log.info("sales today targets startTime {}", LocalDateTime.now());
500
 
501
        scheduledTasks.persistSalesTodayTargets();
502
 
503
    }
504
 
505
    // Sales-hierarchy achievement snapshot — independent of the target chain;
506
    // rolls up live order ACH so it can run any time after orders settle.
507
    // Kept aligned with RBM achievement time (21:00).
508
    @Scheduled(cron = "0 10 21 * * *")
509
    public void setSalesTodayAchievements() throws Throwable {
510
        log.info("sales today achievement startTime {}", LocalDateTime.now());
511
 
512
        scheduledTasks.persistSalesTodayAchievements();
513
 
514
    }
515
 
33078 ranu 516
    @Scheduled(cron = "0 0 8 * * *")
517
    public void reviewNonSdBuyingBrand() throws Throwable {
518
        log.info("startTime" + LocalDateTime.now());
519
 
520
        scheduledTasks.reviewNonSdBuyingBrand();
521
 
522
    }
523
 
32048 tejbeer 524
    @Autowired
525
    private StandAlone standAlone;
30352 amit.gupta 526
 
32832 amit.gupta 527
    @Autowired
528
    OrderTrackingService orderTrackingService;
529
 
37472 amit 530
    // ONE thread, ONE full pass a day, for oppo and realme together.
531
    //
532
    // This replaces four @Scheduled jobs (oppo and realme x secondary and tertiary,
533
    // every 5 minutes), and it supersedes the r37447 / r37448 / r37449 argument about
534
    // how many ChromeDrivers to run. That argument was about the wrong variable.
535
    //
536
    // The revert in r37449 was sized on lookups ATTEMPTED per day, and the re-merge that
537
    // followed blamed the resulting collapse on CPU contention pushing the captcha
538
    // render past the element waits. The logs do not support contention:
539
    //
540
    //   29 Aug        imeis   canvas timeouts   captcha ok   distinct imeis   asks each
541
    //   oppo          4,350                 0       ~100%            4,238        1.03
542
    //   realme        4,524             3,390         19%            1,004        4.50
543
    //
544
    // Same box, same six cores, same driver count, same captcha vendor, load average
545
    // 0.9 -- and oppo took ZERO timeouts in all 24 hours, including the 15:00-23:00
546
    // window in which realme solved nothing at all. Realme's own canvas wait is 15s
547
    // against oppo's 8s, so the LONGER wait is the one expiring.
548
    //
549
    // What realme's timeout rate actually tracks is its own daily request volume, and
550
    // it resets at midnight: 920/day -> 0.3%, 3,467/day -> 28%, 4,524/day -> 75%. That
551
    // is realme.com declining to serve the widget, not a busy box.
552
    //
553
    // The 4.5 asks per imei is why it ran away. A failed lookup never reaches
554
    // dateMap.put, so no row is written, so createTimestamp is not bumped, so the same
555
    // imei was eligible again five minutes later -- more requests hardened the block,
556
    // which caused more failures, which caused more requests. A snapshotted daily pass
557
    // bounds that by construction: a failure costs one retry tomorrow, never one in
558
    // five minutes, however the far end behaves.
559
    //
560
    // Judge this change on dates written, not on timeout count.
37565 amit 561
    // One chunk of 25 for one brand every 20 seconds, oppo and realme by turns, until
562
    // both pools are empty for the day. Was a single 00:30 pass that held this thread for
563
    // 20+ hours; the method name is kept so the cron_job_* series stays continuous.
564
    //
565
    // fixedDelay, not fixedRate: the gap is measured from the END of a tick, so a chunk
566
    // that takes six minutes is not immediately followed by a queued one. The lane
567
    // self-throttles to whatever the far ends are actually giving us.
568
    //
569
    // The start/end log lines are gone deliberately -- at 4,320 ticks a day they were
570
    // pure volume on a log that is already 1.8GB. StandAlone logs the day boundary and
571
    // the chunks; idle ticks say nothing at all.
572
    @Scheduled(fixedDelay = 20 * 1000)
37472 amit 573
    public void oppoRealmeImeiActivation() throws Throwable {
574
        standAlone.checkBrowserImeiActivation();
34421 amit.gupta 575
    }
576
 
32801 amit.gupta 577
    @Scheduled(cron = "0 0 * * * *")
32048 tejbeer 578
    public void markBlueDartOrderDelivered() throws Throwable {
579
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 580
        orderTrackingService.markBlueDartOrderDelivered();
32048 tejbeer 581
        log.info("endTime" + LocalDateTime.now());
582
    }
31117 tejbeer 583
 
32881 amit.gupta 584
    @Scheduled(cron = "0 15 * * * *")
32048 tejbeer 585
    public void markDelhiveryOrderDelivered() throws Throwable {
29673 manish 586
 
32048 tejbeer 587
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 588
        orderTrackingService.markDelhiveryOrderDelivered();
29673 manish 589
 
32048 tejbeer 590
        log.info("endTime" + LocalDateTime.now());
591
    }
29308 tejbeer 592
 
32048 tejbeer 593
    @Scheduled(cron = "0 0 4 * * *")
594
    public void processPriceDrop() throws Throwable {
595
        scheduledTasks.processPriceDrop();
596
    }
30637 amit.gupta 597
 
32048 tejbeer 598
    @Scheduled(cron = "0 0 0 * * *")
599
    public void calculateInterestAccured() throws Throwable {
34710 amit.gupta 600
        scheduledTasks.loanSettlement();
32048 tejbeer 601
        scheduledTasks.calculateInterestAccured();
602
    }
30859 tejbeer 603
 
32117 tejbeer 604
    //  @Scheduled(cron = "0 */5 2-22 * * *")
33181 amit.gupta 605
    @Scheduled(fixedDelay = 1 * 60 * 1000)
32531 amit.gupta 606
    //@Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 607
    public void loanSettlement() throws Throwable {
34756 amit.gupta 608
        LocalTime now = LocalTime.now();
34767 amit.gupta 609
        LocalTime start = LocalTime.of(9, 0);
34757 amit.gupta 610
        LocalTime end = LocalTime.of(23, 0);
34756 amit.gupta 611
 
612
        if (now.isBefore(start) || now.isAfter(end)) {
34762 amit.gupta 613
            System.out.println("Task skipped during restricted hours: " + now);
614
        } else {
34756 amit.gupta 615
            scheduledTasks.loanSettlement();
616
            System.out.println("Task executed at " + now);
617
        }
32048 tejbeer 618
    }
30859 tejbeer 619
 
32048 tejbeer 620
    @Scheduled(cron = "0 */15 * * * *")
621
    public void ccAvenueSettlement() throws Throwable {
622
        scheduledTasks.settleCCAvePayments();
623
    }
31332 amit.gupta 624
 
32048 tejbeer 625
    @Scheduled(cron = "0 0 6 * * *")
626
    public void dailyLoanAlert() throws Throwable {
627
        scheduledTasks.dailyLoanAlert();
628
    }
30896 amit.gupta 629
 
35106 ranu 630
    @Scheduled(cron = "0 0 11 * * *")
34162 ranu 631
    public void groupHidCatalogsByWeeks() throws Throwable {
632
        scheduledTasks.groupHidCatalogsByWeeks();
633
    }
634
 
36113 ranu 635
    @Scheduled(cron = "0 0 9 * * MON")  // Every Monday at 9:00 AM
34321 ranu 636
    public void sendFeebackSalesAndRbm() throws Throwable {
637
        scheduledTasksTest.sendRbmFeedbackSummaryEmail();
638
        scheduledTasksTest.sendSalesFeedbackSummaryEmail();
639
    }
640
 
32165 amit.gupta 641
    //Look out for imeis that have activation pending based of sale and mark create new SIO out of them
32048 tejbeer 642
    @Scheduled(cron = "0 0 1 * * *")
643
    public void processActivatedImeisForSchemes() throws Throwable {
644
        scheduledTasks.processActivatedImeisForSchemes();
645
    }
34241 tejus.loha 646
 
33357 amit.gupta 647
    //On every fifth update deductions
33435 amit.gupta 648
    @Scheduled(cron = "0 30 6 5 * ?")
33357 amit.gupta 649
    public void processSidbiDeductions() throws Throwable {
650
        scheduledTasks.processSidbiDeductions();
651
    }
34669 amit.gupta 652
 
34374 amit.gupta 653
    //Dont reset it for now as proposed by TV
654
    //@Scheduled(cron = "0 30 6 4 * ?")
33904 amit.gupta 655
    public void resetHardLimit() throws Throwable {
656
        scheduledTasks.resetHardLimit();
657
    }
658
 
34830 ranu 659
    @Scheduled(cron = "0 0/20 * * * *")
32048 tejbeer 660
    public void updatePartnerLimit() throws Throwable {
36361 amit 661
        batchScheduledTasks.updatePartnerLimitWithBatch();
32048 tejbeer 662
    }
30929 tejbeer 663
 
34253 ranu 664
    @Scheduled(cron = "0 0 9,14,18 * * *")
33874 ranu 665
    public void createOpeningStockPartyWise() throws Throwable {
666
        scheduledTasks.createOpeningStockPartyWise();
667
    }
30936 tejbeer 668
 
32842 amit.gupta 669
    //Loans due/overdue/default notifications sent to parnters
670
    @Scheduled(cron = "0 0 11 * * *")
32822 ranu 671
    public void sendMailWhatsAppAfterLoanDueDate() throws Throwable {
672
        scheduledTasks.sendMailWhatsAppAfterLoanDueDate();
673
    }
34241 tejus.loha 674
 
32842 amit.gupta 675
    @Scheduled(cron = "0 0 8 * * *")
676
    public void alertForDueDate() throws Throwable {
677
        scheduledTasks.alertForDueDate();
678
    }
32822 ranu 679
 
35133 ranu 680
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 681
    public void notifyLoanDueDateCross() throws Throwable {
682
        scheduledTasks.notifyLoanDueDateCross();
683
    }
30936 tejbeer 684
 
35133 ranu 685
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 686
    public void notifyDefaultLoans() throws Throwable {
687
        scheduledTasks.notifyDefaultLoans();
688
    }
30936 tejbeer 689
 
34910 ranu 690
   // @Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 691
    public void hygineAlertForInternalTeam() throws Throwable {
692
        scheduledTasks.hygineAlertForInternalTeam();
31206 tejbeer 693
 
32048 tejbeer 694
    }
31206 tejbeer 695
 
32048 tejbeer 696
    @Scheduled(cron = "0 0 23 * * *")
697
    public void hygineAlertForPartner() throws Throwable {
698
        scheduledTasks.hygineAlertForPartner();
31206 tejbeer 699
 
32048 tejbeer 700
    }
31206 tejbeer 701
 
32048 tejbeer 702
    @Scheduled(cron = "0 0 0 * * MON")
703
    public void monthlyTargetForPartner() throws Throwable {
704
        scheduledTasks.monthlyTargetForPartner();
31249 tejbeer 705
 
32048 tejbeer 706
    }
31249 tejbeer 707
 
32048 tejbeer 708
    @Scheduled(cron = "0 0 0 * * MON")
709
    public void monthlyTargetForInternalTeam() throws Throwable {
710
        scheduledTasks.monthlyTargetForInternalTeam();
31249 tejbeer 711
 
32048 tejbeer 712
    }
31612 tejbeer 713
 
32048 tejbeer 714
    @Scheduled(cron = "0 0 6 * * *")
715
    public void sendSamsungRebilling() throws Throwable {
716
        scheduledTasks.sendMailForSamsungRebilling();
717
    }
31931 amit.gupta 718
 
32048 tejbeer 719
    @Scheduled(cron = "0 10 8 * * *")
720
    public void sendMailForAgeingAlert() throws Throwable {
721
        scheduledTasks.sendMailForAgeingAlert();
722
    }
723
 
724
    @Scheduled(cron = "0 0 8 * * *")
725
    public void sendFilteredRetailerPerformance() throws Throwable {
726
        scheduledTasks.sendFilteredRetailerPerformance();
727
    }
32690 amit.gupta 728
 
33444 ranu 729
    @Scheduled(cron = "0 0 0 * * MON")
730
    public void findAllLiveDemoBrandItemsByBillingDate() throws Throwable {
731
        scheduledTasks.findAllLiveDemoBrandItemsByBillingDate();
732
    }
34241 tejus.loha 733
 
33464 ranu 734
    @Scheduled(cron = "0 10 6 * * *")
735
    public void findTodayPocoBillingItems() throws Throwable {
736
        scheduledTasks.findTodayPocoBillingItems();
737
    }
32690 amit.gupta 738
 
739
    @Scheduled(cron = "0 0 12 * * *")
740
    public void rejectPriceDropsOfApprovedImeis() throws Throwable {
37083 amit 741
        batchScheduledTasks.reprocessPriceDropsWithBatch();
32690 amit.gupta 742
    }
32907 amit.gupta 743
 
744
    @Autowired
745
    POScheduler poScheduler;
34241 tejus.loha 746
 
32907 amit.gupta 747
    @Scheduled(cron = "0 0 1 * * *")
33643 amit.gupta 748
    public void autoClosePO() {
32907 amit.gupta 749
        poScheduler.autoClosePurchaseOrders();
750
    }
32048 tejbeer 751
    /*
752
     * @Scheduled(cron = "0 0 9 * * *") public void onBoardingDocumentsPending()
753
     * throws Throwable { log.info("startTime" + LocalDateTime.now());
754
     * onBoardingRelatedSchelduleTask.onBoardingDocumentsPending();
755
     * log.info("endTime" + LocalDateTime.now()); }
756
     */
34443 vikas.jang 757
 
34547 vikas.jang 758
    @Scheduled(cron = "0 50 23 * * *")
34443 vikas.jang 759
    public void bidConfirmation() throws Throwable {
34547 vikas.jang 760
        log.info("running bid cron at 23:50PM");
34443 vikas.jang 761
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.YESTERDAY);
762
    }
763
 
34547 vikas.jang 764
    @Scheduled(cron = "0 0 19 * * *")
34443 vikas.jang 765
    public void processLiquidationBids() throws Throwable {
34547 vikas.jang 766
        log.info("running bid cron at 07:00PM");
34443 vikas.jang 767
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
768
    }
769
 
34547 vikas.jang 770
    @Scheduled(cron = "0 30 21 * * *")
34443 vikas.jang 771
    public void bidPurchaseOrder() throws Throwable {
34547 vikas.jang 772
        log.info("running bid cron at 09:30PM");
34443 vikas.jang 773
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
774
    }
34547 vikas.jang 775
 
34669 amit.gupta 776
    /*@Scheduled(cron = "0 0 12 * * *")
777
    public void processCashDiscount() throws Throwable {
778
        scheduledTasks.processCashDiscount();
779
    }*/
780
 
34563 vikas.jang 781
    @Scheduled(cron = "0 0 9,17 * * *")
34547 vikas.jang 782
    public void bidConsolidatedMessage() throws Throwable {
783
        log.info("Running bid cron at 09:00 AM or 05:00 PM");
784
        runOnceTasks.consolidatedBiddingMessage();
34563 vikas.jang 785
    }
34770 vikas.jang 786
 
787
    @Scheduled(cron = "0 0 8 * * *")
34836 vikas 788
    public void yesterdayTrackingReport() throws Throwable {
789
        log.info("Running yesterday employee tracking cron at 08:00 AM");
790
        runOnceTasks.yesterdayTrackingReport();
34770 vikas.jang 791
    }
34836 vikas 792
 
35178 amit 793
    @Scheduled(cron = "0 10 8 * * *")
35177 amit 794
    public void partnerCreditExposureReport() throws Throwable {
795
        log.info("Running yesterday employee tracking cron at 08:00 AM");
796
        runOnceTasks.sendCreditExposureReport();
797
    }
798
 
36552 ranu 799
    @Scheduled(cron = "0 0 22,16 * * *")
34836 vikas 800
    public void dailyTrackingReport() throws Throwable {
36552 ranu 801
        log.info("Running daily employee tracking cron at 10:00 PM and 04:00 PM");
34836 vikas 802
        runOnceTasks.dailyTrackingReport();
803
    }
35105 vikas 804
 
34792 amit.gupta 805
    @Scheduled(cron = "0 0 0 1 1,4,7,10 *")
806
    public void sendUpdateMobileBrandMarketShareQuaterlyMail() throws Throwable {
34791 aman.kumar 807
        log.info("Running Marketshare update remined quaterly");
808
        scheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail();
809
    }
35105 vikas 810
 
811
    @Scheduled(cron = "0 0 * * * *")
812
    public void checkRewardsEligibility() throws Throwable {
813
        log.info("Running Rewards Disburse daily");
814
        runOnceTasks.checkRewardsEligibility();
815
    }
35326 amit 816
 
817
    @Scheduled(cron="0 0 20 * * *")
818
    public void sendTrialExpiry() {
819
        scheduledTasks.sendTrialExpiry();
820
    }
35666 vikas 821
 
822
    @Scheduled(cron = "0 0 0 * * *")
823
    public void fetchOffersByItem() {
824
        scheduledTasks.cachePinelabsOffers();
825
    }
35788 vikas 826
 
827
    @Scheduled(cron = "0 0 0 * * *")
828
    public void syncProductsToShopify() throws Exception {
36058 ranu 829
        scheduledTasks.syncProductsToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
35788 vikas 830
    }
36511 amit 831
 
37162 vikas 832
    @Scheduled(cron = "0 0 6,18 * * *")
833
    public void syncInventoryToShopify() throws Exception {
834
        scheduledTasks.syncInventoryToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
835
    }
836
 
36511 amit 837
    @Autowired
838
    private WarehouseStockReconciliation warehouseStockReconciliation;
839
 
840
    @Scheduled(cron = "0 30 5 * * *")
841
    public void reconcileInventorySnapshot() throws Exception {
842
        log.info("reconcileInventorySnapshot");
843
        warehouseStockReconciliation.reconcile();
844
    }
37159 amit 845
 
846
    @Autowired
847
    private PartnerIdentityIntegrityMonitor partnerIdentityIntegrityMonitor;
848
 
849
    @Scheduled(cron = "0 0 7 * * *")
850
    public void partnerIdentityIntegrityMonitor() throws Exception {
851
        log.info("partnerIdentityIntegrityMonitor");
852
        partnerIdentityIntegrityMonitor.monitor();
853
    }
23756 amit.gupta 854
}