Merge branch 'master' of 39.106.16.162:/home/git/teaching-backend/teaching-backend

master
yh 3 months ago
commit e4f05536b8
  1. 3
      src/main/java/com/teaching/backend/common/ErrorCode.java
  2. 2
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsStudentManageController.java
  3. 1
      src/main/java/com/teaching/backend/mapper/chapter/TemporaryChapterMapper.java
  4. 2
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsStudentMapper.java
  5. 3
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  6. 1
      src/main/java/com/teaching/backend/model/dto/chapter/ChapterDTO.java
  7. 100
      src/main/java/com/teaching/backend/model/dto/chapter/ChapterExcelDTO.java
  8. 2
      src/main/java/com/teaching/backend/model/entity/chapter/TemporaryChapter.java
  9. 4
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudent.java
  10. 2
      src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsStudentManage.java
  11. 2
      src/main/java/com/teaching/backend/model/vo/message/CourseUserInfVO.java
  12. 4
      src/main/java/com/teaching/backend/service/chapter/IChapterService.java
  13. 2
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  14. 13
      src/main/java/com/teaching/backend/service/impl/chapter/ChapterServiceImpl.java
  15. 244
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  16. 5
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  17. 20
      src/main/java/com/teaching/backend/service/impl/message/MessagesServiceImpl.java
  18. 28
      src/main/java/com/teaching/backend/service/impl/message/UserInboxServiceImpl.java
  19. 4
      src/main/java/com/teaching/backend/service/impl/records/CourseLearningRecordServiceImpl.java
  20. 8
      src/main/java/com/teaching/backend/service/impl/records/KnowledgeLearningRecordServiceImpl.java
  21. 2
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsStudentManageServiceImpl.java
  22. 6
      src/main/java/com/teaching/backend/service/impl/umsAdmin/UmsUserServiceImpl.java
  23. 28
      src/main/java/com/teaching/backend/utils/Chapter/ExcelParser.java
  24. 121
      src/main/java/com/teaching/backend/utils/Chapter/SheetHandler.java
  25. 34
      src/main/java/com/teaching/backend/utils/Chapter/SheetPreScanner.java
  26. 2
      src/main/resources/mapper/UmsUserMapper.xml

