fix
This commit is contained in:
parent
d0f40da30e
commit
450cb92d01
@ -25,33 +25,32 @@ public class DeadlineScheduler {
|
||||
this.paperRepository = paperRepository;
|
||||
this.mailService = mailService;
|
||||
}
|
||||
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
||||
|
||||
@Scheduled(cron = "0 0 8 * 1 ?")
|
||||
public void checkDeadlineBeforeWeek() {
|
||||
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek started");
|
||||
List<Paper> allPapers = paperRepository.findAll();
|
||||
for (Paper paper : allPapers) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DAY_OF_YEAR, 7);
|
||||
if (c.getTime().compareTo(paper.getDeadlineDate()) < 0) {
|
||||
sendMessageDeadline(paper);
|
||||
}
|
||||
}
|
||||
sendNotifications(IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
public void checkDeadlineAfterWeek() {
|
||||
log.debug("DeadlineScheduler.checkDeadlineAfterWeek started");
|
||||
sendNotifications(!IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
|
||||
}
|
||||
|
||||
private void sendNotifications(boolean isDeadlineBeforeWeek) {
|
||||
List<Paper> allPapers = paperRepository.findAll();
|
||||
for (Paper paper : allPapers) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DAY_OF_YEAR, 7);
|
||||
if (c.getTime().compareTo(paper.getDeadlineDate()) >= 0) {
|
||||
sendMessageDeadline(paper);
|
||||
if (((c.getTime().compareTo(paper.getDeadlineDate()) < 0) && isDeadlineBeforeWeek) ||
|
||||
(c.getTime().compareTo(paper.getDeadlineDate()) >= 0) && !isDeadlineBeforeWeek) {
|
||||
sendMessageDeadline(paper);
|
||||
}
|
||||
}
|
||||
log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
|
||||
}
|
||||
|
||||
private void sendMessageDeadline(Paper paper){
|
||||
|
Loading…
Reference in New Issue
Block a user