Merge remote-tracking branch 'origin/dev' into 112-ping-stats
This commit is contained in:
commit
bdb8fd8ce4
@ -236,10 +236,8 @@ public class GrantService extends BaseService {
|
|||||||
|
|
||||||
private boolean checkSameDeadline(GrantDto grantDto, Integer id) {
|
private boolean checkSameDeadline(GrantDto grantDto, Integer id) {
|
||||||
Date date = grantDto.getDeadlines().get(0).getDate(); //дата с сайта киас
|
Date date = grantDto.getDeadlines().get(0).getDate(); //дата с сайта киас
|
||||||
if (deadlineService.findByGrantIdAndDate(id, date).compareTo(date) == 0) { //если есть такая строка с датой
|
Date foundGrantDate = deadlineService.findByGrantIdAndDate(id, date);
|
||||||
return true;
|
return foundGrantDate != null && foundGrantDate.compareTo(date) == 0;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getGrantAuthors(GrantDto grantDto) {
|
public List<User> getGrantAuthors(GrantDto grantDto) {
|
||||||
|
@ -17,6 +17,8 @@ import ru.ulstu.user.model.UserDto;
|
|||||||
import ru.ulstu.user.service.UserService;
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -103,9 +105,13 @@ public class EventService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createFromPaper(Paper newPaper) {
|
public void createFromPaper(Paper newPaper) {
|
||||||
|
createFromPaper(newPaper, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createFromPaper(Paper newPaper, List<Event> events) {
|
||||||
List<Timeline> timelines = timelineService.findAll();
|
List<Timeline> timelines = timelineService.findAll();
|
||||||
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
|
Timeline timeline = timelines.isEmpty() ? new Timeline() : timelines.get(0);
|
||||||
|
timeline.getEvents().removeAll(events);
|
||||||
for (Deadline deadline : newPaper.getDeadlines()
|
for (Deadline deadline : newPaper.getDeadlines()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(d -> d.getDate().after(new Date()) || DateUtils.isSameDay(d.getDate(), new Date()))
|
.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.setDescription("Дедлайн '" + deadline.getDescription() + "' cтатьи '" + newPaper.getTitle() + "'");
|
||||||
newEvent.setRecipients(new ArrayList(newPaper.getAuthors()));
|
newEvent.setRecipients(new ArrayList(newPaper.getAuthors()));
|
||||||
newEvent.setPaper(newPaper);
|
newEvent.setPaper(newPaper);
|
||||||
eventRepository.save(newEvent);
|
timeline.getEvents().add(eventRepository.save(newEvent));
|
||||||
|
|
||||||
timeline.getEvents().add(newEvent);
|
|
||||||
timelineService.save(timeline);
|
|
||||||
}
|
}
|
||||||
|
timelineService.save(timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePaperDeadlines(Paper paper) {
|
public void updatePaperDeadlines(Paper paper) {
|
||||||
eventRepository.delete(eventRepository.findAllByPaper(paper));
|
List<Event> foundEvents = eventRepository.findAllByPaper(paper);
|
||||||
|
eventRepository.delete(foundEvents);
|
||||||
createFromPaper(paper);
|
createFromPaper(paper, foundEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Event> findByCurrentDate() {
|
public List<Event> findByCurrentDate() {
|
||||||
|
Loading…
Reference in New Issue
Block a user