Untitled

mail@pastecode.io avatar
unknown
java
a month ago
2.2 kB
1
Indexable
Never
@Scheduled(cron = "${commission.utr.report.auto.mail.scheduler}")
public void commissionTransferDetailsReportAutoMailProcess() {
    log.info("[CommissionUTRDetailsAutoMailerProcess] commissionTransferDetailsReportAutoMailProcess scheduler started ");

    try {
        List<ConfigParam> configObjectValues = configParamRepository.findByNameIgnoreCaseOrderByName(
                Arrays.asList(KeyConstants.COMMISSION_TRANSFER_DETAILS_AUTO_MAILER, KeyConstants.FUND_TRANSFER_DATE));

        if (configObjectValues.isEmpty()) {
            log.error("[CommissionUTRDetailsAutoMailerProcess] config params are missing");
            return;
        }

        String commissionTransferDetailsAutoMailReceivers = configObjectValues.get(0).getValue();
        log.info("[CommissionUTRDetailsAutoMailerProcess] CommissionTransferDetailsAutoMailReceivers ->{}", commissionTransferDetailsAutoMailReceivers);

        if (StringUtils.isBlank(commissionTransferDetailsAutoMailReceivers)) {
            log.error("[CommissionUTRDetailsAutoMailerProcess] Commission Transfer Details AutoMail Receivers are missing");
            return;
        }

        String fundTransferDateStr = configObjectValues.get(1).getValue();
        log.info("[CommissionUTRDetailsAutoMailerProcess] fundTransferDateStr ->{}", fundTransferDateStr);

        if (StringUtils.isBlank(fundTransferDateStr)) {
            log.error("[CommissionUTRDetailsAutoMailerProcess] Commission Transfer Details date is missing");
            return;
        }

        LocalDate currentDate = LocalDate.now();
        LocalDate fundTransferDate = LocalDate.parse(fundTransferDateStr);
        LocalDate fundTransferNextDate = fundTransferDate.plusDays(2);

        if (currentDate.equals(fundTransferNextDate)) {
            processMailDocumentCreation(fundTransferDate, commissionTransferDetailsAutoMailReceivers);
        } else {
            log.error("[CommissionUTRDetailsAutoMailerProcess] currentDate.equals(fundTransferNextDate) ->{}", currentDate.equals(fundTransferNextDate));
        }

    } catch (Exception e) {
        log.error("[CommissionUTRDetailsAutoMailerProcess] Exception occurred as ->{},{}", e.getMessage(), e);
    }
}
Leave a Comment