@ -3,7 +3,6 @@ package cn.teammodel.controller.admin.service.impl;
import cn.hutool.core.lang.Pair ;
import cn.teammodel.common.ErrorCode ;
import cn.teammodel.common.PK ;
import cn.teammodel.common.PageVo ;
import cn.teammodel.config.exception.ServiceException ;
import cn.teammodel.controller.admin.service.AdminAppraiseService ;
import cn.teammodel.dao.* ;
@ -23,13 +22,12 @@ import cn.teammodel.utils.SchoolDateUtil;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest ;
import org.apache.commons.lang3.ObjectUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.data.domain.Page ;
import org.springframework.data.domain.Slice ;
import org.springframework.stereotype.Service ;
import javax.annotation.Resource ;
import java.time. LocalDate ;
import java.time. LocalDateTime ;
import java.time. * ;
import java.time. temporal.TemporalAdjusters ;
import java.util.* ;
import java.util.stream.Collectors ;
@ -126,23 +124,33 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
}
@Override
public PageVo < RecordVo > conditionLatestRecord ( TimeRangeDto timeRangeDto ) {
public List < RecordVo > conditionLatestRecord ( TimeRangeDto timeRangeDto ) {
Long startTime = timeRangeDto . getStartTime ( ) ;
Long endTime = timeRangeDto . getEndTime ( ) ;
String academicYearId = timeRangeDto . getAcademicYearId ( ) ;
Integer current = timeRangeDto . getCurrent ( ) ;
Integer size = timeRangeDto . getSize ( ) ;
String schoolId = SecurityUtil . getLoginUser ( ) . getSchoolId ( ) ;
final CosmosPageRequest pageRequest = new CosmosPageRequest ( current , size , null ) ;
Page < RecordVo > page = appraiseRecordRepository . pageLatestRecords (
// fixme: 是否对时间范围做一些限制
// 无参默认当前周
if ( startTime = = null | | endTime = = null ) {
// 将时间范围调整为当前周的周一到当前时间
LocalDateTime mondayOfCurWeek = LocalDateTime . now ( ) . with ( TemporalAdjusters . previousOrSame ( DayOfWeek . MONDAY ) )
. withHour ( 0 )
. withMinute ( 0 )
. withSecond ( 0 )
. withNano ( 0 ) ;
startTime = mondayOfCurWeek . atZone ( ZoneOffset . systemDefault ( ) ) . toInstant ( ) . toEpochMilli ( ) ;
endTime = Instant . now ( ) . toEpochMilli ( ) ;
}
List < RecordVo > res = appraiseRecordRepository . latestRecords (
String . format ( PK . PK_APPRAISE_RECORD , schoolId ) ,
academicYearId ,
startTime ,
endTime ,
pageRequest ) ;
endTime
) ;
return new PageVo < > ( page . getTotalPages ( ) , page . getTotalElements ( ) , page . getContent ( ) ) ;
return res ;
}
@Override