Subversion Repositories SmartDukaan

Rev

Rev 37482 | Rev 37565 | Go to most recent revision | 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
     */
438
    @Scheduled(cron = "0 15 0 * * *")
32048 tejbeer 439
    public void vivoImeiActivation() throws Throwable {
440
        log.info("startTimevivoImeiActivation" + LocalDateTime.now());
29757 tejbeer 441
 
32048 tejbeer 442
        scheduledTasks.checkImeiActivation();
37472 amit 443
 
32048 tejbeer 444
        log.info("endTimevivoImeiActivation" + LocalDateTime.now());
29757 tejbeer 445
 
32048 tejbeer 446
    }
29255 tejbeer 447
 
37482 amit 448
    /**
449
     * Itel activation from Carlcare, Transsion's own after-sales endpoint. 50 imeis every 5
450
     * minutes, which spreads the work over the whole day rather than bursting: 14,400 lookups a
451
     * day against a pending pool of ~10,400.
452
     *
453
     * The 5-minute cadence is safe here in a way it was not for vivo, whose comment below records
454
     * why that pattern ran away: there, a failed lookup wrote no row, so createTimestamp was not
455
     * bumped and the same imei was eligible again five minutes later. This service stamps the row
456
     * on EVERY outcome, failures included, so each tick advances past the imeis it asked about
457
     * and a failure costs one retry tomorrow rather than one every five minutes.
458
     *
459
     * It is one plain signed GET per imei -- no captcha solver, no ChromeDriver -- so it does not
460
     * contend with the oppo/realme pass. Both this and the 23:00 DCR pull write Itel rows and
461
     * need no coordination: the pool query returns only imeis whose activationTimestamp is still
462
     * null, so whatever one has filled has already left the other's pool.
463
     */
464
    @Scheduled(fixedDelay = 5 * 60 * 1000)
465
    public void carlcareImeiActivation() throws Throwable {
466
        scheduledTasks.checkCarlcareImeiActivation();
467
    }
468
 
32048 tejbeer 469
    @Scheduled(cron = "0 0 8 * * *")
470
    public void reviewUncontactablePartner() throws Throwable {
471
        log.info("startTime" + LocalDateTime.now());
30421 tejbeer 472
 
32048 tejbeer 473
        scheduledTasks.reviewUncontactablePartner();
30421 tejbeer 474
 
32048 tejbeer 475
    }
30421 tejbeer 476
 
33928 ranu 477
    @Scheduled(cron = "0 0 7 * * *")
478
    public void setMovementWiseRbmTodayTargets() throws Throwable {
34669 amit.gupta 479
        log.info("today targets startTime {}", LocalDateTime.now());
33928 ranu 480
 
481
        scheduledTasks.persistRbmTodayTargets();
482
 
483
    }
484
 
33986 ranu 485
    @Scheduled(cron = "0 0 21 * * *")
486
    public void setMovementWiseRbmTodayAchievements() throws Throwable {
34669 amit.gupta 487
        log.info("today achievement startTime {}", LocalDateTime.now());
33986 ranu 488
 
489
        scheduledTasks.persistRbmTodayAchievements();
490
 
491
    }
492
 
37499 ranu 493
    // Sales-hierarchy target snapshot — runs 10 minutes after RBM targets so
494
    // today's rbm_targets rows are guaranteed present for the roll-up.
495
    @Scheduled(cron = "0 10 7 * * *")
496
    public void setSalesTodayTargets() throws Throwable {
497
        log.info("sales today targets startTime {}", LocalDateTime.now());
498
 
499
        scheduledTasks.persistSalesTodayTargets();
500
 
501
    }
502
 
503
    // Sales-hierarchy achievement snapshot — independent of the target chain;
504
    // rolls up live order ACH so it can run any time after orders settle.
505
    // Kept aligned with RBM achievement time (21:00).
506
    @Scheduled(cron = "0 10 21 * * *")
507
    public void setSalesTodayAchievements() throws Throwable {
508
        log.info("sales today achievement startTime {}", LocalDateTime.now());
509
 
510
        scheduledTasks.persistSalesTodayAchievements();
511
 
512
    }
513
 
33078 ranu 514
    @Scheduled(cron = "0 0 8 * * *")
515
    public void reviewNonSdBuyingBrand() throws Throwable {
516
        log.info("startTime" + LocalDateTime.now());
517
 
518
        scheduledTasks.reviewNonSdBuyingBrand();
519
 
520
    }
