Subversion Repositories SmartDukaan

Rev

Rev 37895 | 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;
37751 ranu 8
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
34443 vikas.jang 9
import com.spice.profitmandi.common.model.ProfitMandiConstants;
37751 ranu 10
import com.spice.profitmandi.service.warehouse.PoStockApprovalDigestService;
34241 tejus.loha 11
import com.spice.profitmandi.dao.service.PurSaleService;
37499 ranu 12
import com.spice.profitmandi.service.integrations.icicilombard.IciciLombardService;
13
import com.spice.profitmandi.service.integrations.icicilombard.model.LastTransactionsResponseModel;
23756 amit.gupta 14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
import org.springframework.beans.factory.annotation.Autowired;
37848 amit 17
import org.springframework.beans.factory.annotation.Value;
18
import com.spice.profitmandi.service.warehouse.SuspendedWarehouseStockAlertService;
23756 amit.gupta 19
import org.springframework.scheduling.annotation.Scheduled;
20
import org.springframework.stereotype.Component;
21
 
30049 amit.gupta 22
import java.time.LocalDate;
23
import java.time.LocalDateTime;
34756 amit.gupta 24
import java.time.LocalTime;
36993 amit 25
import java.time.YearMonth;
30049 amit.gupta 26
import java.util.Date;
37499 ranu 27
import java.util.LinkedHashMap;
23756 amit.gupta 28
 
29
@Component
30887 amit.gupta 30
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
23756 amit.gupta 31
public class ScheduledSkeleton {
23794 govind 32
 
32048 tejbeer 33
    private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);
23756 amit.gupta 34
 
32048 tejbeer 35
    @Autowired
36
    private ScheduledTasks scheduledTasks;
28205 tejbeer 37
 
32048 tejbeer 38
    @Autowired
36361 amit 39
    private BatchScheduledTasks batchScheduledTasks;
40
 
41
    @Autowired
34321 ranu 42
    private ScheduledTasksTest scheduledTasksTest;
43
 
44
    @Autowired
34948 ranu 45
    private AbmReportSender abmReportSender;
46
 
47
    @Autowired
32048 tejbeer 48
    private LeadSyncRunner leadSyncRunner;
24841 govind 49
 
32048 tejbeer 50
    @Autowired
51
    private Reconciliation reconciliation;
25822 amit.gupta 52
 
32048 tejbeer 53
    @Autowired
54
    private RunOnceTasks runOnceTasks;
23756 amit.gupta 55
 
32048 tejbeer 56
    @Autowired
57
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;
24841 govind 58
 
32048 tejbeer 59
    @Autowired
60
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;
28921 tejbeer 61
 
37499 ranu 62
//    @Autowired
63
//    private IciciLombardService iciciLombardService;
64
 
65
    String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";
66
 
32048 tejbeer 67
    @Scheduled(cron = "0 0 2 * * *")
68
    public void processDailySchemes() throws Exception {
29757 tejbeer 69
 
32048 tejbeer 70
        int maxMinusDays = 5;
71
        int currentDayOfMonth = LocalDate.now().getDayOfMonth();
72
        int minusDays = currentDayOfMonth > maxMinusDays ? maxMinusDays : currentDayOfMonth - 1;
73
        if (minusDays > 0) {
74
            scheduledTasks.processScheme(LocalDateTime.now().minusDays(minusDays), LocalDateTime.now(), false);
75
        }
29673 manish 76
 
32048 tejbeer 77
    }
24841 govind 78
 
32048 tejbeer 79
    @Scheduled(cron = "0 15 0 * * *")
80
    public void runOnceTasks() throws Exception {
29757 tejbeer 81
 
32048 tejbeer 82
        scheduledTasks.reconcileRecharge();
29757 tejbeer 83
 
32048 tejbeer 84
    }
25822 amit.gupta 85
 
32048 tejbeer 86
    /*
87
     * @Scheduled(cron = "0 0 8 * * *") public void mailDashboardScreenshots()
88
     * throws Exception { runOnceTasks.mailDashboardScreenshots(); }
89
     */
25721 tejbeer 90
 
32048 tejbeer 91
    @Scheduled(cron = "0 05 0 1,16 * ?")
92
    public void processRechargeCashback() throws Throwable {
29673 manish 93
 
32048 tejbeer 94
        scheduledTasks.processRechargeCashback();
29673 manish 95
 
32048 tejbeer 96
    }
23794 govind 97
 
32048 tejbeer 98
    @Scheduled(cron = "0 0 6 * * *")
99
    public void sendPartnerInvestmentDetails() throws Exception {
100
        scheduledTasks.sendPartnerInvestmentDetails();
101
        long secs = (new Date().getTime()) / 1000;
102
        log.info("sendPartnerInvestmentDetails" + LocalDateTime.now());
29757 tejbeer 103
 
32048 tejbeer 104
    }
28921 tejbeer 105
 
36993 amit 106
    // Monthly margins CN dry-run at 06:00 on the 1st. dryRun=true forces the harmless dev path
107
    // (no IRN, no PDF, no DB persist, no partner mail) even on prod. The real pipeline is run
108
    // manually via `--sendCreditNote --live`.
