|
@@ -233,24 +233,34 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
@Override
|
|
|
public CoursePaperTotalInfo getPaperTotalByOrgIdAndExamId(Long orgId, Long examId) {
|
|
|
+ Check.isNull(orgId, "学校ID不能为空!");
|
|
|
+ Check.isNull(examId, "考试ID不能为空!");
|
|
|
//todo
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void checkPaperStructure(Long examId, String paperId) {
|
|
|
+ Check.isNull(examId, "考试ID不能为空!");
|
|
|
+ Check.isEmpty(paperId, "试卷ID不能为空!");
|
|
|
//todo
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public File exportBatchCoursePaper(ExportBatchReq req) {
|
|
|
Check.isNull(req, "参数不能为空!");
|
|
|
- Check.isNull(req.getOrgId(), "学校ID不能为空!");
|
|
|
- Check.isNull(req.getExamId(), "考试ID不能为空!");
|
|
|
- Check.isNull(req.required(), "至少选择一种导出内容!");
|
|
|
- Check.isEmpty(req.getPaperIds(), "至少选择一门课程!");
|
|
|
- //todo
|
|
|
- return null;
|
|
|
+ Check.isEmpty(req.getIds(), "至少选择一门考试课程!");
|
|
|
+ Check.isFalse(req.required(), "至少选择一种导出内容!");
|
|
|
+
|
|
|
+ SearchBuilder searches = new SearchBuilder();
|
|
|
+ searches.in("id", req.getIds());
|
|
|
+ searches.eq("paperStatus", PaperStatus.已有.getIndex());
|
|
|
+ Specification<CourseStatistic> spec = SpecUtils.buildSearchers(CourseStatistic.class, searches.build());
|
|
|
+
|
|
|
+ List<CourseStatistic> statistics = courseStatisticRepository.findAll(spec);
|
|
|
+ return this.doExport(statistics, req.getNeedPaper(), req.getNeedAnswer(), req.getNeedStruct());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -258,16 +268,21 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
Check.isNull(req, "参数不能为空!");
|
|
|
Check.isNull(req.getOrgId(), "学校ID不能为空!");
|
|
|
Check.isNull(req.getExamId(), "考试ID不能为空!");
|
|
|
- Check.isNull(req.required(), "至少选择一种导出内容!");
|
|
|
+ Check.isFalse(req.required(), "至少选择一种导出内容!");
|
|
|
|
|
|
SearchBuilder searches = new SearchBuilder();
|
|
|
searches.eq("orgId", req.getOrgId());
|
|
|
searches.eq("examId", req.getExamId());
|
|
|
searches.eq("paperStatus", PaperStatus.已有.getIndex());
|
|
|
Specification<CourseStatistic> spec = SpecUtils.buildSearchers(CourseStatistic.class, searches.build());
|
|
|
+
|
|
|
List<CourseStatistic> statistics = courseStatisticRepository.findAll(spec);
|
|
|
+ return this.doExport(statistics, req.getNeedPaper(), req.getNeedAnswer(), req.getNeedStruct());
|
|
|
+ }
|
|
|
+
|
|
|
+ private File doExport(List<CourseStatistic> statistics, boolean needPaper, boolean needAnswer, boolean needStruct) {
|
|
|
if (statistics == null || statistics.isEmpty()) {
|
|
|
- log.warn(String.format("No paper to export! orgId = %s examId = %s", req.getOrgId(), req.getExamId()));
|
|
|
+ log.warn("No paper to export!");
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -288,30 +303,30 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
final String title = String.format("%s_%s_%s_", paper.getPaperName(), paper.getCourseCode(), statistic.getPaperType());
|
|
|
ExportFileInfo info = new ExportFileInfo();
|
|
|
|
|
|
- if (req.getNeedPaper()) {
|
|
|
+ if (needPaper) {
|
|
|
info.setPaperWord(new Pair<>(title + PAPER_DOC_NAME, paper.getPaperWordUrl()));
|
|
|
info.setPaperPdf(new Pair<>(title + PAPER_PDF_NAME, paper.getPaperPdfUrl()));
|
|
|
}
|
|
|
|
|
|
- if (req.getNeedAnswer()) {
|
|
|
+ if (needAnswer) {
|
|
|
info.setAnswerWord(new Pair<>(title + ANSWER_DOC_NAME, paper.getAnswerWordUrl()));
|
|
|
info.setAnswerPdf(new Pair<>(title + ANSWER_PDF_NAME, paper.getAnswerPdfUrl()));
|
|
|
}
|
|
|
|
|
|
- if (req.getNeedStruct()) {
|
|
|
+ if (needStruct) {
|
|
|
//客观题结构
|
|
|
- List<ObjectiveQuestionStructure> objectives = questionStructureService.getObjectiveQuestionStructureList(req.getExamId(), paper.getPaperId());
|
|
|
+ List<ObjectiveQuestionStructure> objectives = questionStructureService.getObjectiveQuestionStructureList(paper.getExamId(), paper.getPaperId());
|
|
|
allObjectives.addAll(objectives);
|
|
|
|
|
|
//主观题结构
|
|
|
- List<SubjectiveQuestionStructure> subjectives = questionStructureService.getSubjectiveQuestionStructureList(req.getExamId(), paper.getPaperId());
|
|
|
+ List<SubjectiveQuestionStructure> subjectives = questionStructureService.getSubjectiveQuestionStructureList(paper.getExamId(), paper.getPaperId());
|
|
|
allSubjectives.addAll(subjectives);
|
|
|
}
|
|
|
exportFiles.add(info);
|
|
|
}
|
|
|
|
|
|
//打包所有文件
|
|
|
- return packageFiles(exportFiles, allObjectives, allSubjectives, req.getNeedStruct());
|
|
|
+ return packageFiles(exportFiles, allObjectives, allSubjectives, needStruct);
|
|
|
}
|
|
|
|
|
|
private File packageFiles(List<ExportFileInfo> exportFiles, List<ObjectiveQuestionStructure> allObjectives, List<SubjectiveQuestionStructure> allSubjectives, boolean needStruct) {
|
|
@@ -334,10 +349,10 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
//生成试卷结构文件
|
|
|
if (needStruct) {
|
|
|
final String objectiveFile = targetDir + "/" + OBJECTIVE_EXCEL_NAME;
|
|
|
- ExcelUtils.toExcelFile(ObjectiveQuestionStructure.class, allObjectives, new File(objectiveFile), OBJECTIVE_TITLE);
|
|
|
+ ExcelUtils.exportExcel(ObjectiveQuestionStructure.class, allObjectives, new File(objectiveFile), OBJECTIVE_TITLE);
|
|
|
|
|
|
final String subjectiveFile = targetDir + "/" + SUBJECTIVE_EXCEL_NAME;
|
|
|
- ExcelUtils.toExcelFile(SubjectiveQuestionStructure.class, allSubjectives, new File(subjectiveFile), SUBJECTIVE_TITLE);
|
|
|
+ ExcelUtils.exportExcel(SubjectiveQuestionStructure.class, allSubjectives, new File(subjectiveFile), SUBJECTIVE_TITLE);
|
|
|
}
|
|
|
|
|
|
//压缩打包所有文件
|