Parcourir la source

调卷规则导出bug修改

weiwenhai il y a 7 ans
Parent
commit
248bd2a8e8

+ 40 - 40
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractConfigFileService.java

@@ -1,40 +1,40 @@
-package com.qmth.cqb.paper.service;
-
-import javax.servlet.http.HttpServletResponse;
-
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-
-import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
-import com.qmth.cqb.paper.model.ExtractConfig;
-
-/**
- * @author  	chenken
- * @date    	2017年7月31日 下午6:03:26
- * @company 	QMTH
- * @description 调卷规则--文件处理service
- */
-public interface ExtractConfigFileService {
-	
-	/**
-	 * 保存调卷规则,生成试卷文件
-	 * @param extractConfig
-	 * @param isbuildFile	1:生成试卷文件 0:不生成试卷文件
-	 * @param accessUser
-	 * @throws Exception
-	 */
-	public void saveExtractConfigAndBuildPaperFile(ExtractConfig extractConfig,Integer isbuildFile,AccessUser accessUser)  throws Exception;
-	
-	/**
-	 * 导出考试下的试卷信息  校验
-	 * @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 ;
-}
-
+package com.qmth.cqb.paper.service;
+
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
+import com.qmth.cqb.paper.model.ExtractConfig;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月31日 下午6:03:26
+ * @company 	QMTH
+ * @description 调卷规则--文件处理service
+ */
+public interface ExtractConfigFileService {
+	
+	/**
+	 * 保存调卷规则,生成试卷文件
+	 * @param extractConfig
+	 * @param isbuildFile	1:生成试卷文件 0:不生成试卷文件
+	 * @param accessUser
+	 * @throws Exception
+	 */
+	public void saveExtractConfigAndBuildPaperFile(ExtractConfig extractConfig,Integer isbuildFile,AccessUser accessUser)  throws Exception;
+	
+	/**
+	 * 导出考试下的试卷信息  校验
+	 * @param exportModel
+	 * @param response
+	 * @throws Exception
+	 */
+	public void exportExamPaperInfoCheck(ExportPaperInfoModel exportModel,HttpServletResponse response)  throws Exception ;
+	/**
+	 * 导出考试下的试卷信息
+	 * @param exportModel
+	 */
+	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response,String loginName)  throws Exception ;
+}
+

+ 10 - 8
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigFileServiceImpl.java

@@ -171,11 +171,13 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 	}
 
 	@Override
-	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response) throws Exception {
+	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response,String loginName) throws Exception {
+		String downloadDir = downloadDirectory + loginName;
+		String downZipDir = zipDirectory + loginName;
 		//创建试卷和压缩文件 文件夹
-		FileDisposeUtil.createDirectory(downloadDirectory);
+		FileDisposeUtil.createDirectory(downloadDir);
 		//创建压缩文件的文件夹
-		FileDisposeUtil.createDirectory(zipDirectory);
+		FileDisposeUtil.createDirectory(downZipDir);
 		ExportStructure exportStructure = exportStructureService.findStructureByExamId(exportModel.getExamId()+"");
 		if(exportStructure==null){
 			exportStructure = new ExportStructure();
@@ -196,7 +198,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 			for(int i = 0;i<examFiles.size();i++){
 				ExamFile examFile = examFiles.get(i);
 				UpYun upyun = new UpYun(bucketName,userName,password);
-				File file = new File(downloadDirectory+File.separator+examFile.getFileName());
+				File file = new File(downloadDir+File.separator+examFile.getFileName());
 				upyun.readFile(examFile.getFilePath(), file);
 				
 				if(examFile.getExamFileType()==ExamFileType.PAPER){
@@ -219,12 +221,12 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
 		//创建压缩文件名称
 		String zipFileName = exportModel.getExamId();
 		//将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
-		FileDisposeUtil.fileToZip(downloadDirectory,zipDirectory,zipFileName);
+		FileDisposeUtil.fileToZip(downloadDir,downZipDir,zipFileName);
 		//下载zip文件到客户端
-		FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+File.separator+zipFileName+".zip",response);
+		FileDisposeUtil.downloadFile(zipFileName+".zip",downZipDir+File.separator+zipFileName+".zip",response);
 		//删除文件夹
-		FileUtils.deleteQuietly(new File(downloadDirectory));
-		FileUtils.deleteQuietly(new File(zipDirectory));
+		FileUtils.deleteQuietly(new File(downloadDir));
+		FileUtils.deleteQuietly(new File(downZipDir));
 	}
 	
 	/**

+ 8 - 6
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractConfigController.java

@@ -161,12 +161,13 @@ public class ExtractConfigController {
 	}
 	
 	@ApiOperation(value = "导出单张考试试卷、答案、试卷结构", notes = "导出单张考试试卷、答案、试卷结构")
-	@GetMapping(value = "/exportSingleExamPaperInfo/{exportWay}/{examId}/{courseId}/{exportContentList}")
+	@GetMapping(value = "/exportSingleExamPaperInfo/{exportWay}/{examId}/{courseId}/{exportContentList}/{loginName}")
 	public void exportSingleExamPaperInfo(HttpServletResponse response,
 											@PathVariable String exportWay,
 											@PathVariable String examId,
 											@PathVariable String courseId,
-											@PathVariable String exportContentList){
+											@PathVariable String exportContentList,
+											@PathVariable String loginName){
 		ExportPaperInfoModel exportModel = new ExportPaperInfoModel();
 		exportModel.setExportWay(ExportWay.strToEnum(exportWay));
 		exportModel.setExamId(examId);
@@ -178,7 +179,7 @@ public class ExtractConfigController {
 		}
 		exportModel.setExportContentList(list);
 		try {
-			extractConfigFileService.exportExamPaperInfo(exportModel,response);
+			extractConfigFileService.exportExamPaperInfo(exportModel,response,loginName);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -203,11 +204,12 @@ public class ExtractConfigController {
 	
 	
 	@ApiOperation(value = "导出整个考试下所有 课程的试卷、答案、试卷结构", notes = "导出整个考试下所有 课程的试卷、答案、试卷结构")
-	@GetMapping(value = "/exportBatchExamPaperInfo/{exportWay}/{examId}/{exportContentList}")
+	@GetMapping(value = "/exportBatchExamPaperInfo/{exportWay}/{examId}/{exportContentList}/{loginName}")
 	public void exportBatchExamPaperInfo(HttpServletResponse response,
 											@PathVariable String exportWay,
 											@PathVariable String examId,
-											@PathVariable String exportContentList){
+											@PathVariable String exportContentList,
+											@PathVariable String loginName){
 		ExportPaperInfoModel exportModel = new ExportPaperInfoModel();
 		exportModel.setExportWay(ExportWay.strToEnum(exportWay));
 		exportModel.setExamId(examId);
@@ -218,7 +220,7 @@ public class ExtractConfigController {
 		}
 		exportModel.setExportContentList(list);
 		try {
-			extractConfigFileService.exportExamPaperInfo(exportModel,response);
+			extractConfigFileService.exportExamPaperInfo(exportModel,response,loginName);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}