Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1b2db5b5d4
@ -23,7 +23,11 @@ import java.util.Set;
|
||||
@Entity
|
||||
public class Paper extends BaseEntity implements UserContainer {
|
||||
public enum PaperStatus {
|
||||
ATTENTION("Обратить внимание"), ON_PREPARATION("На подготовке"), DRAFT("Черновик"), COMPLETED("Завершена");
|
||||
ATTENTION("Обратить внимание"),
|
||||
ON_PREPARATION("На подготовке"),
|
||||
DRAFT("Черновик"),
|
||||
COMPLETED("Завершена"),
|
||||
FAILED("Провалены сроки");
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -55,4 +55,11 @@ public class PaperNotificationService {
|
||||
mailService.sendEmailFromTemplate(variables, author, "paperStatusChangeNotification", "Изменился статус статьи");
|
||||
});
|
||||
}
|
||||
|
||||
public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) {
|
||||
Map<String, Object> variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus);
|
||||
paper.getAuthors().forEach(author -> {
|
||||
mailService.sendEmailFromTemplate(variables, author, "paperFailedNotification", "Статья провалена");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,15 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DeadlineScheduler {
|
||||
public class PaperScheduler {
|
||||
private final static boolean IS_DEADLINE_NOTIFICATION_BEFORE_WEEK = true;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(DeadlineScheduler.class);
|
||||
private final Logger log = LoggerFactory.getLogger(PaperScheduler.class);
|
||||
|
||||
private final PaperNotificationService paperNotificationService;
|
||||
private final PaperService paperService;
|
||||
|
||||
public DeadlineScheduler(PaperNotificationService paperNotificationService,
|
||||
public PaperScheduler(PaperNotificationService paperNotificationService,
|
||||
PaperService paperService) {
|
||||
this.paperNotificationService = paperNotificationService;
|
||||
this.paperService = paperService;
|
||||
@ -23,15 +23,22 @@ public class DeadlineScheduler {
|
||||
|
||||
@Scheduled(cron = "0 0 8 * 1 ?")
|
||||
public void checkDeadlineBeforeWeek() {
|
||||
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek started");
|
||||
log.debug("PaperScheduler.checkDeadlineBeforeWeek started");
|
||||
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), !IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("DeadlineScheduler.checkDeadlineBeforeWeek finished");
|
||||
log.debug("PaperScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
public void checkDeadlineAfterWeek() {
|
||||
log.debug("DeadlineScheduler.checkDeadlineAfterWeek started");
|
||||
log.debug("PaperScheduler.checkDeadlineAfterWeek started");
|
||||
paperNotificationService.sendDeadlineNotifications(paperService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("DeadlineScheduler.checkDeadlineAfterWeek finished");
|
||||
log.debug("PaperScheduler.checkDeadlineAfterWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 6 * * ?")
|
||||
public void closeFailedPapers() {
|
||||
log.debug("PaperScheduler.closeFailedPapers started");
|
||||
paperService.closeFailedPapers();
|
||||
log.debug("PaperScheduler.closeFailedPapers finished");
|
||||
}
|
||||
}
|
@ -18,6 +18,9 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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.DRAFT;
|
||||
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
||||
|
||||
@Service
|
||||
public class PaperService {
|
||||
@ -65,7 +68,7 @@ public class PaperService {
|
||||
paper.setComment(paperDto.getComment());
|
||||
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
|
||||
paper.setLocked(paperDto.getLocked());
|
||||
paper.setStatus(paperDto.getStatus() == null ? Paper.PaperStatus.DRAFT : paperDto.getStatus());
|
||||
paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());
|
||||
paper.setTitle(paperDto.getTitle());
|
||||
paper.setUpdateDate(new Date());
|
||||
paper.setDeadlineDate(paperDto.getDeadlineDate());
|
||||
@ -115,7 +118,7 @@ public class PaperService {
|
||||
paper.setDeadlineDate(deadlineDate);
|
||||
paper.setCreateDate(new Date());
|
||||
paper.setUpdateDate(new Date());
|
||||
paper.setStatus(Paper.PaperStatus.DRAFT);
|
||||
paper.setStatus(DRAFT);
|
||||
paper = paperRepository.save(paper);
|
||||
|
||||
paperNotificationService.sendCreateNotification(paper);
|
||||
@ -126,4 +129,21 @@ public class PaperService {
|
||||
public List<PaperDto> filter(PaperFilterDto filterDto) {
|
||||
return convert(paperRepository.filter(userService.findById(filterDto.getAuthorId()), filterDto.getYear()), PaperDto::new);
|
||||
}
|
||||
|
||||
public void closeFailedPapers() {
|
||||
List<Paper> papers = paperRepository.findAll()
|
||||
.stream()
|
||||
.filter(paper -> paper.getDeadlineDate() != null
|
||||
&& (paper.getStatus() == ON_PREPARATION
|
||||
|| paper.getStatus() == DRAFT
|
||||
|| paper.getStatus() == ATTENTION)
|
||||
&& paper.getDeadlineDate().before(new Date()))
|
||||
.collect(Collectors.toList());
|
||||
papers.forEach(paper -> {
|
||||
Paper.PaperStatus oldStatus = paper.getStatus();
|
||||
paper.setStatus(Paper.PaperStatus.FAILED);
|
||||
paperRepository.save(paper);
|
||||
paperNotificationService.sendFailedNotification(paper, oldStatus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Уведомление о провале статьи</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="shortcut icon" th:href="@{|${baseUrl}/favicon.ico|}"/>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Уважаемый(ая) <span th:text="${user.firstName + ' ' + user.lastName}">Ivan Ivanov</span>
|
||||
</p>
|
||||
<p>
|
||||
Статья "<span th:text="${paper.title}">Title</span>" провалена.
|
||||
Предыдущий статус - "<span th:text="${oldStatus.name}">oldStatus</span>".
|
||||
</p>
|
||||
<p>
|
||||
Regards,
|
||||
<br/>
|
||||
<em>NG-tracker.</em>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -13,6 +13,20 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Dashboard</h2>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./grants" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
|
||||
Список</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||
aria-hidden="true"></i> Панель управления</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./grant" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
|
||||
Добавить грант</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
|
201
src/main/resources/templates/grants/grant.html
Normal file
201
src/main/resources/templates/grants/grant.html
Normal file
@ -0,0 +1,201 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorator="default">
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container" layout:fragment="content">
|
||||
|
||||
<section id="paper">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Редактирование гранта</h2>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./grants" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
|
||||
Список</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||
aria-hidden="true"></i> Панель управления</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./grant" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
|
||||
Добавить грант</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form id="contactForm" name="sentMessage" novalidate="">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label for="name">Название:</label>
|
||||
<input class="form-control" id="name" type="text" placeholder="Название гранта"
|
||||
required="" data-validation-required-message="Введите название гранта"/>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="status">Статус:</label>
|
||||
<select class="form-control" id="status">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="comment">Комментарий:</label>
|
||||
<textarea class="form-control" rows="3" id="comment"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Дедлайн:</label>
|
||||
<input type="date" class="form-control" name="deadline"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="loader">Загрузить заявку:</label>
|
||||
<div id="loader">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Список статей:</label>
|
||||
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
|
||||
</i> Добавить статью</a></p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>К этому гранту привязан проект:</label>
|
||||
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
|
||||
</i> Добавить проект</a></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Научные показатели:</label>
|
||||
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
|
||||
</i> Добавить показатель</a></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Публикационные показатели:</label>
|
||||
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
|
||||
</i> Добавить показатель</a></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Последнее изменение:</label>
|
||||
<input type="date" class="form-control" name="date-update"/>
|
||||
</div>
|
||||
<p><a href="#myModal1" class="btn btn-primary" data-toggle="modal">Редактировать
|
||||
участников гранта</a></p>
|
||||
<div id="myModal1" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×
|
||||
</button>
|
||||
<h4 class="modal-title">Авторы статьи</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Фамилия</th>
|
||||
<th>Имя</th>
|
||||
<th>Отчество</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Иванов</td>
|
||||
<td>Иван</td>
|
||||
<td>Иванович</td>
|
||||
<td>
|
||||
<span class="table-remove"><button type="button"
|
||||
class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>text</td>
|
||||
<td>text</td>
|
||||
<td>text</td>
|
||||
<td>
|
||||
<span class="table-remove"><button type="button"
|
||||
class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
|
||||
</td>
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle"
|
||||
type="button" data-toggle="dropdown">Выберите автора
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<input class="form-control" id="myInput" type="text"
|
||||
placeholder="Search.."/>
|
||||
<li><a href="#">Иванов</a></li>
|
||||
<li><a href="#">Смирнов</a></li>
|
||||
<li><a href="#">Кузнецов</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary">Сохранить изменения
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<button id="sendMessageButton" class="btn btn-success text-uppercase"
|
||||
type="submit">
|
||||
Сохранить
|
||||
</button>
|
||||
<button id="cancelButton" class="btn btn-default text-uppercase" type="button">
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script type="text/javascript" src="/js/file-loader.js"></script>
|
||||
<script src="/js/papers.js"></script>
|
||||
<script>
|
||||
/*<![CDATA[*/
|
||||
$(document).ready(function () {
|
||||
new FileLoader({
|
||||
div: "loader",
|
||||
url: urlFileUpload,
|
||||
maxSize: 1.5,
|
||||
extensions: ["doc", "docx", "xls", "jpg", "pdf", "txt", "png"],
|
||||
callback: function (response) {
|
||||
showFeedbackMessage("Файл успешно загружен");
|
||||
console.debug(response);
|
||||
}
|
||||
});
|
||||
|
||||
getFromRest(urlPaperStatuses, function (response) {
|
||||
fillSelect($("#status"), response);
|
||||
});
|
||||
});
|
||||
/*]]>*/
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorator="default">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container" layout:fragment="content">
|
||||
<section id="papers">
|
||||
<div class="container">
|
||||
<div class="row" id="paper-list">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Пустая страница</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user