Merge remote-tracking branch 'origin/dev' into 112-ping-stats

This commit is contained in:
Artem.Arefev 2019-06-05 18:12:38 +04:00
commit bdb8fd8ce4
2 changed files with 14 additions and 12 deletions

View File

@ -236,10 +236,8 @@ public class GrantService extends BaseService {
private boolean checkSameDeadline(GrantDto grantDto, Integer id) {
Date date = grantDto.getDeadlines().get(0).getDate(); //дата с сайта киас
if (deadlineService.findByGrantIdAndDate(id, date).compareTo(date) == 0) { //если есть такая строка с датой
return true;
}
return false;
Date foundGrantDate = deadlineService.findByGrantIdAndDate(id, date);
return foundGrantDate != null && foundGrantDate.compareTo(date) == 0;
}
public List<User> getGrantAuthors(GrantDto grantDto) {

View File

@ -17,6 +17,8 @@ import ru.ulstu.user.model.UserDto;
import ru.ulstu.user.service.UserService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -103,9 +105,13 @@ public class EventService {
}
public void createFromPaper(Paper newPaper) {
createFromPaper(newPaper, Collections.emptyList());
}
public void createFromPaper(Paper newPaper, List<Event> events) {
List<Timeline> timelines = timelineService.findAll();
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
timeline.getEvents().removeAll(events);
for (Deadline deadline : newPaper.getDeadlines()
.stream()
.filter(d -> d.getDate().after(new Date()) || DateUtils.isSameDay(d.getDate(), new Date()))
@ -119,17 +125,15 @@ public class EventService {
newEvent.setDescription("Дедлайн '" + deadline.getDescription() + "' cтатьи '" + newPaper.getTitle() + "'");
newEvent.setRecipients(new ArrayList(newPaper.getAuthors()));
newEvent.setPaper(newPaper);
eventRepository.save(newEvent);
timeline.getEvents().add(newEvent);
timelineService.save(timeline);
timeline.getEvents().add(eventRepository.save(newEvent));
}
timelineService.save(timeline);
}
public void updatePaperDeadlines(Paper paper) {
eventRepository.delete(eventRepository.findAllByPaper(paper));
createFromPaper(paper);
List<Event> foundEvents = eventRepository.findAllByPaper(paper);
eventRepository.delete(foundEvents);
createFromPaper(paper, foundEvents);
}
public List<Event> findByCurrentDate() {