Procházet zdrojové kódy

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

dzx před 1 rokem
rodič
revize
7c17438a20

+ 9 - 0
src/main/java/com/xjrsoft/common/enums/TimeNumberEnum.java

@@ -59,4 +59,13 @@ public enum TimeNumberEnum {
         }
         return 0;
     }
+
+    public static String getValue(int code) {
+        for (TimeNumberEnum c : TimeNumberEnum.values()) {
+            if (c.getCode() == code) {
+                return c.getValue();
+            }
+        }
+        return "";
+    }
 }

+ 9 - 0
src/main/java/com/xjrsoft/common/enums/TimePeriodEnum.java

@@ -42,4 +42,13 @@ public enum TimePeriodEnum {
         }
         return 0;
     }
+
+    public static String getValue(int code) {
+        for (TimePeriodEnum c : TimePeriodEnum.values()) {
+            if (c.getCode() == code) {
+                return c.getValue();
+            }
+        }
+        return "";
+    }
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/courseTable/service/ICourseTableService.java

@@ -6,10 +6,12 @@ import com.xjrsoft.module.courseTable.entity.CourseTable;
 import com.xjrsoft.module.courseTable.vo.ClassListVo;
 import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
 import com.xjrsoft.module.schedule.dto.CourseTableDto;
+import com.xjrsoft.module.schedule.dto.ScheduleWeekExportQueryDto;
 import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
 import com.xjrsoft.module.schedule.vo.CourseListVo;
 import com.xjrsoft.module.schedule.vo.CourseTableVo;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Date;
@@ -41,4 +43,6 @@ public interface ICourseTableService extends IService<CourseTable> {
      * @return
      */
     Boolean adjustCourse(WfCourseAdjust courseAdjust) throws Exception;
+
+    ByteArrayOutputStream listScheduleWeekExportQuery(ScheduleWeekExportQueryDto dto);
 }

+ 261 - 34
src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java

@@ -6,6 +6,13 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.alibaba.excel.write.metadata.WriteTable;
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
+import com.alibaba.excel.write.metadata.style.WriteFont;
+import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -19,6 +26,8 @@ import com.xjrsoft.common.enums.TimeNumberEnum;
 import com.xjrsoft.common.enums.TimePeriodEnum;
 import com.xjrsoft.common.enums.WeekEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.excel.ExcelFillCellMergePrevColUtil;
+import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
 import com.xjrsoft.config.TimetableConfig;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseSemester;
@@ -35,24 +44,37 @@ import com.xjrsoft.module.courseTable.service.ICourseTableService;
 import com.xjrsoft.module.courseTable.vo.ClassListVo;
 import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
 import com.xjrsoft.module.schedule.dto.CourseTableDto;
+import com.xjrsoft.module.schedule.dto.ScheduleWeekExportQueryDto;
 import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
 import com.xjrsoft.module.schedule.mapper.CourseTableBakMapper;
 import com.xjrsoft.module.schedule.util.ScheduleUtil;
 import com.xjrsoft.module.schedule.vo.CourseDetailVo;
 import com.xjrsoft.module.schedule.vo.CourseListVo;
 import com.xjrsoft.module.schedule.vo.CourseTableVo;
+import com.xjrsoft.module.schedule.vo.ScheduleWeekExportQueryVo;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
+import com.xjrsoft.module.textbook.entity.SubjectGroupCourse;
+import com.xjrsoft.module.textbook.vo.TextbookClaimExportQueryVo;
+import com.xjrsoft.module.textbook.vo.TextbookIssueRecordExcelVo;
+import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
 import org.apache.poi.xwpf.usermodel.XWPFTable;
 import org.apache.poi.xwpf.usermodel.XWPFTableCell;
 import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.checkerframework.checker.units.qual.C;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.time.DayOfWeek;
@@ -61,10 +83,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -150,7 +169,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     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());
+                .eq(ObjectUtil.isNotEmpty(dto.getWeeks()), CourseTable::getWeeks, dto.getWeeks());
 
         List<CourseTable> courseTables = courseTableMapper.selectList(queryWrapper);
 
