@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.scheduling.annotation.EnableScheduling ;
import org.springframework.scheduling.annotation.EnableScheduling ;
import org.springframework.scheduling.annotation.Scheduled ;
import org.springframework.scheduling.annotation.Scheduled ;
import org.springframework.transaction.annotation.Transactional ;
import java.util.Date ;
import java.util.Date ;
import java.util.List ;
import java.util.List ;
@ -29,19 +30,44 @@ public class MySchduler {
@Autowired
@Autowired
PetLogRepo petLogRepo ;
PetLogRepo petLogRepo ;
@Scheduled ( fixedRate = 3600000 ) / / Runs every 1 hour ( 3600000 milliseconds )
@Scheduled ( fixedRate = 3600000 ) / / Runs every 1 hour
public void hourlyScheduled ( ) {
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 ( ) {
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 ( ) {
public void oneHourCmhSch ( ) {
System . out . println ( "community Hourly Post data" + new Date ( ) ) ;
System . out . println ( "community Hourly Post data" + new Date ( ) ) ;
int lastBookingIdInserted = communityHallLogRepo . getLastBookingIdInserted ( ) ;
int lastBookingIdInserted = communityHallLogRepo . getLastBookingIdInserted ( ) ;
@ -49,6 +75,8 @@ public class MySchduler {
queryBank . hourlyPushData ( lastBookingIdInserted ) ;
queryBank . hourlyPushData ( lastBookingIdInserted ) ;
}
}
@Transactional
public void threeHourCmhSch ( ) {
public void threeHourCmhSch ( ) {
System . out . println ( "CommunityHall Three Hour Post data" + new Date ( ) ) ; List < Map < String , Object > > dataByStatus = communityHallLogRepo . getDataByStatus ( String . valueOf ( 0 ) ) ;
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 ) {
for ( Map < String , Object > data : dataByStatus ) {
@ -59,12 +87,14 @@ public class MySchduler {
}
}
@Transactional
public void oneHourPetSch ( ) {
public void oneHourPetSch ( ) {
System . out . println ( "Pet Hourly Post data" + new Date ( ) ) ;
System . out . println ( "Pet Hourly Post data" + new Date ( ) ) ;
int lastUniqueIdInserted = petLogRepo . getLastUniqueIdInserted ( ) ;
int lastUniqueIdInserted = petLogRepo . getLastUniqueIdInserted ( ) ;
System . out . println ( "Pet License lastUniqueIdInserted:--->" + lastUniqueIdInserted ) ;
System . out . println ( "Pet License lastUniqueIdInserted:--->" + lastUniqueIdInserted ) ;
petQueryBank . hourlyPushData ( lastUniqueIdInserted ) ;
petQueryBank . hourlyPushData ( lastUniqueIdInserted ) ;
}
}
@Transactional
public void threeHourPetSch ( ) {
public void threeHourPetSch ( ) {
System . out . println ( "Pet Three Hour Post data" + new Date ( ) ) ;
System . out . println ( "Pet Three Hour Post data" + new Date ( ) ) ;
List < Map < String , Object > > dataByStatus = petLogRepo . getDataByStatus ( String . valueOf ( 0 ) ) ;
List < Map < String , Object > > dataByStatus = petLogRepo . getDataByStatus ( String . valueOf ( 0 ) ) ;