mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-25 02:32:57 +08:00
fix:【FCJDFDXTXS-169】修改导出excel的展示逻辑,修改为课程名称的作业名称
This commit is contained in:
@@ -1471,11 +1471,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("课程名称", "课程名称");
|
||||
@@ -1494,22 +1492,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集合(去重),调用用户中心接口获取人员信息,填充部门字段
|
||||
@@ -1614,7 +1620,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) {
|
||||
|
||||
Reference in New Issue
Block a user