|
@@ -12,6 +12,7 @@ import cn.com.qmth.examcloud.core.print.common.Constants;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.ExcelUtils;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.FileUtils;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.CoursePaper;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.CourseStatistic;
|
|
@@ -273,9 +274,9 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
//封装待导出的试卷文件列表
|
|
|
List<ExportFileInfo> exportFiles = new ArrayList<>();
|
|
|
//封装试卷结构-客观题数据
|
|
|
- List<ObjectiveQuestionStructure> objectiveStructures = new ArrayList<>();
|
|
|
+ List<ObjectiveQuestionStructure> allObjectives = new ArrayList<>();
|
|
|
//封装试卷结构-主观题数据
|
|
|
- List<SubjectiveQuestionStructure> subjectiveStructures = new ArrayList<>();
|
|
|
+ List<SubjectiveQuestionStructure> allSubjectives = new ArrayList<>();
|
|
|
|
|
|
for (CourseStatistic statistic : statistics) {
|
|
|
CoursePaper paper = statistic.getCoursePaper();
|
|
@@ -298,18 +299,22 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
}
|
|
|
|
|
|
if (req.getNeedStruct()) {
|
|
|
- //todo
|
|
|
- //objectiveStructures.add(...)
|
|
|
- //subjectiveStructures.add(...)
|
|
|
+ //客观题结构
|
|
|
+ List<ObjectiveQuestionStructure> objectives = questionStructureService.getObjectiveQuestionStructureList(req.getExamId(), paper.getPaperId());
|
|
|
+ allObjectives.addAll(objectives);
|
|
|
+
|
|
|
+ //主观题结构
|
|
|
+ List<SubjectiveQuestionStructure> subjectives = questionStructureService.getSubjectiveQuestionStructureList(req.getExamId(), paper.getPaperId());
|
|
|
+ allSubjectives.addAll(subjectives);
|
|
|
}
|
|
|
exportFiles.add(info);
|
|
|
}
|
|
|
|
|
|
//打包所有文件
|
|
|
- return packageFiles(exportFiles);
|
|
|
+ return packageFiles(exportFiles, allObjectives, allSubjectives, req.getNeedStruct());
|
|
|
}
|
|
|
|
|
|
- private File packageFiles(List<ExportFileInfo> exportFiles) {
|
|
|
+ private File packageFiles(List<ExportFileInfo> exportFiles, List<ObjectiveQuestionStructure> allObjectives, List<SubjectiveQuestionStructure> allSubjectives, Boolean needStruct) {
|
|
|
//文件存放目录
|
|
|
final String rootDir = Constants.rootFileDir();
|
|
|
final String targetDir = rootDir + "/" + FileUtils.randomUUID();
|
|
@@ -326,6 +331,15 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
this.loadFile(answerDir, info.getAnswerPdf());
|
|
|
}
|
|
|
|
|
|
+ //生成试卷结构文件
|
|
|
+ if (needStruct) {
|
|
|
+ final String objectiveFile = targetDir + "/" + OBJECTIVE_EXCEL_NAME;
|
|
|
+ ExcelUtils.toExcelFile(ObjectiveQuestionStructure.class, allObjectives, new File(objectiveFile), "");
|
|
|
+
|
|
|
+ final String subjectiveFile = targetDir + "/" + SUBJECTIVE_EXCEL_NAME;
|
|
|
+ ExcelUtils.toExcelFile(SubjectiveQuestionStructure.class, allSubjectives, new File(subjectiveFile), "");
|
|
|
+ }
|
|
|
+
|
|
|
//压缩打包所有文件
|
|
|
File target = new File(targetDir);
|
|
|
File zipFile = new File(targetDir + SUFFIX_ZIP);
|