|
|
@ -8,6 +8,7 @@ import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
|
|
|
|
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;
|
|
|
|
|
|
|
|
import cn.teammodel.model.entity.school.LessonRecord;
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
import cn.teammodel.model.entity.school.Teacher;
|
|
|
|
import cn.teammodel.model.entity.school.Teacher;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDuty;
|
|
|
|
import cn.teammodel.model.entity.weekDuty.WeekDuty;
|
|
|
@ -15,11 +16,9 @@ import cn.teammodel.model.vo.admin.DutyIndexData;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyIndexPo;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyIndexPo;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyNodeRankVo;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyNodeRankVo;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyRankPo;
|
|
|
|
import cn.teammodel.model.vo.admin.DutyRankPo;
|
|
|
|
import cn.teammodel.repository.ClassRepository;
|
|
|
|
import cn.teammodel.repository.*;
|
|
|
|
import cn.teammodel.repository.DutyRecordRepository;
|
|
|
|
|
|
|
|
import cn.teammodel.repository.SchoolRepository;
|
|
|
|
|
|
|
|
import cn.teammodel.repository.TeacherRepository;
|
|
|
|
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
|
|
|
|
import cn.teammodel.test.LessonRecordQueryService;
|
|
|
|
import cn.teammodel.utils.GroupUtil;
|
|
|
|
import cn.teammodel.utils.GroupUtil;
|
|
|
|
import cn.teammodel.utils.SchoolDateUtil;
|
|
|
|
import cn.teammodel.utils.SchoolDateUtil;
|
|
|
|
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
|
|
|
|
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
|
|
|
@ -38,6 +37,7 @@ import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static cn.teammodel.utils.SchoolDateUtil.calculateWeekNum;
|
|
|
|
import static cn.teammodel.utils.SchoolDateUtil.calculateWeekNum;
|
|
|
@ -62,6 +62,8 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
private DutyRecordRepository dutyRecordRepository;
|
|
|
|
private DutyRecordRepository dutyRecordRepository;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private Environment env;
|
|
|
|
private Environment env;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private LessonRecordRepository lessonRecordRepository;
|
|
|
|
|
|
|
|
|
|
|
|
/* @Autowired
|
|
|
|
/* @Autowired
|
|
|
|
public AdminIndexDutyServiceImpl(Environment env) {
|
|
|
|
public AdminIndexDutyServiceImpl(Environment env) {
|
|
|
@ -238,6 +240,84 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
mapper = GroupUtil.getGroupId(lessonRecordDto,new GroupUtil(env), request,url);
|
|
|
|
mapper = GroupUtil.getGroupId(lessonRecordDto,new GroupUtil(env), request,url);
|
|
|
|
|
|
|
|
return mapper;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Map<String, Object> getTeachingQuality(LessonRecordDto lessonRecordDto, 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;
|
|
|
|
|
|
|
|
LessonRecordQueryService queryService = new LessonRecordQueryService(lessonRecordRepository);
|
|
|
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
|
|
|
Map<String, Object> mapper = new HashMap<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String lessonRecordKey = String.format(PK.PK_LESSON_RECORD, lessonRecordDto.getSchool());
|
|
|
|
|
|
|
|
Long startTime = lessonRecordDto.getStime();
|
|
|
|
|
|
|
|
Long endTime = lessonRecordDto.getEtime();
|
|
|
|
|
|
|
|
String subjectId = lessonRecordDto.getSubjectId().isEmpty() ? null:lessonRecordDto.getSubjectId().get(0);
|
|
|
|
|
|
|
|
String tmdId = lessonRecordDto.getTmdid();
|
|
|
|
|
|
|
|
String grade = lessonRecordDto.getGrade().isEmpty() ? null :lessonRecordDto.getGrade().get(0);
|
|
|
|
|
|
|
|
String periodId = lessonRecordDto.getPeriodId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
records = queryService.queryLessonsInParallel(
|
|
|
|
|
|
|
|
lessonRecordKey, startTime, endTime, subjectId, tmdId, grade, periodId
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算本学期互动总数
|
|
|
|
|
|
|
|
int totalClientInteractionCount = records.stream()
|
|
|
|
|
|
|
|
.mapToInt(LessonRecord::getClientInteractionCount)
|
|
|
|
|
|
|
|
.sum();
|
|
|
|
|
|
|
|
mapper.put("totalClientInteractionCount", totalClientInteractionCount);
|
|
|
|
|
|
|
|
// 获取当前月和上个月的时间范围
|
|
|
|
|
|
|
|
LocalDateTime startOfCurrentMonth = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
|
|
|
|
|
|
|
|
LocalDateTime startOfLastMonth = startOfCurrentMonth.minusMonths(1);
|
|
|
|
|
|
|
|
LocalDateTime endOfLastMonth = startOfCurrentMonth.minusSeconds(1);
|
|
|
|
|
|
|
|
long st = startOfCurrentMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
|
|
|
|
|
|
|
|
long et = startOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
|
|
|
|
|
|
|
|
long endMath = endOfLastMonth.atZone(ZoneId.of("Asia/Shanghai")).toInstant().toEpochMilli();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 过滤出当前月和上个月的记录
|
|
|
|
|
|
|
|
List<LessonRecord> currentMonthRecords = records.stream()
|
|
|
|
|
|
|
|
.filter(record -> record.getStartTime() > st )
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LessonRecord> lastMonthRecords = records.stream()
|
|
|
|
|
|
|
|
.filter(record -> record.getStartTime() > et && record.getStartTime() < endMath)
|
|
|
|
|
|
|
|
.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);
|
|
|
|
|
|
|
|
//System.out.println("当前月上浮:" + percentageChange);
|
|
|
|
|
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据查询异常");
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
queryService.shutdown();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mapper;
|
|
|
|
return mapper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|