109
    @Scheduled(cron = "0 0 6 1 * ?")
110
    public void monthlyMarginsCnDryRun() throws Exception {
111
 
112
        scheduledTasks.sendCreditNote(YearMonth.now().minusMonths(1), true);
113
 
114
    }
115
 
37234 vikas 116
    @Scheduled(cron = "0 30 6 * * *")
34648 ranu 117
    public void generateBiReport() throws Exception {
118
        scheduledTasksTest.generateBiReport();
119
    }
34939 ranu 120
    @Scheduled(cron = "0 30 4 * * *")
121
    public void createFofoSmartCartSuggestion() throws Exception {
122
        scheduledTasksTest.createFofoSmartCartSuggestion();
123
    }
35980 amit 124
    /*@Scheduled(cron = "0 0 6,22 * * *")
34948 ranu 125
    public void sendAbmSmartCartReport() throws Exception {
126
        abmReportSender.sendAbmSmartCartReport();
35980 amit 127
    }*/
34648 ranu 128
 
32048 tejbeer 129
    @Scheduled(cron = "0 0 10,15,17 * * *")
130
    public void sendIndentTertiaryReport() throws Exception {
29757 tejbeer 131
 
32048 tejbeer 132
        scheduledTasks.sendIndentTertiary();
29757 tejbeer 133
 
32048 tejbeer 134
    }
28921 tejbeer 135
 
32048 tejbeer 136
    @Scheduled(cron = "0 0 6 * * *")
137
    public void checkPartnerActiveStoreByStatus() throws Exception {
29673 manish 138
 
32048 tejbeer 139
        scheduledTasks.checkPartnerActiveStore();
29673 manish 140
 
32048 tejbeer 141
    }
26790 tejbeer 142
 
37938 amit 143
    // Mondays 09:00 — stores suspended for more than 7 days, to Neeraj with the other closers in CC.
144
    @Scheduled(cron = "0 0 9 * * MON")
145
    public void sendStoreClosureReminder() throws Exception {
146
        scheduledTasks.sendStoreClosureReminder();
147
    }
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
 
35568 amit 284
    // REMOVED: ticketClosed() scheduler - now handled by TicketRelatedScheduledTask.autoCloseResolvedTickets()
285
    // which uses 8 working days instead of 7 calendar days and runs as part of processAllTicketTasks()
26283 tejbeer 286
 
32048 tejbeer 287
    @Scheduled(cron = "0 0 8 * * *")
288
    public void checkfocusedModelInPartnerStock() throws Throwable {
289
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 290
 
32048 tejbeer 291
        scheduledTasks.checkfocusedModelInPartnerStock();
25721 tejbeer 292
 
32048 tejbeer 293
        log.info("endTime" + LocalDateTime.now());
294
    }
28205 tejbeer 295
 
32048 tejbeer 296
    @Scheduled(cron = "0 0 8,10,12,14,16,18,20 * * *")
297
    public void notifyLead() throws Throwable {
29757 tejbeer 298
 
32048 tejbeer 299
        scheduledTasks.notifyLead();
29757 tejbeer 300
 
32048 tejbeer 301
        // scheduledTasks.notifyVisits();
302
    }
25721 tejbeer 303
 
32411 amit.gupta 304
    @Scheduled(cron = "0 0 7 * * *")
305
    //Send all lead owners the report for scheduled followups missed
306
    public void sendUnscheduledFollowUpMail() throws Exception {
307
        scheduledTasks.sendUnscheduledFollowUpMail();
308
    }
309
 
32048 tejbeer 310
    @Scheduled(cron = "0 0 1 * * *")
311
    public void checkValidateReferral() throws Throwable {
312
        log.info("startTime" + LocalDateTime.now());
29673 manish 313
 
32048 tejbeer 314
        scheduledTasks.checkValidateReferral();
29757 tejbeer 315
 
32048 tejbeer 316
        log.info("endTime" + LocalDateTime.now());
317
    }
26790 tejbeer 318
 
32048 tejbeer 319
    // @Scheduled(cron = "0 0 8 * * *")
320
    public void partnerProblemAlert() throws Throwable {
321
        log.info("startTime" + LocalDateTime.now());
29673 manish 322
 
32048 tejbeer 323
        scheduledTasks.partnerProblemAlert();
29673 manish 324
 
32048 tejbeer 325
        log.info("endTime" + LocalDateTime.now());
326
    }
28921 tejbeer 327
 
35109 ranu 328
    @Scheduled(cron = "0 0 10 * * *")
32048 tejbeer 329
    public void onboardingEventDelays() throws Throwable {
330
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 331
 
32048 tejbeer 332
        onBoardingRelatedSchelduleTask.onboardingEventDelays();
29757 tejbeer 333
 
32048 tejbeer 334
        log.info("endTime" + LocalDateTime.now());
335
    }
28921 tejbeer 336
 
36065 aman 337
    @Scheduled(cron = "0 30 10 * * *")
338
    public void sendStockDeliveredTrainingNotification() {
339
        log.info("sendStockDeliveredTrainingNotification startTime " + LocalDateTime.now());
340
        onBoardingRelatedSchelduleTask.sendStockDeliveredTrainingNotification();
341
        log.info("sendStockDeliveredTrainingNotification endTime " + LocalDateTime.now());
342
    }
