学年
This commit is contained in:
@@ -62,15 +62,14 @@ public class BaseYearTermService implements IBaseYearTermService {
|
||||
public BaseYearTerm getNowYearTerm() {
|
||||
Date now = new Date();
|
||||
List<BaseYearTerm> yearTermList = getAllYearTerm();
|
||||
// 升学以 upgradeDate 当天 06:00:00 为界:6点之前算上学期(当前 active 学年),6点(含)之后算新学期
|
||||
// 取 upgradeDate@06:00 倒序后第一个 boundary <= now 的学年(即 now 落在该学年 [上学年边界, 本学年边界) 区间内)
|
||||
// 上学期升学日期@06:00 <= now < 本学期升学日期@06:00:取 upgradeDate@06:00 升序后第一个严格大于 now 的学年
|
||||
return yearTermList.stream()
|
||||
.sorted(Comparator.comparing(
|
||||
(BaseYearTerm s) -> toUpgradeBoundary(s.getUpgradeDate()),
|
||||
Comparator.nullsLast(Comparator.naturalOrder())))
|
||||
.filter(s -> {
|
||||
Date boundary = toUpgradeBoundary(s.getUpgradeDate());
|
||||
return boundary != null && boundary.compareTo(now) <= 0;
|
||||
return boundary != null && boundary.compareTo(now) > 0;
|
||||
})
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new DException("获取学年失败,当前时间不在当学年时间范围"));
|
||||
|
||||
Reference in New Issue
Block a user