|
|
|
|
@ -3,7 +3,6 @@ package com.ruoyi.course.controller;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.course.domain.*;
|
|
|
|
|
import com.ruoyi.course.domain.dto.ScheduleRequest;
|
|
|
|
|
import com.ruoyi.course.domain.dto.ScheduleResult;
|
|
|
|
|
@ -11,6 +10,7 @@ import com.ruoyi.course.domain.vo.CourseInfoVO;
|
|
|
|
|
import com.ruoyi.course.mapper.*;
|
|
|
|
|
import com.ruoyi.course.service.impl.CourseScheduler;
|
|
|
|
|
import com.ruoyi.course.service.impl.TimeTableManager;
|
|
|
|
|
import com.ruoyi.course.util.ScheduleUtil;
|
|
|
|
|
import com.ruoyi.course.util.TimeUtil;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
@ -71,38 +71,6 @@ public class ScheduleController extends BaseController {
|
|
|
|
|
return courseScheduler.scheduleCourses(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Operation(summary = "获取学生个人课表", description = "获取指定学生在指定学期的个人课表")
|
|
|
|
|
// @GetMapping("/student/{studentId}")
|
|
|
|
|
// public Map<String, Object> getStudentSchedule(
|
|
|
|
|
// @Parameter(description = "学生ID", required = true, example = "1001")
|
|
|
|
|
// @PathVariable Long studentId,
|
|
|
|
|
// @Parameter(description = "学期", required = true, example = "2025-2026-1")
|
|
|
|
|
// @RequestParam String semester) {
|
|
|
|
|
//
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
//
|
|
|
|
|
// // 获取学生信息
|
|
|
|
|
// Student student = studentMapper.selectById(studentId);
|
|
|
|
|
// if (student == null) {
|
|
|
|
|
// result.put("success", false);
|
|
|
|
|
// result.put("message", "学生不存在");
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 获取学生课表
|
|
|
|
|
// Map<String, Map<Integer, String>> timetable = courseScheduler.getStudentTimetable(studentId, semester);
|
|
|
|
|
//
|
|
|
|
|
// result.put("success", true);
|
|
|
|
|
// result.put("studentId", studentId);
|
|
|
|
|
// result.put("studentName", student.getName());
|
|
|
|
|
// result.put("className", getClassName(student.getClassId()));
|
|
|
|
|
// result.put("grade", student.getGrade());
|
|
|
|
|
// result.put("semester", semester);
|
|
|
|
|
// result.put("timetable", timetable);
|
|
|
|
|
//
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取学生个人课表", description = "获取指定学生在指定学期的个人课表")
|
|
|
|
|
@GetMapping("/student/{studentId}")
|
|
|
|
|
@ -137,7 +105,7 @@ public class ScheduleController extends BaseController {
|
|
|
|
|
String courseInfo = periodEntry.getValue();
|
|
|
|
|
|
|
|
|
|
// 解析课程信息
|
|
|
|
|
CourseInfoVO courseInfoVO = parseCourseInfo(courseInfo);
|
|
|
|
|
CourseInfoVO courseInfoVO = ScheduleUtil.parseCourseInfo(courseInfo);
|
|
|
|
|
if (courseInfoVO != null) {
|
|
|
|
|
formattedPeriodMap.put(period, courseInfoVO);
|
|
|
|
|
}
|
|
|
|
|
@ -164,98 +132,9 @@ public class ScheduleController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 解析课程信息字符串
|
|
|
|
|
* 格式示例:"语文,王老师,101教室,必修"
|
|
|
|
|
*/
|
|
|
|
|
private CourseInfoVO parseCourseInfo(String courseInfo) {
|
|
|
|
|
if (StringUtils.isBlank(courseInfo)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] parts = courseInfo.split(",");
|
|
|
|
|
if (parts.length >= 4) {
|
|
|
|
|
return new CourseInfoVO(
|
|
|
|
|
parts[0], // 课程名
|
|
|
|
|
parts[1], // 教师名
|
|
|
|
|
parts[2], // 教室名
|
|
|
|
|
parts[3] // 课程类型
|
|
|
|
|
);
|
|
|
|
|
} else if (parts.length > 0) {
|
|
|
|
|
// 如果格式不完整,提供默认值
|
|
|
|
|
return new CourseInfoVO(
|
|
|
|
|
parts[0], // 课程名
|
|
|
|
|
parts.length > 1 ? parts[1] : "", // 教师名(如有)
|
|
|
|
|
parts.length > 2 ? parts[2] : "", // 教室名(如有)
|
|
|
|
|
parts.length > 3 ? parts[3] : "必修" // 课程类型(默认为必修)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// @Operation(summary = "获取班级课表", description = "获取指定班级在指定学期的课表")
|
|
|
|
|
// @GetMapping("/class/{classId}")
|
|
|
|
|
// public Map<String, Object> getClassSchedule(
|
|
|
|
|
// @Parameter(description = "班级ID", required = true, example = "1")
|
|
|
|
|
// @PathVariable Long classId,
|
|
|
|
|
// @Parameter(description = "学期", required = true, example = "2025-2026-1")
|
|
|
|
|
// @RequestParam String semester) {
|
|
|
|
|
//
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
//
|
|
|
|
|
// // 获取班级信息
|
|
|
|
|
// Clazz clazz = clazzMapper.selectById(classId);
|
|
|
|
|
// if (clazz == null) {
|
|
|
|
|
// result.put("success", false);
|
|
|
|
|
// result.put("message", "班级不存在");
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 查询班级的所有排课项
|
|
|
|
|
// LambdaQueryWrapper<ScheduleItem> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// wrapper.eq(ScheduleItem::getClassId, classId).eq(ScheduleItem::getSemester, semester).eq(ScheduleItem::getStatus, 1).orderByAsc(ScheduleItem::getDayOfWeek).orderByAsc(ScheduleItem::getPeriod);
|
|
|
|
|
//
|
|
|
|
|
// List<ScheduleItem> scheduleItems = scheduleItemMapper.selectList(wrapper);
|
|
|
|
|
//
|
|
|
|
|
// // 构建课表
|
|
|
|
|
// Map<String, Map<Integer, Map<String, Object>>> timetable = new HashMap<>();
|
|
|
|
|
// String[] days = {"周一", "周二", "周三", "周四", "周五", "周六"};
|
|
|
|
|
// for (String day : days) {
|
|
|
|
|
// timetable.put(day, new HashMap<>());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// for (ScheduleItem item : scheduleItems) {
|
|
|
|
|
// String day = TimeUtil.getDayName(item.getDayOfWeek());
|
|
|
|
|
// Integer period = item.getPeriod();
|
|
|
|
|
//
|
|
|
|
|
// // 获取课程、教师、教室信息
|
|
|
|
|
// Course course = courseMapper.selectById(item.getCourseId());
|
|
|
|
|
// Teacher teacher = teacherMapper.selectById(item.getTeacherId());
|
|
|
|
|
// Classroom classroom = classroomMapper.selectById(item.getClassroomId());
|
|
|
|
|
//
|
|
|
|
|
// Map<String, Object> courseInfo = new HashMap<>();
|
|
|
|
|
// courseInfo.put("courseId", item.getCourseId());
|
|
|
|
|
// courseInfo.put("courseName", course != null ? course.getCourseName() : "未知课程");
|
|
|
|
|
// courseInfo.put("teacherId", item.getTeacherId());
|
|
|
|
|
// courseInfo.put("teacherName", teacher != null ? teacher.getTeacherName() : "未知教师");
|
|
|
|
|
// courseInfo.put("classroomId", item.getClassroomId());
|
|
|
|
|
// courseInfo.put("classroomName", classroom != null ? classroom.getRoomName() : "未知教室");
|
|
|
|
|
// courseInfo.put("courseType", item.getCourseType());
|
|
|
|
|
//
|
|
|
|
|
// timetable.get(day).put(period, courseInfo);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// result.put("success", true);
|
|
|
|
|
// result.put("classId", classId);
|
|
|
|
|
// result.put("className", clazz.getClassName());
|
|
|
|
|
// result.put("grade", clazz.getGrade());
|
|
|
|
|
// result.put("semester", semester);
|
|
|
|
|
// result.put("timetable", timetable);
|
|
|
|
|
//
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取班级课表", description = "获取指定班级在指定学期的课表")
|
|
|
|
|
|