343
 
36003 aman 344
    @Scheduled(cron = "0 0 9 * * ?")
345
    public void sendDelayAlertEmail() {
346
        log.info("sendDelayAlertEmail startTime " + LocalDateTime.now());
347
        onBoardingRelatedSchelduleTask.sendDelayAlertEmail();
348
        log.info("sendDelayAlertEmail endTime " + LocalDateTime.now());
349
    }
350
 
32048 tejbeer 351
    @Scheduled(cron = "0 0 8 * * *")
352
    public void brandingAlert() throws Throwable {
353
        log.info("startTime" + LocalDateTime.now());
29673 manish 354
 
32048 tejbeer 355
        onBoardingRelatedSchelduleTask.brandingAlert();
29673 manish 356
 
32048 tejbeer 357
        log.info("endTime" + LocalDateTime.now());
358
    }
28921 tejbeer 359
 
32048 tejbeer 360
    @Scheduled(cron = "0 0 8 * * *")
361
    public void fullPaymentPendingAlert() throws Throwable {
362
        log.info("startTime" + LocalDateTime.now());
29757 tejbeer 363
 
32048 tejbeer 364
        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();
29757 tejbeer 365
 
32048 tejbeer 366
        log.info("endTime" + LocalDateTime.now());
367
    }
28921 tejbeer 368
 
32048 tejbeer 369
    @Scheduled(cron = "0 */5 * * * *")
370
    public void onBoardingCompleteEventEmail() throws Throwable {
371
        log.info("startTime" + LocalDateTime.now());
29673 manish 372
 
32048 tejbeer 373
        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();
29673 manish 374
 
32048 tejbeer 375
        log.info("endTime" + LocalDateTime.now());
376
    }
29040 tejbeer 377
 
32048 tejbeer 378
    @Scheduled(cron = "0 */5 * * * *")
379
    public void updateSaholicCISTable() throws Throwable {
380
        log.info("updateSaholicCISTable startTime" + LocalDateTime.now());
381
        runOnceTasks.updateSaholicCISTable();
382
        log.info("updateSaholicCISTable endTime" + LocalDateTime.now());
383
    }
30667 amit.gupta 384
 
34241 tejus.loha 385
    @Autowired
386
    PurSaleService purSaleService;
387
 
35133 ranu 388
    @Scheduled(cron = "0 0 6,22 * * ?")
34241 tejus.loha 389
    public void send10DaysEgedStockReport() throws Throwable {
34275 tejus.loha 390
        log.info("moreThen10DaysEgedStockReport startTime" + LocalDateTime.now());
391
        scheduledTasks.send10OrMoreOlderStockReport();
392
        log.info("moreThen10DaysEgedStockReport endTime" + LocalDateTime.now());
34241 tejus.loha 393
    }
394
 
35616 amit 395
    @Scheduled(fixedDelay = 5 * 60 * 1000)
32048 tejbeer 396
    public void fetchPartnerStat() throws Throwable {
397
        scheduledTasks.fetchParnterStats();
398
    }
30390 amit.gupta 399
 
37472 amit 400
    @Scheduled(cron = "0 0 23 * * *")
32214 jai.hind 401
    public void checkItelImeiActivationNew() throws Throwable {
402
        log.info("startTime" + LocalDate.now());
403
 
404
        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
405
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
406
        long secs = (new Date().getTime()) / 1000;
407
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());
408
 
409
    }
410
 
37472 amit 411
    /**
412
     * Vivo: one full pass a day, then nothing until tomorrow.
413
     *
414
     * Was two parallel jobs every 5 minutes capped at 50 and 10 imeis, which never
415
     * finished a pass over a 9,510-row pool and retried a failed lookup five minutes
416
     * later instead of the next day. Vivo stays on its own schedule and its own thread:
417
     * it is direct HTTP plus the captcha solver, no ChromeDriver, so it does not
418
     * contend for the resource the oppo/realme pass is rationing.
419
     *
420
     * ~9,510 imeis at roughly 2.5s each is about 6.6 hours.
421
     */
37565 amit 422
    // One chunk of 250 every 20 seconds until the day's pool is empty, then idle ticks
423
    // until midnight. Was a single 00:15 pass; the method name is kept so the
424
    // cron_job_* series and anything keyed on it stay continuous.
425
    //
426
    // The 20s cadence is not a throttle -- vivo is 0.24s an imei and does not rate-limit
427
    // us. It is what makes progress durable: the old pass held one thread for its whole
428
    // run and kept its position nowhere else, so a restart mid-pass forfeited the rest.
429
    @Scheduled(fixedDelay = 20 * 1000)
32048 tejbeer 430
    public void vivoImeiActivation() throws Throwable {
431
        scheduledTasks.checkImeiActivation();
432
    }
29255 tejbeer 433
 
