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.

80 lines
2.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package com.gcc.erppostdata.common;
  2. import com.gcc.erppostdata.communityhall.CmhQueryBank;
  3. import com.gcc.erppostdata.petregistration.PetQueryBank;
  4. import com.gcc.erppostdata.repo.CommunityHallLogRepo;
  5. import com.gcc.erppostdata.repo.PetLogRepo;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.context.annotation.Configuration;
  8. import org.springframework.scheduling.annotation.EnableScheduling;
  9. import org.springframework.scheduling.annotation.Scheduled;
  10. import java.util.Date;
  11. import java.util.List;
  12. import java.util.Map;
  13. @Configuration
  14. @EnableScheduling
  15. public class MySchduler {
  16. @Autowired
  17. CmhQueryBank queryBank;
  18. @Autowired
  19. CommunityHallLogRepo communityHallLogRepo;
  20. @Autowired
  21. PetQueryBank petQueryBank;
  22. @Autowired
  23. PetLogRepo petLogRepo;
  24. @Scheduled(fixedRate = 3600000) // Runs every 1 hour (3600000 milliseconds)
  25. public void hourlyScheduled() {
  26. oneHourCmhSch();
  27. oneHourPetSch();
  28. }
  29. @Scheduled(fixedRate = 10800000)
  30. public void threeHoursScheduled() {
  31. threeHourCmhSch();
  32. threeHourPetSch();
  33. }
  34. public void oneHourCmhSch() {
  35. System.out.println("community Hourly Post data"+new Date());
  36. int lastBookingIdInserted = communityHallLogRepo.getLastBookingIdInserted();
  37. System.out.println("community Hall lastBookingIdInserted:---->"+lastBookingIdInserted);
  38. queryBank.hourlyPushData( lastBookingIdInserted);
  39. }
  40. public void threeHourCmhSch() {
  41. System.out.println("CommunityHall Three Hour Post data"+new Date()); List<Map<String, Object>> dataByStatus = communityHallLogRepo.getDataByStatus(String.valueOf(0));
  42. for (Map<String, Object> data : dataByStatus) {
  43. queryBank.resendPushData(data.get("transactionId").toString(),
  44. data.get("id").toString()
  45. );
  46. }
  47. }
  48. public void oneHourPetSch() {
  49. System.out.println("Pet Hourly Post data"+new Date());
  50. int lastUniqueIdInserted = petLogRepo.getLastUniqueIdInserted();
  51. System.out.println("Pet License lastUniqueIdInserted:--->"+lastUniqueIdInserted);
  52. petQueryBank.hourlyPushData(lastUniqueIdInserted);
  53. }
  54. public void threeHourPetSch() {
  55. System.out.println("Pet Three Hour Post data"+new Date());
  56. List<Map<String, Object>> dataByStatus = petLogRepo.getDataByStatus(String.valueOf(0));
  57. for (Map<String, Object> data : dataByStatus) {
  58. petQueryBank.resendPushData(data.get("uniqueId").toString(),
  59. data.get("id").toString()
  60. );
  61. }
  62. }
  63. }