|
@@ -16,6 +16,12 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
+import org.springframework.data.domain.Sort.Order;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
@@ -39,6 +45,7 @@ import com.qmth.cqb.question.model.Question;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
import com.qmth.cqb.utils.FileDisposeUtil;
|
|
|
import com.qmth.cqb.utils.SpringContextUtils;
|
|
|
+import com.qmth.cqb.utils.enums.PaperType;
|
|
|
|
|
|
@Service("exportPaperService")
|
|
|
public class ExportPaperServiceImpl implements ExportPaperService{
|
|
@@ -53,6 +60,9 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
|
|
|
|
@Autowired
|
|
|
private PaperDetailService paperDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
|
|
|
@Override
|
|
|
public void exportPaperFile(String paperId,String serviceName,String exportContentList,HttpServletResponse response,String loginName) throws Exception {
|
|
@@ -312,4 +322,39 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportPaperFiles(List<String> paperIds,String serviceName,String exportContentList, HttpServletResponse response,String loginName) throws Exception {
|
|
|
+ ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(serviceName);
|
|
|
+ //根据试卷id查询所有试卷
|
|
|
+ List<Paper> papers = CommonUtils.toList(paperRepo.findAll(paperIds));
|
|
|
+ String zipFileName = loginName;
|
|
|
+ //创建压缩文件夹
|
|
|
+ File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
|
|
|
+ if(!directory.exists()){
|
|
|
+ directory.mkdirs();
|
|
|
+ }
|
|
|
+ //下载试卷
|
|
|
+ if(exportContentList.indexOf("PAPER")>-1){
|
|
|
+ for(Paper paper:papers){
|
|
|
+ exportPaperAbstractService.downloadPaper(paper.getId(),zipFileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //下载答案
|
|
|
+ if(exportContentList.indexOf("ANSWER")>-1){
|
|
|
+ for(Paper paper:papers){
|
|
|
+ exportPaperAbstractService.downloadPaperAnswer(paper.getId(),zipFileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //下载机考数据包
|
|
|
+ if(exportContentList.indexOf("COMPUTERTEST_PACKAGE")>-1){
|
|
|
+ for(Paper paper:papers){
|
|
|
+ ComputerTestPaper computerTestPaper = buildComputerTestPapers(paper);
|
|
|
+ makeComputerTestPaperToJsonFile(paper.getCourse().getCode()+ "_" +paper.getName(),computerTestPaper,TEMP_FILE_EXP+File.separator+zipFileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FileDisposeUtil.fileToZip(TEMP_FILE_EXP+File.separator+zipFileName,TEMP_FILE_EXP,zipFileName);
|
|
|
+ FileDisposeUtil.downloadFile(CommonUtils.getCurDate() +".zip", TEMP_FILE_EXP+File.separator+zipFileName+".zip",response);
|
|
|
+ deteleFolder(TEMP_FILE_EXP,zipFileName);
|
|
|
+ }
|
|
|
+
|
|
|
}
|