update 教师看板个人数据

develop
hhb@hotmail.com 1 month ago
parent 3449d2bcbd
commit 1dcd782331

@ -18,6 +18,7 @@ public interface PK {
*/
String PK_APPRAISE_RECORD = "AppraiseRecord-%s";
String COMMON_BASE = "Base";
String PK_LESSON_RECORD = "LessonRecord-%s";
/**
* , id
*/

@ -35,5 +35,17 @@ public class TeacherController {
Map<String, Object> res = teacherService.getTeacherDetail(teacherDto,request);
return R.success(res);
}
@PostMapping("getTeacherCountRecordOfWeek")
@ApiOperation("获取当前学期指定教师每周课程数")
public R<Map<Long, Integer>> getTeacherCountRecordOfWeek(@Valid @RequestBody TeacherDto teacherDto) {
Map<Long, Integer> res = teacherService.getTeacherByRecord(teacherDto);
return R.success(res);
}
@PostMapping("getTeacherLearningCategoryCount")
@ApiOperation("获取指定教师教学法统计")
public R<Map<String, Object>> getTeacherLearningCategoryCount(@Valid @RequestBody TeacherDto teacherDto) {
Map<String, Object> res = teacherService.getTeacherLearningCategory(teacherDto);
return R.success(res);
}
}

@ -9,4 +9,6 @@ import java.util.Map;
public interface TeacherService {
List<Map<String,Integer>> getTeacherList(TeacherDto teacherDto);
Map<String,Object> getTeacherDetail(TeacherDto teacherDto, HttpServletRequest request);
Map<Long, Integer> getTeacherByRecord(TeacherDto teacherDto);
Map<String,Object> getTeacherLearningCategory(TeacherDto teacherDto);
}