521
 
32048 tejbeer 522
    @Autowired
523
    private StandAlone standAlone;
30352 amit.gupta 524
 
32832 amit.gupta 525
    @Autowired
526
    OrderTrackingService orderTrackingService;
527
 
37472 amit 528
    // ONE thread, ONE full pass a day, for oppo and realme together.
529
    //
530
    // This replaces four @Scheduled jobs (oppo and realme x secondary and tertiary,
531
    // every 5 minutes), and it supersedes the r37447 / r37448 / r37449 argument about
532
    // how many ChromeDrivers to run. That argument was about the wrong variable.
533
    //
534
    // The revert in r37449 was sized on lookups ATTEMPTED per day, and the re-merge that
535
    // followed blamed the resulting collapse on CPU contention pushing the captcha
536
    // render past the element waits. The logs do not support contention:
537
    //
538
    //   29 Aug        imeis   canvas timeouts   captcha ok   distinct imeis   asks each
539
    //   oppo          4,350                 0       ~100%            4,238        1.03
540
    //   realme        4,524             3,390         19%            1,004        4.50
541
    //
542
    // Same box, same six cores, same driver count, same captcha vendor, load average
543
    // 0.9 -- and oppo took ZERO timeouts in all 24 hours, including the 15:00-23:00
544
    // window in which realme solved nothing at all. Realme's own canvas wait is 15s
545
    // against oppo's 8s, so the LONGER wait is the one expiring.
546
    //
547
    // What realme's timeout rate actually tracks is its own daily request volume, and
548
    // it resets at midnight: 920/day -> 0.3%, 3,467/day -> 28%, 4,524/day -> 75%. That
549
    // is realme.com declining to serve the widget, not a busy box.
550
    //
551
    // The 4.5 asks per imei is why it ran away. A failed lookup never reaches
552
    // dateMap.put, so no row is written, so createTimestamp is not bumped, so the same
553
    // imei was eligible again five minutes later -- more requests hardened the block,
554
    // which caused more failures, which caused more requests. A snapshotted daily pass
555
    // bounds that by construction: a failure costs one retry tomorrow, never one in
556
    // five minutes, however the far end behaves.
557
    //
558
    // Judge this change on dates written, not on timeout count.
559
    @Scheduled(cron = "0 30 0 * * *")
560
    public void oppoRealmeImeiActivation() throws Throwable {
561
        log.info("startTimeOppoRealmeImeiActivation {}", LocalDateTime.now());
30352 amit.gupta 562
 
37472 amit 563
        standAlone.checkBrowserImeiActivation();
37448 amit 564
 
37472 amit 565
        log.info("endTimeOppoRealmeImeiActivation {}", LocalDateTime.now());
34421 amit.gupta 566
    }
567
 
32801 amit.gupta 568
    @Scheduled(cron = "0 0 * * * *")
32048 tejbeer 569
    public void markBlueDartOrderDelivered() throws Throwable {
570
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 571
        orderTrackingService.markBlueDartOrderDelivered();
32048 tejbeer 572
        log.info("endTime" + LocalDateTime.now());
573
    }
31117 tejbeer 574
 
32881 amit.gupta 575
    @Scheduled(cron = "0 15 * * * *")
32048 tejbeer 576
    public void markDelhiveryOrderDelivered() throws Throwable {
29673 manish 577
 
32048 tejbeer 578
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 579
        orderTrackingService.markDelhiveryOrderDelivered();
29673 manish 580
 
32048 tejbeer 581
        log.info("endTime" + LocalDateTime.now());
582
    }
29308 tejbeer 583
 
32048 tejbeer 584
    @Scheduled(cron = "0 0 4 * * *")
585
    public void processPriceDrop() throws Throwable {
586
        scheduledTasks.processPriceDrop();
587
    }
30637 amit.gupta 588
 
32048 tejbeer 589
    @Scheduled(cron = "0 0 0 * * *")
590
    public void calculateInterestAccured() throws Throwable {
34710 amit.gupta 591
        scheduledTasks.loanSettlement();
32048 tejbeer 592
        scheduledTasks.calculateInterestAccured();
593
    }
30859 tejbeer 594
 
32117 tejbeer 595
    //  @Scheduled(cron = "0 */5 2-22 * * *")
33181 amit.gupta 596
    @Scheduled(fixedDelay = 1 * 60 * 1000)
