|
@@ -2,6 +2,7 @@ package com.qmth.cqb.paper.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
@@ -188,7 +189,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
Map<String,String> paperIds = checkAllCourseByExamId(exportModel.getExamId(),exportStructure.getExportType());
|
|
|
if(exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
if(paperIds.size()>0&&exportModel.getExportContentList().contains(ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name())){
|
|
|
- makePaperStructure(exportStructure.getExamName(),paperIds,exportStructure);
|
|
|
+ makePaperStructure(downloadDir,exportStructure.getExamName(),paperIds,exportStructure);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -362,7 +363,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
* @param exportStructure
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private void makePaperStructure(String examName,Map<String,String> paperIds,ExportStructure exportStructure) throws Exception{
|
|
|
+ private void makePaperStructure(String downloadDir,String examName,Map<String,String> paperIds,ExportStructure exportStructure) throws Exception{
|
|
|
logger.info("正在批量生成试卷结构...");
|
|
|
List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
//客观题集合
|
|
@@ -411,14 +412,30 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
}
|
|
|
|
|
|
ExcelWriter objectiveExcelExporter = new ExcelWriter(ObjectiveQuestionStructure.class);
|
|
|
- FileOutputStream out1 = new FileOutputStream(downloadDirectory+File.separator+examName+"_客观题.xlsx");
|
|
|
- objectiveExcelExporter.write(examName+"_客观题.xlsx",objectiveQuestionStructureList,out1);
|
|
|
+ String keguanFileName = examName+"_客观题.xlsx";
|
|
|
+ FileOutputStream out1 = getFileOutputStream(downloadDir,keguanFileName);
|
|
|
+ objectiveExcelExporter.write(keguanFileName,objectiveQuestionStructureList,out1);
|
|
|
|
|
|
ExcelWriter subjectiveExcelExporter = new ExcelWriter(SubjectiveQuestionStructure.class);
|
|
|
- FileOutputStream out2 = new FileOutputStream(downloadDirectory+File.separator+examName+"_主观题.xlsx");
|
|
|
- subjectiveExcelExporter.write(examName+"_主观题.xlsx",subjectiveQuestionStructureList,out2);
|
|
|
+ String zhuguanFileName = examName+"_主观题.xlsx";
|
|
|
+ FileOutputStream out2 = getFileOutputStream(downloadDir,zhuguanFileName);
|
|
|
+ subjectiveExcelExporter.write(zhuguanFileName,subjectiveQuestionStructureList,out2);
|
|
|
|
|
|
+ out1.close();
|
|
|
+ out2.close();
|
|
|
logger.info("批量生成试卷结构完成");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private FileOutputStream getFileOutputStream(String downloadDir,String fileName) throws IOException{
|
|
|
+ File directory = new File(downloadDir);
|
|
|
+ if(!directory.exists()){
|
|
|
+ directory.mkdirs();
|
|
|
+ }
|
|
|
+ File file = new File(downloadDir+File.separator+fileName);
|
|
|
+ if(!file.exists()){
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ return new FileOutputStream(file);
|
|
|
+ }
|
|
|
+
|
|
|
}
|