Subversion Repositories SmartDukaan

Rev

Rev 24135 | Rev 24155 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.smartdukaan.cron.scheduled;

import java.io.IOException;
import java.text.MessageFormat;
import java.time.LocalDate;
import java.util.List;

import javax.mail.MessagingException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;

@Component
public class ScheduledSkeleton {

        private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);

        @Autowired
        ScheduledTasks scheduledTasks;

        @Autowired
        NagiosMonitorTasks nagiosMonitorTasks;
        
        @Autowired
        private FofoStoreRepository fofoStoreRepository;

        @Scheduled(cron = "0 15 0 * * *")
        public void reconcileRecharge() throws Exception {
                scheduledTasks.reconcileRecharge();
        }

        @Scheduled(cron = "0 05 0 1,16 * ?")
        public void processRechargeCashback() throws Throwable {
                scheduledTasks.processRechargeCashback();
        }

        /*
         * Value so big so that it got to run only once.
         * 
         */

        @Scheduled(cron = "0 0 9 * * *")
        public void migrateLineItems() throws Throwable {
                log.info("Started run Once");
                scheduledTasks.sendPartnerInvestmentDetails();
        }

        @Scheduled(cron = " 0 0 23 ? * *")
        public void sendMail() throws MessagingException, ProfitMandiBusinessException, IOException {
                log.info("sending mail");
                String message = MessageFormat.format("Sale Target summary for {0}", LocalDate.now());
                List<SaleHeadDetails> saleHeadDetails=fofoStoreRepository.selectAllSalesHeadDetails();
                for(SaleHeadDetails saleHeadDetail:saleHeadDetails)
                {
                        if(saleHeadDetail.getName().equals("Kamal"))
                        {
                                String[] to= {saleHeadDetail.getEmail(),"mohinder.mutreja@smartdukaan.com"};
                                scheduledTasks.sendMailWithAttachmentsForSalesHead(to, "Daily Sale Report", message,saleHeadDetail.getName());
                        }
                        else
                        {
                        String[] to= {saleHeadDetail.getEmail()};
                        scheduledTasks.sendMailWithAttachmentsForSalesHead(to, "Daily Sale Report", message,saleHeadDetail.getName());
                        }
                }
                
        }
}