@@ -181,13 +200,13 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     public CourseTableVo getList(CourseTableDto dto) {
 
         List<ClassTime> classTimes = classTimeMapper.selectList(
-            new QueryWrapper<ClassTime>().lambda().orderByAsc(ClassTime::getSummerStartTime)
+                new QueryWrapper<ClassTime>().lambda().orderByAsc(ClassTime::getSummerStartTime)
         );
 
         CourseTableVo tableVo = new CourseTableVo();
         tableVo.setClassTimeList(classTimes);
 
-        if(dto.getSemesterId() != null){
+        if (dto.getSemesterId() != null) {
             BaseSemester baseSemester = baseSemesterMapper.selectById(dto.getSemesterId());
             tableVo.setSemesterName(baseSemester.getName());
             LocalDateTime now = LocalDateTime.now();
@@ -197,16 +216,16 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             Duration between = Duration.between(startDateTime, endDateTime);
             long days = between.toDays();
             int weeks = (int) Math.ceil((double) days / 7);
-            if(dto.getWeek() == null){
+            if (dto.getWeek() == null) {
 
-                for (int i = 0; i < weeks; i ++){
+                for (int i = 0; i < weeks; i++) {
                     LocalDateTime startDate = startDateTime.plusDays(i * 6).withHour(0).withMinute(0).withSecond(0).withNano(0);
                     LocalDateTime endDate = startDateTime.plusDays((i + 1) * 6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
-                    if(now.isAfter(startDate) && now.isBefore(endDate)){
+                    if (now.isAfter(startDate) && now.isBefore(endDate)) {
                         tableVo.setWeek("第" + (i + 1) + "周");
                     }
                 }
-            }else{
+            } else {
                 LocalDateTime startDate = startDateTime.plusDays((dto.getWeek() - 1) * 6).withHour(0).withMinute(0).withSecond(0).withNano(0);
                 LocalDateTime endDate = startDateTime.plusDays(dto.getWeek() * 6).withHour(23).withMinute(59).withSecond(59).withNano(9999);
                 dto.setStartDate(startDate);
@@ -215,17 +234,17 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             }
 
         }
-        if(!StrUtil.isEmpty(dto.getTeacherName())){
+        if (!StrUtil.isEmpty(dto.getTeacherName())) {
             List<XjrUser> userList = teacherbaseManagerService.list(
-                new QueryWrapper<XjrUser>().lambda()
-                .like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getName, dto.getTeacherName())
+                    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())
+                    new QueryWrapper<XjrUser>().lambda()
+                            .like(!StrUtil.isEmpty(dto.getTeacherName()), XjrUser::getCode, dto.getTeacherName())
             );
             userList.addAll(userList2);
-            if(userList != null && !userList.isEmpty()){
+            if (userList != null && !userList.isEmpty()) {
                 XjrUser xjrUser = userList.get(0);
                 dto.setTeacherId(xjrUser.getId());
                 tableVo.setTeacherName(xjrUser.getName());
@@ -234,7 +253,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         List<CourseDetailVo> list = courseTableMapper.getList(dto);
         tableVo.setCourseList(list);
         tableVo.setClassHour(list.size());
-        if(dto.getClassId() != null){
+        if (dto.getClassId() != null) {
             BaseClass baseClass = baseClassService.getById(dto.getClassId());
             tableVo.setClassName(baseClass.getName());
         }
@@ -248,7 +267,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     @Override
     public List<CourseListVo> getAdjustList(String teacherId, String adjustDate, String classId) {
         CourseTableAdjustDto dto = new CourseTableAdjustDto();
-        if(adjustDate != null && !"".equals(adjustDate)){
+        if (adjustDate != null && !"".equals(adjustDate)) {
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
             LocalDate localDateTime = LocalDate.parse(adjustDate, formatter);
             DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
@@ -259,11 +278,11 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         dto.setTeacherId(Long.parseLong(teacherId));
         List<CourseListVo> list = courseTableMapper.getAdjustList(dto);
         for (CourseListVo courseListVo : list) {
-            if(courseListVo.getTimePeriod() == 1){
+            if (courseListVo.getTimePeriod() == 1) {
                 courseListVo.setTimePeriodCn("上午");
-            }else if(courseListVo.getTimePeriod() == 2){
+            } else if (courseListVo.getTimePeriod() == 2) {
                 courseListVo.setTimePeriodCn("下午");
-            }else if(courseListVo.getTimePeriod() == 3){
+            } else if (courseListVo.getTimePeriod() == 3) {
                 courseListVo.setTimePeriodCn("晚上");
             }
         }
@@ -273,26 +292,26 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
     @Override
     public String getPreCheck(String preCheckType, String courseId, String swapCourseId, String swapDate, String subTeacherId) {
-        if(preCheckType != null && !"".equals(preCheckType)){
-            if(CourseAdjustTypeEnum.courseExchange.getCode().equals(preCheckType)){
+        if (preCheckType != null && !"".equals(preCheckType)) {
+            if (CourseAdjustTypeEnum.courseExchange.getCode().equals(preCheckType)) {
                 CourseTable courseTable = courseTableMapper.selectById(courseId);
                 CourseTable swapCourseTable = courseTableMapper.selectById(swapCourseId);
                 try {
                     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                     LocalDate localDateTime = LocalDate.parse(swapDate, formatter);
                     JsonObject preCheck = getExtendPreCheck(localDateTime, courseTable, swapCourseTable);
-                    if(preCheck.get("code").getAsInt() == -1 && !preCheck.get("msg").isJsonNull()){
+                    if (preCheck.get("code").getAsInt() == -1 && !preCheck.get("msg").isJsonNull()) {
                         return preCheck.get("msg").getAsString();
                     }
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
 
-            }else if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(preCheckType)){
+            } else if (CourseAdjustTypeEnum.courseSubstitute.getCode().equals(preCheckType)) {
                 CourseTable courseTable = courseTableMapper.selectById(courseId);
                 try {
                     JsonObject jsonObject = substitutePreTestin(subTeacherId, courseTable);
-                    if(jsonObject.get("code").getAsInt() == -1 && !jsonObject.get("msg").isJsonNull()){
+                    if (jsonObject.get("code").getAsInt() == -1 && !jsonObject.get("msg").isJsonNull()) {
                         return jsonObject.get("msg").getAsString();
                     }
                 } catch (Exception e) {
@@ -305,7 +324,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
     @Override
     public Boolean adjustCourse(WfCourseAdjust courseAdjust) throws Exception {
-        if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseAdjust.getAdjustType())){
+        if (CourseAdjustTypeEnum.courseExchange.getCode().equals(courseAdjust.getAdjustType())) {
             //调课,将双方课程的日期(schedule_date)、时段(time_period)、节次(time_number)、周(week)、星期几(1-7)(weeks)、星期中文(weeks_cn)对调
             CourseTable courseTable = courseTableMapper.selectById(courseAdjust.getCourseId());
             CourseTable swapCourseTable = courseTableMapper.selectById(courseAdjust.getExchangeCourseId());
@@ -331,7 +350,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             //提交调课接口
             sendExchange(courseTableBak, swapCourseTableBak, courseAdjust);
 
-        }else if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseAdjust.getAdjustType())){
+        } else if (CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseAdjust.getAdjustType())) {
             CourseTable courseTable = courseTableMapper.selectById(courseAdjust.getCourseId());
 
             courseTable.setTeacherId(courseAdjust.getExchangeTeacherId());
@@ -342,8 +361,213 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         return Boolean.TRUE;
     }
 
+    @Override
+    public ByteArrayOutputStream listScheduleWeekExportQuery(ScheduleWeekExportQueryDto dto) {
+        // 创建一个字节输出流
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+        // 获取课程表数据
+        CourseTableVo courseTableVo = getCourseTableVo(dto);
+
+        // 构建课程安排导出列表
+        List<ScheduleWeekExportQueryVo> scheduleWeekExportQueryVoList = buildScheduleWeekExportQueryList(courseTableVo);
+
+        // 将数据写入Excel文件
+        writeScheduleWeekExportToExcel(courseTableVo, outputStream, scheduleWeekExportQueryVoList);
+
+        return outputStream;
+    }
+
+    private CourseTableVo getCourseTableVo(ScheduleWeekExportQueryDto dto) {
+        CourseTableDto courseTableDto = new CourseTableDto();
+        BeanUtils.copyProperties(dto, courseTableDto);
+        return this.getList(courseTableDto);
+    }
+
+    private List<ScheduleWeekExportQueryVo> buildScheduleWeekExportQueryList(CourseTableVo courseTableVo) {
+        List<ClassTime> classTimeList = courseTableVo.getClassTimeList();
+        List<CourseDetailVo> courseList = courseTableVo.getCourseList();
+        List<ScheduleWeekExportQueryVo> scheduleWeekExportQueryVoList = new ArrayList<>();
+
+        if (!courseList.isEmpty()) {
+            Map<Integer, Map<Integer, List<CourseDetailVo>>> courseDetailVoMap = buildCourseDetailMap(courseList);
+            scheduleWeekExportQueryVoList.addAll(buildScheduleWeekExportQueryVoList(courseDetailVoMap, classTimeList));
+        }
+
+        return scheduleWeekExportQueryVoList;
+    }
+
+    private Map<Integer, Map<Integer, List<CourseDetailVo>>> buildCourseDetailMap(List<CourseDetailVo> courseList) {
+        // 实现构建课程详情Map的逻辑
+        Map<Integer, Map<Integer, List<CourseDetailVo>>> courseDetailVoMap = new HashMap<>();
+
+        for (CourseDetailVo courseDetailVo : courseList) {
+            int timePeriod = Integer.parseInt(courseDetailVo.getTimePeriod().trim());
+            int timeNumber = Integer.parseInt(courseDetailVo.getTimeNumber().trim());
+
+            // 如果时间段不存在,则创建一个新的时间段Map
+            courseDetailVoMap.putIfAbsent(timePeriod, new HashMap<>());
+
+            // 获取当前时间段的Map
+            Map<Integer, List<CourseDetailVo>> timePeriodMap = courseDetailVoMap.get(timePeriod);
+
+            // 如果时间序号不存在,则创建一个新的课程列表
+            timePeriodMap.putIfAbsent(timeNumber, new ArrayList<>());
+
+            // 将课程详情添加到对应的时间段和时间序号中
+            timePeriodMap.get(timeNumber).add(courseDetailVo);
+        }
+
+        // 返回构建好的课程详情Map
+        return courseDetailVoMap;
+    }
+
+    private List<ScheduleWeekExportQueryVo> buildScheduleWeekExportQueryVoList(Map<Integer, Map<Integer, List<CourseDetailVo>>> courseDetailVoMap, List<ClassTime> classTimeList) {
+        List<ScheduleWeekExportQueryVo> scheduleWeekExportQueryVoList = new ArrayList<>();
+        // 实现构建ScheduleWeekExportQueryVo对象列表的逻辑
+        for (ClassTime classTime : classTimeList) {
+            ScheduleWeekExportQueryVo scheduleWeekExportQueryVo = new ScheduleWeekExportQueryVo();
+            scheduleWeekExportQueryVo.setTimePeriod(TimePeriodEnum.getValue(classTime.getTimePeriod()));
+            scheduleWeekExportQueryVo.setTimeNumber(TimeNumberEnum.getValue(classTime.getNumber()));
+
+            Map<Integer, List<CourseDetailVo>> timePeriodListMap = courseDetailVoMap.get(classTime.getTimePeriod());
+            if (timePeriodListMap != null) {
+                List<CourseDetailVo> courseDetailVoList = timePeriodListMap.get(classTime.getNumber());
+                if (courseDetailVoList != null) {
+                    Map<Integer, CourseDetailVo> courseDetailVoByWeeksMap = courseDetailVoList.stream()
+                            .collect(Collectors.toMap(CourseDetailVo::getWeeks, item -> item));
+
+                    for (int i = 1; i <= 7; i++) {
+                        CourseDetailVo courseDetailVo = courseDetailVoByWeeksMap.get(i);
+                        if (courseDetailVo != null) {
+                            String courseInfo = courseDetailVo.getCourseName() + "\n" +
+                                    courseDetailVo.getTeacherName() + "\n" +
+                                    courseDetailVo.getClassName() + "\n" +
+                                    courseDetailVo.getClassroomName() + "\n";
+                            switch (i) {
+                                case 1:
+                                    scheduleWeekExportQueryVo.setMonday(courseInfo);
+                                    break;
+                                case 2:
+                                    scheduleWeekExportQueryVo.setTuesday(courseInfo);
+                                    break;
+                                case 3:
+                                    scheduleWeekExportQueryVo.setWednesday(courseInfo);
+                                    break;
+                                case 4:
+                                    scheduleWeekExportQueryVo.setThursday(courseInfo);
+                                    break;
+                                case 5:
+                                    scheduleWeekExportQueryVo.setFriday(courseInfo);
+                                    break;
+                                case 6:
+                                    scheduleWeekExportQueryVo.setSaturday(courseInfo);
+                                    break;
+                                case 7:
+                                    scheduleWeekExportQueryVo.setSunday(courseInfo);
+                                    break;
+                            }
+                        }
+                    }
+                }
+            }
+
+            scheduleWeekExportQueryVoList.add(scheduleWeekExportQueryVo);
+        }
+        // 返回构建好的ScheduleWeekExportQueryVo对象列表
+        return scheduleWeekExportQueryVoList;
+    }
+
+    private void writeScheduleWeekExportToExcel(CourseTableVo courseTableVo, ByteArrayOutputStream outputStream, List<ScheduleWeekExportQueryVo> scheduleWeekExportQueryVoList) {
+        // 创建内容样式
+        WriteCellStyle contentWriteCellStyle = createContentCellStyle();
+        // 创建头部样式
+        WriteCellStyle headWriteCellStyle = createHeadCellStyle();
+        // 将数据写入Excel文件
+        try (ExcelWriter excelWriter = EasyExcel.write(outputStream, ScheduleWeekExportQueryVo.class)
+                .registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle))
+                .build()) {
+
+            writeSheetHead(courseTableVo, excelWriter);
+
+            writeSheetContent(excelWriter, scheduleWeekExportQueryVoList);
+
+        }
+    }
+
+    private void writeSheetContent(ExcelWriter excelWriter, List<ScheduleWeekExportQueryVo> scheduleWeekExportQueryVoList) {
+        int mergeRowIndex = 2;
+        int[] mergeColumeIndex = {0};
+        ExcelMergeUtil excelFillCellMergeStrategy = new ExcelMergeUtil(mergeRowIndex, mergeColumeIndex);
+
+        WriteTable writeSheetContentTable = EasyExcel.writerTable(1).needHead(Boolean.TRUE).automaticMergeHead(Boolean.TRUE).registerWriteHandler(excelFillCellMergeStrategy).build();
+        excelWriter.write(scheduleWeekExportQueryVoList, EasyExcel.writerSheet("模板").build(), writeSheetContentTable);
+    }
+
+    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() + " "
+                + "课程表"));
+
+        ExcelFillCellMergePrevColUtil sheetHeadColumn = new ExcelFillCellMergePrevColUtil();
+        sheetHeadColumn.add(0, 0, 8);
+
+        WriteTable writeSheetHeadTable = EasyExcel.writerTable(0).needHead(Boolean.TRUE).head(sheetHeadList).registerWriteHandler(sheetHeadColumn).build();
+        excelWriter.write(new ArrayList<>(), EasyExcel.writerSheet("模板").needHead(Boolean.FALSE).build(), writeSheetHeadTable);
+    }
+
+    private WriteCellStyle createContentCellStyle() {
+        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        contentWriteCellStyle.setWrapped(true);
+
+        WriteFont contentWriteFont = new WriteFont();
+        contentWriteFont.setFontHeightInPoints((short) 12);
+        contentWriteFont.setFontName("宋体");
+        contentWriteCellStyle.setWriteFont(contentWriteFont);
+
+        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
+        contentWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
+        contentWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
+        contentWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
+        contentWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+
+        return contentWriteCellStyle;
+    }
+
+    private WriteCellStyle createHeadCellStyle() {
+        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
+        WriteFont headWriteFont = new WriteFont();
+        headWriteFont.setFontName("宋体");
+        headWriteFont.setFontHeightInPoints((short) 14);
+        headWriteFont.setBold(true);
+        headWriteCellStyle.setWriteFont(headWriteFont);
+
+        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);
+        headWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);
+        headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        headWriteCellStyle.setBorderRight(BorderStyle.THIN);
+        headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        headWriteCellStyle.setBorderTop(BorderStyle.THIN);
+        headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        headWriteCellStyle.setWrapped(true);
+        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
+        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        headWriteCellStyle.setShrinkToFit(true);
+
+        return headWriteCellStyle;
+    }
+
     /**
      * 提交顶课接口
+     *
      * @param courseTable
      * @param courseAdjust
      * @throws Exception
@@ -368,6 +592,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
     /**
      * 提交调课
+     *
      * @param courseTable
      * @param swapCourseTable
      * @throws Exception
@@ -393,7 +618,8 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 
 
     /**
-     *  顶课预检查
+     * 顶课预检查
+     *
      * @param courseTable
      * @return 检查结果
      */
@@ -411,7 +637,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         //生成签名
         String sign = ScheduleUtil.createSign(timestamp);
         String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
-        if(StrUtil.isEmpty(result)){
+        if (StrUtil.isEmpty(result)) {
             return null;
         }
 
@@ -419,8 +645,9 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
     }
 
     /**
-     *  调课预检查
-     * @param courseTable 需要调整的课程
+     * 调课预检查
+     *
+     * @param courseTable     需要调整的课程
      * @param swapCourseTable 对调的课程
      * @return 检查结果
      */
@@ -443,7 +670,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         //生成签名
         String sign = ScheduleUtil.createSign(timestamp);
         String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
-        if(StrUtil.isEmpty(result)){
+        if (StrUtil.isEmpty(result)) {
             return null;
         }
 

+ 1 - 1
src/main/java/com/xjrsoft/module/job/EvaluateTask.java

@@ -36,7 +36,7 @@ public class EvaluateTask {
             for(EvaluateManage evaluateManage : evaluateManageList){
                 //TODO 根据评价的频率进行新增
 
-                //默认每天新增根据评价管理
+                //默认每天新增根据评价管理id
                 String insertSubmitScoreSql = "insert into evaluate_submit_record (id, evaluate_manage_id, evaluate_executer_id, create_date, evaluated_object, evaluated_object_id, status)" +
                         "            (SELECT" +
                         "                 UUID()," +

+ 1 - 1
src/main/java/com/xjrsoft/module/organization/dto/AddDepartmentDto.java

@@ -21,7 +21,7 @@ public class AddDepartmentDto  implements Serializable {
 
     @ApiModelProperty("机构名称")
     @NotNull(message = "机构名称不能为空!")
-    @Length(min = 1,max = 20,message = "机构名称最少2个字符,最多20个字符!")
+    @Length(min = 1,max = 50,message = "机构名称最少2个字符,最多50个字符!")
     private String name;
 
     @ApiModelProperty("机构名称")

+ 2 - 2
src/main/java/com/xjrsoft/module/organization/dto/UpdateDepartmentDto.java

@@ -25,7 +25,7 @@ public class UpdateDepartmentDto  implements Serializable {
 
     @ApiModelProperty("机构名称")
     @NotNull(message = "机构名称不能为空!")
-    @Length(min = 1,max = 10,message = "机构名称最少2个字符,最多20个字符!")
+    @Length(min = 1,max = 50,message = "机构名称最少2个字符,最多50个字符!")
     private String name;
 
     @ApiModelProperty("机构名称")
@@ -33,7 +33,7 @@ public class UpdateDepartmentDto  implements Serializable {
 
     @ApiModelProperty("编码")
     @NotNull(message = "机构编码不能为空!")
-    @Length(min = 1,max = 20,message = "机构编码最少2个字符,最多10个字符!")
+    @Length(min = 1,max = 10,message = "机构编码最少2个字符,最多10个字符!")
     private String code;
 
     @ApiModelProperty("电话")

+ 18 - 4
src/main/java/com/xjrsoft/module/schedule/controller/ScheduleController.java

@@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.db.Db;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
@@ -19,6 +20,7 @@ import com.xjrsoft.module.courseTable.service.ICourseTableService;
 import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
 import com.xjrsoft.module.schedule.dto.CourseTableDto;
 import com.xjrsoft.module.schedule.dto.CourseTablePreCheckDto;
+import com.xjrsoft.module.schedule.dto.ScheduleWeekExportQueryDto;
 import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
 import com.xjrsoft.module.schedule.entity.JianyueData;
 import com.xjrsoft.module.schedule.service.ICourseReceiveMsgService;
@@ -31,16 +33,17 @@ import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.service.impl.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
 import com.xjrsoft.module.teacher.service.IBaseTeacherService;
+import com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
 
 import javax.sql.DataSource;
+import javax.validation.Valid;
+import java.io.ByteArrayOutputStream;
 import java.sql.SQLException;
 import java.time.DayOfWeek;
 import java.time.LocalDateTime;
@@ -231,4 +234,15 @@ public class ScheduleController {
 
         return jsonParser.parse(result).getAsJsonObject();
     }
+
+    @PostMapping("/schedule-week-export-query")
+    @ApiOperation(value = "按周导出课表")
+    public ResponseEntity<byte[]> scheduleWeekExportQuery(@Valid @RequestBody ScheduleWeekExportQueryDto dto) {
+//    @GetMapping("/schedule-week-export-query")
+//    @ApiOperation(value = "按周导出课表")
+//    public ResponseEntity<byte[]> textbookClaimExportQuery(@Valid ScheduleWeekExportQueryDto dto) {
+
+        ByteArrayOutputStream bot = courseTableService.listScheduleWeekExportQuery(dto);
+        return RT.fileStream(bot.toByteArray(), "scheduleWeek" + ExcelTypeEnum.XLSX.getValue());
+    }
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/schedule/dto/ScheduleWeekExportQueryDto.java

@@ -0,0 +1,5 @@
+package com.xjrsoft.module.schedule.dto;
+
+public class ScheduleWeekExportQueryDto extends CourseTableDto {
+
+}

+ 58 - 0
src/main/java/com/xjrsoft/module/schedule/vo/ScheduleWeekExportQueryVo.java

@@ -0,0 +1,58 @@
+package com.xjrsoft.module.schedule.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 周课表导出
+ */
+@Data
+public class ScheduleWeekExportQueryVo {
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("时间")
+    @ApiModelProperty("时段(1=上午 2=下午 3=晚上)")
+    private String timePeriod;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("时间")
+    @ApiModelProperty("节次")
+    private String timeNumber;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周一")
+    @ApiModelProperty("星期一的课")
+    private String monday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周二")
+    @ApiModelProperty("星期二的课")
+    private String tuesday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周三")
+    @ApiModelProperty("星期三的课")
+    private String wednesday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周四")
+    @ApiModelProperty("星期四的课")
+    private String thursday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周五")
+    @ApiModelProperty("星期五的课")
+    private String friday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周六")
+    @ApiModelProperty("星期六的课")
+    private String saturday;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("周日")
+    @ApiModelProperty("星期日的课")
+    private String sunday;
+}

+ 2 - 1
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java

@@ -40,11 +40,13 @@ import com.xjrsoft.module.textbook.vo.*;
 import lombok.AllArgsConstructor;
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -774,7 +776,6 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
         }
         return bot;
     }
-
     @Override
     @Transactional
     public Boolean deliverWarehouse(AddTextbookWarehouseRecordDto dto) {

+ 9 - 0
src/main/java/com/xjrsoft/module/textbook/vo/TextbookClaimExportQueryVo.java

@@ -102,4 +102,13 @@ public class TextbookClaimExportQueryVo {
     @ExcelProperty("备注")
     @ApiModelProperty("备注")
     private String remark;
+
+    public TextbookClaimExportQueryVo() {
+
+    }
+
+    public TextbookClaimExportQueryVo(String bookName, BigDecimal subtotal) {
+        this.bookName = bookName;
+        this.subtotal = subtotal;
+    }
 }

+ 2 - 1
src/main/resources/mapper/textbook/TextbookIssueRecordMapper.xml

@@ -20,7 +20,7 @@
         t1.create_date,
         t9.name  AS claim_user,
         t1.issue_number,
-        t3.base_semester_id as baseSemesterIdCn
+        t15.name as baseSemesterIdCn
         FROM textbook_issue_record t1
         LEFT JOIN wf_textbook_claim_item t2 ON t1.data_item_id = t2.id
         LEFT JOIN wf_textbook_claim t4 ON t1.data_id = t4.id
@@ -35,6 +35,7 @@
         LEFT JOIN xjr_user t9 ON t1.receive_user_id = t9.id
         LEFT JOIN xjr_dictionary_detail t10 ON t3.textbook_type = t10.code AND t10.item_id = 1739209191193636865
         LEFT JOIN xjr_dictionary_detail t11 ON t1.issue_mode = t11.code AND t11.item_id = 1739821685805215745
+        LEFT JOIN base_semester t15 ON t15.id = t3.base_semester_id
         WHERE t1.delete_mark = 0
         <if test="dto.textbookType != null and dto.textbookType != ''">
             and t3.textbook_type = #{dto.textbookType}

+ 4 - 2
src/main/resources/mapper/textbook/TextbookWarehouseRecordMapper.xml

@@ -19,7 +19,7 @@
         t1.create_date,
         t2.name AS warehouse_user,
         t1.warehouse_number,
-        t3.base_semester_id as baseSemesterIdCn,
+        t9.name as baseSemesterIdCn,
         (SELECT GROUP_CONCAT(c2.name)
         FROM textbook_class_relation c1
         LEFT JOIN base_class c2 ON c1.class_id = c2.id
@@ -32,6 +32,8 @@
         LEFT JOIN base_course_subject t5 ON t3.course_subject_id = t5.id
         LEFT JOIN xjr_dictionary_detail t6 ON t3.textbook_type = t6.code AND t6.item_id = 1739209191193636865
         LEFT JOIN base_grade t7 ON t3.grade_id = t7.id
+        LEFT JOIN textbook_class_relation t8 ON t8.textbook_id = t3.id
+        LEFT JOIN base_semester t9 ON t9.id = t3.base_semester_id
         WHERE t1.delete_mark = 0
         <if test="dto.textbookType != null and dto.textbookType != ''">
             and t3.textbook_type = #{dto.textbookType}
@@ -49,7 +51,7 @@
             and t3.course_subject_id = #{dto.courseSubjectId}
         </if>
         <if test="dto.classId != null">
-            and t3.class_id like concat('%',#{dto.classId}, '%')
+            and t8.class_id = #{dto.classId}
         </if>
         <if test="dto.bookName != null and dto.bookName != ''">
             and t3.book_name like concat('%',#{dto.bookName}, '%')