fix failed conditions

This commit is contained in:
Anton Romanov 2019-01-17 00:57:34 +04:00
parent c17591bf10
commit 779bc3eafc
3 changed files with 12 additions and 4 deletions

View File

@ -169,4 +169,13 @@ public class Paper extends BaseEntity implements UserContainer {
.filter(d -> d.getDate().after(new Date())) .filter(d -> d.getDate().after(new Date()))
.findFirst(); .findFirst();
} }
public boolean lastDeadlineFailed() {
return !deadlines
.stream()
.filter(deadline -> deadline.getDate() != null)
.filter(d -> d.getDate().after(new Date()))
.findAny()
.isPresent();
}
} }

View File

@ -166,11 +166,10 @@ public class PaperService {
public void closeFailedPapers() { public void closeFailedPapers() {
List<Paper> papers = paperRepository.findAll() List<Paper> papers = paperRepository.findAll()
.stream() .stream()
.filter(paper -> paper.getNextDeadline().isPresent() .filter(paper -> paper.lastDeadlineFailed()
&& (paper.getStatus() == ON_PREPARATION && (paper.getStatus() == ON_PREPARATION
|| paper.getStatus() == DRAFT || paper.getStatus() == DRAFT
|| paper.getStatus() == ATTENTION) || paper.getStatus() == ATTENTION))
&& paper.getNextDeadline().get().getDate().before(new Date()))
.collect(Collectors.toList()); .collect(Collectors.toList());
papers.forEach(paper -> { papers.forEach(paper -> {
Paper.PaperStatus oldStatus = paper.getStatus(); Paper.PaperStatus oldStatus = paper.getStatus();

View File

@ -11,7 +11,7 @@
</p> </p>
<p> <p>
Статья "<span th:text="${paper.title}">Title</span>" провалена. Статья "<span th:text="${paper.title}">Title</span>" провалена.
Предыдущий статус - "<span th:text="${oldStatus.name}">oldStatus</span>". Предыдущий статус - "<span th:text="${oldStatus.statusName}">oldStatus</span>".
</p> </p>
<p> <p>
Regards, Regards,