Quellcode durchsuchen

优化上传试卷代码

chenken vor 8 Jahren
Ursprung
Commit
9309bc98a2

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

@@ -797,7 +797,7 @@ public abstract class ExportPaperAbstractService {
 			DocxProcessUtil.exportWord(paperExp,paperfileName,template);
 			DocxProcessUtil.processImage(paperfileName,getPkgList(paperExp.getId()));
 			File file  = new File(TEMP_FILE_EXP+paperfileName);
-			String paperFilePath = uploadUrl+paperfileName;
+			String paperFilePath = uploadUrl+extractConfig.getOrgId()+"/"+paperfileName;
             UpYun upyun = new UpYun(bucketName,userName,password);
 			upyun.writeFile(paperFilePath,file,true);
 			examFileService.saveExamFile(new ExamFile(extractConfig,paperFilePath,examFileType,DOCX_SUFFIX),accessUser);
@@ -836,7 +836,7 @@ public abstract class ExportPaperAbstractService {
 			File file = new File(TEMP_FILE_EXP+objectiveFilename);
 			FileOutputStream out = new FileOutputStream(file);
 			objectiveExcelExporter.write(objectiveFilename,objectiveQuestionStructureList,out);
-			String objectiveFilePath = uploadUrl+objectiveFilename;
+			String objectiveFilePath = uploadUrl+extractConfig.getOrgId()+"/"+objectiveFilename;
             UpYun upyun = new UpYun(bucketName,userName,password);
 			upyun.writeFile(objectiveFilePath,file,true);
 			examFileService.saveExamFile(new ExamFile(extractConfig,objectiveFilePath,ExamFileType.PAPER_STRUCTURE_OBJECTIVE,EXCEL_SUFFIX),accessUser);
@@ -925,7 +925,7 @@ public abstract class ExportPaperAbstractService {
 			File file = new File(TEMP_FILE_EXP+subjectiveFileName);
 			FileOutputStream out = new FileOutputStream(file);
 			subjectiveExcelExporter.write(subjectiveFileName,subjectiveQuestionStructureList,out);
-			String subjectiveFilePath = uploadUrl+subjectiveFileName;
+			String subjectiveFilePath = uploadUrl+extractConfig.getOrgId()+"/"+subjectiveFileName;
             UpYun upyun = new UpYun(bucketName,userName,password);
 			upyun.writeFile(subjectiveFilePath,file,true);
 			examFileService.saveExamFile(new ExamFile(extractConfig,subjectiveFilePath,ExamFileType.PAPER_STRUCTURE_SUBJECTIVE,EXCEL_SUFFIX),accessUser);

+ 31 - 31
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/SydxExportPaperService.java

@@ -90,13 +90,43 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
             DocxProcessUtil.processDownload(fileNames, response);
         }
     }
+    
+    @Override
+    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,AccessUser accessUser) throws Exception{
+    	PaperExp exportPaperExp = initExportSydxPaper(paperId);
+    	PaperExp exportPaperStructureExp = initExportPaper(paperId);
+        if (exportPaperExp!=null&&exportPaperStructureExp!=null) {
+        	String currNum = CommonUtils.getCurNum();
+        	List<PaperDetailExp> objectiveDetails = exportPaperStructureExp.getObjectiveDetails();
+        	//没有试卷结构导出设置
+        	if(exportStructure==null){
+        		//上传试卷
+        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER);
+	        	//上传答案----石油大学无答案模板
+	        	//uploadAnswerWord(paperExp,extractConfig,paperId,accessUser,currNum);
+        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
+        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+        		checkObjectiveDetailsNum(exportPaperStructureExp,objectiveDetails,questionTypeNums);
+	    		//上传试卷
+        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER);
+	        	//上传答案----石油大学无答案模板
+	        	//uploadAnswerWord(paperExp,extractConfig,paperId,accessUser,currNum);
+				//上传试卷结构   不能在上传试卷和答案之前
+        		uploadPaperStructure(exportPaperStructureExp,extractConfig,accessUser,currNum,questionTypeNums);
+        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
+        		//上传机考JSON文件
+        		uploadComputerTestFile(extractConfig,accessUser);
+        	}
+        }
+    }
 	
     /**
      * 初始化导出石油大学试卷DTO
      * @param id
      * @return
      */
-    public PaperExp initExportSydxPaper(String id) throws Exception{
+    private PaperExp initExportSydxPaper(String id) throws Exception{
         //获取paper
         Paper paper = paperRepo.findOne(id);
         paperService.formatPaper(paper,null);
@@ -318,34 +348,4 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
         }
     }
     
-    @Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,AccessUser accessUser) throws Exception{
-    	PaperExp exportPaperExp = initExportSydxPaper(paperId);
-    	PaperExp exportPaperStructureExp = initExportPaper(paperId);
-        if (exportPaperExp!=null&&exportPaperStructureExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	List<PaperDetailExp> objectiveDetails = exportPaperStructureExp.getObjectiveDetails();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER);
-	        	//上传答案----石油大学无答案模板
-	        	//uploadAnswerWord(paperExp,extractConfig,paperId,accessUser,currNum);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(exportPaperStructureExp,objectiveDetails,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER);
-	        	//上传答案----石油大学无答案模板
-	        	//uploadAnswerWord(paperExp,extractConfig,paperId,accessUser,currNum);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(exportPaperStructureExp,extractConfig,accessUser,currNum,questionTypeNums);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser);
-        	}
-        }
-    }
-
 }