Done ticket GEPAFINBE-90

This commit is contained in:
nisha
2024-11-24 23:52:51 +05:30
parent cac2fd209b
commit 36725d3d46
15 changed files with 186 additions and 23 deletions

View File

@@ -0,0 +1,29 @@
package net.gepafin.tendermanagement.scheduler;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import java.time.LocalDateTime;
import java.util.List;
public class ApplicationEvaluationScheduler {
@Autowired
private ApplicationEvaluationRepository applicationEvaluationRepository;
@Scheduled(cron = "0 0 1 * * ?") // Runs daily at midnight
public void updateExpiredEvaluations() {
LocalDateTime currentDate = LocalDateTime.now();
List<ApplicationEvaluationEntity> evaluations = applicationEvaluationRepository.findAllByIsDeletedFalseAndEndDateBefore(currentDate);
for (ApplicationEvaluationEntity evaluation : evaluations) {
evaluation.setStatus(ApplicationEvaluationStatusTypeEnum.EXPIRED.getValue());
}
applicationEvaluationRepository.saveAll(evaluations);
}
}