37482 amit 434
    /**
435
     * Itel activation from Carlcare, Transsion's own after-sales endpoint. 50 imeis every 5
436
     * minutes, which spreads the work over the whole day rather than bursting: 14,400 lookups a
437
     * day against a pending pool of ~10,400.
438
     *
439
     * The 5-minute cadence is safe here in a way it was not for vivo, whose comment below records
440
     * why that pattern ran away: there, a failed lookup wrote no row, so createTimestamp was not
441
     * bumped and the same imei was eligible again five minutes later. This service stamps the row
442
     * on EVERY outcome, failures included, so each tick advances past the imeis it asked about
443
     * and a failure costs one retry tomorrow rather than one every five minutes.
444
     *
445
     * It is one plain signed GET per imei -- no captcha solver, no ChromeDriver -- so it does not
446
     * contend with the oppo/realme pass. Both this and the 23:00 DCR pull write Itel rows and
447
     * need no coordination: the pool query returns only imeis whose activationTimestamp is still
448
     * null, so whatever one has filled has already left the other's pool.
449
     */
450
    @Scheduled(fixedDelay = 5 * 60 * 1000)
451
    public void carlcareImeiActivation() throws Throwable {
452
        scheduledTasks.checkCarlcareImeiActivation();
453
    }
454
 
32048 tejbeer 455
    @Scheduled(cron = "0 0 8 * * *")
456
    public void reviewUncontactablePartner() throws Throwable {
457
        log.info("startTime" + LocalDateTime.now());
30421 tejbeer 458
 
32048 tejbeer 459
        scheduledTasks.reviewUncontactablePartner();
30421 tejbeer 460
 
32048 tejbeer 461
    }
30421 tejbeer 462
 
33928 ranu 463
    @Scheduled(cron = "0 0 7 * * *")
464
    public void setMovementWiseRbmTodayTargets() throws Throwable {
34669 amit.gupta 465
        log.info("today targets startTime {}", LocalDateTime.now());
33928 ranu 466
 
467
        scheduledTasks.persistRbmTodayTargets();
468
 
469
    }
470
 
33986 ranu 471
    @Scheduled(cron = "0 0 21 * * *")
472
    public void setMovementWiseRbmTodayAchievements() throws Throwable {
34669 amit.gupta 473
        log.info("today achievement startTime {}", LocalDateTime.now());
33986 ranu 474
 
475
        scheduledTasks.persistRbmTodayAchievements();
476
 
477
    }
478
 
37499 ranu 479
    // Sales-hierarchy target snapshot — runs 10 minutes after RBM targets so
480
    // today's rbm_targets rows are guaranteed present for the roll-up.
481
    @Scheduled(cron = "0 10 7 * * *")
482
    public void setSalesTodayTargets() throws Throwable {
483
        log.info("sales today targets startTime {}", LocalDateTime.now());
484
 
485
        scheduledTasks.persistSalesTodayTargets();
486
 
487
    }
488
 
489
    // Sales-hierarchy achievement snapshot — independent of the target chain;
490
    // rolls up live order ACH so it can run any time after orders settle.
491
    // Kept aligned with RBM achievement time (21:00).
492
    @Scheduled(cron = "0 10 21 * * *")
493
    public void setSalesTodayAchievements() throws Throwable {
494
        log.info("sales today achievement startTime {}", LocalDateTime.now());
495
 
496
        scheduledTasks.persistSalesTodayAchievements();
497
 
498
    }
499
 
33078 ranu 500
 
32048 tejbeer 501
    @Autowired
502
    private StandAlone standAlone;
30352 amit.gupta 503
 
32832 amit.gupta 504
    @Autowired
505
    OrderTrackingService orderTrackingService;
506
 
37472 amit 507
    // ONE thread, ONE full pass a day, for oppo and realme together.
508
    //
509
    // This replaces four @Scheduled jobs (oppo and realme x secondary and tertiary,
510
    // every 5 minutes), and it supersedes the r37447 / r37448 / r37449 argument about
511
    // how many ChromeDrivers to run. That argument was about the wrong variable.
512
    //
513
    // The revert in r37449 was sized on lookups ATTEMPTED per day, and the re-merge that
514
    // followed blamed the resulting collapse on CPU contention pushing the captcha
515
    // render past the element waits. The logs do not support contention:
516
    //
517
    //   29 Aug        imeis   canvas timeouts   captcha ok   distinct imeis   asks each
518
    //   oppo          4,350                 0       ~100%            4,238        1.03
519
    //   realme        4,524             3,390         19%            1,004        4.50
520
    //
521
    // Same box, same six cores, same driver count, same captcha vendor, load average
522
    // 0.9 -- and oppo took ZERO timeouts in all 24 hours, including the 15:00-23:00
523
    // window in which realme solved nothing at all. Realme's own canvas wait is 15s
524
    // against oppo's 8s, so the LONGER wait is the one expiring.
525
    //
526
    // What realme's timeout rate actually tracks is its own daily request volume, and
527
    // it resets at midnight: 920/day -> 0.3%, 3,467/day -> 28%, 4,524/day -> 75%. That
528
    // is realme.com declining to serve the widget, not a busy box.
529
    //
530
    // The 4.5 asks per imei is why it ran away. A failed lookup never reaches
531
    // dateMap.put, so no row is written, so createTimestamp is not bumped, so the same
