Resolve "Список периодических событий" #129

Merged
romanov73 merged 57 commits from 4-show-time-line into master 2018-10-30 23:32:01 +04:00
Showing only changes of commit 92f86e70c9 - Show all commits

View File

@ -27,38 +27,37 @@ public class DeadlineScheduler {
}
@Scheduled(cron = "0 0 8 * 1 ?")
public void sendMessageDeadlineBeforeWeek() {
log.debug("DeadlineSсheduler.sendMessageDeadlineBeforeWeek started");
public void checkDeadlineBeforeWeek() {
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek started");
List<Paper> allPapers = paperRepository.findAll();
for (Paper element : allPapers) {
for (Paper paper : allPapers) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, 7);
if (c.getTime().compareTo(element.getDeadlineDate()) < 0) {
List<User> users = element.getAuthors();
for (User user : users) {
mailService.sendEmail(user.getEmail(), "Приближается срок сдачи статьи",
"Срок сдачи статьи " + element.getTitle() + " " + element.getDeadlineDate().toString());
if (c.getTime().compareTo(paper.getDeadlineDate()) < 0) {
sendMessageDeadline(paper);
}
}
}
log.debug("DeadlineSсheduler.sendMessageDeadlineBeforeWeek finished");
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek finished");
}
@Scheduled(cron = "0 0 8 * * ?")
public void sendMessageDeadlineAfterWeek() {
log.debug("DeadlineSсheduler.sendMessageDeadlineAfterWeek started");
public void checkDeadlineAfterWeek() {
log.debug("DeadlineScheduler.checkDeadlineAfterWeek started");
List<Paper> allPapers = paperRepository.findAll();
for (Paper element : allPapers) {
for (Paper paper : allPapers) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_YEAR, 7);
if (c.getTime().compareTo(element.getDeadlineDate()) >= 0) {
List<User> users = element.getAuthors();
for (User user : users) {
if (c.getTime().compareTo(paper.getDeadlineDate()) >= 0) {
sendMessageDeadline(paper);
}
}
log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
}
private void sendMessageDeadline(Paper paper){
for (User user : paper.getAuthors()) {
mailService.sendEmail(user.getEmail(), "Приближается срок сдачи статьи",
"Срок сдачи статьи " + element.getTitle() + " " + element.getDeadlineDate().toString());
"Срок сдачи статьи " + paper.getTitle() + " " + paper.getDeadlineDate().toString());
}
}
}
log.debug("DeadlineSсheduler.sendMessageDeadlineAfterWeek finished");
}
}