You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package com.gcc.erppostdata.common;
import com.gcc.erppostdata.communityhall.CmhQueryBank;import com.gcc.erppostdata.petregistration.PetQueryBank;import com.gcc.erppostdata.repo.CommunityHallLogRepo;import com.gcc.erppostdata.repo.PetLogRepo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.annotation.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.transaction.annotation.Transactional;
import java.util.Date;import java.util.List;import java.util.Map;
@Configuration@EnableSchedulingpublic class MySchduler {
@Autowired CmhQueryBank queryBank;
@Autowired CommunityHallLogRepo communityHallLogRepo;
@Autowired PetQueryBank petQueryBank;
@Autowired PetLogRepo petLogRepo;
@Scheduled(fixedRate = 3600000) // Runs every 1 hour
public void hourlyScheduled() { try { oneHourCmhSch(); } catch (Exception e) { System.err.println("Error in oneHourCmhSch: " + e.getMessage()); e.printStackTrace(); }
try { oneHourPetSch(); } catch (Exception e) { System.err.println("Error in oneHourPetSch: " + e.getMessage()); e.printStackTrace(); } }
@Scheduled(fixedRate = 10800000) // Runs every 1 hour
public void threeHoursScheduled() { try { threeHourCmhSch(); } catch (Exception e) { System.err.println("Error in oneHourCmhSch: " + e.getMessage()); e.printStackTrace(); }
try { threeHourPetSch(); } catch (Exception e) { System.err.println("Error in oneHourPetSch: " + e.getMessage()); e.printStackTrace(); } }
@Transactional public void oneHourCmhSch() { System.out.println("community Hourly Post data"+new Date()); int lastBookingIdInserted = communityHallLogRepo.getLastBookingIdInserted(); System.out.println("community Hall lastBookingIdInserted:---->"+lastBookingIdInserted); queryBank.hourlyPushData( lastBookingIdInserted);
}
@Transactional public void threeHourCmhSch() { System.out.println("CommunityHall Three Hour Post data"+new Date()); List<Map<String, Object>> dataByStatus = communityHallLogRepo.getDataByStatus(String.valueOf(0)); for (Map<String, Object> data : dataByStatus) { queryBank.resendPushData(data.get("transactionId").toString(), data.get("id").toString() ); } }
@Transactional public void oneHourPetSch() { System.out.println("Pet Hourly Post data"+new Date()); int lastUniqueIdInserted = petLogRepo.getLastUniqueIdInserted(); System.out.println("Pet License lastUniqueIdInserted:--->"+lastUniqueIdInserted); petQueryBank.hourlyPushData(lastUniqueIdInserted); } @Transactional public void threeHourPetSch() { System.out.println("Pet Three Hour Post data"+new Date()); List<Map<String, Object>> dataByStatus = petLogRepo.getDataByStatus(String.valueOf(0)); for (Map<String, Object> data : dataByStatus) { petQueryBank.resendPushData(data.get("uniqueId").toString(), data.get("id").toString() ); }
}
}
|