532
    // imei was eligible again five minutes later -- more requests hardened the block,
533
    // which caused more failures, which caused more requests. A snapshotted daily pass
534
    // bounds that by construction: a failure costs one retry tomorrow, never one in
535
    // five minutes, however the far end behaves.
536
    //
537
    // Judge this change on dates written, not on timeout count.
37565 amit 538
    // One chunk of 25 for one brand every 20 seconds, oppo and realme by turns, until
539
    // both pools are empty for the day. Was a single 00:30 pass that held this thread for
540
    // 20+ hours; the method name is kept so the cron_job_* series stays continuous.
541
    //
542
    // fixedDelay, not fixedRate: the gap is measured from the END of a tick, so a chunk
543
    // that takes six minutes is not immediately followed by a queued one. The lane
544
    // self-throttles to whatever the far ends are actually giving us.
545
    //
546
    // The start/end log lines are gone deliberately -- at 4,320 ticks a day they were
547
    // pure volume on a log that is already 1.8GB. StandAlone logs the day boundary and
548
    // the chunks; idle ticks say nothing at all.
549
    @Scheduled(fixedDelay = 20 * 1000)
37472 amit 550
    public void oppoRealmeImeiActivation() throws Throwable {
551
        standAlone.checkBrowserImeiActivation();
34421 amit.gupta 552
    }
553
 
32801 amit.gupta 554
    @Scheduled(cron = "0 0 * * * *")
32048 tejbeer 555
    public void markBlueDartOrderDelivered() throws Throwable {
556
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 557
        orderTrackingService.markBlueDartOrderDelivered();
32048 tejbeer 558
        log.info("endTime" + LocalDateTime.now());
559
    }
31117 tejbeer 560
 
32881 amit.gupta 561
    @Scheduled(cron = "0 15 * * * *")
32048 tejbeer 562
    public void markDelhiveryOrderDelivered() throws Throwable {
29673 manish 563
 
32048 tejbeer 564
        log.info("startTime" + LocalDateTime.now());
32832 amit.gupta 565
        orderTrackingService.markDelhiveryOrderDelivered();
29673 manish 566
 
32048 tejbeer 567
        log.info("endTime" + LocalDateTime.now());
568
    }
29308 tejbeer 569
 
32048 tejbeer 570
    @Scheduled(cron = "0 0 4 * * *")
571
    public void processPriceDrop() throws Throwable {
572
        scheduledTasks.processPriceDrop();
573
    }
30637 amit.gupta 574
 
32048 tejbeer 575
    @Scheduled(cron = "0 0 0 * * *")
576
    public void calculateInterestAccured() throws Throwable {
34710 amit.gupta 577
        scheduledTasks.loanSettlement();
32048 tejbeer 578
        scheduledTasks.calculateInterestAccured();
579
    }
30859 tejbeer 580
 
32117 tejbeer 581
    //  @Scheduled(cron = "0 */5 2-22 * * *")
33181 amit.gupta 582
    @Scheduled(fixedDelay = 1 * 60 * 1000)
32531 amit.gupta 583
    //@Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 584
    public void loanSettlement() throws Throwable {
34756 amit.gupta 585
        LocalTime now = LocalTime.now();
34767 amit.gupta 586
        LocalTime start = LocalTime.of(9, 0);
34757 amit.gupta 587
        LocalTime end = LocalTime.of(23, 0);
34756 amit.gupta 588
 
589
        if (now.isBefore(start) || now.isAfter(end)) {
34762 amit.gupta 590
            System.out.println("Task skipped during restricted hours: " + now);
591
        } else {
34756 amit.gupta 592
            scheduledTasks.loanSettlement();
593
            System.out.println("Task executed at " + now);
594
        }
32048 tejbeer 595
    }
30859 tejbeer 596
 
32048 tejbeer 597
    @Scheduled(cron = "0 */15 * * * *")
598
    public void ccAvenueSettlement() throws Throwable {
599
        scheduledTasks.settleCCAvePayments();
600
    }
31332 amit.gupta 601
 
32048 tejbeer 602
    @Scheduled(cron = "0 0 6 * * *")
603
    public void dailyLoanAlert() throws Throwable {
604
        scheduledTasks.dailyLoanAlert();
605
    }
30896 amit.gupta 606
 
35106 ranu 607
    @Scheduled(cron = "0 0 11 * * *")
34162 ranu 608
    public void groupHidCatalogsByWeeks() throws Throwable {
609
        scheduledTasks.groupHidCatalogsByWeeks();
610
    }
611
 
36113 ranu 612
    @Scheduled(cron = "0 0 9 * * MON")  // Every Monday at 9:00 AM
34321 ranu 613
    public void sendFeebackSalesAndRbm() throws Throwable {
614
        scheduledTasksTest.sendRbmFeedbackSummaryEmail();
615
        scheduledTasksTest.sendSalesFeedbackSummaryEmail();
616
    }
617
 
37895 ranu 618
    // Monthly RBM composite ranking — fires at 23:30 on days 28/29/30/31 but
619
    // only executes on the actual last day of the month (handles Feb and
620
    // 30-day months without adding a leap-year calendar).
621
    @Scheduled(cron = "0 30 23 28-31 * *")
