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.

110 lines
3.4 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 org.springframework.transaction.annotation.Transactional;
  11. import java.util.Date;
  12. import java.util.List;
  13. import java.util.Map;
  14. @Configuration
  15. @EnableScheduling
  16. public class MySchduler {
  17. @Autowired
  18. CmhQueryBank queryBank;
  19. @Autowired
  20. CommunityHallLogRepo communityHallLogRepo;
  21. @Autowired
  22. PetQueryBank petQueryBank;
  23. @Autowired
  24. PetLogRepo petLogRepo;
  25. @Scheduled(fixedRate = 3600000) // Runs every 1 hour
  26. public void hourlyScheduled() {
  27. try {
  28. oneHourCmhSch();
  29. } catch (Exception e) {
  30. System.err.println("Error in oneHourCmhSch: " + e.getMessage());
  31. e.printStackTrace();
  32. }
  33. try {
  34. oneHourPetSch();
  35. } catch (Exception e) {
  36. System.err.println("Error in oneHourPetSch: " + e.getMessage());
  37. e.printStackTrace();
  38. }
  39. }
  40. @Scheduled(fixedRate = 10800000) // Runs every 1 hour
  41. public void threeHoursScheduled() {
  42. try {
  43. threeHourCmhSch();
  44. } catch (Exception e) {
  45. System.err.println("Error in oneHourCmhSch: " + e.getMessage());
  46. e.printStackTrace();
  47. }
  48. try {
  49. threeHourPetSch();
  50. } catch (Exception e) {
  51. System.err.println("Error in oneHourPetSch: " + e.getMessage());
  52. e.printStackTrace();
  53. }
  54. }
  55. @Transactional
  56. public void oneHourCmhSch() {
  57. System.out.println("community Hourly Post data"+new Date());
  58. int lastBookingIdInserted = communityHallLogRepo.getLastBookingIdInserted();
  59. System.out.println("community Hall lastBookingIdInserted:---->"+lastBookingIdInserted);
  60. queryBank.hourlyPushData( lastBookingIdInserted);
  61. }
  62. @Transactional
  63. public void threeHourCmhSch() {
  64. System.out.println("CommunityHall Three Hour Post data"+new Date()); List<Map<String, Object>> dataByStatus = communityHallLogRepo.getDataByStatus(String.valueOf(0));
  65. for (Map<String, Object> data : dataByStatus) {
  66. queryBank.resendPushData(data.get("transactionId").toString(),
  67. data.get("id").toString()
  68. );
  69. }
  70. }
  71. @Transactional
  72. public void oneHourPetSch() {
  73. System.out.println("Pet Hourly Post data"+new Date());
  74. int lastUniqueIdInserted = petLogRepo.getLastUniqueIdInserted();
  75. System.out.println("Pet License lastUniqueIdInserted:--->"+lastUniqueIdInserted);
  76. petQueryBank.hourlyPushData(lastUniqueIdInserted);
  77. }
  78. @Transactional
  79. public void threeHourPetSch() {
  80. System.out.println("Pet Three Hour Post data"+new Date());
  81. List<Map<String, Object>> dataByStatus = petLogRepo.getDataByStatus(String.valueOf(0));
  82. for (Map<String, Object> data : dataByStatus) {
  83. petQueryBank.resendPushData(data.get("uniqueId").toString(),
  84. data.get("id").toString()
  85. );
  86. }
  87. }
  88. }