@ -1,24 +1,36 @@
package cn.teammodel.controller.admin.service.impl;
import cn.teammodel.common.ErrorCode;
import cn.teammodel.common.PK;
import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.controller.admin.service.TeacherService;
import cn.teammodel.model.dto.admin.teacher.TeacherDto;
import cn.teammodel.model.entity.common.GroupList;
import cn.teammodel.model.entity.school.LessonRecord;
import cn.teammodel.model.entity.school.School;
import cn.teammodel.model.entity.school.SchoolTeacher;
import cn.teammodel.model.vo.appraise.RecordVo;
import cn.teammodel.repository.LessonRecordRepository;
import cn.teammodel.repository.SchoolGroupListRepository;
import cn.teammodel.repository.SchoolRepository;
import cn.teammodel.repository.SchoolTeacherRepository;
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.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.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.*;
import java.util.*;
import static cn.teammodel.utils.SchoolDateUtil.calculateWeekNum;
@Service
public class TeacherServiceImpl implements TeacherService {
@Resource
@ -27,6 +39,8 @@ public class TeacherServiceImpl implements TeacherService {
private SchoolTeacherRepository schoolTeacherRepository;
@Resource
private SchoolRepository schoolRepository;
@Resource
private LessonRecordRepository lessonRecordRepository;
@Autowired
private Environment env;
@Override
@ -95,6 +109,102 @@ public class TeacherServiceImpl implements TeacherService {
return teachers;
}
@Override
public Map<Long, Integer> getTeacherByRecord(TeacherDto teacherDto) {
final int SLICE_SIZE = 100;
// 获取学期起止时间
List<School.Semester> semesters = schoolRepository.findSemestersById(teacherDto.getCode(), teacherDto.getPeriodId());
SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now());
LocalDateTime startDatetime = null;
LocalDateTime endDatetime = null;
if(teacherDto.getStartTime() != null) {
startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(teacherDto.getStartTime()), ZoneId.systemDefault());
endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(teacherDto.getEndTime()), ZoneId.systemDefault());
}else {
startDatetime = semesterModel.getStartDatetime();
endDatetime = semesterModel.getEndDatetime();
}
if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR);
long totalWeek = calculateWeekNum(startDatetime, endDatetime, null);
// slice 分段读取
CosmosPageRequest pageRequest = new CosmosPageRequest(0, SLICE_SIZE, null);
Slice<LessonRecord> slice;
Map<Long, Integer> countByWeek = SchoolDateUtil.createEmptyWeekMap(totalWeek);
do {
slice = lessonRecordRepository.findAllByAcademicYearId(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getTmdId(),pageRequest);
List<LessonRecord> content = slice.getContent();
if (ObjectUtils.isEmpty(content)) {
break;
}
// 分批次计算
for (LessonRecord item : content) {
// 处理每周的课程数
long weekNum = calculateWeekNum(startDatetime, endDatetime, item.getStartTime());
countByWeek.put(weekNum, countByWeek.getOrDefault(weekNum, 0) + 1);
}
if (slice.hasNext()) {
pageRequest = (CosmosPageRequest) slice.nextPageable();
}
} while (slice.hasNext());
countByWeek.entrySet().removeIf(entry -> entry.getKey() == -1);
return countByWeek;
}
@Override
public Map<String, Object> getTeacherLearningCategory(TeacherDto teacherDto) {
Map<String, Object> LearningCategory = new HashMap<>(Collections.emptyMap());
try {
// 获取学期起止时间
List<School.Semester> semesters = schoolRepository.findSemestersById(teacherDto.getCode(), teacherDto.getPeriodId());
SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now());
LocalDateTime startDatetime = null;
LocalDateTime endDatetime = null;
if(teacherDto.getStartTime() != null) {
startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(teacherDto.getStartTime()), ZoneId.systemDefault());
endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(teacherDto.getEndTime()), ZoneId.systemDefault());
}else {
startDatetime = semesterModel.getStartDatetime();
endDatetime = semesterModel.getEndDatetime();
}
if (startDatetime == null || endDatetime == null) throw new ServiceException(ErrorCode.PARAMS_ERROR);
// 将 LocalDateTime 转换为 Long 类型的时间戳
long startTimestamp = startDatetime.toInstant(ZoneOffset.UTC).toEpochMilli();
long endTimestamp = endDatetime.toInstant(ZoneOffset.UTC).toEpochMilli();
List<LessonRecord> lessonRecords = lessonRecordRepository.getLessonsByConditions(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), startTimestamp, endTimestamp, teacherDto.getTmdId());
int cooperationCount = 0;
int internetCount = 0;
int taskCount = 0;
int examCount = 0;
int diffentialCount = 0;
for (LessonRecord record : lessonRecords) {
if (record.getLearningCategory() != null) {
cooperationCount += record.getLearningCategory().getCooperation();
internetCount += record.getLearningCategory().getInteraction();
taskCount += record.getLearningCategory().getTask();
examCount += record.getLearningCategory().getExam();
diffentialCount += record.getLearningCategory().getDiffential();
}
}
LearningCategory.put("cooperation", cooperationCount);
LearningCategory.put("internet", internetCount);
LearningCategory.put("task", taskCount);
LearningCategory.put("exam", examCount);
LearningCategory.put("diffential", diffentialCount);
}catch (Exception e) {
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误");
}
return LearningCategory;
}
private static @NotNull Map<String, Integer> getStringIntegerMap(List<School.Subject> subjects, List<SchoolTeacher> schoolTeachers) {
Map<String, String> subjectNameMap = new HashMap<>();
for (School.Subject subject : subjects) {

@ -11,8 +11,8 @@ public class TeacherDto {
public String school_code;
@ApiModelProperty("TmdId")
public String tmdId;
public long startTime;
public long endTime;
public Long startTime;
public Long endTime;
@ApiModelProperty("学段Id")
public String periodId;
}

@ -0,0 +1,268 @@
package cn.teammodel.model.entity.school;
import cn.teammodel.model.entity.BaseItem;
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Container(containerName = "School")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LessonRecord extends BaseItem {
/// <summary>
///必填 教师醍摩豆id
/// </summary>
public String tmdid ;
/// <summary>
/// 教师醍摩豆id名称
/// </summary>
public String tmdname ;
/// <summary>
/// 教师醍摩豆id名称
/// </summary>
public String tmdpicture ;
/// <summary>
///必填 课堂名称
/// </summary>
public String name ;
/// <summary>
///必填 scope==school必填 | String | 学校id
/// </summary>
public String school ;
/// <summary>
///必填 private/school|
/// </summary>
public String scope ;
/// <summary>
///必填 视频封面地址
/// </summary>
// public String poster ;
/// <summary>
///必填 开始时间(时间戳) 1606393763434
/// </summary>
public long startTime ;
/// <summary>
///必填 上课时长,最后更新
/// </summary>
public double duration ;
/// <summary>
///选填 t分科技应用 ,最后更新
/// </summary>
public int tScore ;
/// <summary>
///选填 p分教法应用 ,最后更新
/// </summary>
public int pScore ;
/// <summary>
///选填 t灯科技应用 0红灯1 黄灯2绿灯
/// </summary>
public int tLevel ;
/// <summary>
///选填 p灯教法应用 0红灯1 黄灯2绿灯
/// </summary>
public int pLevel ;
/// <summary>
///选填 选用IES5的课程id
/// </summary>
public String courseId ;
/// <summary>
/// 选填 课程名称 是因支持VR/AR那边课例
/// </summary>
public String courseName ;
/// <summary>
///选填 选用IES5固定名单的id
/// </summary>
public List<String> groupIds ;
public List<String> groupNames ;
/// <summary>
///选填 学生人数 ,最后更新
/// </summary>
public int mCount ;
/// <summary>
///选填 议课次数大于1则是优课苏格拉底获取
/// </summary>
public int discuss ;
/// <summary>
///选填 科技互动次数,
/// </summary>
public int techCount ;
/// <summary>
/// 学 不填 段id由课程或者名单获取
/// </summary>
public String periodId ;
/// <summary>
/// 选填 学段名称 是因支持VR/AR那边课例
/// </summary>
public String periodName ;
/// <summary>
/// 不填 科目id,由课程id获取
/// </summary>
public String subjectId ;
/// <summary>
/// 选填 科目名称 是因支持VR/AR那边课例
/// </summary>
public String subjecName ;
/// <summary>
/// 不填 年级id,由名单id获取
/// </summary>
public List<String> grade ;
public List<String> gradeName ;
/// <summary>
/// 不填 收藏次数IES5更新
/// </summary>
public int favorite ;
/// <summary>
/// 不填 点赞数
/// </summary>
public int like ;
/// <summary>
/// 不填 分享转发数
/// </summary>
public int share ;
/// <summary>
/// 不填 ["混合学习","语文教研"]课例类别tag标签,IES5维护
/// </summary>
public List<String> category ;
/// <summary>
/// 0 是否包含视频,1包含视频
/// </summary>
public int hasVideo ;
//public long videoSize ;
/// <summary>
///
/// 科技互动详细次数。[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
/// </summary>
public List<Integer> tech ;
public int status ;
/// <summary>
/// 专家好课默认0 1 是好课
/// </summary>
public int excellent ;
/// <summary>
/// 出席人数
/// </summary>
public int attendCount ;
/// <summary>
/// 总人数
/// </summary>
public int clientCount ;
/// <summary>
///出席率
/// </summary>
public double attendRate ;
/// <summary>
/// 小组数
/// </summary>
public int groupCount ;
/// <summary>
/// 任务总数,作品收集任务数
/// </summary>
public int collateTaskCount ;
/// <summary>
/// 作品总数
/// </summary>
public int collateCount ;
/// <summary>
/// 推送总数(页面,资源,讯息,差异化)
/// </summary>
public int pushCount ;
/// <summary>
/// 总计分
/// </summary>
public double totalPoint ;
/// <summary>
/// 测验总题数
/// </summary>
public int examQuizCount ;
/// <summary>
/// 互动题数
/// </summary>
public int interactionCount ;
/// <summary>
/// 测验得分率
/// </summary>
public double examPointRate ;
/// <summary>
/// 学生互动总数
/// </summary>
public int clientInteractionCount ;
/// <summary>
/// 学生互动率
/// </summary>
public double clientInteractionAverge ;
public int examCount ;
/// <summary>
/// 总互动分
/// </summary>
public double totalInteractPoint ;
/// <summary>
/// 过期时间,-1永不过期 1577808000000 2020-01-01
/// </summary>
public long expire ;
/// <summary>
/// 先使用这种模式,["all","student"], 暂不 开放 school【开放给部分学校查看】teacher【开放给部分教师查看】 ["all","school","teacher","student"]
/// </summary>
public List<String> show ;
/// <summary>
/// 暂不 开放 school【开放给部分学校查看】学校编码
/// </summary>
public List<String> showSchs ;
/// <summary>
/// 暂不 开放 teacher【开放给部分教师查看】醍摩豆id
/// </summary>
public List<String> showTchs ;
/// <summary>
/// 设置强制保留的 =1 ,不会被自动清理的。但是可以被手动清理。
/// </summary>
public int save ;
/// <summary>
/// 默认未上传
/// </summary>
public int upload ;
public LearningCategory learningCategory ;
public int hitaClientCmpCount ;
/// <summary>
/// 课例来源 0 本公司 1 第三方公司 是因支持VR/AR那边课例
/// </summary>
public int source ;
@Data
public static class LearningCategory {
/// <summary>
/// //合作學習
/// </summary>
public int cooperation ;
/// <summary>
/// 互動學習
/// </summary>
public int interaction ;
/// <summary>
/// 任務學習
/// </summary>
public int task;
/// <summary>
/// 測驗學習
/// </summary>
public int exam ;
/// <summary>
/// 差異化學習
/// </summary>
public int diffential ;
/// <summary>
/// 只會有 1跟0,有進行1個以上的智慧評分活動就是1反之是0
/// </summary>
public int smartRating ;
/// <summary>
/// 只會有 1跟0,有進行1個以上的協作活動就是1反之是0
/// </summary>
public int cowork ;
}
}

@ -0,0 +1,25 @@
package cn.teammodel.repository;
import cn.teammodel.model.entity.school.LessonRecord;
import cn.teammodel.model.vo.appraise.RecordVo;
import com.azure.spring.data.cosmos.repository.CosmosRepository;
import com.azure.spring.data.cosmos.repository.Query;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface LessonRecordRepository extends CosmosRepository<LessonRecord, String> {
@Query("select * from LessonRecord as c where " +
"c.code = @code and " +
"(IS_NULL(@startTime) or c.startTime >= @startTime) and " +
"(IS_NULL(@endTime) or c.startTime <= @endTime) and" +
" c.tmdid = @tmdId")
List<LessonRecord> getLessonsByConditions(String code, Long startTime, Long endTime,String tmdId);
@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);
}
Loading…
Cancel
Save