update 教学质量接口内容

develop
hhb@hotmail.com 2 months ago
parent 042979a5ae
commit d8b9df497d

@ -3,6 +3,7 @@ package cn.teammodel.controller.admin.controller;
import cn.teammodel.common.R; import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.AdminIndexDutyService; import cn.teammodel.controller.admin.service.AdminIndexDutyService;
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto; import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
import cn.teammodel.model.dto.admin.teacher.TeacherDto;
import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto; import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto; import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
import cn.teammodel.model.vo.admin.AppraiseNodeRankVo; import cn.teammodel.model.vo.admin.AppraiseNodeRankVo;
@ -79,8 +80,8 @@ public class AdminDutyController {
} }
@PostMapping("getTeachingQuality") @PostMapping("getTeachingQuality")
@ApiOperation("获取教学质量") @ApiOperation("获取教学质量")
public R<Map<String, Object> > getTeachingQuality(@Valid @RequestBody LessonRecordDto lessonRecordDto , HttpServletRequest request) { public R<List<Map<String, Object>> > getTeachingQuality(@Valid @RequestBody TeacherDto teacherDto , HttpServletRequest request) {
Map<String, Object> res = adminIndexDutyService.getTeachingQuality(lessonRecordDto,request); List<Map<String, Object>> res = adminIndexDutyService.getTeachingQuality(teacherDto,request);
return R.success(res); return R.success(res);
} }
} }

@ -1,6 +1,7 @@
package cn.teammodel.controller.admin.service; package cn.teammodel.controller.admin.service;
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto; import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
import cn.teammodel.model.dto.admin.teacher.TeacherDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto; import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
import cn.teammodel.model.vo.admin.DutyIndexData; import cn.teammodel.model.vo.admin.DutyIndexData;
import cn.teammodel.model.vo.admin.DutyNodeRankVo; import cn.teammodel.model.vo.admin.DutyNodeRankVo;
@ -25,6 +26,6 @@ public interface AdminIndexDutyService {
List<DutyNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto); List<DutyNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto);
Map<String, Object> getLessonRecord (LessonRecordDto lessonRecordDto, HttpServletRequest request); Map<String, Object> getLessonRecord (LessonRecordDto lessonRecordDto, HttpServletRequest request);
Map<String, Object> getTeachingQuality (LessonRecordDto lessonRecordDto, HttpServletRequest request); List<Map<String, Object>> getTeachingQuality (TeacherDto teacherDto, HttpServletRequest request);
} }

