Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev0410' into dev0410

宋悦 8 жил өмнө
parent
commit
a2e2f94a07

+ 3 - 1
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/FileDisposeUtil.java

@@ -119,6 +119,7 @@ public class FileDisposeUtil {
 	 * @return
 	 */
 	public static boolean fileToZip(String sourceFilePath, String zipFilePath,String fileName) {
+		logger.info("开始压缩"+sourceFilePath+"目录");
 		boolean flag = false;
 		File sourceFile = new File(sourceFilePath);
 		FileInputStream fis = null;
@@ -130,7 +131,7 @@ public class FileDisposeUtil {
 			logger.error("待压缩的文件目录:" + sourceFilePath + "不存在.");
 		} else {
 			try {
-				File zipFile = new File(zipFilePath+"/"+fileName+".zip");
+				File zipFile = new File(zipFilePath+File.separator+fileName+".zip");
 				if (zipFile.exists()) {
 					logger.error(zipFilePath + "目录下存在名字为:" + fileName+ ".zip" + "打包文件.");
 				} else {
@@ -174,6 +175,7 @@ public class FileDisposeUtil {
 				}
 			}
 		}
+		logger.info("压缩"+sourceFilePath+"目录完成");
 		return flag;
 	}
 	

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

@@ -8,7 +8,6 @@ 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.ExamFile;
 import com.qmth.cqb.paper.model.ExtractConfig;
 import com.qmth.cqb.paper.model.Paper;
 
@@ -96,10 +95,4 @@ public interface ExtractConfigService {
 	 */
 	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response)  throws Exception ;
 	
-	/**
-	 * 检查该考试下该课程是否生成试卷文件
-	 * @param examId
-	 * @param courseId
-	 */
-	public List<ExamFile> findPaperStructure(String examId, String courseId);
 }

+ 1 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperService.java

@@ -219,7 +219,7 @@ public class PaperService {
      */
     public Page<Paper> getGenPapers(PaperSearchInfo paperSearchInfo, int curPage, int pageSize) {
         Query query = new Query();
-        query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE));
+        query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE.name()));
         if(StringUtils.isNotBlank(paperSearchInfo.getCourseNo())){
         	query.addCriteria(Criteria.where("courseNo").is(paperSearchInfo.getCourseNo()));
         }

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

@@ -1,5 +1,6 @@
 package com.qmth.cqb.paper.service.impl;
 
+import java.io.File;
 import java.io.FileOutputStream;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -714,15 +715,15 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		List<ExamFile> examFiles = examFileService.findExamFileListByExportPaperInfoModel(exportModel);
 		if(examFiles!=null&&examFiles.size()>0){
 			for(ExamFile examFile:examFiles){
-				FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+"\\"+examFile.getFileName());
+				FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+File.separator+examFile.getFileName());
 			}
+			//创建压缩文件名称
+			String zipFileName = CommonUtils.getCurNum();
+			//将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
+			FileDisposeUtil.fileToZip(downloadDirectory,zipDirectory,zipFileName);
+			//下载zip文件到客户端
+			FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+File.separator+zipFileName+".zip",response);
 		}
-		//创建压缩文件名称
-		String zipFileName = exportStructure.getExamName()+"_"+exportStructure.getExamType().name()+"_"+CommonUtils.getCurNum();
-		//将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
-		FileDisposeUtil.fileToZip(downloadDirectory,zipDirectory,zipFileName);
-		//下载zip文件到客户端
-		FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+"\\"+zipFileName+".zip",response);
 	}
 	
 	/**
@@ -752,14 +753,6 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		return paperIdList;
 	}
 	
-	@Override
-	public List<ExamFile> findPaperStructure(String examId, String courseId) {
-		ExamFile examFile = new ExamFile();
-		examFile.setExamId(examId);
-		examFile.setCourseId(courseId);
-		return examFileService.findExamFileListByExamFile(examFile);
-	}
-	
 	private void makePaperStructure(String examName,List<String> paperIds,ExportStructure exportStructure) throws Exception{
 		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
 		

+ 39 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExamFileController.java

@@ -0,0 +1,39 @@
+package com.qmth.cqb.paper.web;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import com.qmth.cqb.paper.model.ExamFile;
+import com.qmth.cqb.paper.service.ExamFileService;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月25日 下午2:21:57
+ * @company 	QMTH
+ * @description ExamFileController.java
+ */
+@Controller
+@RequestMapping("${api_cqb}/")
+public class ExamFileController {
+	
+	@Autowired
+	private ExamFileService examFileService;
+	
+	@ApiOperation(value = "查询试卷文件", notes = "查询试卷文件")
+	@PostMapping(value = "/findExamFile")
+	public ResponseEntity findExamFile(@RequestBody ExamFile examFile){
+		List<ExamFile> examFiles = examFileService.findExamFileListByExamFile(examFile);
+		return new ResponseEntity(examFiles,HttpStatus.OK);
+	}
+}
+

