|
|
|
@ -189,15 +189,30 @@ public class GrantService extends BaseService {
|
|
|
|
|
if (errors.hasErrors()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isEmpty(grantDto.getId())) {
|
|
|
|
|
create(grantDto);
|
|
|
|
|
} else {
|
|
|
|
|
update(grantDto);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean saveFromKias(GrantDto grantDto) throws IOException {
|
|
|
|
|
grantDto.setName(grantDto.getTitle());
|
|
|
|
|
String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени
|
|
|
|
|
if (title != null) {
|
|
|
|
|
Grant grantFromDB = grantRepository.findByTitle(title); //грант с таким же названием из бд
|
|
|
|
|
if (checkSameDeadline(grantDto, grantFromDB.getId())) { //если дедайны тоже совпадают
|
|
|
|
|
return false;
|
|
|
|
|
} else { //иначе грант уже был в системе, но в другом году, поэтому надо создать
|
|
|
|
|
create(grantDto);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else { //иначе такого гранта ещё нет, поэтому надо создать
|
|
|
|
|
create(grantDto);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkEmptyLeader(GrantDto grantDto, Errors errors) {
|
|
|
|
|
if (grantDto.getLeaderId().equals(-1)) {
|
|
|
|
@ -211,6 +226,14 @@ 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<User> getGrantAuthors(GrantDto grantDto) {
|
|
|
|
|
List<User> filteredUsers = userService.filterByAgeAndDegree(grantDto.isHasAge(), grantDto.isHasDegree());
|
|
|
|
|
if (grantDto.isWasLeader()) {
|
|
|
|
|