|
|
@@ -32,7 +32,11 @@ 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.BaseClassroom;
|
|
|
+import com.xjrsoft.module.base.entity.BaseOfficeBuild;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseClassroomMapper;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseOfficeBuildMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
@@ -109,6 +113,8 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
|
|
|
private final CourseTableBakMapper courseTableBakMapper;
|
|
|
private final IUserService userService;
|
|
|
+ private final BaseClassroomMapper classroomMapper;
|
|
|
+ private final BaseOfficeBuildMapper officeBuildMapper;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -1264,6 +1270,13 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
CourseTableExportQueryUtil exportQueryUtil = new CourseTableExportQueryUtil();
|
|
|
String schoolName = "重庆市铜梁职业教育中心";
|
|
|
ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ //查询数据
|
|
|
+ CourseTableDto dataDto = new CourseTableDto();
|
|
|
+ dataDto.setSemesterId(dto.getSemesterId());
|
|
|
+ dataDto.setWeek(dto.getWeek());
|
|
|
+ CourseTableVo tableVo = this.getList(dataDto);
|
|
|
+
|
|
|
if("calss".equals(dto.getCourseType())){//班级课表
|
|
|
//根据年级、专业部,查询需要导出的班级
|
|
|
List<BaseClass> classList = baseClassService.list(
|
|
|
@@ -1274,6 +1287,8 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
.in(BaseClass::getOrgId, dto.getDeptIds())
|
|
|
);
|
|
|
|
|
|
+ Map<String, List<CourseDetailVo>> classDataMap = tableVo.getCourseList().stream().collect(Collectors.groupingBy(CourseDetailVo::getClassName));
|
|
|
+
|
|
|
Workbook workbook = new XSSFWorkbook();
|
|
|
String sheetName = "班级课表";
|
|
|
Sheet sheet = workbook.createSheet(sheetName);
|
|
|
@@ -1282,15 +1297,13 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
int classTableRowCount = 16;//每个班的课表占用的总行数
|
|
|
for(int i = 0; i < classList.size(); i ++){
|
|
|
BaseClass baseClass = classList.get(i);
|
|
|
- //查询数据
|
|
|
- CourseTableDto dataDto = new CourseTableDto();
|
|
|
- dataDto.setSemesterId(dto.getSemesterId());
|
|
|
- dataDto.setClassId(baseClass.getId());
|
|
|
- dataDto.setWeek(dto.getWeek());
|
|
|
- CourseTableVo tableVo = this.getList(dataDto);
|
|
|
- String rightName = "班主任:" + tableVo.getTeacherName() + " 行政班:" + tableVo.getClassName();
|
|
|
-
|
|
|
- int bigHeadRow = (classTableRowCount + 2) * i;
|
|
|
+
|
|
|
+ CourseTableVo classData = new CourseTableVo();
|
|
|
+ classData.setClassTimeList(tableVo.getClassTimeList());
|
|
|
+ classData.setCourseList(classDataMap.get(baseClass.getName()));
|
|
|
+
|
|
|
+ String rightName = "班主任:" + tableVo.getTeacherName() + " 行政班:" + baseClass.getName();
|
|
|
+ int bigHeadRow = (classTableRowCount + 3) * i;
|
|
|
//生成第一行title
|
|
|
ImportExcelUtil.createBigHead(workbook, sheet, bigHead, bigHeadRow, 8);
|
|
|
//生成副标题,展示所属学期
|
|
|
@@ -1300,7 +1313,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
//生成表头
|
|
|
createSecondTitle(workbook, sheet, bigHeadRow + 3);
|
|
|
//生成内容
|
|
|
- exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, tableVo, dto.getCourseType());
|
|
|
+ exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
|
|
|
}
|
|
|
workbook.write(bot);
|
|
|
}else if("teacher".equals(dto.getCourseType())){//教师课表
|
|
|
@@ -1316,12 +1329,93 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
.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) {
|
|
|
+ String[] split = teacherId.split(", ");
|
|
|
+ for (String s : split) {
|
|
|
+ teacherIdList.add(Long.parseLong(s));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<User> userList = userService.listByIds(teacherIdList);
|
|
|
+
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ String sheetName = "教师课表";
|
|
|
+ Sheet sheet = workbook.createSheet(sheetName);
|
|
|
+ String bigHead = "课程表";
|
|
|
+ int classTableRowCount = 16;//每个班的课表占用的总行数
|
|
|
+
|
|
|
+ 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());
|
|
|
|
|
|
+ CourseTableVo classData = new CourseTableVo();
|
|
|
+ classData.setClassTimeList(tableVo.getClassTimeList());
|
|
|
+ classData.setCourseList(courseList);
|
|
|
|
|
|
+ String rightName = "教师:" + user.getName();
|
|
|
+ int bigHeadRow = (classTableRowCount + 3) * i;
|
|
|
+ //生成第一行title
|
|
|
+ ImportExcelUtil.createBigHead(workbook, sheet, bigHead, bigHeadRow, 8);
|
|
|
+ //生成副标题,展示所属学期
|
|
|
+ ImportExcelUtil.createSubtitle(workbook, sheet, baseSemester.getName(), bigHeadRow + 1, 8);
|
|
|
+ //生成第三行,显示学校名字、班主任和班级名字
|
|
|
+ exportQueryUtil.createThirdTitle(workbook, sheet, bigHeadRow + 2, schoolName, rightName);
|
|
|
+ //生成表头
|
|
|
+ createSecondTitle(workbook, sheet, bigHeadRow + 3);
|
|
|
+ //生成内容
|
|
|
+ exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
|
|
|
+ }
|
|
|
+ workbook.write(bot);
|
|
|
}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())
|
|
|
+ );
|
|
|
+ Map<Long, String> buildMap = buildList.stream().collect(Collectors.toMap(BaseOfficeBuild::getId, BaseOfficeBuild::getName));
|
|
|
|
|
|
- }else if("all".equals(dto.getCourseType())){//总课表
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ String sheetName = "教室课表";
|
|
|
+ Sheet sheet = workbook.createSheet(sheetName);
|
|
|
+ String bigHead = "课程表";
|
|
|
+ int classTableRowCount = 16;//每个班的课表占用的总行数
|
|
|
+
|
|
|
+ for (int i = 0; i < classroomList.size(); i ++){
|
|
|
+ BaseClassroom baseClassroom = classroomList.get(i);
|
|
|
+ String classroomName = buildMap.get(baseClassroom.getOfficeBuildId()) + baseClassroom.getName();
|
|
|
+ List<CourseDetailVo> courseList = classroomDataMap.get(classroomName);
|
|
|
+
|
|
|
+ CourseTableVo classData = new CourseTableVo();
|
|
|
+ classData.setClassTimeList(tableVo.getClassTimeList());
|
|
|
+ classData.setCourseList(courseList);
|
|
|
|
|
|
+ int bigHeadRow = (classTableRowCount + 3) * i;
|
|
|
+ //生成第一行title
|
|
|
+ ImportExcelUtil.createBigHead(workbook, sheet, bigHead, bigHeadRow, 8);
|
|
|
+ //生成副标题,展示所属学期
|
|
|
+ ImportExcelUtil.createSubtitle(workbook, sheet, baseSemester.getName(), bigHeadRow + 1, 8);
|
|
|
+ //生成第三行,显示学校名字、班主任和班级名字
|
|
|
+ exportQueryUtil.createThirdTitle(workbook, sheet, bigHeadRow + 2, schoolName, classroomName);
|
|
|
+ //生成表头
|
|
|
+ createSecondTitle(workbook, sheet, bigHeadRow + 3);
|
|
|
+ //生成内容
|
|
|
+ exportQueryUtil.createContent(workbook, sheet, bigHeadRow + 4, classData, dto.getCourseType());
|
|
|
+ }
|
|
|
+ workbook.write(bot);
|
|
|
+ }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())
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
return bot;
|