Subversion Repositories SmartDukaan

Rev

Rev 37482 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37482 Rev 37499
Line 5... Line 5...
5
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
5
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
6
import com.smartdukaan.cron.scheduled.ordertracking.OrderTrackingService;
6
import com.smartdukaan.cron.scheduled.ordertracking.OrderTrackingService;
7
import com.smartdukaan.cron.scheduled.purchaseorder.POScheduler;
7
import com.smartdukaan.cron.scheduled.purchaseorder.POScheduler;
8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
9
import com.spice.profitmandi.dao.service.PurSaleService;
9
import com.spice.profitmandi.dao.service.PurSaleService;
-
 
10
import com.spice.profitmandi.service.integrations.icicilombard.IciciLombardService;
-
 
11
import com.spice.profitmandi.service.integrations.icicilombard.model.LastTransactionsResponseModel;
10
import org.apache.logging.log4j.LogManager;
12
import org.apache.logging.log4j.LogManager;
11
import org.apache.logging.log4j.Logger;
13
import org.apache.logging.log4j.Logger;
12
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.beans.factory.annotation.Autowired;
13
import org.springframework.scheduling.annotation.Scheduled;
15
import org.springframework.scheduling.annotation.Scheduled;
14
import org.springframework.stereotype.Component;
16
import org.springframework.stereotype.Component;
Line 16... Line 18...
16
import java.time.LocalDate;
18
import java.time.LocalDate;
17
import java.time.LocalDateTime;
19
import java.time.LocalDateTime;
18
import java.time.LocalTime;
20
import java.time.LocalTime;
19
import java.time.YearMonth;
21
import java.time.YearMonth;
20
import java.util.Date;
22
import java.util.Date;
-
 
23
import java.util.LinkedHashMap;
21
 
24
 
22
@Component
25
@Component
23
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
26
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
24
public class ScheduledSkeleton {
27
public class ScheduledSkeleton {
25
 
28
 
Line 50... Line 53...
50
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;
53
    private TicketRelatedScheduledTask ticketRelatedScheduledTask;
51
 
54
 
52
    @Autowired
55
    @Autowired
53
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;
56
    private OnBoardingRelatedSchelduleTask onBoardingRelatedSchelduleTask;
54
 
57
 
-
 
58
//    @Autowired
-
 
59
//    private IciciLombardService iciciLombardService;
-
 
60
 
-
 
61
    String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";
-
 
62
 
55
    @Scheduled(cron = "0 0 2 * * *")
63
    @Scheduled(cron = "0 0 2 * * *")
56
    public void processDailySchemes() throws Exception {
64
    public void processDailySchemes() throws Exception {
57
 
65
 
58
        int maxMinusDays = 5;
66
        int maxMinusDays = 5;
59
        int currentDayOfMonth = LocalDate.now().getDayOfMonth();
67
        int currentDayOfMonth = LocalDate.now().getDayOfMonth();
Line 174... Line 182...
174
 
182
 
175
        ticketRelatedScheduledTask.alertforTicket();
183
        ticketRelatedScheduledTask.alertforTicket();
176
 
184
 
177
    }
185
    }
178
 
186
 
-
 
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
 
179
    //@Scheduled(cron = "0 0 14,18,23 ? * *")
226
    //@Scheduled(cron = "0 0 14,18,23 ? * *")
180
    public void dailySaleNotification() throws Exception {
227
    public void dailySaleNotification() throws Exception {
181
        log.info("daily send Notification");
228
        log.info("daily send Notification");
182
 
229
 
183
        scheduledTasks.sendDailySalesNotificationToPartner(null);
230
        scheduledTasks.sendDailySalesNotificationToPartner(null);
Line 441... Line 488...
441
 
488
 
442
        scheduledTasks.persistRbmTodayAchievements();
489
        scheduledTasks.persistRbmTodayAchievements();
443
 
490
 
444
    }
491
    }
445
 
492
 
-
 
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
 
446
    @Scheduled(cron = "0 0 8 * * *")
514
    @Scheduled(cron = "0 0 8 * * *")
447
    public void reviewNonSdBuyingBrand() throws Throwable {
515
    public void reviewNonSdBuyingBrand() throws Throwable {
448
        log.info("startTime" + LocalDateTime.now());
516
        log.info("startTime" + LocalDateTime.now());
449
 
517
 
450
        scheduledTasks.reviewNonSdBuyingBrand();
518
        scheduledTasks.reviewNonSdBuyingBrand();