update 评价调整以及教学质量接口的雏形

develop
hhb@hotmail.com 3 months ago
parent 31df666440
commit 042979a5ae

@ -77,4 +77,10 @@ public class AdminDutyController {
Map<String, Object> res = adminIndexDutyService.getLessonRecord(lessonRecordDto,request);
return R.success(res);
}
@PostMapping("getTeachingQuality")
@ApiOperation("获取教学质量")
public R<Map<String, Object> > getTeachingQuality(@Valid @RequestBody LessonRecordDto lessonRecordDto , HttpServletRequest request) {
Map<String, Object> res = adminIndexDutyService.getTeachingQuality(lessonRecordDto,request);
return R.success(res);
}
}

@ -25,5 +25,6 @@ public interface AdminIndexDutyService {
List<DutyNodeRankVo> appraiseNodeRank(TimeRangeDto timeRangeDto);
Map<String, Object> getLessonRecord (LessonRecordDto lessonRecordDto, HttpServletRequest request);
Map<String, Object> getTeachingQuality (LessonRecordDto lessonRecordDto, HttpServletRequest request);
}

@ -8,6 +8,7 @@ import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
import cn.teammodel.model.entity.User;
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.Teacher;
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.DutyNodeRankVo;
import cn.teammodel.model.vo.admin.DutyRankPo;
import cn.teammodel.repository.ClassRepository;
import cn.teammodel.repository.DutyRecordRepository;
import cn.teammodel.repository.SchoolRepository;
import cn.teammodel.repository.TeacherRepository;
import cn.teammodel.repository.*;
import cn.teammodel.security.utils.SecurityUtil;
import cn.teammodel.test.LessonRecordQueryService;
import cn.teammodel.utils.GroupUtil;
import cn.teammodel.utils.SchoolDateUtil;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
@ -38,6 +37,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static cn.teammodel.utils.SchoolDateUtil.calculateWeekNum;
@ -62,6 +62,8 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
private DutyRecordRepository dutyRecordRepository;
@Autowired
private Environment env;
@Resource
private LessonRecordRepository lessonRecordRepository;
/* @Autowired
public AdminIndexDutyServiceImpl(Environment env) {
@ -238,6 +240,84 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
}
}*/
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;
}
}

@ -30,4 +30,6 @@ public class AppraiseVoteDto {
@NotNull
@ApiModelProperty(value = "评价项唯一 id", required = true)
private String appraiseId;
@ApiModelProperty(value = "评价来源")
private String from;
}

@ -22,4 +22,5 @@ public class AppraiseRecordItem {
String creator;
String creatorId;
private Long createTime;
private String from;
}

@ -12,7 +12,7 @@ import java.util.List;
@Repository
public interface LessonRecordRepository extends CosmosRepository<LessonRecord, String> {
@Query("select c.id from LessonRecord as c where " +
@Query("select c.id,c.tmdid,c.groupIds,c.startTime,c.clientInteractionCount,c.clientInteractionAverge 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 "+

@ -314,6 +314,7 @@ public class EvaluationServiceImpl implements EvaluationService {
boolean pushParent = appraiseVoteDto.isPushParent();
String targetType = appraiseVoteDto.getTargetType();
String appraiseId = appraiseVoteDto.getAppraiseId();
String from = appraiseVoteDto.getFrom();
User loginUser = SecurityUtil.getLoginUser();
String schoolId = loginUser.getSchoolId();
String classId;
@ -379,6 +380,7 @@ public class EvaluationServiceImpl implements EvaluationService {
item.setCreator(loginUser.getName());
item.setCreatorId(loginUser.getId());
item.setCreateTime(Instant.now().toEpochMilli());
item.setFrom(from);
// 处理学校与学生的差异
if (targetType.equals(TARGET_CLASS)) {
item.setSpread(spread);

Loading…
Cancel
Save