Ver Fonte

提交导出试题BUG

chenken há 8 anos atrás
pai
commit
cdece41280

+ 16 - 5
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/ExportPaperAbstractService.java

@@ -128,6 +128,9 @@ public abstract class ExportPaperAbstractService {
 	public static Configuration CONFIGURATION;
 
 	public static final String ENCODING = "UTF-8";
+	
+	
+	private static final String UNDERSCORE = "_";
 
 	//陕西师范模板
 	protected static Template SXSF_TEMPLATE_PAPER;
@@ -598,8 +601,10 @@ public abstract class ExportPaperAbstractService {
      */
     protected void uploadComputerTestFile(ExtractConfig extractConfig,AccessUser accessUser) throws IOException{
     	List<ComputerTestPaper>  computerTestPaperList = buildComputerTestPapers(extractConfig);
-    	for(ComputerTestPaper computerTestPaper:computerTestPaperList){
-    		String jsonDirectoryName = extractConfig.getCourseCode()+"_"+computerTestPaper.getName();
+    	String currentTimeStr = CommonUtils.getCurNum();
+    	for(int i = 0;i<computerTestPaperList.size();i++){
+    		ComputerTestPaper computerTestPaper = computerTestPaperList.get(i);
+    		String jsonDirectoryName = currentTimeStr+UNDERSCORE+ExamFileType.COMPUTERTEST_PACKAGE.name()+UNDERSCORE+i;
     		String jsonDirectoryPath = TEMP_FILE_EXP + File.separator + jsonDirectoryName;
     		//新建文件夹
     		File dirFile = new File(jsonDirectoryPath);
@@ -619,7 +624,7 @@ public abstract class ExportPaperAbstractService {
 			FileDisposeUtil.fileToZip(jsonDirectoryPath,"docxExport",jsonDirectoryName);
 			//上传到又拍云
 			File zipFile = new File(TEMP_FILE_EXP+jsonDirectoryName+ZIP_SUFFIX);
-			String zipUpyunFilePath = uploadUrl+jsonDirectoryName+ZIP_SUFFIX;
+			String zipUpyunFilePath = uploadUrl+extractConfig.getOrgId()+"/"+jsonDirectoryName+ZIP_SUFFIX;
 			UpYun upyun = new UpYun(bucketName,userName,password);
 			upyun.writeFile(zipUpyunFilePath,zipFile,true);
 			//保存数据库记录
@@ -652,9 +657,12 @@ public abstract class ExportPaperAbstractService {
     			ComputerTestPaperDetail computerTestPaperDetail = new ComputerTestPaperDetail(paperDetail);
     			List<ComputerTestQuestion> questions = new ArrayList<ComputerTestQuestion>();
     			//遍历所有的小题对象
-    			for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
+    			for(int i = 0;i<paperDetailUnits.size();i++){
+    				PaperDetailUnit paperDetailUnit = paperDetailUnits.get(i);
     				//根据旧的小题对象,生成新的小题对象
     				ComputerTestQuestion  computerTestQuestion = new ComputerTestQuestion(paperDetailUnit);
+    				//设置小题题号
+    				computerTestQuestion.setNumber(i+1);
     				//得到小题题干
     				computerTestQuestion.setBody(getBody(paperDetailUnit.getQuestion()));
     				//得到小题所有选项
@@ -665,8 +673,11 @@ public abstract class ExportPaperAbstractService {
     				if(subQuestionsList!=null&&subQuestionsList.size()>0){
     					List<ComputerTestQuestion> subQuestions = new ArrayList<ComputerTestQuestion>();
     					//遍历每个套题
-    					for(Question subQuestion:subQuestionsList){
+    					for(int j = 0;j<subQuestionsList.size();j++){
+    						Question subQuestion = subQuestionsList.get(j);
         					ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
+        					//设置套题中小题题号
+        					subcomputerTestQuestion.setNumber(j+1);
         					subcomputerTestQuestion.setBody(getBody(subQuestion));
         					subcomputerTestQuestion.setOptions(getOption(subQuestion));
         					subQuestions.add(subcomputerTestQuestion);

+ 20 - 11
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigFileServiceImpl.java

@@ -125,8 +125,8 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 			if(exportStructure==null){
 				throw new RuntimeException("该考试下的试卷结构导出设置未制定,不能导出");
 			}
-			//查询该考试下是否所有课程都制定了调卷规则
-			checkAllCourseByExamId(exportModel.getExamId());
+			//查询该考试下是否所有课程都制定了调卷规则和考试文件
+			checkAllCourseByExamId(exportModel.getExamId(),exportStructure.getExportType());
 		}
 	}
 
@@ -143,7 +143,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 		if(exportModel.getExportContentList().contains(ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name())
 				&&exportModel.getExportWay()==ExportWay.BATCH
 					&&exportStructure.getExportType()==ExportType.NORMAL){
-			paperIds = checkAllCourseByExamId(exportModel.getExamId());
+			paperIds = checkAllCourseByExamId(exportModel.getExamId(),exportStructure.getExportType());
 			//生成试卷结构到downloadDirectory目录
 			if(paperIds.size()>0){
 				//创建试卷结构Excel文件
@@ -172,7 +172,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 	 * 查询该考试下是否所有课程都制定了调卷规则
 	 * @param examId
 	 */
-	private List<String> checkAllCourseByExamId(String examId) {
+	private List<String> checkAllCourseByExamId(String examId,ExportType exportType) {
 		List<String> paperIdList = new ArrayList<String>();
 		List<ExamCourseDto> examCourseDtoList = examCourseClient.findExamCourseByExamId(examId);
 		for(ExamCourseDto examCourseDto:examCourseDtoList){
@@ -186,7 +186,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 			if(extractConfig.getIfFinish()==null||extractConfig.getIfFinish()==0){
 				throw new RuntimeException("该考试下的课程“"+extractConfig.getCourseName()+"”考试文件没有生成,不能批量导出,请保存调卷规则生成文件");
 			}
-			checkExamFileExists(examId,examCourseDto);
+			checkExamFileExists(examId,examCourseDto,exportType);
 			Map<String,String> finishedPaperIdMap = extractConfig.getFinishedPaperIdMap();
 			Set<Entry<String,String>> entry = finishedPaperIdMap.entrySet();
 			Iterator<Entry<String,String>> iterator = entry.iterator();
@@ -203,7 +203,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 	 * @param examId
 	 * @param examCourseDto
 	 */
-	private void checkExamFileExists(String examId,ExamCourseDto examCourseDto){
+	private void checkExamFileExists(String examId,ExamCourseDto examCourseDto,ExportType exportType){
 		ExamFile examFileCondition = new ExamFile();
 		examFileCondition.setExamId(examId);
 		examFileCondition.setCourseId(examCourseDto.getCourseCode());
@@ -212,14 +212,23 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 		
 		//检查是否都生成了试卷文件
 		boolean paperFlag = false;
-		for(ExamFile examFile:examfiles){
-			if(examFile.getExamFileType()==ExamFileType.PAPER){
-				paperFlag = true;
-				continue;
+		if(exportType == ExportType.NORMAL){
+			for(ExamFile examFile:examfiles){
+				if(examFile.getExamFileType()==ExamFileType.PAPER){
+					paperFlag = true;
+				}
+			}
+		}else{
+			for(ExamFile examFile:examfiles){
+				if(examFile.getExamFileType()==ExamFileType.COMPUTERTEST_PACKAGE){
+					paperFlag = true;
+				}
 			}
 		}
+		
 		if(!paperFlag){
-			throw new RuntimeException("该考试下的课程“"+examCourseDto.getCourseName()+"”考试文件没有生成,不能批量导出,请重新保存调卷规则生成");
+			String message = exportType == ExportType.NORMAL?"考试文件":"机考数据包";
+			throw new RuntimeException("该考试下的课程“"+examCourseDto.getCourseName()+"”"+message+"没有生成,不能批量导出,请重新保存调卷规则生成");
 		}
 	}
 	

+ 0 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperController.java

@@ -16,7 +16,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Example;
-import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;