+ 3 - 7
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractConfigController.java

@@ -29,7 +29,6 @@ import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
 
 import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
-import com.qmth.cqb.paper.model.ExamFile;
 import com.qmth.cqb.paper.model.ExtractConfig;
 import com.qmth.cqb.paper.service.ExtractConfigService;
 import com.qmth.cqb.utils.enums.ExportWay;
@@ -164,6 +163,7 @@ public class ExtractConfigController {
 		try {
 			extractConfigService.exportExamPaperInfo(exportModel,response);
 		} catch (Exception e) {
+			logger.error("Method:exportExamPaperInfo"+e.getMessage());
 			e.printStackTrace();
 		}
 	}
@@ -180,6 +180,7 @@ public class ExtractConfigController {
 			extractConfigService.exportExamPaperInfoCheck(exportModel,response);
 			return new ResponseEntity<String>(HttpStatus.OK);
 		} catch (Exception e) {
+			logger.error("Method:exportExamPaperInfoCheck"+e.getMessage());
 			return new ResponseEntity<String>(e.getMessage(),HttpStatus.OK);
 		}
 	}
@@ -203,14 +204,9 @@ public class ExtractConfigController {
 		try {
 			extractConfigService.exportExamPaperInfo(exportModel,response);
 		} catch (Exception e) {
+			logger.error("Method:exportExamPaperInfo"+e.getMessage());
 			e.printStackTrace();
 		}
 	}
 	
-	@ApiOperation(value = "检查该考试下该课程是否生成试卷文件", notes = "检查该考试下该课程是否生成试卷文件")
-	@GetMapping(value = "/findPaperStructure/{examId}/{courseId}")
-	public ResponseEntity findPaperStructure(@PathVariable String examId,@PathVariable String courseId){
-		List<ExamFile> examFiles = extractConfigService.findPaperStructure(examId,courseId);
-		return new ResponseEntity(examFiles,HttpStatus.OK);
-	}
 }	

+ 3 - 4
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperController.java

@@ -49,6 +49,7 @@ import cn.com.qmth.examcloud.common.uac.annotation.Uac;
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
 import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
+import cn.com.qmth.examcloud.common.util.ErrorMsg;
 import io.swagger.annotations.ApiOperation;
 
 /**
@@ -543,21 +544,19 @@ public class PaperController {
     @PutMapping(value = "/useBasePaper/{paperIds}")
     public ResponseEntity useBasePaper(HttpServletRequest request,@PathVariable String paperIds){
     	AccessUser user = (AccessUser) request.getAttribute("accessUser");
-    	user = new AccessUser();
-    	user.setRootOrgId(1L);
     	try{
     		String[] paperIdArray = paperIds.split(",");
         	for(int i = 0;i<paperIdArray.length;i++){
         		Paper oldpaper = paperRepo.findOne(paperIdArray[i]);
         		boolean result = paperService.checkPaperName(oldpaper.getName(), PaperType.GENERATE,user.getRootOrgId()+"");
         		if(!result){
-        			return new ResponseEntity("考试试卷:"+oldpaper.getName()+"已经存在",HttpStatus.INTERNAL_SERVER_ERROR);
+        			return new ResponseEntity(new ErrorMsg("考试试卷:"+oldpaper.getName()+"已经存在"),HttpStatus.OK);
         		}
         	}
     		paperService.useBasePaper(paperIds, user.getName());
     		return new ResponseEntity(HttpStatus.OK);
     	}catch(Exception e){
-    		return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+    		return new ResponseEntity(e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
     	}
     }
 }