Browse Source

提交导出文件校验代码

chenken 8 years ago
parent
commit
ff39f1a114

+ 8 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractConfigService.java

@@ -83,11 +83,19 @@ public interface ExtractConfigService {
 	 * @return
 	 */
 	public boolean checkIsAllQbjectiveQuestion(String paperId);
+	/**
+	 * 导出考试下的试卷信息  校验
+	 * @param exportModel
+	 * @param response
+	 * @throws Exception
+	 */
+	public void exportExamPaperInfoCheck(ExportPaperInfoModel exportModel,HttpServletResponse response)  throws Exception ;
 	/**
 	 * 导出考试下的试卷信息
 	 * @param exportModel
 	 */
 	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response)  throws Exception ;
+	
 	/**
 	 * 检查该考试下该课程是否生成试卷文件
 	 * @param examId

+ 15 - 5
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigServiceImpl.java

@@ -1,6 +1,5 @@
 package com.qmth.cqb.paper.service.impl;
 
-import java.io.File;
 import java.io.FileOutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -14,7 +13,6 @@ import java.util.Set;
 
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.nlpcn.commons.lang.util.StringUtil;
 import org.slf4j.Logger;
@@ -675,6 +673,20 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
         quesOptions = null;
         return newQuesOptions;
     }
+    
+    @Override
+	public void exportExamPaperInfoCheck(ExportPaperInfoModel exportModel,HttpServletResponse response) throws Exception {
+    	Map<String, Object> exportStructureMap = exportStructureService.findStructureByExamIdAndExamType(exportModel.getExamId()+"",exportModel.getExamType());
+		ExportStructure exportStructure = (ExportStructure) exportStructureMap.get("exportStructure");
+		//如果是批量导出
+		if(exportModel.getExportWay()==ExportWay.BATCH){
+			if(exportStructure==null){
+				throw new RuntimeException("该考试下的试卷结构导出设置未制定,不能导出");
+			}
+			//查询该考试下是否所有课程都制定了调卷规则
+			checkAllCourseByExamId(exportModel.getExamId());
+		}
+	}
 
 	@Override
 	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response) throws Exception {
@@ -740,7 +752,6 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		return paperIdList;
 	}
 	
-
 	@Override
 	public List<ExamFile> findPaperStructure(String examId, String courseId) {
 		ExamFile examFile = new ExamFile();
@@ -749,7 +760,6 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		return examFileService.findExamFileListByExamFile(examFile);
 	}
 	
-	
 	private void makePaperStructure(String examName,List<String> paperIds,ExportStructure exportStructure) throws Exception{
 		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
 		
@@ -789,5 +799,5 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
     	FileOutputStream out2 = new FileOutputStream(downloadDirectory+"\\"+examName+"_主观题.xlsx");
     	subjectiveExcelExporter.write(examName+"_主观题.xlsx",subjectiveQuestionStructureList,out2);
 	}
-	
+
 }

+ 17 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractConfigController.java

@@ -168,6 +168,23 @@ public class ExtractConfigController {
 		}
 	}
 	
+	@ApiOperation(value = "导出试卷文件前校验", notes = "导出试卷文件前校验")
+	@GetMapping(value = "/exportBatchExamPaperInfoCheck/{exportWay}/{examId}")
+	public ResponseEntity<String> exportExamPaperInfoCheck(HttpServletResponse response,
+											@PathVariable String exportWay,
+											@PathVariable String examId){
+		ExportPaperInfoModel exportModel = new ExportPaperInfoModel();
+		exportModel.setExportWay(ExportWay.strToEnum(exportWay));
+		exportModel.setExamId(examId);
+		try {
+			extractConfigService.exportExamPaperInfoCheck(exportModel,response);
+			return new ResponseEntity<String>(HttpStatus.OK);
+		} catch (Exception e) {
+			return new ResponseEntity<String>(e.getMessage(),HttpStatus.OK);
+		}
+	}
+	
+	
 	@ApiOperation(value = "导出整个考试下所有 课程的试卷、答案、试卷结构", notes = "导出整个考试下所有 课程的试卷、答案、试卷结构")
 	@GetMapping(value = "/exportBatchExamPaperInfo/{exportWay}/{examId}/{exportContentList}")
 	public void exportExamPaperInfo(HttpServletResponse response,