|
|
@ -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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|