622
    public void sendMonthlyRbmRankingProbe() throws Throwable {
623
        LocalDate today = LocalDate.now();
624
        if (today.getDayOfMonth() != today.lengthOfMonth()) return;
625
        runOnceTasks.printRbmRankingForMonth(YearMonth.from(today));
626
    }
627
 
32165 amit.gupta 628
    //Look out for imeis that have activation pending based of sale and mark create new SIO out of them
32048 tejbeer 629
    @Scheduled(cron = "0 0 1 * * *")
630
    public void processActivatedImeisForSchemes() throws Throwable {
631
        scheduledTasks.processActivatedImeisForSchemes();
632
    }
34241 tejus.loha 633
 
33357 amit.gupta 634
    //On every fifth update deductions
33435 amit.gupta 635
    @Scheduled(cron = "0 30 6 5 * ?")
33357 amit.gupta 636
    public void processSidbiDeductions() throws Throwable {
637
        scheduledTasks.processSidbiDeductions();
638
    }
34669 amit.gupta 639
 
34374 amit.gupta 640
    //Dont reset it for now as proposed by TV
641
    //@Scheduled(cron = "0 30 6 4 * ?")
33904 amit.gupta 642
    public void resetHardLimit() throws Throwable {
643
        scheduledTasks.resetHardLimit();
644
    }
645
 
37589 amit 646
    /**
647
     * Investment snapshot for every active partner, then the credit limit for the partners whose
37595 amit 648
     * base moved. This is the path that keeps limits current: it replaces the 20-minute full rescan,
649
     * so a limit follows a payment within ~2 minutes instead of up to 20 — which matters because a
650
     * quarter of advance payments are followed by an order within five minutes.
651
     *
652
     * <p>Measured on production: ~3 partners per 2-minute window show a changed base (peak 18), so
653
     * the limit work behind this is a handful of rows rather than a 980-partner scan.
37589 amit 654
     */
655
    @Scheduled(cron = "0 0/2 * * * *")
656
    public void sweepPartnerInvestment() throws Throwable {
657
        batchScheduledTasks.sweepPartnerInvestment();
658
    }
659
 
660
    /**
37595 amit 661
     * Daily: refresh the time-driven haircuts, then run a full limit pass.
662
     *
663
     * <p>The 2-minute sweep already recalculates the limit for every partner whose base moved, which
664
     * covers investment and utilisation. The full pass exists only for inputs the base cannot see —
665
     * credit risk, the SIDBI floor and hard_limit — and those move on a far slower clock: risk
666
     * decays on a 90-day threshold, and the SIDBI sanction table has had no new row since Oct 2024
667
     * and no recorded settlement. Running a 980-partner rescan every 20 minutes to catch that was 72
668
     * wasted passes a day.
669
     *
670
     * <p>Order matters: the haircut refresh changes base for the partners whose Apple or demo stock
671
     * crossed its threshold overnight, so the limit pass runs after it and sees the new values.
37589 amit 672
     */
673
    @Scheduled(cron = "0 20 0 * * *")
674
    public void refreshAgedStockDaily() throws Throwable {
675
        batchScheduledTasks.refreshAgedStockDaily();
37595 amit 676
        batchScheduledTasks.updatePartnerLimitWithBatch();
37589 amit 677
    }
678
 
37642 amit 679
    /**
680
     * Hourly at :40 — close out batches left RUNNING by a run that died mid-loop, so they
681
     * raise their alert and stop blocking the job from running again. No-ops when clean.
682
     */
683
    @Scheduled(cron = "0 40 * * * *")
684
    public void reapStaleCronBatches() {
685
        try {
686
            batchScheduledTasks.reapStaleBatches();
687
        } catch (Exception e) {
688
            log.error("reapStaleBatches failed: {}", e.getMessage(), e);
689
        }
690
    }
691
 
34253 ranu 692
    @Scheduled(cron = "0 0 9,14,18 * * *")
33874 ranu 693
    public void createOpeningStockPartyWise() throws Throwable {
694
        scheduledTasks.createOpeningStockPartyWise();
695
    }
30936 tejbeer 696
 
32842 amit.gupta 697
    //Loans due/overdue/default notifications sent to parnters
698
    @Scheduled(cron = "0 0 11 * * *")
32822 ranu 699
    public void sendMailWhatsAppAfterLoanDueDate() throws Throwable {
700
        scheduledTasks.sendMailWhatsAppAfterLoanDueDate();
701
    }
34241 tejus.loha 702
 
32842 amit.gupta 703
    @Scheduled(cron = "0 0 8 * * *")
704
    public void alertForDueDate() throws Throwable {
705
        scheduledTasks.alertForDueDate();
706
    }
32822 ranu 707
 
35133 ranu 708
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 709
    public void notifyLoanDueDateCross() throws Throwable {
710
        scheduledTasks.notifyLoanDueDateCross();
711
    }
30936 tejbeer 712
 
35133 ranu 713
    @Scheduled(cron = "0 0 4,21 * * *")
32048 tejbeer 714
    public void notifyDefaultLoans() throws Throwable {
715
        scheduledTasks.notifyDefaultLoans();
716
    }
