Browse Source

my Scheduler changes

master
Thaqi2021 2 years ago
parent
commit
6b2a3daf5c
  1. 42
      src/main/java/com/gcc/erppostdata/common/MySchduler.java
  2. 2
      src/main/java/com/gcc/erppostdata/config/DatabaseConfig.java

42
src/main/java/com/gcc/erppostdata/common/MySchduler.java

@ -8,6 +8,7 @@ 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;
@ -29,19 +30,44 @@ public class MySchduler {
@Autowired
PetLogRepo petLogRepo;
@Scheduled(fixedRate = 3600000) // Runs every 1 hour (3600000 milliseconds)
@Scheduled(fixedRate = 3600000) // Runs every 1 hour
public void hourlyScheduled() {
oneHourCmhSch();
oneHourPetSch();
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)
@Scheduled(fixedRate = 10800000) // Runs every 1 hour
public void threeHoursScheduled() {
threeHourCmhSch();
threeHourPetSch();
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();
@ -49,6 +75,8 @@ public class MySchduler {
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) {
@ -59,12 +87,14 @@ public class MySchduler {
}
@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));

2
src/main/java/com/gcc/erppostdata/config/DatabaseConfig.java

@ -28,7 +28,7 @@ public class DatabaseConfig {
String petDb="gcc_pets";
String userName="root";
String password="gccroot";
String password="root";
// String chDb= appConfig.getCmhDb();
// String petDb= appConfig.getPetDb();

Loading…
Cancel
Save