32531 amit.gupta 597
    //@Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 598
    public void loanSettlement() throws Throwable {
34756 amit.gupta 599
        LocalTime now = LocalTime.now();
34767 amit.gupta 600
        LocalTime start = LocalTime.of(9, 0);
34757 amit.gupta 601
        LocalTime end = LocalTime.of(23, 0);
34756 amit.gupta 602
 
603
        if (now.isBefore(start) || now.isAfter(end)) {
34762 amit.gupta 604
            System.out.println("Task skipped during restricted hours: " + now);
605
        } else {
34756 amit.gupta 606
            scheduledTasks.loanSettlement();
607
            System.out.println("Task executed at " + now);
608
        }
32048 tejbeer 609
    }
30859 tejbeer 610
 
32048 tejbeer 611
    @Scheduled(cron = "0 */15 * * * *")
612
    public void ccAvenueSettlement() throws Throwable {
613
        scheduledTasks.settleCCAvePayments();
614
    }
31332 amit.gupta 615
 
32048 tejbeer 616
    @Scheduled(cron = "0 0 6 * * *")
617
    public void dailyLoanAlert() throws Throwable {
618
        scheduledTasks.dailyLoanAlert();
619
    }
30896 amit.gupta 620
 
35106 ranu 621
    @Scheduled(cron = "0 0 11 * * *")
34162 ranu 622
    public void groupHidCatalogsByWeeks() throws Throwable {
623
        scheduledTasks.groupHidCatalogsByWeeks();
624
    }
625
 
36113 ranu 626
    @Scheduled(cron = "0 0 9 * * MON")  // Every Monday at 9:00 AM
34321 ranu 627
    public void sendFeebackSalesAndRbm() throws Throwable {
628
        scheduledTasksTest.sendRbmFeedbackSummaryEmail();
629
        scheduledTasksTest.sendSalesFeedbackSummaryEmail();
630
    }
631
 
32165 amit.gupta 632
    //Look out for imeis that have activation pending based of sale and mark create new SIO out of them
32048 tejbeer 633
    @Scheduled(cron = "0 0 1 * * *")
634
    public void processActivatedImeisForSchemes() throws Throwable {
635
        scheduledTasks.processActivatedImeisForSchemes();
636
    }
34241 tejus.loha 637
 
33357 amit.gupta 638
    //On every fifth update deductions
33435 amit.gupta 639
    @Scheduled(cron = "0 30 6 5 * ?")
33357 amit.gupta 640
    public void processSidbiDeductions() throws Throwable {
641
        scheduledTasks.processSidbiDeductions();
642
    }
34669 amit.gupta 643
 
34374 amit.gupta 644
    //Dont reset it for now as proposed by TV
645
    //@Scheduled(cron = "0 30 6 4 * ?")
33904 amit.gupta 646
    public void resetHardLimit() throws Throwable {
647
        scheduledTasks.resetHardLimit();
648
    }
649
 
34830 ranu 650
    @Scheduled(cron = "0 0/20 * * * *")
32048 tejbeer 651
    public void updatePartnerLimit() throws Throwable {
36361 amit 652
        batchScheduledTasks.updatePartnerLimitWithBatch();
32048 tejbeer 653
    }
30929 tejbeer 654
 
34253 ranu 655
    @Scheduled(cron = "0 0 9,14,18 * * *")
33874 ranu 656
    public void createOpeningStockPartyWise() throws Throwable {
657
        scheduledTasks.createOpeningStockPartyWise();
658
    }
30936 tejbeer 659
 
32842 amit.gupta 660
    //Loans due/overdue/default notifications sent to parnters
661
    @Scheduled(cron = "0 0 11 * * *")
32822 ranu 662
    public void sendMailWhatsAppAfterLoanDueDate() throws Throwable {
663
        scheduledTasks.sendMailWhatsAppAfterLoanDueDate();
664
    }
34241 tejus.loha 665
 
32842 amit.gupta 666
    @Scheduled(cron = "0 0 8 * * *")
667
    public void alertForDueDate() throws Throwable {
668
        scheduledTasks.alertForDueDate();
669
    }
32822 ranu 670
 
35133 ranu 671
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 672
    public void notifyLoanDueDateCross() throws Throwable {
673
        scheduledTasks.notifyLoanDueDateCross();
674
    }
30936 tejbeer 675
 