30936 tejbeer 717
 
34910 ranu 718
   // @Scheduled(cron = "0 0 23 * * *")
32048 tejbeer 719
    public void hygineAlertForInternalTeam() throws Throwable {
720
        scheduledTasks.hygineAlertForInternalTeam();
31206 tejbeer 721
 
32048 tejbeer 722
    }
31206 tejbeer 723
 
32048 tejbeer 724
    @Scheduled(cron = "0 0 23 * * *")
725
    public void hygineAlertForPartner() throws Throwable {
726
        scheduledTasks.hygineAlertForPartner();
31206 tejbeer 727
 
32048 tejbeer 728
    }
31206 tejbeer 729
 
32048 tejbeer 730
    @Scheduled(cron = "0 0 0 * * MON")
731
    public void monthlyTargetForPartner() throws Throwable {
732
        scheduledTasks.monthlyTargetForPartner();
31249 tejbeer 733
 
32048 tejbeer 734
    }
31249 tejbeer 735
 
32048 tejbeer 736
    @Scheduled(cron = "0 0 0 * * MON")
737
    public void monthlyTargetForInternalTeam() throws Throwable {
738
        scheduledTasks.monthlyTargetForInternalTeam();
31249 tejbeer 739
 
32048 tejbeer 740
    }
31612 tejbeer 741
 
32048 tejbeer 742
    @Scheduled(cron = "0 0 6 * * *")
743
    public void sendSamsungRebilling() throws Throwable {
744
        scheduledTasks.sendMailForSamsungRebilling();
745
    }
31931 amit.gupta 746
 
32048 tejbeer 747
    @Scheduled(cron = "0 10 8 * * *")
748
    public void sendMailForAgeingAlert() throws Throwable {
749
        scheduledTasks.sendMailForAgeingAlert();
750
    }
751
 
752
    @Scheduled(cron = "0 0 8 * * *")
753
    public void sendFilteredRetailerPerformance() throws Throwable {
754
        scheduledTasks.sendFilteredRetailerPerformance();
755
    }
32690 amit.gupta 756
 
33444 ranu 757
    @Scheduled(cron = "0 0 0 * * MON")
758
    public void findAllLiveDemoBrandItemsByBillingDate() throws Throwable {
759
        scheduledTasks.findAllLiveDemoBrandItemsByBillingDate();
760
    }
34241 tejus.loha 761
 
33464 ranu 762
    @Scheduled(cron = "0 10 6 * * *")
763
    public void findTodayPocoBillingItems() throws Throwable {
764
        scheduledTasks.findTodayPocoBillingItems();
765
    }
32690 amit.gupta 766
 
767
    @Scheduled(cron = "0 0 12 * * *")
768
    public void rejectPriceDropsOfApprovedImeis() throws Throwable {
37083 amit 769
        batchScheduledTasks.reprocessPriceDropsWithBatch();
32690 amit.gupta 770
    }
32907 amit.gupta 771
 
772
    @Autowired
773
    POScheduler poScheduler;
34241 tejus.loha 774
 
32907 amit.gupta 775
    @Scheduled(cron = "0 0 1 * * *")
33643 amit.gupta 776
    public void autoClosePO() {
32907 amit.gupta 777
        poScheduler.autoClosePurchaseOrders();
778
    }
37751 ranu 779
 
37771 amit 780
    @Scheduled(cron = "0 0 9,17 * * *")
781
    public void openMovementPODigest() {
782
        poScheduler.sendOpenMovementDigest();
783
    }
784
 
37751 ranu 785
    // Daily PO stock-cover approval digest — 5 heads notified of the day's
786
    // APPROVED / REJECTED decisions. Manual trigger for testing lives at
787
    // POST /po/stock-approvals/digest/trigger.
788
    @Scheduled(cron = "0 0 22 * * *")
789
    public void poStockApprovalDailyDigest() throws Exception {
790
        log.info("poStockApprovalDailyDigest startTime {}", LocalDateTime.now());
791
        runOnceTasks.poStockApprovalDailyDigest();
792
    }
32048 tejbeer 793
    /*
794
     * @Scheduled(cron = "0 0 9 * * *") public void onBoardingDocumentsPending()
795
     * throws Throwable { log.info("startTime" + LocalDateTime.now());
796
     * onBoardingRelatedSchelduleTask.onBoardingDocumentsPending();
797
     * log.info("endTime" + LocalDateTime.now()); }
798
     */
34443 vikas.jang 799
 
34547 vikas.jang 800
    @Scheduled(cron = "0 50 23 * * *")
34443 vikas.jang 801
    public void bidConfirmation() throws Throwable {
34547 vikas.jang 802
        log.info("running bid cron at 23:50PM");
34443 vikas.jang 803
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.YESTERDAY);
804
    }
805
 
34547 vikas.jang 806
    @Scheduled(cron = "0 0 19 * * *")
34443 vikas.jang 807
    public void processLiquidationBids() throws Throwable {
34547 vikas.jang 808
        log.info("running bid cron at 07:00PM");
34443 vikas.jang 809
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
810
    }
811
 
34547 vikas.jang 812
    @Scheduled(cron = "0 30 21 * * *")