@ -26,7 +26,8 @@ public enum ErrorCode {
NO_AUTH_ERROR(40101, "无权限"),
NOT_FOUND_ERROR(40400, "请求数据不存在"),
CONTENT_EXISTS(41000, "内容存在"),
STUDENT_ROLE_CANT_MULTIPLESEND(41001, "学生用户不能群发,只能单发"),
LEAST_ONE_USER(41002, "最少选择一个用户"),
KNOWS_EXISTS(41001, "存在关联的知识点"),
ADD_RELATION_FAILED(41002, "添加关系失败"),

@ -1,6 +1,5 @@
package com.teaching.backend.controller.umsAdmin;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentPageQueryDTO;
import com.teaching.backend.model.entity.umsAdmin.UmsStudentManage;
@ -11,7 +10,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.chapter.TemporaryChapter;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@ -14,6 +14,6 @@ import com.teaching.backend.model.entity.umsAdmin.UmsStudent;
public interface UmsStudentMapper extends BaseMapper<UmsStudent> {
boolean updateStudentInfo(UmsStudent umsStudent);
UmsStudent selectByUserId(Integer userId);
UmsStudent selectByUserId(Long userId);
}

@ -1,7 +1,6 @@
package com.teaching.backend.mapper.umsAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.courses.StudentCourses;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
@ -19,5 +18,5 @@ public interface UmsUserMapper extends BaseMapper<UmsUser> {
UmsStudentVO getByIdStudent(String id);
String getbyIdRoleId(String userId);
String getByIdRoleId(String userId);
}

@ -67,7 +67,6 @@ public class ChapterDTO implements Serializable {
@ApiModelProperty(value = "要求")
private String requirement;
@ApiModelProperty(value = "线上学时")
private String onlineClassHours;

@ -0,0 +1,100 @@
package com.teaching.backend.model.dto.chapter;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* ClassName: ChapterExcelDto
* Package: com.teaching.backend.model.dto.chapter
* Description:
*
* @Author 姜钧瀚
* @Create 2024/8/10 13:44
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ChapterExcelDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "创建日期")
@JsonFormat(pattern = "yyyy/M/d HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@ApiModelProperty(value = "更新日期")
@JsonFormat(pattern = "yyyy/M/d HH-mm-ss")
private LocalDateTime updateTime;
@ApiModelProperty(value = "所属部门")
private String sysOrgCode;
@ApiModelProperty(value = "序号")
private Double orderNum;
@ApiModelProperty(value = "章节名称")
private String name;
@ApiModelProperty(value = "简介")
private String content;
@ApiModelProperty(value = "父章节")
private Long pid;
@ApiModelProperty(value = "课程id")
private String courseId;
@ApiModelProperty(value = "课程目标")
private String courseObjectivesId;
@ApiModelProperty(value = "总学时")
private double totalClassHours;
@ApiModelProperty(value = "要求")
private String requirement;
@TableField(exist = false)
@ApiModelProperty(value = "是否是节")
private boolean isSection;
@TableField(exist = false)
@ApiModelProperty(value = "章内序号")
private Integer internalOrder;
@ApiModelProperty(value = "线上学时")
private String onlineClassHours;
@ApiModelProperty(value = "周次")
private String zc;
@ApiModelProperty(value = "内部序号显示")
private String numshow;
@ApiModelProperty(value = "excel上级序号")
@TableField(exist = false)
private Long ParentExcelId;
@ApiModelProperty(value = "excel序号")
@TableField(exist = false)
private Long ExcelId;
public void setIsSection(boolean b) {
this.isSection=b;
}
}

@ -69,7 +69,7 @@ public class TemporaryChapter implements Serializable {
private String courseObjectivesId;
@ApiModelProperty(value = "总学时")
private String totalClassHours;
private double totalClassHours;
@ApiModelProperty(value = "要求")
private String requirement;

@ -6,6 +6,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -60,7 +62,7 @@ public class UmsStudent implements Serializable {
private String className;
//user_id
private Integer userId;
private Long userId;
}

@ -78,7 +78,7 @@ public class UmsStudentManage implements Serializable {
private String className;
//user_id
private Integer userId;
private Long userId;
}

@ -13,8 +13,6 @@ public class CourseUserInfVO {
private String courseId;
@ApiModelProperty(value = "课程name")
private String courseName;
@ApiModelProperty(value = "与课程有关的用户信息集合")
private List<UserReadMessageTimeVO> usersInf;
}

@ -4,12 +4,12 @@ package com.teaching.backend.service.chapter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.chapter.ChapterDTO;
import com.teaching.backend.model.dto.chapter.ChapterExcelDTO;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.vo.chapter.ChapterVo;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.LinkedList;
import java.util.List;
@ -54,7 +54,7 @@ public interface IChapterService extends IService<Chapter> {
void moveDataFromTemporaryToFinal();
Long saveToTemporaryTable(ChapterDTO chapterDTO);
Long saveToTemporaryTable(ChapterExcelDTO chapterDTO);
void downExcel(HttpServletResponse response) throws IOException;

@ -51,6 +51,8 @@ public interface ICoursesService extends IService<Courses> {
Map<String, Object> getPagePageSize2(int page, int pageSize);
List<PersonalCenterStudentListVO> queryStudentList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentLearningRecordList(String userId);
LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId);
List<CourseUserInfVO> getUserInfByCourse(Long userId);

@ -14,12 +14,12 @@ import com.teaching.backend.mapper.chapter.ChapterMapper;
import com.teaching.backend.mapper.chapter.TemporaryChapterMapper;
import com.teaching.backend.model.dto.chapter.ChapterDTO;
import com.teaching.backend.model.dto.chapter.ChapterExcelDTO;
import com.teaching.backend.model.entity.chapter.Chapter;
import com.teaching.backend.model.entity.chapter.TemporaryChapter;
import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.model.vo.chapter.ChapterVo;
import com.teaching.backend.service.Know.KnowService;
import com.teaching.backend.service.chapter.IChapterService;
import com.teaching.backend.utils.Chapter.ExcelUtils;
import org.springframework.beans.BeanUtils;
@ -29,7 +29,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -517,7 +516,7 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
@Transactional(rollbackFor = Exception.class)
@Override
public Long saveToTemporaryTable(ChapterDTO chapterDTO) {
public Long saveToTemporaryTable(ChapterExcelDTO chapterDTO) {
TemporaryChapter temporaryChapter = new TemporaryChapter();
try {
BeanUtils.copyProperties(chapterDTO, temporaryChapter);
@ -526,10 +525,13 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
}
Long pid = temporaryChapter.getPid();
//pid=0的时候
if (pid == null || pid == 0) {
temporaryChapter.setPid(0L);
setChapterOrder(temporaryChapter, 0L);
} else {
}
//pid!=0的时候
else {
TemporaryChapter parentChapter = temporaryChapterMapper.selectById(pid);
if (parentChapter != null) {
temporaryChapter.setPid(parentChapter.getId());
@ -538,8 +540,9 @@ public class ChapterServiceImpl extends ServiceImpl<ChapterMapper, Chapter> impl
throw new BusinessException(ErrorCode.PARAMS_ERROR, "未找到父章节,ID 为: " + pid);
}
}
// 执行
temporaryChapterMapper.insert(temporaryChapter);
return temporaryChapter.getId();
}

@ -52,6 +52,7 @@ import java.io.File;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@ -359,7 +360,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
@Override
public List<PersonalCenterStudentListVO> queryStudentList(String userId) {
LinkedHashSet<UmsStudentManage> umsStudentManageList = queryTeacherByStudentList(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = queryTeacherByStudentLearningRecordList(userId);
List<PersonalCenterStudentListVO> personalCenterStudentListVOList = new ArrayList<>();
PersonalCenterStudentListVO personalCenterStudentListVO = null;
for (UmsStudentManage umsStudentManage : umsStudentManageList) {
@ -373,8 +374,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
@Override
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentLearningRecordList(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>();
@ -387,8 +388,10 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
List<CourseLearningRecord> courseLearningRecordList = new ArrayList<>();
for (StudentCourses studentUsername : studentUsernames) {
CourseLearningRecord courseLearningRecord = courseLearningRecordMapper.selectNewRecord(String.valueOf(studentUsername.getStudent()));
if (courseLearningRecord != null){
courseLearningRecordList.add(courseLearningRecord);
}
}
courseLearningRecordList = courseLearningRecordList.stream().sorted(Comparator.comparing(CourseLearningRecord::getTimes).reversed()).collect(Collectors.toList());
for (CourseLearningRecord courseLearningRecord : courseLearningRecordList) {
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(courseLearningRecord.getUserId());
@ -400,7 +403,29 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
throw new BusinessException(400,"只有老师才有此功能");
}
@Override
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId) {
String roleId = umsUserMapper.getByIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>();
if (roleId.equals("1")){
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList());
for (String courseId : courseIds) {
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
for (StudentCourses studentUsername : studentUsernames) {
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(String.valueOf(studentUsername.getStudent()));
if (umsStudentManage != null){
umsStudentManageList.add(umsStudentManage);
}
}
}
return umsStudentManageList;
}
throw new BusinessException(400,"只有老师才有此功能");
}
@Override
public List<CoursesVO> getPagePageSize(int page, int pageSize) {
@ -640,57 +665,76 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
private List<CourseUserInfVO> queryCourseUserForTeacher(Long userId) {
// 查询所有与该教师相关的课程
List<Courses> teacherCoursesInf = coursesMapper.selectList(
new LambdaQueryWrapper<Courses>()
// 1. 获取该教师负责的所有课程
List<Courses> teacherCoursesInf = coursesMapper.selectList(new LambdaQueryWrapper<Courses>()
.apply("FIND_IN_SET({0}, teacher)", userId)
.select(Courses::getId, Courses::getTeacher)
.select(Courses::getId, Courses::getTeacher, Courses::getName)
);
// 2. 提取所有课程的ID
Set<String> courseIds = teacherCoursesInf.stream()
.map(Courses::getId)
.collect(Collectors.toSet());
// 3. 批量查询所有课程的学生ID
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>().in(StudentCourses::getCourse, courseIds)
);
// 4. 获取所有的学生ID
Set<Long> studentIds = studentCourses.stream()
.map(StudentCourses::getStudent)
.collect(Collectors.toSet());
// 5. 批量查询所有学生的信息
List<UmsStudent> students = umsStudentMapper.selectList(
new LambdaQueryWrapper<UmsStudent>().in(UmsStudent::getUserId, studentIds)
);
// 6. 将学生信息缓存到Map中,Key为学生ID
Map<Long, UmsStudent> studentMap = students.stream()
.collect(Collectors.toMap(UmsStudent::getUserId, Function.identity()));
// 7. 处理教师信息并构建返回结果
List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>();
for (Courses courses : teacherCoursesInf) {
for (Courses course : teacherCoursesInf) {
CourseUserInfVO courseUserInfVO = new CourseUserInfVO();
courseUserInfVO.setCourseId(course.getId());
courseUserInfVO.setCourseName(course.getName());
List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>();
courseUserInfVO.setCourseId(courses.getId());
// 查询与课程相关的所有学生
List<Long> studentIds = studentCoursesMapper.selectList(
new LambdaQueryWrapper<>(StudentCourses.class)
.eq(StudentCourses::getCourse, courses.getId())
).stream().map(StudentCourses::getStudent).collect(Collectors.toList());
// 为每个学生创建一个新的 UserReadMessageTimeVO 对象
for (Long studentId : studentIds) {
UmsStudent umsStudent = umsStudentMapper.selectOne(
new LambdaQueryWrapper<>(UmsStudent.class)
.eq(UmsStudent::getUserId, studentId)
.select(UmsStudent::getName)
);
if (umsStudent == null) {
log.error("用户不存在: {}",studentId);
// 添加学生信息
for (StudentCourses sc : studentCourses) {
if (sc.getCourse().equals(course.getId())) {
UmsStudent student = studentMap.get(sc.getStudent()); // 类型转换
if (student != null) {
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(student.getUserId());
userReadMessageTimeVO.setReceiverName(student.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else {
log.error("学生不存在: {}", sc.getStudent());
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(studentId);
userReadMessageTimeVO.setReceiverName(umsStudent.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
}
}
// 为每个教师创建一个新的 UserReadMessageTimeVO 对象
String[] teacherUserIds = courses.getTeacher().split(",");
// 添加教师信息
String[] teacherUserIds = course.getTeacher().split(",");
for (String teacherId : teacherUserIds) {
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, teacherId)
new LambdaQueryWrapper<UmsTeacher>().eq(UmsTeacher::getUserId, teacherId)
);
if (umsTeacher == null) {
log.error("教师不存在: {}",teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
if (umsTeacher != null) {
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else {
log.error("教师不存在: {}", teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
}
courseUserInfVO.setUsersInf(userReadMessageTimeVOS);
@ -700,64 +744,94 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
}
private List<CourseUserInfVO> queryCourseUserForStudent(Long userId) {
// 查询学生所参与的所有课程
List<StudentCourses> studentCoursesList = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>()
.eq(StudentCourses::getStudent, userId)
.select(StudentCourses::getCourse)
// 1. 获取学生参与的所有课程
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>().eq(StudentCourses::getStudent, userId)
);
// 2. 提取所有课程的ID
Set<String> courseIds = studentCourses.stream()
.map(StudentCourses::getCourse)
.collect(Collectors.toSet());
// 3. 批量查询所有课程的信息
List<Courses> coursesList = coursesMapper.selectBatchIds(courseIds);
// 4. 获取所有的教师ID
Set<Long> teacherIds = coursesList.stream()
.flatMap(course -> Arrays.stream(course.getTeacher().split(",")))
.map(Long::parseLong)
.collect(Collectors.toSet());
// 5. 批量查询所有教师的信息
List<UmsTeacher> teachers = umsTeacherMapper.selectList(
new LambdaQueryWrapper<UmsTeacher>().in(UmsTeacher::getUserId, teacherIds)
);
// 6. 将教师信息缓存到Map中,Key为教师ID
Map<Long, UmsTeacher> teacherMap = teachers.stream()
.collect(Collectors.toMap(UmsTeacher::getUserId, Function.identity()));
// 7. 批量查询所有课程的学生信息
List<StudentCourses> allStudentCourses = studentCoursesMapper.selectList(
new LambdaQueryWrapper<StudentCourses>().in(StudentCourses::getCourse, courseIds)
);
// 8. 提取所有学生的ID
Set<Long> allStudentIds = allStudentCourses.stream()
.map(StudentCourses::getStudent)
.collect(Collectors.toSet());
// 9. 批量查询所有学生的信息
List<UmsStudent> students = umsStudentMapper.selectList(
new LambdaQueryWrapper<UmsStudent>().in(UmsStudent::getUserId, allStudentIds)
);
// 10. 将学生信息缓存到Map中,Key为学生ID
Map<Long, UmsStudent> studentMap = students.stream()
.collect(Collectors.toMap(UmsStudent::getUserId, Function.identity()));
// 11. 处理课程信息并构建返回结果
List<CourseUserInfVO> courseUserInfVOS = new ArrayList<>();
for (StudentCourses studentCourse : studentCoursesList) {
for (Courses course : coursesList) {
CourseUserInfVO courseUserInfVO = new CourseUserInfVO();
courseUserInfVO.setCourseId(course.getId());
courseUserInfVO.setCourseName(course.getName());
List<UserReadMessageTimeVO> userReadMessageTimeVOS = new ArrayList<>();
courseUserInfVO.setCourseId(studentCourse.getCourse());
// 查询与课程相关的所有学生
List<Long> studentIds = studentCoursesMapper.selectList(
new LambdaQueryWrapper<>(StudentCourses.class)
.eq(StudentCourses::getCourse, studentCourse.getCourse())
).stream().map(StudentCourses::getStudent).collect(Collectors.toList());
// 为每个学生创建一个新的 UserReadMessageTimeVO 对象
for (Long studentId : studentIds) {
UmsStudent umsStudent = umsStudentMapper.selectOne(
new LambdaQueryWrapper<>(UmsStudent.class)
.eq(UmsStudent::getUserId, studentId)
.select(UmsStudent::getName)
);
if (umsStudent == null) {
log.error("用户不存在: {}", studentId);
// 添加教师信息
String[] courseTeacherIds = course.getTeacher().split(",");
for (String teacherId : courseTeacherIds) {
UmsTeacher umsTeacher = teacherMap.get(Long.valueOf(teacherId));
if (umsTeacher != null) {
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else {
log.error("教师不存在: {}", teacherId);
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(studentId);
userReadMessageTimeVO.setReceiverName(umsStudent.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
}
// 查询与课程相关的所有教师
Courses course = coursesMapper.selectById(studentCourse.getCourse());
if (course != null) {
String[] teacherUserIds = course.getTeacher().split(",");
for (String teacherId : teacherUserIds) {
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>()
.eq(UmsTeacher::getUserId, teacherId)
);
if (umsTeacher == null) {
log.error("教师不存在: {}", teacherId);
// 添加学生信息
for (StudentCourses sc : allStudentCourses) {
if (sc.getCourse().equals(course.getId())) {
UmsStudent student = studentMap.get(sc.getStudent()); // 类型转换
if (student != null) {
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO();
userReadMessageTimeVO.setId(student.getUserId());
userReadMessageTimeVO.setReceiverName(student.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
} else {
log.error("学生不存在: {}", sc.getStudent());
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
UserReadMessageTimeVO userReadMessageTimeVO = new UserReadMessageTimeVO(); // 在循环中创建新对象
userReadMessageTimeVO.setId(umsTeacher.getUserId());
userReadMessageTimeVO.setReceiverName(umsTeacher.getName());
userReadMessageTimeVOS.add(userReadMessageTimeVO);
}
} else {
log.error("课程不存在: {}", studentCourse.getCourse());
throw new BusinessException(ErrorCode.PARAMS_COURSE_NOTEXISTS);
}
courseUserInfVO.setUsersInf(userReadMessageTimeVOS);
@ -766,6 +840,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
return courseUserInfVOS;
}
}

@ -16,9 +16,6 @@ import com.teaching.backend.mapper.favour.SeCourseFavourMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService;
@ -157,7 +154,7 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
@Override
public List<CoursesVO> queryNewCollect(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
String roleId = umsUserMapper.getByIdRoleId(userId);
List<Courses> coursesList = new ArrayList<>();
if (roleId.equals("1")){
//老师

@ -7,9 +7,11 @@ import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.message.MessagesMapper;
import com.teaching.backend.mapper.message.UserInboxMapper;
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.dto.message.SysMessageDTO;
import com.teaching.backend.model.entity.message.SysMessages;
import com.teaching.backend.model.entity.message.UserInbox;
import com.teaching.backend.model.entity.umsAdmin.UmsUser;
import com.teaching.backend.service.message.IMessagesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
@ -38,6 +40,8 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
@Autowired
private UserInboxMapper userInboxMapper;
@Autowired
private UmsUserMapper umsUserMapper;
@Override
@Transactional
public String sendMessageToUserInbox(SysMessageDTO sysMessageDTO) {
@ -51,8 +55,20 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
List<Long> receiverIds = Arrays.stream(sysMessageDTO.getReceiverId().split(","))
.map(Long::valueOf)
.collect(Collectors.toList());
if (receiverIds.size()<1){
throw new BusinessException(ErrorCode.LEAST_ONE_USER);
}
// 4.判断是什么用户,只有教师可以群发,学生只能单发
String roleId = umsUserMapper.selectOne(new LambdaQueryWrapper<>(UmsUser.class)
.eq(UmsUser::getId, sysMessageDTO.getSenderId())).getRoleId();
if(roleId.equals("2")){
if (receiverIds.size()>1){
throw new BusinessException(ErrorCode.STUDENT_ROLE_CANT_MULTIPLESEND);
}
}
// 4.数据写入收件箱
// 5.数据写入收件箱
List<UserInbox> userInboxes = receiverIds.stream()
.map(receiverId -> {
UserInbox userInbox = new UserInbox();
@ -68,7 +84,7 @@ public class MessagesServiceImpl extends ServiceImpl<MessagesMapper, SysMessages
throw new BusinessException(ErrorCode.OPERATION_ERROR, "收件箱数据插入失败!");
}
// 5.更新或保存消息数据
// 6.更新或保存消息数据
SysMessages sysMessages = new SysMessages();
BeanUtils.copyProperties(sysMessageDTO, sysMessages);
sysMessages.setId(messageId);

@ -56,7 +56,6 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
@Autowired
private UserInboxMapper userInboxMapper;
//TODO 不需要特别指定“已读”或者是“未读”
@Override
public PageDTO<SysMessageVO> queryReceiveMessages(MessagesQuery messagesQuery) {
// 先按用户的id找到其的消息列表 默认看未删除的,(是否读 作为筛选条件后传进去)
@ -126,10 +125,10 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
@Override
public PageDTO<SysMessageVO> querySendMessages(MessagesQuery messagesQuery) {
// 初始化一个按发送时间降序排序的Page对象
// 1. 初始化一个按发送时间降序排序的Page对象
Page<SysMessages> page = messagesQuery.toMpPage("send_time", false);
// 根据条件查询SysMessages表
// 2. 根据条件查询SysMessages表
Page<SysMessages> p = messagesService.page(page,
new LambdaQueryWrapper<SysMessages>()
.eq(SysMessages::getSenderId, messagesQuery.getUserId())
@ -138,7 +137,7 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
.select(SysMessages::getId, SysMessages::getCourseId, SysMessages::getTitle, SysMessages::getSendTime)
);
// 将Page<SysMessages>转换为PageDTO<SysMessageVO>
// 3. 将Page<SysMessages>转换为PageDTO<SysMessageVO>
PageDTO<SysMessageVO> messages = PageDTO.of(p, SysMessageVO.class);
List<SysMessageVO> messagesList = messages.getList();
@ -146,31 +145,33 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
throw new BusinessException(ErrorCode.MESSAGE_NO_EXIT);
}
// 批量查询课程名称
// 4. 批量查询课程ID
Set<String> courseIds = messagesList.stream()
.map(SysMessageVO::getCourseId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 5. 批量查询课程ID对应的课程名称 并把ID:name 对应到一起
Map<String, String> courseNames = coursesMapper.selectBatchIds(courseIds).stream()
.collect(Collectors.toMap(Courses::getId, Courses::getName));
// 批量查询所有用户收件箱数据
// 6. 批量查询当前用户对应的消息集合messageIds
Set<Long> messageIds = messagesList.stream()
.map(SysMessageVO::getId)
.collect(Collectors.toSet());
// 在用户邮箱中批量查询 对应消息的 信息(消息id,接受者id,是否已读)
List<UserInbox> allUserInboxes = userInboxMapper.selectList(
new LambdaQueryWrapper<UserInbox>()
.in(UserInbox::getMessageId, messageIds)
.select(UserInbox::getMessageId, UserInbox::getReceiverId, UserInbox::getIsRead)
);
// 将UserInbox数据按消息ID进行分组
// 7. 将UserInbox数据按消息ID进行分组(已经初步得到了消息的详情)
Map<Long, List<UserInbox>> userInboxesByMessageId = allUserInboxes.stream()
.collect(Collectors.groupingBy(UserInbox::getMessageId));
// 缓存用户名称以避免重复查询
// 8. 缓存用户名称以避免重复查询
Map<Long, String> userNamesCache = new HashMap<>();
for (SysMessageVO sysMessageVO : messagesList) {
@ -201,7 +202,7 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(
new LambdaQueryWrapper<UmsTeacher>().eq(UmsTeacher::getUserId, id)
);
return umsTeacher != null ? umsTeacher.getName() : null;
return umsTeacher != null ? umsTeacher.getName() : "教师不存在";
}
});
@ -213,14 +214,21 @@ public class UserInboxServiceImpl extends ServiceImpl<UserInboxMapper, UserInbox
}
}
// 更新PageDTO中的消息列表并返回
// 9. 更新PageDTO中的消息列表并返回
messages.setList(messagesList);
return messages;
}
@Override
public SysMessageVO getMessageDetail(MessagesQuery messagesQuery) {
Long count = userInboxMapper.selectCount(new LambdaQueryWrapper<>(UserInbox.class)
.eq(UserInbox::getMessageId, messagesQuery.getMessageId())
.eq(UserInbox::getReceiverId, messagesQuery.getUserId()));
if (!(count > 0)){
throw new BusinessException(ErrorCode.MESSAGE_NO_EXIT);
}
SysMessages sysMessage = messagesService.getById(messagesQuery.getMessageId());
SysMessageVO sysMessageVO = new SysMessageVO();
sysMessageVO.setId(messagesQuery.getMessageId());

@ -123,7 +123,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
@Override
public List<CoursesVO> queryCourseList(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
String roleId = umsUserMapper.getByIdRoleId(userId);
List<Courses> coursesList = new ArrayList<>();
if (roleId.equals("1")){
List<String> courseIds = courseLearningRecordMapper.selectMaxNumber();
@ -148,7 +148,7 @@ public class CourseLearningRecordServiceImpl extends ServiceImpl<CourseLearningR
@Override
public List<CoursesVO> queryrecommendCourses(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
String roleId = umsUserMapper.getByIdRoleId(userId);
if (roleId.equals("1")) {

@ -12,18 +12,12 @@ import com.teaching.backend.mapper.umsAdmin.UmsUserMapper;
import com.teaching.backend.model.entity.KnowGraph.KnowledgeLearningNumber;
import com.teaching.backend.model.entity.courses.CourseLearningNumber;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.knowtmp.Knowtmp;
import com.teaching.backend.model.entity.records.KnowledgeLearningRecord;
import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.model.vo.knowGraph.KnowVO;
import com.teaching.backend.model.vo.records.KnowledgeLearningRecordVo;
import com.teaching.backend.service.Know.KnowService;
import com.teaching.backend.service.impl.courses.CourseLearningNumberServiceImpl;
import com.teaching.backend.service.impl.knowledge.KnowledgeLearningNumberServiceImpl;
import com.teaching.backend.service.knowtmp.KnowtmpService;
import com.teaching.backend.service.records.IKnowledgeLearningRecordService;
@ -141,7 +135,7 @@ public class KnowledgeLearningRecordServiceImpl extends ServiceImpl<KnowledgeLea
@Override
public List<KnowVO> queryMaxKnowledge(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
String roleId = umsUserMapper.getByIdRoleId(userId);
List<KnowVO> coursesList = new ArrayList<>();
KnowVO knowVO = null;
if (roleId.equals("1")){

@ -91,7 +91,7 @@ public class UmsStudentManageServiceImpl extends ServiceImpl<UmsStudentManageMap
}
UmsUser umsUser = new UmsUser();
BeanUtils.copyProperties(umsStudentManage, umsUser);
umsUser.setId(Long.valueOf(umsStudentManage.getUserId()));
umsUser.setId(umsStudentManage.getUserId());
boolean userInformation = umsUserMapper.updateUserInformation(umsUser);
if (userInformation == false){
throw new BusinessException(400,"修改失败");

@ -42,8 +42,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@Service
@Slf4j
public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService {
@ -90,7 +88,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser byUsername = lambdaQuery().eq(UmsUser::getUsername, umsUser.getUsername())
.one();
UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId()));
umsStudent.setUserId(byUsername.getId());
umsStudentMapper.insert(umsStudent);
return umsUser;
@ -311,7 +309,7 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
UmsUser byUsername = lambdaQuery().eq(UmsUser::getPhone, umsUser.getPhone())
.one();
UmsStudent umsStudent = new UmsStudent();
umsStudent.setUserId(Math.toIntExact(byUsername.getId()));
umsStudent.setUserId(byUsername.getId());
umsStudentMapper.insert(umsStudent);
return umsUser;

@ -10,12 +10,16 @@ package com.teaching.backend.utils.Chapter;
* @Version 1.0
*/
import com.teaching.backend.mapper.chapter.TemporaryChapterMapper;
import com.teaching.backend.service.chapter.IChapterService;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xml.sax.InputSource;
@ -31,27 +35,43 @@ import java.util.List;
*/
@Component
public class ExcelParser {
@Autowired
TemporaryChapterMapper temporaryChapterMapper;
@Autowired
IChapterService chapterService;
public List<String> parse(InputStream inputStream, String courseId) throws Exception {
OPCPackage pkg = OPCPackage.open(inputStream);
List<String> validationErrors = new ArrayList<>();
int totalRows = 0;
try {
XSSFReader reader = new XSSFReader(pkg);
SharedStringsTable sst = reader.getSharedStringsTable();
StylesTable styles = reader.getStylesTable();
XMLReader parser = XMLReaderFactory.createXMLReader();
SheetHandler sheetHandler = new SheetHandler(chapterService, courseId);
parser.setContentHandler(new XSSFSheetXMLHandler(styles, sst, sheetHandler, false));
XSSFReader.SheetIterator sheets = (XSSFReader.SheetIterator) reader.getSheetsData();
SheetPreScanner preScanner = new SheetPreScanner();
while (sheets.hasNext()) {
InputStream sheetstream = sheets.next();
InputSource sheetSource = new InputSource(sheetstream);
try {
parser.setContentHandler(new XSSFSheetXMLHandler(styles, sst, preScanner, false));
parser.parse(sheetSource);
} finally {
sheetstream.close();
}
}
totalRows = preScanner.getRowCount();
sheets = (XSSFReader.SheetIterator) reader.getSheetsData();
SheetHandler sheetHandler = null;
while (sheets.hasNext()) {
InputStream sheetstream = sheets.next();
InputSource sheetSource = new InputSource(sheetstream);
try {
sheetHandler = new SheetHandler(temporaryChapterMapper, chapterService, courseId, totalRows);
parser.setContentHandler(new XSSFSheetXMLHandler(styles, sst, sheetHandler, false));
parser.parse(sheetSource);
} finally {
sheetstream.close();

@ -1,12 +1,13 @@
package com.teaching.backend.utils.Chapter;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.chapter.ChapterDTO;
import com.teaching.backend.mapper.chapter.TemporaryChapterMapper;
import com.teaching.backend.model.dto.chapter.ChapterExcelDTO;
import com.teaching.backend.service.chapter.IChapterService;
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
import org.apache.poi.xssf.usermodel.XSSFComment;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@ -22,66 +23,52 @@ import java.util.*;
public class SheetHandler implements XSSFSheetXMLHandler.SheetContentsHandler {
private Long currentChapterPid;
private final TemporaryChapterMapper temporaryChapterMapper;
private Double chapterHour;
private final IChapterService chapterService;
private final String courseId;
private ChapterDTO chapterDTO;
private ChapterExcelDTO chapterDTO;
private Map<Long, Long> excelIdToDatabaseIdMap = new HashMap<>();
private List<String> validationErrors = new ArrayList<>();
private boolean hasErrors = false;
private List<ChapterDTO> collectedChapters = new ArrayList<>();
private int totalRows;
public SheetHandler(IChapterService chapterService, String courseId) {
public SheetHandler(TemporaryChapterMapper temporaryChapterMapper, IChapterService chapterService, String courseId,int totalRows) {
this.temporaryChapterMapper = temporaryChapterMapper;
this.chapterService = chapterService;
this.courseId = courseId;
this.totalRows=totalRows;
}
@Override
public void startRow(int rowIndex) {
if (rowIndex == 0) {
if (rowIndex < totalRows - 1) {
if (rowIndex == 0 || rowIndex == 1) {
chapterDTO = null;
} else {
chapterDTO = new ChapterDTO();
chapterDTO = new ChapterExcelDTO();
chapterDTO.setCourseId(courseId);
}
} else {
chapterDTO = null;
}
@Override
public void endRow(int rowIndex) {
if (rowIndex != 0 && chapterDTO != null) {
List<String> errors = validateChapter(chapterDTO);
if (!errors.isEmpty()) {
validationErrors.addAll(errors);
hasErrors = true;
return;
}
collectedChapters.add(chapterDTO);
}
}
@Transactional(rollbackFor = Exception.class)
public List<String> finalizeProcess() {
if (hasErrors) {
return validationErrors;
}
for (ChapterDTO chapter : collectedChapters) {
if (chapter.getParentExcelId() == null || chapter.getParentExcelId() == 0) {
saveToTemporaryTable(chapter);
}
}
for (ChapterDTO chapter : collectedChapters) {
if (chapter.getParentExcelId() != null && chapter.getParentExcelId() != 0) {
saveToTemporaryTable(chapter);
}
}
chapterService.moveDataFromTemporaryToFinal();
return Collections.emptyList();
}
private void saveToTemporaryTable(ChapterDTO chapterDTO) {
private void saveToTemporaryTable(ChapterExcelDTO chapterDTO) {
Long pid = chapterDTO.getParentExcelId();
if (pid != null && pid != 0) {
Long parentId = excelIdToDatabaseIdMap.get(pid);
@ -91,44 +78,84 @@ public class SheetHandler implements XSSFSheetXMLHandler.SheetContentsHandler {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "未找到父章节,Excel ID 为: " + pid);
}
}
Long savedChapterId = chapterService.saveToTemporaryTable(chapterDTO);
excelIdToDatabaseIdMap.put(chapterDTO.getExcelId(), savedChapterId);
}
}
private List<String> validateChapter(ChapterExcelDTO chapterDTO) {
List<String> errors = new ArrayList<>();
return errors;
}
@Override
public void endRow(int rowIndex) {
if (rowIndex != 0 && chapterDTO != null) {
List<String> errors = validateChapter(chapterDTO);
if (!errors.isEmpty()) {
validationErrors.addAll(errors);
hasErrors = true;
return;
}
private List<String> validateChapter(ChapterDTO chapterDTO) {
List<String> errors = new ArrayList<>();
if (chapterDTO.getName() == null || chapterDTO.getName().isEmpty()) {
errors.add("编号:"+chapterDTO.getExcelId()+"的章节名字不能为空");
if (chapterDTO.isSection()) {
if (currentChapterPid != null) {
chapterDTO.setTotalClassHours(chapterHour);
chapterDTO.setPid(currentChapterPid);
saveToTemporaryTable(chapterDTO);
} else {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "未找到父章节,Excel ID 为: " + chapterDTO.getExcelId());
}
if (chapterDTO.getExcelId() == null || chapterDTO.getExcelId() <= 0) {
errors.add("编号不能小于0");
}
if (chapterDTO.getParentExcelId() == null || chapterDTO.getParentExcelId() < 0) {
errors.add("编号:"+chapterDTO.getExcelId()+"的上级编号不能小于0");
}
return errors;
}
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
if (chapterDTO != null && formattedValue != null) {
if (chapterDTO != null) {
String letter = cellReference.substring(0, 1);
switch (letter) {
case "A":
chapterDTO.setExcelId(Long.valueOf(formattedValue));
break;
case "B":
chapterDTO.setName(formattedValue);
break;
case "C":
chapterDTO.setParentExcelId(Long.valueOf(formattedValue));
if (!chapterDTO.isSection()) {
chapterDTO.setTotalClassHours(Double.parseDouble(formattedValue));
saveToTemporaryTable(chapterDTO);
currentChapterPid = excelIdToDatabaseIdMap.get(chapterDTO.getExcelId());
}
break;
case "D":
chapterDTO.setOrderNum(Double.valueOf(formattedValue));
break;
case "E":
if (!formattedValue.isEmpty()) {
chapterDTO.setName(formattedValue);
chapterDTO.setIsSection(true);
}
break;
case "F":
if (chapterDTO.isSection()) {
chapterDTO.setTotalClassHours(Double.parseDouble(formattedValue));
chapterHour = chapterDTO.getTotalClassHours();
}
break;
}
}
}
}

@ -0,0 +1,34 @@
package com.teaching.backend.utils.Chapter;
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
import org.apache.poi.xssf.usermodel.XSSFComment;
/**
* ClassName: Sheet
* Package: com.teaching.backend.utils.Chapter
* Description:
*
* @Author 姜钧瀚
* @Create 2024/8/11 18:04
* @Version 1.0
*/
public class SheetPreScanner implements XSSFSheetXMLHandler.SheetContentsHandler {
private int rowCount = 0;
@Override
public void startRow(int rowNum) {
rowCount++;
}
@Override
public void endRow(int rowNum) {
}
@Override
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
}
public int getRowCount() {
return rowCount;
}
}

@ -76,7 +76,7 @@
WHERE
s.user_id = #{id}
</select>
<select id="getbyIdRoleId" parameterType="java.lang.String" resultType="java.lang.String">
<select id="getByIdRoleId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
us.role_id roleId
FROM

Loading…
Cancel
Save