Updated code for notification

This commit is contained in:
Piyush
2024-12-23 11:24:25 +05:30
parent 91ec063327
commit 288fde0a88
11 changed files with 144 additions and 22 deletions

View File

@@ -1,8 +1,11 @@
package net.gepafin.tendermanagement.scheduler;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.dao.NotificationDao;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
@@ -22,6 +25,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
@Component
public class ApplicationEvaluationScheduler {
@@ -35,6 +39,9 @@ public class ApplicationEvaluationScheduler {
@Autowired
private HttpServletRequest httpServletRequest;
@Autowired
private NotificationDao notificationDao;
private static final Logger log = LoggerFactory.getLogger(ApplicationEvaluationScheduler.class);
@Scheduled(cron = "0 0 2 * * ?") // Runs daily at midnight
@@ -76,10 +83,15 @@ public class ApplicationEvaluationScheduler {
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils
.getClonedEntityForData(evaluation);
ApplicationEntity application=evaluation.getAssignedApplicationsEntity().getApplication();
evaluation.setStatus(ApplicationEvaluationStatusTypeEnum.EXPIRED.getValue());
evaluation = applicationEvaluationRepository.save(evaluation);
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_EXPIRED);
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_EXPIRED);
notificationDao.sendNotificationToInstructor(placeHolders,evaluation,NotificationTypeEnum.EVALUATION_EXPIRED);
// Logging version history for the update operation
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest)
.actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity)