#70 added schedule for deadline of conference
This commit is contained in:
parent
16e9bf1fb5
commit
34925b81ff
@ -39,7 +39,7 @@ public class ConferenceNotificationService {
|
||||
conferences
|
||||
.stream()
|
||||
.filter(conference -> needToSendDeadlineNotification(conference, now, isDeadlineBeforeWeek))
|
||||
.forEach(conference -> sendMessageDeadline(conference));
|
||||
.forEach(this::sendMessageDeadline);
|
||||
}
|
||||
|
||||
private boolean needToSendDeadlineNotification(Conference conference, Date compareDate, boolean isDeadlineBeforeWeek) {
|
||||
@ -69,16 +69,6 @@ public class ConferenceNotificationService {
|
||||
sendForAllParticipals(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle()));
|
||||
}
|
||||
|
||||
// public void statusChangeNotification(Paper paper, Paper.PaperStatus oldStatus) {
|
||||
// Map<String, Object> variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus);
|
||||
// sendForAllParticipals(variables, paper, TEMPLATE_STATUS_CHANGED, TITLE_STATUS_CHANGED);
|
||||
// }
|
||||
//
|
||||
// public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) {
|
||||
// Map<String, Object> variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus);
|
||||
// sendForAllParticipals(variables, paper, TEMPLATE_FAILED, TITLE_FAILED);
|
||||
// }
|
||||
|
||||
private void sendForAllUsers(Map<String, Object> variables, String template, String title) {
|
||||
userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, template, title));
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package ru.ulstu.conference.service;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ConferenceScheduler {
|
||||
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ConferenceScheduler.class);
|
||||
|
||||
private final ConferenceNotificationService conferenceNotificationService;
|
||||
private final ConferenceService conferenceService;
|
||||
|
||||
public ConferenceScheduler(ConferenceNotificationService conferenceNotificationService,
|
||||
ConferenceService conferenceService) {
|
||||
this.conferenceNotificationService = conferenceNotificationService;
|
||||
this.conferenceService = conferenceService;
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0 21-22 * * *", zone = "Europe/Samara")
|
||||
public void checkDeadlineBeforeWeek() {
|
||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek started");
|
||||
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("ConferenceScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 21-22 * * ?", zone = "Europe/Samara")
|
||||
public void checkDeadlineAfterWeek() {
|
||||
log.debug("ConferenceScheduler.checkDeadlineAfterWeek started");
|
||||
conferenceNotificationService.sendDeadlineNotifications(conferenceService.findAll(), !IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("ConferenceScheduler.checkDeadlineAfterWeek finished");
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Уведомление о дедлайне конференции</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="shortcut icon" th:href="@{|${baseUrl}/favicon.ico|}"/>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Уважаемый(ая) <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span>
|
||||
</p>
|
||||
<p>
|
||||
Приближается дедлайн конференции "<a th:href="@{|${baseUrl}/conferences/conference?id=${conference.id}|}">
|
||||
<span th:text="${conference.title}">Title</span></a>".
|
||||
</p>
|
||||
<p>
|
||||
Срок исполнения: <b><span th:text="${#dates.format(conference.nextDeadline.get().date, 'dd.MM.yyyy')}"></span></b>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Примечание: <b><span th:text="${conference.nextDeadline.get().description}"></span></b>.
|
||||
</p>
|
||||
<p>
|
||||
Regards,
|
||||
<br/>
|
||||
<em>NG-tracker.</em>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user