35133 ranu 676
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 677
    public void notifyDefaultLoans() throws Throwable {
678
        scheduledTasks.notifyDefaultLoans();
679
    }
30936 tejbeer 680
 
34910 ranu 681
   // @Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 682
    public void hygineAlertForInternalTeam() throws Throwable {
683
        scheduledTasks.hygineAlertForInternalTeam();
31206 tejbeer 684
 
32048 tejbeer 685
    }
31206 tejbeer 686
 
32048 tejbeer 687
    @Scheduled(cron = "0 0 23 * * *")
688
    public void hygineAlertForPartner() throws Throwable {
689
        scheduledTasks.hygineAlertForPartner();
31206 tejbeer 690
 
32048 tejbeer 691
    }
31206 tejbeer 692
 
32048 tejbeer 693
    @Scheduled(cron = "0 0 0 * * MON")
694
    public void monthlyTargetForPartner() throws Throwable {
695
        scheduledTasks.monthlyTargetForPartner();
31249 tejbeer 696
 
32048 tejbeer 697
    }
31249 tejbeer 698
 
32048 tejbeer 699
    @Scheduled(cron = "0 0 0 * * MON")
700
    public void monthlyTargetForInternalTeam() throws Throwable {
701
        scheduledTasks.monthlyTargetForInternalTeam();
31249 tejbeer 702
 
32048 tejbeer 703
    }
31612 tejbeer 704
 
32048 tejbeer 705
    @Scheduled(cron = "0 0 6 * * *")
706
    public void sendSamsungRebilling() throws Throwable {
707
        scheduledTasks.sendMailForSamsungRebilling();
708
    }
31931 amit.gupta 709
 
32048 tejbeer 710
    @Scheduled(cron = "0 10 8 * * *")
711
    public void sendMailForAgeingAlert() throws Throwable {
712
        scheduledTasks.sendMailForAgeingAlert();
713
    }
714
 
715
    @Scheduled(cron = "0 0 8 * * *")
716
    public void sendFilteredRetailerPerformance() throws Throwable {
717
        scheduledTasks.sendFilteredRetailerPerformance();
718
    }
32690 amit.gupta 719
 
33444 ranu 720
    @Scheduled(cron = "0 0 0 * * MON")
721
    public void findAllLiveDemoBrandItemsByBillingDate() throws Throwable {
722
        scheduledTasks.findAllLiveDemoBrandItemsByBillingDate();
723
    }
34241 tejus.loha 724
 
33464 ranu 725
    @Scheduled(cron = "0 10 6 * * *")
726
    public void findTodayPocoBillingItems() throws Throwable {
727
        scheduledTasks.findTodayPocoBillingItems();
728
    }
32690 amit.gupta 729
 
730
    @Scheduled(cron = "0 0 12 * * *")
731
    public void rejectPriceDropsOfApprovedImeis() throws Throwable {
37083 amit 732
        batchScheduledTasks.reprocessPriceDropsWithBatch();
32690 amit.gupta 733
    }
32907 amit.gupta 734
 
735
    @Autowired
736
    POScheduler poScheduler;
34241 tejus.loha 737
 
32907 amit.gupta 738
    @Scheduled(cron = "0 0 1 * * *")
33643 amit.gupta 739
    public void autoClosePO() {
32907 amit.gupta 740
        poScheduler.autoClosePurchaseOrders();
741
    }
32048 tejbeer 742
    /*
743
     * @Scheduled(cron = "0 0 9 * * *") public void onBoardingDocumentsPending()
744
     * throws Throwable { log.info("startTime" + LocalDateTime.now());
745
     * onBoardingRelatedSchelduleTask.onBoardingDocumentsPending();
746
     * log.info("endTime" + LocalDateTime.now()); }
747
     */
34443 vikas.jang 748
 
34547 vikas.jang 749
    @Scheduled(cron = "0 50 23 * * *")
34443 vikas.jang 750
    public void bidConfirmation() throws Throwable {
34547 vikas.jang 751
        log.info("running bid cron at 23:50PM");
34443 vikas.jang 752
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.YESTERDAY);
753
    }
754
 
34547 vikas.jang 755
    @Scheduled(cron = "0 0 19 * * *")
34443 vikas.jang 756
    public void processLiquidationBids() throws Throwable {
34547 vikas.jang 757
        log.info("running bid cron at 07:00PM");
34443 vikas.jang 758
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
759
    }
760
 
34547 vikas.jang 761
    @Scheduled(cron = "0 30 21 * * *")