@ -5,6 +5,7 @@ import cn.teammodel.common.PK;
import cn.teammodel.config.exception.ServiceException; import cn.teammodel.config.exception.ServiceException;
import cn.teammodel.controller.admin.service.AdminIndexDutyService; import cn.teammodel.controller.admin.service.AdminIndexDutyService;
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto; import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
import cn.teammodel.model.dto.admin.teacher.TeacherDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto; import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
import cn.teammodel.model.entity.User; import cn.teammodel.model.entity.User;
import cn.teammodel.model.entity.school.ClassInfo; import cn.teammodel.model.entity.school.ClassInfo;
@ -89,9 +90,9 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
// 获取学期起止时间 // 获取学期起止时间
List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, timeRangeDto.getPeriodId()); List<School.Semester> semesters = schoolRepository.findSemestersById(schoolId, timeRangeDto.getPeriodId());
SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now()); SchoolDateUtil.semesterModel semesterModel = SchoolDateUtil.getSemesterByNow(semesters, LocalDate.now());
LocalDateTime startDatetime = null; LocalDateTime startDatetime;
LocalDateTime endDatetime = null; LocalDateTime endDatetime;
String academicYearId = null; String academicYearId;
if(timeRangeDto.getStartTime() != null) { if(timeRangeDto.getStartTime() != null) {
startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getStartTime()), ZoneId.systemDefault()); startDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getStartTime()), ZoneId.systemDefault());
endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getEndTime()), ZoneId.systemDefault()); endDatetime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeRangeDto.getEndTime()), ZoneId.systemDefault());
@ -244,80 +245,90 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
} }
@Override @Override
public Map<String, Object> getTeachingQuality(LessonRecordDto lessonRecordDto, HttpServletRequest request) { public List<Map<String, Object>> getTeachingQuality(TeacherDto teacherDto, HttpServletRequest request) {
/*LocalDateTime now = LocalDateTime.now();
LocalDateTime twoMonthsAgo = now.minusMonths(2);*/
// 转换为时间戳(毫秒)
/* long nowTimestamp = now.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
long twoMonthsAgoTimestamp = twoMonthsAgo.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
lessonRecordDto.setStime(twoMonthsAgoTimestamp);
lessonRecordDto.setEtime(nowTimestamp);*/
List<LessonRecord> records; List<LessonRecord> records;
LessonRecordQueryService queryService = new LessonRecordQueryService(lessonRecordRepository); LessonRecordQueryService queryService = new LessonRecordQueryService(lessonRecordRepository);
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
Map<String, Object> mapper = new HashMap<>(); List<Map<String, Object>> list = new ArrayList<>();
//Map<String, Object> mapAll = new HashMap<>();
try { try {
String lessonRecordKey = String.format(PK.PK_LESSON_RECORD, lessonRecordDto.getSchool()); String lessonRecordKey = String.format(PK.PK_LESSON_RECORD, teacherDto.getCode());
Long startTime = lessonRecordDto.getStime(); Long startTime = teacherDto.getStartTime();
Long endTime = lessonRecordDto.getEtime(); Long endTime = teacherDto.getEndTime();
String subjectId = lessonRecordDto.getSubjectId().isEmpty() ? null:lessonRecordDto.getSubjectId().get(0); String subjectId = teacherDto.getSubjectId();
String tmdId = lessonRecordDto.getTmdid(); String tmdId = teacherDto.getTmdId();
String grade = lessonRecordDto.getGrade().isEmpty() ? null :lessonRecordDto.getGrade().get(0); String grade = teacherDto.getGrade();
String periodId = lessonRecordDto.getPeriodId(); String periodId = teacherDto.getPeriodId();
records = queryService.queryLessonsInParallel( records = queryService.queryLessonsInParallel(
lessonRecordKey, startTime, endTime, subjectId, tmdId, grade, periodId lessonRecordKey, startTime, endTime, subjectId, tmdId, grade, periodId
); );
// 计算本学期互动总数 for(String classId : teacherDto.getClassIds()) {
int totalClientInteractionCount = records.stream() Map<String, Object> mapper = new HashMap<>();
.mapToInt(LessonRecord::getClientInteractionCount) // 计算本学期互动总数
.sum(); int totalClientInteractionCount = records.stream().filter(lessonRecord ->
mapper.put("totalClientInteractionCount", totalClientInteractionCount); lessonRecord.getGroupIds().contains(classId))
// 获取当前月和上个月的时间范围 .mapToInt(LessonRecord::getClientInteractionCount)
LocalDateTime startOfCurrentMonth = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0); .sum();
LocalDateTime startOfLastMonth = startOfCurrentMonth.minusMonths(1); mapper.put("totalClientInteractionCount", totalClientInteractionCount);
LocalDateTime endOfLastMonth = startOfCurrentMonth.minusSeconds(1); int countRecord = (int) records.stream().filter(lessonRecord ->
long st = startOfCurrentMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); lessonRecord.getGroupIds().contains(classId)).count();
long et = startOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); int engagementIndexAvergeSum = records.stream().filter(lessonRecord ->
long endMath = endOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli(); lessonRecord.getGroupIds().contains(classId))
.mapToInt(LessonRecord::getEngagementIndexAverge)
// 过滤出当前月和上个月的记录 .sum();
List<LessonRecord> currentMonthRecords = records.stream() if (countRecord == 0) {
.filter(record -> record.getStartTime() > st ) mapper.put("engagementIndexAverge", 0);
.collect(Collectors.toList()); continue;
}else if (engagementIndexAvergeSum == 0) {
List<LessonRecord> lastMonthRecords = records.stream() mapper.put("engagementIndexAverge", 0);
.filter(record -> record.getStartTime() > et && record.getStartTime() < endMath) }else {
.collect(Collectors.toList()); mapper.put("engagementIndexAverge", engagementIndexAvergeSum / countRecord);
}
// 计算当前月和上个月的clientInteractionCount总数 // 获取当前月和上个月的时间范围
int currentMonthTotal = currentMonthRecords.stream() LocalDateTime startOfCurrentMonth = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
.mapToInt(LessonRecord::getClientInteractionCount) LocalDateTime startOfLastMonth = startOfCurrentMonth.minusMonths(1);
.sum(); LocalDateTime endOfLastMonth = startOfCurrentMonth.minusSeconds(1);
mapper.put("currentMonthTotal", currentMonthTotal); long st = startOfCurrentMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
int lastMonthTotal = lastMonthRecords.stream() long et = startOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
.mapToInt(LessonRecord::getClientInteractionCount) long endMath = endOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
.sum();
mapper.put("lastMonthTotal", lastMonthTotal); // 过滤出当前月和上个月的记录
// 计算百分比变化 List<LessonRecord> currentMonthRecords = records.stream()
double percentageChange = 0; .filter(record -> record.getStartTime() > st && record.getGroupIds().contains(classId))
if (lastMonthTotal != 0) { .collect(Collectors.toList());
percentageChange = ((double) (currentMonthTotal - lastMonthTotal) / lastMonthTotal) * 100;
List<LessonRecord> lastMonthRecords = records.stream()
.filter(record -> record.getStartTime() > et && record.getStartTime() < endMath && record.getGroupIds().contains(classId))
.collect(Collectors.toList());
// 计算当前月和上个月的clientInteractionCount总数
int currentMonthTotal = currentMonthRecords.stream()
.mapToInt(LessonRecord::getClientInteractionCount)
.sum();
mapper.put("currentMonthTotal", currentMonthTotal);
int lastMonthTotal = lastMonthRecords.stream()
.mapToInt(LessonRecord::getClientInteractionCount)
.sum();
mapper.put("lastMonthTotal", lastMonthTotal);
// 计算百分比变化
double percentageChange = 0;
if (lastMonthTotal != 0) {
percentageChange = ((double) (currentMonthTotal - lastMonthTotal) / lastMonthTotal) * 100;
}
String formattedPercentageChange = String.format("%.2f", percentageChange);
mapper.put("percentageChange", formattedPercentageChange);
mapper.put("classId", classId);
list.add(mapper);
} }
String formattedPercentageChange = String.format("%.2f", percentageChange);
mapper.put("percentageChange", formattedPercentageChange);
//System.out.println("当前月上浮:" + percentageChange); //System.out.println("当前月上浮:" + percentageChange);
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据查询异常"); throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据查询异常");
} finally { } finally {
queryService.shutdown(); queryService.shutdown();
} }
return list;
return mapper;
} }
} }

@ -27,4 +27,5 @@ public class TeacherDto {
public String semesterId; public String semesterId;
public List<String> duration = new ArrayList<>(); public List<String> duration = new ArrayList<>();
public List<String> school_shortcode = new ArrayList<>(); public List<String> school_shortcode = new ArrayList<>();
private List<String> classIds;
} }

@ -201,6 +201,10 @@ public class LessonRecord extends BaseItem {
/// </summary> /// </summary>
public double totalInteractPoint ; public double totalInteractPoint ;
/// <summary> /// <summary>
/// 全班参与度
/// </summary>
public int engagementIndexAverge;
/// <summary>
/// 过期时间,-1永不过期 1577808000000 2020-01-01 /// 过期时间,-1永不过期 1577808000000 2020-01-01
/// </summary> /// </summary>
public long expire ; public long expire ;

Loading…
Cancel
Save