Explorar o código

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/resources/application-prod.yml
fanxp hai 3 meses
pai
achega
b37139cec3

+ 1 - 1
Makefile

@@ -5,7 +5,7 @@ merge-pre:
 	git checkout pre;git merge dev;git push;git checkout dev;
 
 create-tag:
-	git checkout master;git tag v5.2.6;git push origin --tags;git checkout dev;
+	git checkout master;git tag v5.3.0;git push origin --tags;git checkout dev;
 
 remove-tag:
 	git tag -d v1.2.0;git push origin :refs/tags/v1.1.8;

+ 31 - 2
src/main/java/com/xjrsoft/config/FileCheckRuleConfig.java

@@ -58,7 +58,11 @@ public final class FileCheckRuleConfig {
      * 文档规则
      */
     public static final FileCheckRuleConfig DOCUMENT = builder()
-            .withExtensions("pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt")
+            .withExtensions(
+                    "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt",
+                    // WPS 文件扩展名
+                    "wps", "et", "dps", "wpt", "ett", "dpt", "vsd", "vsdx"
+            )
             .withMimeTypes(
                     "application/pdf",
                     "application/msword",
@@ -67,9 +71,34 @@ public final class FileCheckRuleConfig {
                     "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                     "application/vnd.ms-powerpoint",
                     "application/vnd.openxmlformats-officedocument.presentationml.presentation",
-                    "text/plain"
+                    "text/plain",
+                    // WPS MIME 类型
+                    "application/vnd.ms-works",
+                    "application/wps-office.wps",
+                    "application/wps-office.et",
+                    "application/wps-office.dps",
+                    "application/wps-office.wpt",
+                    "application/wps-office.ett",
+                    "application/wps-office.dpt",
+                    // 其他可能的 MIME 类型
+                    "application/octet-stream", // 某些 WPS 文件可能被识别为此类型
+                    "application/x-msdownload"
             )
             .build();
+//    /**
+//     * 特殊文件类型规则
+//     */
+//    public static final FileCheckRuleConfig SPECIAL = builder()
+//            .withExtensions("mp4", "mov", "avi", "wmv", "flv", "mkv")
+//            .withMimeTypes(
+//                    "video/mp4",
+//                    "video/quicktime",
+//                    "video/x-msvideo",
+//                    "video/x-ms-wmv",
+//                    "video/x-flv",
+//                    "video/x-matroska"
+//            )
+//            .build();
     /* ========== 组合类型规则 ========== */
     /**
      * 媒体规则(图片+视频)

+ 90 - 120
src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java

@@ -84,6 +84,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -139,10 +141,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
         // 获取教师信息
         MPJLambdaWrapper<XjrUser> queryWrapper = new MPJLambdaWrapper<>();
-        queryWrapper
-                .disableSubLogicDel()
-                .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, XjrUser::getId)
-                .selectAll(XjrUser.class);
+        queryWrapper.disableSubLogicDel().innerJoin(BaseTeacher.class, BaseTeacher::getUserId, XjrUser::getId).selectAll(XjrUser.class);
         List<XjrUser> xjrUserList = teacherbaseManagerService.list(queryWrapper);
         Map<String, XjrUser> xjrUsersMap = xjrUserList.stream().collect(Collectors.toMap(XjrUser::getName, a -> a, (k1, k2) -> k1));
 
@@ -172,8 +171,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     @Override
     public List<ClassListVo> classList(ClassListDto dto) {
         LambdaQueryWrapper<CourseTable> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(CourseTable::getClassId, dto.getClassId())
-                .eq(ObjectUtil.isNotEmpty(dto.getWeeks()), CourseTable::getWeeks, dto.getWeeks());
+        queryWrapper.eq(CourseTable::getClassId, dto.getClassId()).eq(ObjectUtil.isNotEmpty(dto.getWeeks()), CourseTable::getWeeks, dto.getWeeks());
 
         List<CourseTable> courseTables = courseTableMapper.selectList(queryWrapper);
 
@@ -203,10 +201,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     @Override
     public CourseTableVo getList(CourseTableDto dto) {
 
-        List<ClassTime> classTimes = classTimeMapper.selectList(
-                new QueryWrapper<ClassTime>().lambda()
-                        .ne(ClassTime::getTimePeriod, 0)
-                        .orderByAsc(ClassTime::getSummerStartTime)
+        List<ClassTime> classTimes = classTimeMapper.selectList(new QueryWrapper<ClassTime>().lambda().ne(ClassTime::getTimePeriod, 0).orderByAsc(ClassTime::getSummerStartTime)
 
         );
 
@@ -217,42 +212,67 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             BaseSemester baseSemester = baseSemesterMapper.selectById(dto.getSemesterId());
             tableVo.setSemesterName(baseSemester.getName());
             LocalDateTime now = LocalDateTime.now();
-            //计算本周是第几周
-            LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getTeachingStart().toInstant(), ZoneId.systemDefault());
-            LocalDateTime endDateTime = LocalDateTime.ofInstant(baseSemester.getTeachingEnd().toInstant(), ZoneId.systemDefault());
-            Duration between = Duration.between(startDateTime, endDateTime);
-            long days = between.toDays();
-            int weeks = (int) Math.ceil((double) days / 7);
+            // 计算本周是第几周
+            LocalDate semesterStart = LocalDate.ofInstant(baseSemester.getTeachingStart().toInstant(), ZoneId.systemDefault());
+            LocalDate semesterEnd = LocalDate.ofInstant(baseSemester.getTeachingEnd().toInstant(), ZoneId.systemDefault());
+
+            // 调整到完整的周范围(周一到周日)
+            LocalDate weekStart = semesterStart.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDate weekEnd = semesterEnd.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
+
+            // 计算总周数
+            long totalWeeks = ChronoUnit.WEEKS.between(weekStart, weekEnd.plusDays(1)); // 加1天以确保包含最后一周
+
             if (dto.getWeek() == null) {
-                for (int i = 0; i < weeks; i++) {
-                    LocalDateTime startDate = startDateTime.plusDays(i * 7L).withHour(0).withMinute(0).withSecond(0).withNano(0);
-                    LocalDateTime endDate = startDate.plusDays(6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
-                    if (now.isAfter(startDate) && now.isBefore(endDate)) {
-                        tableVo.setWeek("第" + (i + 1) + "周");
-                    }
-                    tableVo.setStartDate(startDate.toLocalDate());
-                    tableVo.setEndDate(endDate.toLocalDate());
+                // 查找当前日期所在的周
+                long weeksBetween = ChronoUnit.WEEKS.between(weekStart, now);
+                LocalDate calculatedWeekStart = weekStart.plusWeeks(weeksBetween);
+                LocalDate calculatedWeekEnd = calculatedWeekStart.plusDays(6);
+
+                // 验证是否在学期范围内
+                LocalDate nowDate = now.toLocalDate();
+
+                if (!nowDate.isBefore(weekStart) && !nowDate.isAfter(weekEnd)) {
+                    int currentWeek = (int) (weeksBetween + 1);
+                    tableVo.setWeek("第" + currentWeek + "周");
+                    tableVo.setStartDate(calculatedWeekStart);
+                    tableVo.setEndDate(calculatedWeekEnd);
+                } else {
+                    tableVo.setWeek("不在学期范围内");
+                    tableVo.setStartDate(weekStart);
+                    tableVo.setEndDate(weekEnd);
                 }
             } else {
-                LocalDateTime startDate = startDateTime.plusDays((dto.getWeek() - 1) * 7L).withHour(0).withMinute(0).withSecond(0).withNano(0);
-                LocalDateTime endDate = startDate.plusDays(6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
-                dto.setStartDate(startDate);
-                dto.setEndDate(endDate);
-                tableVo.setWeek("第" + dto.getWeek() + "周");
-                tableVo.setStartDate(startDate.toLocalDate());
-                tableVo.setEndDate(endDate.toLocalDate());
-            }
+                // 根据指定周数计算日期范围
+                int weekNumber = dto.getWeek();
+                if (weekNumber < 1 || weekNumber > totalWeeks) {
+                    throw new MyException("周数必须在1到" + totalWeeks + "之间");
+                }
 
+                LocalDateTime semesterStartDateTime = baseSemester.getTeachingStart().toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalDateTime();
+
+                LocalDateTime weekStartDateTime = semesterStartDateTime
+                        .plusWeeks(weekNumber - 1)
+                        .toLocalDate()
+                        .with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
+                        .atStartOfDay();
+
+                LocalDateTime weekEndDateTime = weekStartDateTime.plusDays(6)
+                        .with(LocalTime.MAX);
+
+                dto.setStartDate(weekStartDateTime);
+                dto.setEndDate(weekEndDateTime);
+                tableVo.setWeek("第" + weekNumber + "周");
+                tableVo.setWeek("第" + weekNumber + "周");
+                tableVo.setStartDate(weekStartDateTime.toLocalDate());
+                tableVo.setEndDate(weekEndDateTime.toLocalDate());
+            }
         }
         if (!StrUtil.isEmpty(dto.getTeacherName())) {
-            List<XjrUser> userList = teacherbaseManagerService.list(
-                    new QueryWrapper<XjrUser>().lambda()
-                            .like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getName, dto.getTeacherName())
-            );
-            List<XjrUser> userList2 = teacherbaseManagerService.list(
-                    new QueryWrapper<XjrUser>().lambda()
-                            .like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getCode, dto.getTeacherName())
-            );
+            List<XjrUser> userList = teacherbaseManagerService.list(new QueryWrapper<XjrUser>().lambda().like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getName, dto.getTeacherName()));
+            List<XjrUser> userList2 = teacherbaseManagerService.list(new QueryWrapper<XjrUser>().lambda().like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getCode, dto.getTeacherName()));
             userList.addAll(userList2);
             if (!userList.isEmpty()) {
                 XjrUser xjrUser = userList.get(0);
@@ -264,9 +284,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             if (dto.getStudentId() == null && dto.getTeacherId() == null && dto.getClassId() == null) {
                 dto.setTeacherId(StpUtil.getLoginIdAsLong());
             } else {
-                List<BaseStudentSchoolRoll> schoolRolls = baseStudentSchoolRollService.list(
-                        new QueryWrapper<BaseStudentSchoolRoll>().lambda().eq(BaseStudentSchoolRoll::getUserId, dto.getStudentId())
-                );
+                List<BaseStudentSchoolRoll> schoolRolls = baseStudentSchoolRollService.list(new QueryWrapper<BaseStudentSchoolRoll>().lambda().eq(BaseStudentSchoolRoll::getUserId, dto.getStudentId()));
                 if (schoolRolls != null && !schoolRolls.isEmpty()) {
                     dto.setCourseType("class");
                     dto.setClassId(schoolRolls.get(0).getClassId());
@@ -354,13 +372,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     @Transactional(rollbackFor = Exception.class)
     public Boolean adjustCourse(WfCourseAdjust courseAdjust) {
         //先查询课表数据,看是否能够查询到,如果能查到
-        List<CourseTable> list = this.list(
-                new MPJLambdaWrapper<CourseTable>()
-                        .select(CourseTable::getId)
-                        .select(CourseTable.class, x -> VoToColumnUtil.fieldsToColumns(CourseTable.class).contains(x.getProperty()))
-                        .innerJoin(CourseTableBak.class, CourseTableBak::getId, CourseTable::getId)
-                        .eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId())
-        );
+        List<CourseTable> list = this.list(new MPJLambdaWrapper<CourseTable>().select(CourseTable::getId).select(CourseTable.class, x -> VoToColumnUtil.fieldsToColumns(CourseTable.class).contains(x.getProperty())).innerJoin(CourseTableBak.class, CourseTableBak::getId, CourseTable::getId).eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId()));
         String[] courseIds = courseAdjust.getCourseId().split(",");
 
         ArrayList<String> courseIdList = new ArrayList<>(Arrays.asList(courseIds));
@@ -375,18 +387,9 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         LocalDateTime now = LocalDateTime.now();
 
         if (list.isEmpty() || list.size() != courseCount) {
-            list = this.list(
-                    new MPJLambdaWrapper<CourseTable>()
-                            .select(CourseTable::getId)
-                            .select(CourseTable.class, x -> VoToColumnUtil.fieldsToColumns(CourseTable.class).contains(x.getProperty()))
-                            .innerJoin(CourseTableBak.class, CourseTableBak::getKeyInfo, CourseTable::getKeyInfo)
-                            .eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId())
-            );
+            list = this.list(new MPJLambdaWrapper<CourseTable>().select(CourseTable::getId).select(CourseTable.class, x -> VoToColumnUtil.fieldsToColumns(CourseTable.class).contains(x.getProperty())).innerJoin(CourseTableBak.class, CourseTableBak::getKeyInfo, CourseTable::getKeyInfo).eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId()));
             Map<String, CourseTable> courseMap = list.stream().collect(Collectors.toMap(CourseTable::getKeyInfo, x -> x));
-            List<CourseTableBak> bakList = courseTableBakMapper.selectList(
-                    new QueryWrapper<CourseTableBak>().lambda()
-                            .eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId())
-            );
+            List<CourseTableBak> bakList = courseTableBakMapper.selectList(new QueryWrapper<CourseTableBak>().lambda().eq(CourseTableBak::getWfCourseAdjustId, courseAdjust.getId()));
             Map<Long, String> bakKeyInfoMap = bakList.stream().collect(Collectors.toMap(CourseTableBak::getId, CourseTableBak::getKeyInfo));
             Map<Long, CourseTableBak> bakCourseMap = bakList.stream().collect(Collectors.toMap(CourseTableBak::getId, x -> x));
 
@@ -519,7 +522,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             } else if (CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseAdjust.getAdjustType())) {
                 for (String courseId : courseIds) {
                     CourseTable courseTable = courseTableMapper.selectById(courseId);
-                    if(courseTable == null){
+                    if (courseTable == null) {
                         continue;
                     }
 
@@ -628,10 +631,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                                 continue;
                             }
                             if (courseDetailVo != null) {
-                                String courseInfo = courseDetailVo.getCourseName() + "\n" +
-                                        courseDetailVo.getTeacherName() + "\n" +
-                                        courseDetailVo.getClassName() + "\n" +
-                                        courseDetailVo.getClassroomName() + "\n";
+                                String courseInfo = courseDetailVo.getCourseName() + "\n" + courseDetailVo.getTeacherName() + "\n" + courseDetailVo.getClassName() + "\n" + courseDetailVo.getClassroomName() + "\n";
                                 switch (i) {
                                     case 1:
                                         scheduleWeekExportQueryVo.setMonday(courseInfo);
@@ -673,9 +673,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         // 创建头部样式
         WriteCellStyle headWriteCellStyle = createHeadCellStyle();
         // 将数据写入Excel文件
-        try (ExcelWriter excelWriter = EasyExcel.write(outputStream, ScheduleWeekExportQueryVo.class)
-                .registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle))
-                .build()) {
+        try (ExcelWriter excelWriter = EasyExcel.write(outputStream, ScheduleWeekExportQueryVo.class).registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle)).build()) {
 
             writeSheetHead(courseTableVo, excelWriter);
 
@@ -695,10 +693,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
     private void writeSheetHead(CourseTableVo courseTableVo, ExcelWriter excelWriter) {
         List<List<String>> sheetHeadList = new ArrayList<>();
-        sheetHeadList.add(Collections.singletonList(courseTableVo.getSemesterName() + " "
-                + ((courseTableVo.getTeacherName() != null) ? courseTableVo.getTeacherName() : courseTableVo.getClassName()) + " "
-                + courseTableVo.getWeek() + " "
-                + "课程表"));
+        sheetHeadList.add(Collections.singletonList(courseTableVo.getSemesterName() + " " + ((courseTableVo.getTeacherName() != null) ? courseTableVo.getTeacherName() : courseTableVo.getClassName()) + " " + courseTableVo.getWeek() + " " + "课程表"));
 
         ExcelFillCellMergePrevColUtil sheetHeadColumn = new ExcelFillCellMergePrevColUtil();
         sheetHeadColumn.add(0, 0, 8);
@@ -1117,8 +1112,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 row.setHeightInPoints(48);
             }
             //合并
-            Map<Integer, List<Integer>> collect = data.getClassTimeList().stream()
-                    .collect(Collectors.groupingBy(ClassTime::getTimePeriod, Collectors.mapping(ClassTime::getNumber, Collectors.toList())));
+            Map<Integer, List<Integer>> collect = data.getClassTimeList().stream().collect(Collectors.groupingBy(ClassTime::getTimePeriod, Collectors.mapping(ClassTime::getNumber, Collectors.toList())));
             int firstRow = 2;
             for (Integer i : collect.keySet()) {
                 int lastRow = firstRow + collect.get(i).size() - 1;
@@ -1285,16 +1279,10 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         dataDto.setIsCustom(1);
         CourseTableVo tableVo = this.getList(dataDto);
 
-        if("class".equals(dto.getCourseType())){//班级课表
+        if ("class".equals(dto.getCourseType())) {//班级课表
             //根据年级、专业部,查询需要导出的班级
-            List<BaseClass> classList = baseClassService.list(
-                    new QueryWrapper<BaseClass>().lambda()
-                            .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
-                            .eq(BaseClass::getIsGraduate, 1)
-                            .in(BaseClass::getGradeId, dto.getGradeIds())
-                            .in(BaseClass::getOrgId, dto.getDeptIds())
-            );
-            if(classList.isEmpty()){
+            List<BaseClass> classList = baseClassService.list(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode()).eq(BaseClass::getIsGraduate, 1).in(BaseClass::getGradeId, dto.getGradeIds()).in(BaseClass::getOrgId, dto.getDeptIds()));
+            if (classList.isEmpty()) {
                 throw new MyException("未查询到班级,无法导出");
             }
 
@@ -1314,7 +1302,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             for (BaseClass baseClass : classList) {
                 CourseTableVo classData = new CourseTableVo();
                 classData.setClassTimeList(tableVo.getClassTimeList());
-                if(!classDataMap.containsKey(baseClass.getName())){
+                if (!classDataMap.containsKey(baseClass.getName())) {
                     continue;
                 }
                 classData.setCourseList(classDataMap.get(baseClass.getName()));
@@ -1331,22 +1319,17 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 createSecondTitle(workbook, sheet, bigHeadRow + 3);
                 //生成内容
                 exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
-                i ++;
+                i++;
             }
             workbook.write(bot);
-        }else if("teacher".equals(dto.getCourseType())){//教师课表
+        } else if ("teacher".equals(dto.getCourseType())) {//教师课表
             //根据学期和周次,查询当前所有有课表的教师id
             LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getTeachingStart().toInstant(), ZoneId.systemDefault());
 
             LocalDate startDate = startDateTime.plusDays((dto.getWeek() - 1) * 7L).toLocalDate();
             LocalDate endDate = startDate.plusDays(6);
 
-            List<CourseTable> list = this.list(
-                    new QueryWrapper<CourseTable>().lambda()
-                            .eq(CourseTable::getBaseSemesterId, dto.getSemesterId())
-                            .ge(CourseTable::getScheduleDate, startDate)
-                            .le(CourseTable::getScheduleDate, endDate)
-            );
+            List<CourseTable> list = this.list(new QueryWrapper<CourseTable>().lambda().eq(CourseTable::getBaseSemesterId, dto.getSemesterId()).ge(CourseTable::getScheduleDate, startDate).le(CourseTable::getScheduleDate, endDate));
             Set<String> teacherIds = list.stream().map(CourseTable::getTeacherId).collect(Collectors.toSet());
             Set<Long> teacherIdList = new HashSet<>();
             for (String teacherId : teacherIds) {
@@ -1363,7 +1346,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             String bigHead = "课程表";
             int classTableRowCount = 16;//每个班的课表占用的总行数
 
-            for(int i = 0; i < userList.size(); i ++){
+            for (int i = 0; i < userList.size(); i++) {
                 User user = userList.get(i);
                 List<CourseDetailVo> courseList = tableVo.getCourseList().stream().filter(x -> x.getTeacherName().contains(user.getName())).collect(Collectors.toList());
 
@@ -1385,16 +1368,10 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
             }
             workbook.write(bot);
-        }else if("classroom".equals(dto.getCourseType())){//教室课表
+        } else if ("classroom".equals(dto.getCourseType())) {//教室课表
             Map<String, List<CourseDetailVo>> classroomDataMap = tableVo.getCourseList().stream().filter(x -> x.getClassroomName() != null).collect(Collectors.groupingBy(CourseDetailVo::getClassroomName));
-            List<BaseClassroom> classroomList = classroomMapper.selectList(
-                    new QueryWrapper<BaseClassroom>().lambda()
-                            .eq(BaseClassroom::getDeleteMark, DeleteMark.NODELETE.getCode())
-            );
-            List<BaseOfficeBuild> buildList = officeBuildMapper.selectList(
-                    new QueryWrapper<BaseOfficeBuild>().lambda()
-                            .eq(BaseOfficeBuild::getDeleteMark, DeleteMark.NODELETE.getCode())
-            );
+            List<BaseClassroom> classroomList = classroomMapper.selectList(new QueryWrapper<BaseClassroom>().lambda().eq(BaseClassroom::getDeleteMark, DeleteMark.NODELETE.getCode()));
+            List<BaseOfficeBuild> buildList = officeBuildMapper.selectList(new QueryWrapper<BaseOfficeBuild>().lambda().eq(BaseOfficeBuild::getDeleteMark, DeleteMark.NODELETE.getCode()));
             Map<Long, String> buildMap = buildList.stream().collect(Collectors.toMap(BaseOfficeBuild::getId, BaseOfficeBuild::getName));
 
             Workbook workbook = new XSSFWorkbook();
@@ -1405,7 +1382,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             int i = 0;
             for (BaseClassroom baseClassroom : classroomList) {
                 String classroomName = buildMap.get(baseClassroom.getOfficeBuildId()) + baseClassroom.getName();
-                if(!classroomDataMap.containsKey(classroomName)){
+                if (!classroomDataMap.containsKey(classroomName)) {
                     continue;
                 }
 
@@ -1427,27 +1404,20 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 //生成内容
                 exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
 
-                i ++;
+                i++;
             }
             workbook.write(bot);
-        }else if("all".equals(dto.getCourseType())){//总课表
+        } else if ("all".equals(dto.getCourseType())) {//总课表
             //根据年级、专业部,查询需要导出的班级
-            List<BaseClass> classList = baseClassService.list(
-                    new QueryWrapper<BaseClass>().lambda()
-                            .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
-                            .eq(BaseClass::getIsGraduate, 1)
-                            .in(BaseClass::getGradeId, dto.getGradeIds())
-                            .in(BaseClass::getOrgId, dto.getDeptIds())
-                            .orderByAsc(BaseClass::getName)
-            );
-            if(classList.isEmpty()){
+            List<BaseClass> classList = baseClassService.list(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode()).eq(BaseClass::getIsGraduate, 1).in(BaseClass::getGradeId, dto.getGradeIds()).in(BaseClass::getOrgId, dto.getDeptIds()).orderByAsc(BaseClass::getName));
+            if (classList.isEmpty()) {
                 throw new MyException("未查询到班级,无法导出");
             }
             Map<String, List<CourseDetailVo>> classDataMap = tableVo.getCourseList().stream().filter(x -> x.getClassName() != null).collect(Collectors.groupingBy(CourseDetailVo::getClassName));
             ArrayList<ArrayList<String>> dataList = new ArrayList<>();
             for (BaseClass baseClass : classList) {
                 List<CourseDetailVo> detailVoList = classDataMap.get(baseClass.getName());
-                if(detailVoList == null){
+                if (detailVoList == null) {
                     continue;
                 }
                 Map<Integer, List<CourseDetailVo>> weeksMap = detailVoList.stream().collect(Collectors.groupingBy(CourseDetailVo::getWeeks));
@@ -1464,7 +1434,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 ArrayList<String> classData = new ArrayList<>();
                 classData.add(baseClass.getName());
                 for (Integer weeks : weekList) {
-                    if(!weeksMap.containsKey(weeks)){
+                    if (!weeksMap.containsKey(weeks)) {
                         for (ClassTime classTime : tableVo.getClassTimeList()) {
                             classData.add("");
                         }
@@ -1473,12 +1443,12 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                     Map<String, CourseDetailVo> timeNumberMap = weeksMap.get(weeks).stream().filter(x -> x.getTimeNumber() != null).collect(Collectors.toMap(CourseDetailVo::getTimeNumber, x -> x));
                     for (ClassTime classTime : tableVo.getClassTimeList()) {
                         CourseDetailVo courseDetailVo = timeNumberMap.get(classTime.getNumber().toString());
-                        if(courseDetailVo == null){
+                        if (courseDetailVo == null) {
                             classData.add("");
                             continue;
                         }
                         String content = courseDetailVo.getCourseName() + "\r\n" + courseDetailVo.getTeacherName();
-                        if(courseDetailVo.getClassroomName() != null){
+                        if (courseDetailVo.getClassroomName() != null) {
                             content += "\r\n" + courseDetailVo.getClassroomName();
                         }
                         classData.add(content);
@@ -1545,7 +1515,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             LocalDateTime endDate = startDate.plusDays(6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
             if (now.isAfter(startDate) && now.isBefore(endDate)) {
                 CurrentWeekVo currentWeekVo = new CurrentWeekVo();
-                currentWeekVo.setWeek(i+ 1);
+                currentWeekVo.setWeek(i + 1);
                 currentWeekVo.setStartDate(startDate.toLocalDate());
                 currentWeekVo.setEndDate(endDate.toLocalDate());
                 return currentWeekVo;

+ 1 - 1
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -190,7 +190,7 @@ public class UserController {
                     .eq(ObjectUtil.isNotNull(dto.getEmployWay()), BaseTeacher::getEmployWay, dto.getEmployWay())
                     .eq(ObjectUtil.isNotNull(dto.getClassId()), BaseStudentSchoolRoll::getClassId, dto.getClassId())
                     .eq(ObjectUtil.isNotNull(dto.getRoleId()), UserRoleRelation::getRoleId, dto.getRoleId())
-                    .eq(ObjectUtil.isNotNull(dto.getIsTeach()), BaseTeacherRegular::getIsTeach, dto.getIsTeach())
+                    .eq(ObjectUtils.isNotEmpty(dto.getIsTeach()), BaseTeacherRegular::getIsTeach, dto.getIsTeach())
                     .orderByDesc(User::getId)
                     .select(User::getId)
                     .select("d1.name", UserPageVo::getEmployWay)

+ 60 - 29
src/main/java/com/xjrsoft/module/schedule/controller/ScheduleController.java

@@ -45,11 +45,9 @@ import org.springframework.web.bind.annotation.*;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.time.DayOfWeek;
-import java.time.Duration;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -215,7 +213,6 @@ public class ScheduleController {
         return RT.ok("ok");
     }
 
-
     @GetMapping(value = "/getCourseNames")
     @ApiOperation(value = "查询课程接口")
     @SaCheckPermission("schedule:getcoursenames")
@@ -249,7 +246,6 @@ public class ScheduleController {
         return RT.ok(result);
     }
 
-
     @GetMapping(value = "/getCourseInfo")
     @ApiOperation(value = "根据课程id获取课程相关信息")
     @SaCheckPermission("schedule:getcourseinfo")
@@ -302,9 +298,6 @@ public class ScheduleController {
         return RT.ok(resultVo);
     }
 
-
-
-
     /**
      * 顶课预检查
      *
@@ -412,7 +405,6 @@ public class ScheduleController {
     @SaCheckPermission("schedule:weeklist")
     @XjrLog(value = "获取周次列表")
     public RT<List<ScheduleWeekVo>> weekList(@Valid ScheduleWeekDto dto) {
-
         BaseSemester baseSemester;
         if (dto.getSemesterId() != null) {
             baseSemester = semesterService.getById(dto.getSemesterId());
@@ -422,27 +414,66 @@ public class ScheduleController {
                 return RT.ok(new ArrayList<>());
             }
         }
-        LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getTeachingStart().toInstant(), ZoneId.systemDefault());
-        LocalDateTime endDateTime = LocalDateTime.ofInstant(baseSemester.getTeachingEnd().toInstant(), ZoneId.systemDefault());
-        Duration between = Duration.between(startDateTime, endDateTime);
-        long days = between.toDays();
-        int weeks = (int) Math.ceil((double) days / 7);
-        List<ScheduleWeekVo> result = new ArrayList<>();
-        for (int i = 0; i < weeks; i++) {
-            LocalDateTime startDate = startDateTime.plusDays(i * 7L).withHour(0).withMinute(0).withSecond(0).withNano(0);
-            LocalDateTime endDate = startDate.plusDays(6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
-            int week = i + 1;
-            result.add(
-                    new ScheduleWeekVo() {{
-                        setWeek(week);
-                        setWeekCn("第" + week + "周");
-                        setStartDate(startDate.toLocalDate());
-                        setEndDate(endDate.toLocalDate());
-                    }}
-            );
+        LocalDate startDate = LocalDate.ofInstant(baseSemester.getTeachingStart().toInstant(), ZoneId.systemDefault());
+        LocalDate endDate = LocalDate.ofInstant(baseSemester.getTeachingEnd().toInstant(), ZoneId.systemDefault());
+        List<ScheduleWeekVo> weeks = calculateSemesterWeeks(startDate, endDate);
+
+        return RT.ok(weeks);
+//        Duration between = Duration.between(startDateTime, endDateTime);
+//        long days = between.toDays();
+//        int weeks = (int) Math.ceil((double) days / 7);
+//        List<ScheduleWeekVo> result = new ArrayList<>();
+//        for (int i = 0; i < weeks; i++) {
+//            LocalDateTime startDate = startDateTime.plusDays(i * 7L).withHour(0).withMinute(0).withSecond(0).withNano(0);
+//            LocalDateTime endDate = startDate.plusDays(6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
+//            int week = i + 1;
+//            result.add(
+//                    new ScheduleWeekVo() {{
+//                        setWeek(week);
+//                        setWeekCn("第" + week + "周");
+//                        setStartDate(startDate.toLocalDate());
+//                        setEndDate(endDate.toLocalDate());
+//                    }}
+//            );
+//        }
+//
+//        return RT.ok(result);
+    }
+
+    /**
+     * 计算学期的自然周列表
+     * @param semesterStart 学期开始日期
+     * @param semesterEnd 学期结束日期
+     * @return 周次信息列表
+     */
+    private List<ScheduleWeekVo> calculateSemesterWeeks(LocalDate semesterStart, LocalDate semesterEnd) {
+        List<ScheduleWeekVo> weekList = new ArrayList<>();
+
+        // 调整开始日期到本周星期一
+        LocalDate adjustedStart = semesterStart.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+
+        // 调整结束日期到本周星期日
+        LocalDate adjustedEnd = semesterEnd.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
+
+        // 计算总周数
+        long totalDays = java.time.temporal.ChronoUnit.DAYS.between(adjustedStart, adjustedEnd) + 1;
+        int totalWeeks = (int) (totalDays / 7);
+
+        // 生成每一周的信息
+        for (int i = 0; i < totalWeeks; i++) {
+            LocalDate weekStart = adjustedStart.plusWeeks(i);
+            LocalDate weekEnd = weekStart.plusDays(6); // 一周结束是星期日
+
+            ScheduleWeekVo weekVo = new ScheduleWeekVo();
+            weekVo.setWeek(i + 1); // 周次从1开始
+            weekVo.setWeekCn("第" + (i + 1) + "周");
+            weekVo.setStartDate(weekStart);
+            weekVo.setEndDate(weekEnd);
+
+            weekList.add(weekVo);
         }
 
-        return RT.ok(result);
+        return weekList;
     }
 
     @GetMapping(value = "/class-list")

+ 1 - 0
src/main/java/com/xjrsoft/module/schedule/dto/CourseTableDto.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 

+ 8 - 3
src/main/resources/application-prod.yml

@@ -5,16 +5,21 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
+#    url: jdbc:mysql://219.153.208.35:3306/smart_campus?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&autoReconnect=true&failOverReadOnly=false
     url: jdbc:mysql://219.153.208.37:53256/smart_campus?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&autoReconnect=true&failOverReadOnly=false
     username: smart_campus
     password: W2Xk@8QFe3hYR7QZ?-yY
 
 
   redis:
-    database: 10
-    host: 219.153.208.35
+#    database: 10
+#    host: 219.153.208.35
+#    port: 6379
+#    password: huHJMucfC!tJ59Ri   # 密码(默认为空)
+    database: 6
+    host: 10.150.10.136
     port: 6379
-    password: huHJMucfC!tJ59Ri   # 密码(默认为空)
+    password: 9mwar,BNq}oMa63cUd?R   # 密码(默认为空)
     timeout: 6000ms  # 连接超时时长(毫秒)
     jedis:
       pool:

+ 4 - 2
src/main/resources/mapper/courseTable/CourseTable.xml

@@ -32,7 +32,8 @@
             </if>
         </if>
         <if test="dto.startDate != null and dto.endDate != null">
-            and t1.schedule_date between #{dto.startDate} and #{dto.endDate}
+            and t1.schedule_date >= #{dto.startDate}
+            and t1.schedule_date &lt;= DATE(DATE_SUB(#{dto.endDate}, INTERVAL 1 MICROSECOND))
         </if>
         <if test="dto.toDay != null">
             and t1.schedule_date = #{dto.toDay}
@@ -43,8 +44,9 @@
         <if test="dto.classId != null">
             and t5.id = #{dto.classId}
         </if>
-        ORDER BY t1.weeks,t1.time_period,t1.time_number
+        ORDER BY t1.schedule_date, t1.weeks, t1.time_period, t1.time_number
     </select>
+
     <select id="getAdjustList" parameterType="com.xjrsoft.module.schedule.dto.CourseTableAdjustDto" resultType="com.xjrsoft.module.schedule.vo.CourseListVo">
         SELECT t1.time_period,t4.short_name as time_number,t1.course_name,t2.name AS class_name,t3.name AS classroom_name,t1.id,t2.id as class_id FROM course_table t1
         LEFT JOIN base_class t2 ON t1.class_id = t2.id

+ 332 - 0
src/test/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImplTest.java

@@ -1,10 +1,64 @@
 package com.xjrsoft.module.student.service.impl;
 
+import cn.dev33.satoken.secure.BCrypt;
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.NumberUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.constant.GlobalConstant;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.RoleEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.LocalDateTimeUtil;
 import com.xjrsoft.common.utils.LocalDateUtil;
+import com.xjrsoft.common.utils.RedisUtil;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.banding.entity.BandingTask;
+import com.xjrsoft.module.banding.entity.BandingTaskClass;
+import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
+import com.xjrsoft.module.banding.entity.BandingTaskClassStudentSure;
+import com.xjrsoft.module.banding.service.IBandingTaskClassService;
+import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
+import com.xjrsoft.module.banding.service.IBandingTaskService;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseGrade;
+import com.xjrsoft.module.base.entity.BaseMajorSet;
+import com.xjrsoft.module.base.mapper.BaseClassMapper;
+import com.xjrsoft.module.base.mapper.BaseGradeMapper;
+import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
+import com.xjrsoft.module.student.entity.*;
+import com.xjrsoft.module.student.mapper.BaseNewStudentMapper;
+import com.xjrsoft.module.student.mapper.StudentReportPlanMapper;
+import com.xjrsoft.module.student.service.*;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
 
 import static org.junit.jupiter.api.Assertions.*;
 
@@ -12,8 +66,58 @@ import static org.junit.jupiter.api.Assertions.*;
  * @author dzx
  * @date 2025/2/11
  */
+@SpringBootTest
 class StudentReportRecordServiceImplTest {
 
+    @Autowired
+    private BaseNewStudentMapper newStudentMapper;
+
+    @Autowired
+    private IBandingTaskClassService taskClassService;
+
+    @Autowired
+    private BaseClassMapper classMapper;;
+
+    @Autowired
+    private IBaseStudentService studentService;
+
+    @Autowired
+    private IUserService userService;
+
+    @Autowired
+    private IBaseStudentSchoolRollService rollService;
+
+    @Autowired
+    private IUserRoleRelationService roleRelationService;
+
+    @Autowired
+    private IBaseStudentFamilyService familyService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private IBandingTaskService taskService;
+
+    @Autowired
+    private BaseGradeMapper gradeMapper;
+
+    @Autowired
+    private BaseMajorSetMapper majorSetMapper;
+
+
+    @BeforeEach
+    void setUp() {
+        // 模拟用户登录
+        StpUtil.login(1000000000000000000L); // 假设用户ID为1
+    }
+
+    @AfterEach
+    void tearDown() {
+        // 清理会话
+        StpUtil.logout();
+    }
+
     @Test
     void Test(){
         LocalDate startDate = LocalDate.of(2024, 2, 11);
@@ -27,4 +131,232 @@ class StudentReportRecordServiceImplTest {
         }
     }
 
+    @Test
+    @Transactional(rollbackFor = Exception.class)
+    void tryReadingSign() {
+        LocalDateTime now = LocalDateTime.now();
+        // 查出所有有分班存在的新生信息
+        MPJLambdaWrapper<BaseNewStudent> baseNewStudentMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseNewStudentMPJLambdaWrapper
+                .select(BaseNewStudent::getId)
+                .select(BaseNewStudent.class, x -> VoToColumnUtil.fieldsToColumns(BaseNewStudent.class).contains(x.getProperty()))
+                .innerJoin(BandingTaskClassStudent.class, BandingTaskClassStudent::getNewStudentId, BaseNewStudent::getId)
+                .innerJoin(BandingTaskClass.class, BandingTaskClass::getId, BandingTaskClassStudent::getBandingTaskClassId)
+                .innerJoin(BandingTask.class, BandingTask::getId, BandingTaskClass::getBandingTaskId)
+                .eq(BandingTask::getGradeId, 1868532405673439232L)
+                .isNotNull(BandingTaskClassStudent::getBandingTaskClassId)
+                ;
+        List<BaseNewStudent> baseNewStudents =  newStudentMapper.selectJoinList(BaseNewStudent.class, baseNewStudentMPJLambdaWrapper);
+
+        // 进行学生数据处理,学生信息已经存在的要修改学生班级数据
+        for(BaseNewStudent student : baseNewStudents){
+            BandingTaskClass taskClass = taskClassService.getOne(
+                    new MPJLambdaWrapper<BandingTaskClass>()
+                            .select(BandingTaskClass::getId)
+                            .select(BandingTaskClass.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClass.class).contains(x.getProperty()))
+                            .innerJoin(BandingTaskClassStudent.class, BandingTaskClassStudent::getBandingTaskClassId, BandingTaskClass::getId)
+                            .eq(BandingTaskClassStudent::getNewStudentId, student.getId())
+                            .eq(BandingTaskClassStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .eq(BandingTaskClassStudent::getEnabledMark, EnabledMark.ENABLED.getCode())
+                            .eq(BandingTaskClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .eq(BandingTaskClass::getEnabledMark, EnabledMark.ENABLED.getCode())
+            );
+
+            //先查询是否已经存在这个班级,如果存在就更新,不存在就新增
+            BaseClass baseClass = classMapper.selectById(taskClass.getBaseClassId());
+            if(ObjectUtils.isEmpty(baseClass)){
+                BandingTask task = taskService.getById(taskClass.getBandingTaskId());
+                List<BaseClass> classList = classMapper.selectList(
+                        new QueryWrapper<BaseClass>().lambda()
+                                .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+                                .eq(BaseClass::getGradeId, task.getGradeId())
+                                .eq(BaseClass::getEnrollType, task.getEnrollType())
+                );
+                BaseGrade baseGrade = gradeMapper.selectById(task.getGradeId());
+                List<BaseClass> classCodes = classList.stream().filter(x -> x.getCode() != null)
+                        .sorted(Comparator.comparing(BaseClass::getCode))
+                        .collect(Collectors.toList());
+
+                String classCode = null;
+                if(!classCodes.isEmpty()){
+                    classCode = classCodes.get(0).getCode();
+                }
+
+                baseClass = new BaseClass();
+                BeanUtil.copyProperties(taskClass, baseClass);
+                baseClass.setCreateDate(new Date());
+                baseClass.setCreateUserId(StpUtil.getLoginIdAsLong());
+                int i = 0;
+                if(NumberUtil.isNumber(classCode)){
+                    i = Integer.parseInt(classCode.trim().substring(classCode.length() - 3));
+                    i ++;
+                    baseClass.setCode(baseGrade.getTitle().replace("年", "") + String.format("%03d", i));
+                }
+                baseClass.setGradeId(task.getGradeId());
+                BaseMajorSet majorSet = majorSetMapper.selectById(baseClass.getMajorSetId());
+                baseClass.setOrgId(majorSet.getDepartmentId());
+                baseClass.setId(null);
+                classMapper.insert(baseClass);
+
+                taskClass.setBaseClassId(baseClass.getId());
+                taskClassService.updateById(taskClass);
+            }
+
+            //根据身份证号查询这个学生是否存在
+            User user = userService.getOne(
+                    new MPJLambdaWrapper<User>()
+                            .select(User::getId)
+                            .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
+                            .eq(User::getCredentialNumber, student.getCredentialNumber())
+                            .eq(User::getEnabledMark, EnabledMark.ENABLED.getCode())
+            );
+            if(ObjectUtils.isNotEmpty(user)){
+                BaseStudentSchoolRoll isSchoolRoll = rollService.getOne(
+                        new MPJLambdaWrapper<BaseStudentSchoolRoll>()
+                                .disableLogicDel()
+                                .select(BaseStudentSchoolRoll::getId)
+                                .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
+                                .eq(BaseStudentSchoolRoll::getUserId, user.getId())
+                );
+                if(ObjectUtils.isEmpty(isSchoolRoll)){
+                    BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll();
+                    schoolRoll.setUserId(user.getId());
+                    if(student.getScore() != null){
+                        schoolRoll.setGraduatedScore(student.getScore().doubleValue());
+                    }
+                    schoolRoll.setInternshipState("IT_0001");
+                    schoolRoll.setGraduatedUniversity(student.getGraduateSchool());
+                    schoolRoll.setClassId(baseClass.getId());
+                    schoolRoll.setMajorSetId(baseClass.getMajorSetId());
+                    schoolRoll.setStduyStatus(student.getStduyStatus());
+                    schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
+                    schoolRoll.setEnrollType(baseClass.getEnrollType());
+                    schoolRoll.setStudentType(student.getSource());
+                    schoolRoll.setGradeId(baseClass.getGradeId());
+                    schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                    schoolRoll.setCreateDate(now);
+                    rollService.save(schoolRoll);
+                }
+
+                BaseStudent isBaseStudent = studentService.getOne(
+                        new QueryWrapper<BaseStudent>().lambda()
+                                .eq(BaseStudent::getUserId, user.getId())
+                );
+                if(ObjectUtils.isEmpty(isBaseStudent)){
+                    BaseStudent baseStudent = new BaseStudent() {{
+                        setUserId(user.getId());
+                        setCreateDate(now);
+                        setStudentId(student.getCredentialNumber());
+                        if(student.getHeight() != null){
+                            setHeight(student.getHeight().doubleValue());
+                        }
+                        if(student.getWeight() != null){
+                            setWeight(student.getWeight().doubleValue());
+                        }
+                        setIsNormal(1);
+                    }};
+                    studentService.save(baseStudent);
+                }
+
+                // 学生已存在,则修改班级信息
+                rollService.updateStudentClass(baseClass.getId(), user.getId());
+                // 激活学生
+                rollService.activateStudent(user.getId());
+            }else{
+                LocalDate birthDate = getBirthDate(student.getCredentialNumber());
+                User xjrUser = new User() {{
+                    setCreateDate(now);
+                    // setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
+
+                    if (StringUtils.isEmpty(student.getCredentialNumber())) {
+                        throw new MyException(student.getName() + "证件号为空,请填写后提交");
+                    }
+                    String credentialNumber = student.getCredentialNumber();
+                    String lastSixDigits = credentialNumber.length() <= 6
+                            ? credentialNumber
+                            : credentialNumber.substring(credentialNumber.length() - 6);
+                    setPassword(BCrypt.hashpw(lastSixDigits, BCrypt.gensalt()));
+
+                    setName(student.getName());
+                    setUserName(student.getCredentialNumber());
+                    setCredentialNumber(student.getCredentialNumber());
+                    setCredentialType("ZZLS10007");
+                    setMobile(student.getMobile());
+                    setEnabledMark(EnabledMark.ENABLED.getCode());
+                    setGender(student.getGender());
+                    setIsChangePassword(1);
+                    setBirthDate(birthDate.atStartOfDay());
+                }};
+                userService.save(xjrUser);
+
+                UserRoleRelation userRoleRelation = new UserRoleRelation() {{
+                    setRoleId(RoleEnum.STUDENT.getCode());
+                    setUserId(xjrUser.getId());
+                }};
+                roleRelationService.save(userRoleRelation);
+
+                BaseStudent baseStudent = new BaseStudent() {{
+                    setUserId(xjrUser.getId());
+                    setCreateDate(now);
+                    setStudentId(student.getCredentialNumber());
+                    if(student.getHeight() != null){
+                        setHeight(student.getHeight().doubleValue());
+                    }
+                    if(student.getWeight() != null){
+                        setWeight(student.getWeight().doubleValue());
+                    }
+                    setIsNormal(1);
+                }};
+                studentService.save(baseStudent);
+
+                BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll();
+                schoolRoll.setUserId(xjrUser.getId());
+                if(student.getScore() != null){
+                    schoolRoll.setGraduatedScore(student.getScore().doubleValue());
+                }
+                schoolRoll.setInternshipState("IT_0001");
+                schoolRoll.setGraduatedUniversity(student.getGraduateSchool());
+                schoolRoll.setClassId(baseClass.getId());
+                schoolRoll.setMajorSetId(baseClass.getMajorSetId());
+                schoolRoll.setStduyStatus(student.getStduyStatus());
+                schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
+                schoolRoll.setEnrollType(baseClass.getEnrollType());
+                schoolRoll.setStudentType(student.getSource());
+                schoolRoll.setGradeId(baseClass.getGradeId());
+                schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                schoolRoll.setCreateDate(now);
+
+                rollService.save(schoolRoll);
+
+                BaseStudentFamily studentFamily = new BaseStudentFamily() {{
+                    setCreateDate(now);
+                    setUserId(xjrUser.getId());
+                    setTelephone(student.getFamilyMobile());
+                    setAddress(student.getFamilyAddress());
+                }};
+                familyService.save(studentFamily);
+
+                CompletableFuture.runAsync(() -> {
+                    List<User> userList = userService.list();
+                    redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
+
+                    List<UserRoleRelation> userRoleRelationList = roleRelationService.list(Wrappers.lambdaQuery(UserRoleRelation.class));
+                    redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
+                });
+            }
+        }
+    }
+
+    LocalDate getBirthDate(String idCardNumber){
+        // 获取出生日期前6位,即yyyyMM
+        String birthdayString = idCardNumber.substring(6, 14);
+
+        // 将字符串解析为LocalDate对象
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        try {
+            return LocalDate.parse(birthdayString, formatter);
+        }catch (Exception e){
+            throw new MyException("身份证号填写错误,无法提取出生日期");
+        }
+    }
 }