34443 vikas.jang 762
    public void bidPurchaseOrder() throws Throwable {
34547 vikas.jang 763
        log.info("running bid cron at 09:30PM");
34443 vikas.jang 764
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
765
    }
34547 vikas.jang 766
 
34669 amit.gupta 767
    /*@Scheduled(cron = "0 0 12 * * *")
768
    public void processCashDiscount() throws Throwable {
769
        scheduledTasks.processCashDiscount();
770
    }*/
771
 
34563 vikas.jang 772
    @Scheduled(cron = "0 0 9,17 * * *")
34547 vikas.jang 773
    public void bidConsolidatedMessage() throws Throwable {
774
        log.info("Running bid cron at 09:00 AM or 05:00 PM");
775
        runOnceTasks.consolidatedBiddingMessage();
34563 vikas.jang 776
    }
34770 vikas.jang 777
 
778
    @Scheduled(cron = "0 0 8 * * *")
34836 vikas 779
    public void yesterdayTrackingReport() throws Throwable {
780
        log.info("Running yesterday employee tracking cron at 08:00 AM");
781
        runOnceTasks.yesterdayTrackingReport();
34770 vikas.jang 782
    }
34836 vikas 783
 
35178 amit 784
    @Scheduled(cron = "0 10 8 * * *")
35177 amit 785
    public void partnerCreditExposureReport() throws Throwable {
786
        log.info("Running yesterday employee tracking cron at 08:00 AM");
787
        runOnceTasks.sendCreditExposureReport();
788
    }
789
 
36552 ranu 790
    @Scheduled(cron = "0 0 22,16 * * *")
34836 vikas 791
    public void dailyTrackingReport() throws Throwable {
36552 ranu 792
        log.info("Running daily employee tracking cron at 10:00 PM and 04:00 PM");
34836 vikas 793
        runOnceTasks.dailyTrackingReport();
794
    }
35105 vikas 795
 
34792 amit.gupta 796
    @Scheduled(cron = "0 0 0 1 1,4,7,10 *")
797
    public void sendUpdateMobileBrandMarketShareQuaterlyMail() throws Throwable {
34791 aman.kumar 798
        log.info("Running Marketshare update remined quaterly");
799
        scheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail();
800
    }
35105 vikas 801
 
802
    @Scheduled(cron = "0 0 * * * *")
803
    public void checkRewardsEligibility() throws Throwable {
804
        log.info("Running Rewards Disburse daily");
805
        runOnceTasks.checkRewardsEligibility();
806
    }
35326 amit 807
 
808
    @Scheduled(cron="0 0 20 * * *")
809
    public void sendTrialExpiry() {
810
        scheduledTasks.sendTrialExpiry();
811
    }
35666 vikas 812
 
813
    @Scheduled(cron = "0 0 0 * * *")
814
    public void fetchOffersByItem() {
815
        scheduledTasks.cachePinelabsOffers();
816
    }
35788 vikas 817
 
818
    @Scheduled(cron = "0 0 0 * * *")
819
    public void syncProductsToShopify() throws Exception {
36058 ranu 820
        scheduledTasks.syncProductsToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
35788 vikas 821
    }
36511 amit 822
 
37162 vikas 823
    @Scheduled(cron = "0 0 6,18 * * *")
824
    public void syncInventoryToShopify() throws Exception {
825
        scheduledTasks.syncInventoryToShopifyByWarehouseId(ProfitMandiConstants.WAREHOUSE_NAME_MAP.get("UP-WEST/NOIDA"));
826
    }
827
 
36511 amit 828
    @Autowired
829
    private WarehouseStockReconciliation warehouseStockReconciliation;
830
 
831
    @Scheduled(cron = "0 30 5 * * *")
832
    public void reconcileInventorySnapshot() throws Exception {
833
        log.info("reconcileInventorySnapshot");
834
        warehouseStockReconciliation.reconcile();
835
    }
37159 amit 836
 
837
    @Autowired
838
    private PartnerIdentityIntegrityMonitor partnerIdentityIntegrityMonitor;
839
 
840
    @Scheduled(cron = "0 0 7 * * *")
841
    public void partnerIdentityIntegrityMonitor() throws Exception {
842
        log.info("partnerIdentityIntegrityMonitor");
843
        partnerIdentityIntegrityMonitor.monitor();
844
    }
23756 amit.gupta 845
}