|
|
|
@ -24,7 +24,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
import static org.springframework.util.ObjectUtils.isEmpty;
|
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
|
import static ru.ulstu.paper.model.Paper.PaperStatus.ATTENTION;
|
|
|
|
|
import static ru.ulstu.paper.model.Paper.PaperStatus.COMPLETED;
|
|
|
|
|
import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT;
|
|
|
|
|
import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED;
|
|
|
|
|
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -59,6 +61,13 @@ public class PaperService {
|
|
|
|
|
return papers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<PaperDto> findAllActive() {
|
|
|
|
|
return findAllDto()
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PaperDto findOneDto(Integer id) {
|
|
|
|
|
return new PaperDto(paperRepository.findOne(id));
|
|
|
|
|
}
|
|
|
|
@ -166,11 +175,10 @@ public class PaperService {
|
|
|
|
|
public void closeFailedPapers() {
|
|
|
|
|
List<Paper> papers = paperRepository.findAll()
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(paper -> paper.getNextDeadline().isPresent()
|
|
|
|
|
.filter(paper -> paper.lastDeadlineFailed()
|
|
|
|
|
&& (paper.getStatus() == ON_PREPARATION
|
|
|
|
|
|| paper.getStatus() == DRAFT
|
|
|
|
|
|| paper.getStatus() == ATTENTION)
|
|
|
|
|
&& paper.getNextDeadline().get().getDate().before(new Date()))
|
|
|
|
|
|| paper.getStatus() == ATTENTION))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
papers.forEach(paper -> {
|
|
|
|
|
Paper.PaperStatus oldStatus = paper.getStatus();
|
|
|
|
|