update 每周不同层级课例数据

develop
hhb@hotmail.com 1 month ago
parent be289caf37
commit a9c6c6a499

@ -17,10 +17,12 @@ import cn.teammodel.utils.GroupUtil;
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.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -136,7 +138,13 @@ public class TeacherServiceImpl implements TeacherService {
Map<Long, Integer> countByWeek = SchoolDateUtil.createEmptyWeekMap(totalWeek);
do {
if(StringUtils.isNotEmpty(teacherDto.getGrade())) {
slice = lessonRecordRepository.findAllByGrade(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getGrade(),pageRequest);
} else if(StringUtils.isNotEmpty(teacherDto.getTmdId())) {
slice = lessonRecordRepository.findAllByAcademicYearId(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getTmdId(),pageRequest);
} else {
slice = lessonRecordRepository.findAll(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), pageRequest);
}
List<LessonRecord> content = slice.getContent();
if (ObjectUtils.isEmpty(content)) {
break;

@ -16,4 +16,6 @@ public class TeacherDto {
@ApiModelProperty("学段Id")
public String periodId;
public Integer year;
@ApiModelProperty("年级")
public String grade;
}

@ -21,5 +21,9 @@ public interface LessonRecordRepository extends CosmosRepository<LessonRecord, S
@Query("select * from LessonRecord as c where c.code = @code and c.expire<=0 and c.status<>404 and c.tmdid = @tmdId ")
Slice<LessonRecord> findAllByAcademicYearId(String code, String tmdId,Pageable pageable);
@Query("select * from LessonRecord as c where c.code = @code and c.expire<=0 and c.status<>404 and array_contains(c.grade,@grade) ")
Slice<LessonRecord> findAllByGrade(String code, String grade,Pageable pageable);
@Query("select * from LessonRecord as c where c.code = @code and c.expire<=0 and c.status<>404 ")
Slice<LessonRecord> findAll(String code,Pageable pageable);
}

Loading…
Cancel
Save