Subversion Repositories SmartDukaan

Rev

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