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