From 349e89d6fc95a31e0c45941b2720157bd9c3e751 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sun, 28 Jul 2024 18:34:39 +0900 Subject: [PATCH 1/3] =?UTF-8?q?update=20::=20=EA=B0=95=EC=9D=98=20?= =?UTF-8?q?=EC=B6=9C=EB=A0=A5=20=EC=96=91=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/service/LectureServiceImpl.kt | 154 ++++++++---------- 1 file changed, 72 insertions(+), 82 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index f331374b..62e04852 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -26,7 +26,6 @@ import team.msg.domain.lecture.presentation.data.response.* import team.msg.domain.lecture.repository.LectureDateRepository import team.msg.domain.lecture.repository.LectureRepository import team.msg.domain.lecture.repository.RegisteredLectureRepository -import team.msg.domain.school.exception.SchoolNotFoundException import team.msg.domain.school.repository.SchoolRepository import team.msg.domain.student.exception.StudentNotFoundException import team.msg.domain.student.model.Student @@ -576,34 +575,6 @@ class LectureServiceImpl( override fun lectureReceiptStatusExcel(response: HttpServletResponse) { val workBook = XSSFWorkbook() - val cellStyle = workBook.createCellStyle() - cellStyle.alignment = HorizontalAlignment.CENTER - cellStyle.verticalAlignment = VerticalAlignment.CENTER - - // 엑셀 삽입할 헤더 - val headers = listOf( - "연번" to 10, - "학교" to 20, - "동아리명" to 20, - "학과명" to 20, - "반" to 5, - "이름" to 10, - "휴대폰 번호(학생)" to 20, - "담당교사명" to 20, - "휴대폰번호(담당교사)" to 20, - "이메일(담당교사)" to 20, - "강의명" to 30, - "학기" to 20, - "강의 구분" to 30, - "강의 과" to 20, - "강의 계열" to 30, - "강의 유형" to 30, - "담당 강사" to 20, - "학점" to 20, - "필수강의 여부" to 20, - "강의 이수 완료일" to 30 - ) - val font = workBook.createFont() font.fontName = "Arial" font.fontHeightInPoints = 11 @@ -613,70 +584,89 @@ class LectureServiceImpl( style.verticalAlignment = VerticalAlignment.CENTER style.setFont(font) + // 엑셀 삽입할 헤더 + val headers = listOf( + "연번" to 10, + "구분" to 30, + "계열" to 20, + "학기" to 10, + "대학" to 30, + "학과" to 20, + "교과명" to 40, + "교육일정" to 50, + "교육내용" to 50, + "교육 장소" to 30, + "담당 교수" to 20, + "연락처" to 30, + "학교명" to 30, + "동아리" to 30, + "학년" to 10, + "학생 성명" to 20, + "담당교사" to 20, + "담당교사 연락처" to 30, + "이수 상태" to 20 + ) + val schools = schoolRepository.findAll() schools.forEach { highSchool -> - // 엑셀 시트 생성 val sheet = workBook.createSheet(highSchool.name) - // 열 생성 val headerRow = sheet.createRow(0) - headers.forEachIndexed { idx, header -> - headerRow.createCellWithOptions(idx, header.first, style, 20F) + headers.forEachIndexed { idx,header -> + headerRow.createCellWithOptions(idx, header.first, style, 30F) sheet.autoSizeColumn(idx) - sheet.setColumnWidth(idx,sheet.getColumnWidth(idx) + (256 * header.second)) - } - - val school = schoolRepository.findByName(highSchool.name) - ?: throw SchoolNotFoundException("해당하는 학교를 찾을 수 없습니다. info : [ school = $highSchool]") - - val clubs = clubRepository.findAllBySchool(school) - - val students = clubs.map { club -> - studentRepository.findAllByClub(club) - }.flatten() - - val registeredLecture = students.map { student -> - val registeredLecture = registeredLectureRepository.findAllByStudent(student) - - student to registeredLecture + sheet.setColumnWidth(idx, sheet.getColumnWidth(idx) + (256 * header.second)) } - registeredLecture.forEach { studentAndRegisteredLecture -> - val teacher = teacherRepository findByClub studentAndRegisteredLecture.first.club - - studentAndRegisteredLecture.second.forEachIndexed { idx, registeredLecture -> - val lecture = registeredLecture.lecture - - val row = sheet.createRow(idx+1) - - listOf( - (idx+1).toString(), - school.name, - studentAndRegisteredLecture.first.club.name, - "", - studentAndRegisteredLecture.first.classRoom.toString(), - studentAndRegisteredLecture.first.user!!.name, - studentAndRegisteredLecture.first.user!!.phoneNumber, - teacher.user!!.name, - teacher.user!!.phoneNumber, - teacher.user!!.email, - lecture.name, - lecture.semester.yearAndSemester, - lecture.division, - lecture.department, - lecture.line, - lecture.lectureType, - lecture.instructor, - lecture.credit.toString(), - if(lecture.essentialComplete) "O" else "X" - ).forEachIndexed { - cellIdx, parameter -> - val cell = row.createCell(cellIdx) - cell.setCellValue(parameter) - cell.cellStyle = cellStyle + val clubs = clubRepository.findAllBySchool(highSchool) + + clubs.map { club -> + val teacher = teacherRepository.findByClub(club) + ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다. info : [ clubId = ${club.id} ]") + + val students = studentRepository.findAllByClub(club) + + students.forEachIndexed { idx, student -> + val registeredLectures = registeredLectureRepository.findAllByStudent(student) + + registeredLectures.map { registeredLecture -> + val lecture = registeredLecture.lecture + val lectureDates = lectureDateRepository.findAllByLecture(lecture).sortedBy { it.completeDate } + val startTime = "${lectureDates.first().startTime.hour}:${lectureDates.first().startTime.minute}" + val endTime = "${lectureDates.first().endTime.hour}:${lectureDates.first().endTime.minute}" + + val location = lectureLocationRepository.findByLectureId(lecture.id) + + val row = sheet.createRow(idx+1) + + listOf( + (idx+1).toString(), + lecture.division, + lecture.line, + lecture.semester.yearAndSemester, + location.address, + lecture.department, + lecture.name, + "${lectureDates.first().completeDate} ~ ${lectureDates.last().completeDate} $startTime ~ $endTime", + lecture.content, + location.details, + lecture.instructor, + lecture.user!!.phoneNumber, + highSchool.name, + club.name, + student.grade.toString(), + student.user!!.name, + teacher.user!!.name, + teacher.user!!.phoneNumber, + registeredLecture.completeStatus.name + ).forEachIndexed { cellIdx, parameter -> + val cell = row.createCell(cellIdx) + cell.setCellValue(parameter) + cell.cellStyle = style + } } } } From ce58bfc44f079d7e1fe286dc174043287d75ed39 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sun, 28 Jul 2024 19:35:48 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor=20::=20=EA=B0=80=EB=8F=85=EC=84=B1?= =?UTF-8?q?=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 62e04852..e41d8260 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -634,8 +634,11 @@ class LectureServiceImpl( registeredLectures.map { registeredLecture -> val lecture = registeredLecture.lecture + val lectureDates = lectureDateRepository.findAllByLecture(lecture).sortedBy { it.completeDate } + val startTime = "${lectureDates.first().startTime.hour}:${lectureDates.first().startTime.minute}" + val endTime = "${lectureDates.first().endTime.hour}:${lectureDates.first().endTime.minute}" val location = lectureLocationRepository.findByLectureId(lecture.id) From be211d48818b419fb36a69504351bda0d3d4aea5 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sun, 28 Jul 2024 20:57:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?update=20::=20=EC=9D=B4=EC=88=98=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20description=EC=9D=84=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index e41d8260..5a1255f9 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -664,7 +664,7 @@ class LectureServiceImpl( student.user!!.name, teacher.user!!.name, teacher.user!!.phoneNumber, - registeredLecture.completeStatus.name + registeredLecture.completeStatus.description ).forEachIndexed { cellIdx, parameter -> val cell = row.createCell(cellIdx) cell.setCellValue(parameter)