feat: 新增后台条件查询值周评价

11111
winter 12 months ago
parent 2fb38aa62c
commit 70ffad27a3

@ -13,8 +13,6 @@ import javax.validation.constraints.NotNull;
public class AdminFindDutyRecordDto {
@ApiModelProperty("老师 id")
private String teacherId;
@ApiModelProperty("学生 id")
private String studentId;
@ApiModelProperty(value = "班级 id", notes = "若不携带默认不指定某个班级")
private String classId;
@ApiModelProperty(required = true)

@ -19,7 +19,7 @@ public interface DutyRecordRepository extends CosmosRepository<WeekDutyRecord, S
@Query(value = "SELECT c.id as recordId, c.classId, c.className, n as info FROM c join n in c.nodes WHERE " +
"c.code = @code " +
"AND c.academicYearId = @academicYearId " +
"AND n.creatorId = @userId " +
"AND (IS_NULL(@userId) or n.creatorId = @userId) " +
"AND (IS_NULL(@classId) or c.classId = @classId) " +
"AND (IS_NULL(@positive) or n.dutyTreeNode.positive = @positive) " +
"AND (IS_NULL(@startTime) or n.createTime >= @startTime) " +

@ -1,5 +1,6 @@
package cn.teammodel.service.impl;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.lang.UUID;
import cn.teammodel.common.ErrorCode;
import cn.teammodel.common.PK;
@ -25,8 +26,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.time.Instant;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@ -326,15 +327,9 @@ public class DutyServiceImpl implements DutyService {
List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, periodId);
String academicYearId = SchoolDateUtil.calculateAcademicYearId(semesters, LocalDate.now());
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();
}
Pair<Long, Long> pair = SchoolDateUtil.adjustTimeRangeToCurrentWeekIfNull(startTime, endTime);
startTime = pair.getKey();
endTime = pair.getValue();
List<DutyRecordVo> records = dutyRecordRepository.findRecordsByConditions(
String.format(PK.WEEK_DUTY_RECORD, schoolId),
academicYearId,
@ -371,7 +366,28 @@ public class DutyServiceImpl implements DutyService {
@Override
public List<DutyRecordVo> findAdminRecords(AdminFindDutyRecordDto adminFindDutyRecordDto) {
return null;
String teacherId = adminFindDutyRecordDto.getTeacherId();
String classId = adminFindDutyRecordDto.getClassId();
String academicYearId = adminFindDutyRecordDto.getAcademicYearId();
Boolean positive = adminFindDutyRecordDto.getPositive();
Long startTime = adminFindDutyRecordDto.getStartTime();
Long endTime = adminFindDutyRecordDto.getEndTime();
User user = SecurityUtil.getLoginUser();
String schoolId = user.getSchoolId();
Pair<Long, Long> pair = SchoolDateUtil.adjustTimeRangeToCurrentWeekIfNull(startTime, endTime);
startTime = pair.getKey();
endTime = pair.getValue();
List<DutyRecordVo> records = dutyRecordRepository.findRecordsByConditions(
String.format(PK.WEEK_DUTY_RECORD, schoolId),
academicYearId,
teacherId,
classId,
positive,
startTime,
endTime);
records = records.stream().sorted((o1, o2) -> o2.getInfo().getCreateTime().compareTo(o1.getInfo().getCreateTime())).collect(Collectors.toList());
return records;
}
/**

@ -1,5 +1,6 @@
package cn.teammodel.utils;
import cn.hutool.core.lang.Pair;
import cn.teammodel.common.CommonConstant;
import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.model.entity.school.School;
@ -128,6 +129,19 @@ public class SchoolDateUtil {
return initialMap;
}
public static Pair<Long, Long> adjustTimeRangeToCurrentWeekIfNull(Long startTime, Long endTime) {
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();
}
return new Pair<>(startTime, endTime);
}
@Data
@AllArgsConstructor

Loading…
Cancel
Save