fix:【FCJDFDXTXS-169】修改导出excel的展示逻辑,修改为课程名称的作业名称

This commit is contained in:
miaowenbo
2025-12-16 17:22:12 +08:00
committed by joshen
parent 88e5958a02
commit 2f981735be

View File

@@ -1563,11 +1563,9 @@ public class StudyCourseApi extends ApiBaseController{
return;
}
OutputStream outputStream = null;
// 25.12.16新增修改导出excel的展示逻辑修改为课程名称的作业名称
String excelName;
try {
// 创建临时文件用于存储Excel
File tempExcelFile = File.createTempFile("HomeWorkRecord", ".xlsx");
String tempExcelPath = tempExcelFile.getAbsolutePath();
LinkedHashMap<String, String> exportMap = new LinkedHashMap<>();
// 1.拼接固定表头(课程名称、资源名称、姓名、工号、部门、作业状态、作业成绩、完成时间)
exportMap.put("课程名称", "课程名称");
@@ -1586,22 +1584,30 @@ public class StudyCourseApi extends ApiBaseController{
if (studyCourses != null && !studyCourses.isEmpty()) {
courseName = studyCourses.get(0).getCourseName();
} else {
courseName = "";
courseName = "空课程名称";
}
// 查询资源名称
List<CourseContent> courseContents = contentService.getByCourseId(courseId);
String contentName = "空作业名称";
String displayName = "";
if (courseContents != null && !courseContents.isEmpty()) {
for (CourseContent cc : courseContents) {
// 实体类解耦
entityManager.detach(cc);
// 25.12.15新增,修改课程名称的展示逻辑,修改为章名称+节名称
// 详细逻辑如下默认取sectionName-contentName如果sectionName不存在就用courseName-contentName
studyService.setContentDisplayName(courseContents);
if (contentId.equals(cc.getId())) {
displayName = cc.getDisplayName();
contentName = cc.getContentName();
break;
}
}
}
excelName = courseName + "" + contentName;
// 创建临时文件用于存储Excel
File tempExcelFile = File.createTempFile(excelName, ".xlsx");
String tempExcelPath = tempExcelFile.getAbsolutePath();
// 查询特定作业信息
List<StudyHomeWork> studyHomeWorks = studyHomeWorkService.getByCourseIdAndContentId(courseId, contentId);
// 通过studyHomeWorks中的人员id集合(去重),调用用户中心接口获取人员信息,填充部门字段
@@ -1706,7 +1712,7 @@ public class StudyCourseApi extends ApiBaseController{
File excelFile = new File(tempExcelPath);
if (excelFile.exists()) {
FileInputStream fis = new FileInputStream(excelFile);
ZipEntry zipEntry = new ZipEntry("HomeWorkRecord.xlsx");
ZipEntry zipEntry = new ZipEntry(excelName + ".xlsx");
zos.putNextEntry(zipEntry);
int length;
while ((length = fis.read(buffer)) > 0) {