34443 vikas.jang 813
    public void bidPurchaseOrder() throws Throwable {
34547 vikas.jang 814
        log.info("running bid cron at 09:30PM");
34443 vikas.jang 815
        runOnceTasks.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
816
    }
34547 vikas.jang 817
 
34669 amit.gupta 818
    /*@Scheduled(cron = "0 0 12 * * *")
819
    public void processCashDiscount() throws Throwable {
820
        scheduledTasks.processCashDiscount();
821
    }*/
822
 
34563 vikas.jang 823
    @Scheduled(cron = "0 0 9,17 * * *")
34547 vikas.jang 824
    public void bidConsolidatedMessage() throws Throwable {
825
        log.info("Running bid cron at 09:00 AM or 05:00 PM");
826
        runOnceTasks.consolidatedBiddingMessage();
34563 vikas.jang 827
    }
34770 vikas.jang 828
 
829
    @Scheduled(cron = "0 0 8 * * *")
34836 vikas 830
    public void yesterdayTrackingReport() throws Throwable {
831
        log.info("Running yesterday employee tracking cron at 08:00 AM");
832
        runOnceTasks.yesterdayTrackingReport();
34770 vikas.jang 833
    }
34836 vikas 834
 
35178 amit 835
    @Scheduled(cron = "0 10 8 * * *")
35177 amit 836
    public void partnerCreditExposureReport() throws Throwable {
837
        log.info("Running yesterday employee tracking cron at 08:00 AM");
838
        runOnceTasks.sendCreditExposureReport();
839
    }
840
 
36552 ranu 841
    @Scheduled(cron = "0 0 22,16 * * *")
34836 vikas 842
    public void dailyTrackingReport() throws Throwable {
36552 ranu 843
        log.info("Running daily employee tracking cron at 10:00 PM and 04:00 PM");
34836 vikas 844
        runOnceTasks.dailyTrackingReport();
845
    }
35105 vikas 846
 
34792 amit.gupta 847
    @Scheduled(cron = "0 0 0 1 1,4,7,10 *")
848
    public void sendUpdateMobileBrandMarketShareQuaterlyMail() throws Throwable {
34791 aman.kumar 849
        log.info("Running Marketshare update remined quaterly");
850
        scheduledTasks.sendUpdateMobileBrandMarketShareQuaterlyMail();
851
    }
35105 vikas 852
 
853
    @Scheduled(cron = "0 0 * * * *")
854
    public void checkRewardsEligibility() throws Throwable {
855
        log.info("Running Rewards Disburse daily");
856
        runOnceTasks.checkRewardsEligibility();
857
    }
35326 amit 858
 
859
    @Scheduled(cron="0 0 20 * * *")
860
    public void sendTrialExpiry() {
861
        scheduledTasks.sendTrialExpiry();
862
    }
35666 vikas 863
 
864
    @Scheduled(cron = "0 0 0 * * *")
865
    public void fetchOffersByItem() {
866
        scheduledTasks.cachePinelabsOffers();
867
    }
35788 vikas 868
 
37848 amit 869
    // Billing warehouse whose stock is listed on the Shopify store.
870
    @Value("${shopify.warehouseId:13372}")
871
    private int shopifyWarehouseId;
872
 
35788 vikas 873
    @Scheduled(cron = "0 0 0 * * *")
874
    public void syncProductsToShopify() throws Exception {
37848 amit 875
        scheduledTasks.syncProductsToShopifyByWarehouseId(shopifyWarehouseId);
35788 vikas 876
    }
36511 amit 877
 
37162 vikas 878
    @Scheduled(cron = "0 0 6,18 * * *")
879
    public void syncInventoryToShopify() throws Exception {
37848 amit 880
        scheduledTasks.syncInventoryToShopifyByWarehouseId(shopifyWarehouseId);
37162 vikas 881
    }
882
 
36511 amit 883
    @Autowired
37848 amit 884
    private SuspendedWarehouseStockAlertService suspendedWarehouseStockAlertService;
885
 
886
    // Stock left in suspended or closed warehouses no longer shows on any dashboard.
887
    @Scheduled(cron = "0 0 10 * * *")
888
    public void sendSuspendedWarehouseStockAlert() throws Exception {
889
        suspendedWarehouseStockAlertService.sendAlert();
890
    }
891
 
892
    @Autowired
36511 amit 893
    private WarehouseStockReconciliation warehouseStockReconciliation;
894
 
895
    @Scheduled(cron = "0 30 5 * * *")
896
    public void reconcileInventorySnapshot() throws Exception {
897
        log.info("reconcileInventorySnapshot");
898
        warehouseStockReconciliation.reconcile();
899
    }
37159 amit 900
 
901
    @Autowired
902
    private PartnerIdentityIntegrityMonitor partnerIdentityIntegrityMonitor;
903
 
904
    @Scheduled(cron = "0 0 7 * * *")
905
    public void partnerIdentityIntegrityMonitor() throws Exception {
906
        log.info("partnerIdentityIntegrityMonitor");
907
        partnerIdentityIntegrityMonitor.monitor();
908
    }
23756 amit.gupta 909
}