fix grant doubling cause date comparison
This commit is contained in:
parent
2012a58fc2
commit
ff19001f1f
@ -16,7 +16,7 @@ public class DateUtils {
|
||||
public static Date clearTime(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.HOUR, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
@ -20,7 +20,7 @@ public class Deadline extends BaseEntity {
|
||||
|
||||
private String description;
|
||||
|
||||
@Temporal(value = TemporalType.TIMESTAMP)
|
||||
@Temporal(value = TemporalType.DATE)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date date;
|
||||
|
||||
|
@ -3,14 +3,13 @@ package ru.ulstu.deadline.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface DeadlineRepository extends JpaRepository<Deadline, Integer> {
|
||||
|
||||
@Query(
|
||||
value = "SELECT date FROM Deadline d WHERE (d.grant_id = ?1) AND (d.date = ?2)",
|
||||
nativeQuery = true)
|
||||
Date findByGrantIdAndDate(Integer grantId, Date date);
|
||||
@Query("SELECT d.date FROM Grant g JOIN g.deadlines d WHERE (g.id = :id) AND (d.date = :date)")
|
||||
Date findByGrantIdAndDate(@Param("id") Integer grantId, @Param("date") Date date);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.Errors;
|
||||
import ru.ulstu.core.util.DateUtils;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.file.model.FileDataDto;
|
||||
@ -223,8 +224,8 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
|
||||
private boolean checkSameDeadline(GrantDto grantDto, Integer id) {
|
||||
Date date = grantDto.getDeadlines().get(0).getDate(); //дата с сайта киас
|
||||
Date foundGrantDate = deadlineService.findByGrantIdAndDate(id, date);
|
||||
Date date = DateUtils.clearTime(grantDto.getDeadlines().get(0).getDate()); //дата с сайта киас
|
||||
Date foundGrantDate = DateUtils.clearTime(deadlineService.findByGrantIdAndDate(id, date));
|
||||
return foundGrantDate != null && foundGrantDate.compareTo(date) == 0;
|
||||
}
|
||||
|
||||
|
@ -26,4 +26,10 @@
|
||||
newDataType="text"
|
||||
schemaName="public"/>
|
||||
</changeSet>
|
||||
<changeSet author="orion" id="20190525_000000-5">
|
||||
<modifyDataType tableName="deadline"
|
||||
columnName="date"
|
||||
newDataType="date"
|
||||
schemaName="public"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
|
@ -5,34 +5,34 @@
|
||||
</head>
|
||||
<body>
|
||||
<span th:fragment="paperStatus (paperStatus, title, small)" class="fa-stack fa-1x">
|
||||
<th:block th:switch="${paperStatus.name()}">
|
||||
<th:block th:switch="${paperStatus.name()}" >
|
||||
<div th:case="'ATTENTION'">
|
||||
<i class="fa fa-circle text-warning" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-warning" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'DRAFT'">
|
||||
<i class="fa fa-circle fa-stack-2x text-draft" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-draft" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'ON_PREPARATION'">
|
||||
<i class="fa fa-circle fa-stack-2x text-primary" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-primary" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'ON_REVIEW'">
|
||||
<i class="fa fa-circle fa-stack-2x text-review" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-review" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'COMPLETED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-success" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-success" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'FAILED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-failed" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-failed" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'ACCEPTED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-accepted" th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
<i class="fa fa-circle text-accepted" th:classappend="${small} ? fa-stack-1x : fa-stack-2x" th:title="${title}"></i>
|
||||
</div>
|
||||
<div th:case="'NOT_ACCEPTED'">
|
||||
<i class="fa fa-circle fa-stack-2x text-not-accepted"
|
||||
<i class="fa fa-circle text-not-accepted"
|
||||
th:classappend="${small} ? fa-stack-1x : fa-stack-2x"></i>
|
||||
</div>
|
||||
</th:block>
|
||||
<i class="fa fa-file-text-o fa-stack-1x fa-inverse" th:title="${title}"></i>
|
||||
<i th:if="not ${small}" class="fa fa-file-text-o fa-stack-1x fa-inverse" th:title="${title}"></i>
|
||||
</span>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user