|
@@ -182,94 +182,75 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
FileDisposeUtil.createDirectory(downloadDir);
|
|
|
// 创建压缩文件的文件夹
|
|
|
FileDisposeUtil.createDirectory(downZipDir);
|
|
|
- ExportStructure exportStructure = exportStructureService.findStructureByExamId(exportModel.getExamId() + "");
|
|
|
- if (exportStructure == null) {
|
|
|
- exportStructure = new ExportStructure();
|
|
|
- exportStructure.setExportType(ExportType.NORMAL);
|
|
|
- }
|
|
|
-
|
|
|
- // 导出分布式印刷的数据包
|
|
|
- if (exportModel.getExportContentList().contains(ExamFileType.PRINT_EXAM_PACKAGE.name())) {
|
|
|
- ExtractConfig condition = new ExtractConfig();
|
|
|
- condition.setExamId(Long.valueOf(exportModel.getExamId()));
|
|
|
- condition.setCourseCode(exportModel.getCourseId());
|
|
|
- // 获取调卷规则
|
|
|
- ExtractConfig extractConfig = extractConfigService.findConfig(condition);
|
|
|
- if (extractConfig != null) {
|
|
|
- List<Paper> papers = new ArrayList<>();
|
|
|
- List<ExamPaper> examPapers = extractConfig.getExamPaperList();
|
|
|
- if (examPapers != null && examPapers.size() > 0) {
|
|
|
- for (ExamPaper examPaper : examPapers) {
|
|
|
- papers.add(examPaper.getPaper());
|
|
|
+ try {
|
|
|
+ ExportStructure exportStructure = exportStructureService
|
|
|
+ .findStructureByExamId(exportModel.getExamId() + "");
|
|
|
+ if (exportStructure == null) {
|
|
|
+ exportStructure = new ExportStructure();
|
|
|
+ exportStructure.setExportType(ExportType.NORMAL);
|
|
|
+ }
|
|
|
+ // 导出分布式印刷的数据包
|
|
|
+ if (exportModel.getExportContentList().contains(ExamFileType.PRINT_EXAM_PACKAGE.name())) {
|
|
|
+ ExtractConfig condition = new ExtractConfig();
|
|
|
+ condition.setExamId(Long.valueOf(exportModel.getExamId()));
|
|
|
+ condition.setCourseCode(exportModel.getCourseId());
|
|
|
+ // 获取调卷规则
|
|
|
+ ExtractConfig extractConfig = extractConfigService.findConfig(condition);
|
|
|
+ if (extractConfig != null) {
|
|
|
+ List<Paper> papers = new ArrayList<>();
|
|
|
+ List<ExamPaper> examPapers = extractConfig.getExamPaperList();
|
|
|
+ if (examPapers != null && examPapers.size() > 0) {
|
|
|
+ for (ExamPaper examPaper : examPapers) {
|
|
|
+ papers.add(examPaper.getPaper());
|
|
|
+ }
|
|
|
}
|
|
|
+ printExamPaperService.downloadPaper(papers, downloadDir, psw);
|
|
|
+ } else {
|
|
|
+ LOG.info("exportPrintExamPaper fail, extractConfig is not exist!");
|
|
|
}
|
|
|
- printExamPaperService.downloadPaper(papers, downloadDir, psw);
|
|
|
- } else {
|
|
|
- LOG.info("exportPrintExamPaper fail, extractConfig is not exist!");
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 如果是普通类型的批量导出 导出试卷结构
|
|
|
- if (exportModel.getExportWay() == ExportWay.BATCH) {
|
|
|
- Map<String, String> paperIds = checkAllCourseByExamId(exportModel.getExamId(),
|
|
|
- exportStructure.getExportType());
|
|
|
- if (exportStructure.getExportType() == ExportType.NORMAL) {
|
|
|
- if (paperIds.size() > 0
|
|
|
- && exportModel.getExportContentList().contains(ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name())) {
|
|
|
- makePaperStructure(downloadDir, exportStructure.getExamName(), paperIds, exportStructure);// for
|
|
|
- // export
|
|
|
- // test
|
|
|
+ // 如果是普通类型的批量导出 导出试卷结构
|
|
|
+ if (exportModel.getExportWay() == ExportWay.BATCH) {
|
|
|
+ Map<String, String> paperIds = checkAllCourseByExamId(exportModel.getExamId(),
|
|
|
+ exportStructure.getExportType());
|
|
|
+ if (exportStructure.getExportType() == ExportType.NORMAL) {
|
|
|
+ if (paperIds.size() > 0 && exportModel.getExportContentList()
|
|
|
+ .contains(ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name())) {
|
|
|
+ makePaperStructure(downloadDir, exportStructure.getExamName(), paperIds, exportStructure);// for
|
|
|
+ // export
|
|
|
+ // test
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- // 根据条件获取到文件下载路径,下载文件到服务器的downloadDirectory文件夹
|
|
|
- List<ExamFile> examFiles = examFileService.findExamFileListByExportPaperInfoModel(exportModel);
|
|
|
- if (examFiles != null && examFiles.size() > 0) {
|
|
|
- for (int i = 0; i < examFiles.size(); i++) {
|
|
|
- ExamFile examFile = examFiles.get(i);
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
- File file = new File(downloadDir + File.separator + examFile.getFileName());
|
|
|
-// upyun.readFile(examFile.getFilePath(), file);
|
|
|
- // 通用存储
|
|
|
- FileStorageUtil.saveUrlAs(FileStorageUtil.realPath(examFile.getFilePath()), file);
|
|
|
-
|
|
|
- if (examFile.getExamFileType() == ExamFileType.PAPER) {
|
|
|
- Long examId = Long.parseLong(exportModel.getExamId());
|
|
|
- ExtractConfig extractConfig = extractConfigService
|
|
|
- .findConfig(new ExtractConfig(examId, examFile.getCourseId()));
|
|
|
- List<ExamPaper> list = extractConfig.getExamPaperList();
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
- for (ExamPaper examPaper : list) {
|
|
|
- String groupCode = examPaper.getGroupCode();
|
|
|
- String paperId = examPaper.getPaper().getId();
|
|
|
- if (groupCode.equals(examFile.getGroupCode())) {
|
|
|
- downloadAudio(paperId, examFile, downloadDir, orgId);
|
|
|
- }
|
|
|
-
|
|
|
+ // 根据条件获取到文件下载路径,下载文件到服务器的downloadDirectory文件夹
|
|
|
+ List<ExamFile> examFiles = examFileService.findExamFileListByExportPaperInfoModel(exportModel);
|
|
|
+ if (examFiles != null && examFiles.size() > 0) {
|
|
|
+ for (int i = 0; i < examFiles.size(); i++) {
|
|
|
+ ExamFile examFile = examFiles.get(i);
|
|
|
+ File file = new File(downloadDir + File.separator + examFile.getFileName());
|
|
|
+ // 通用存储
|
|
|
+ FileStorageUtil.saveUrlAs(FileStorageUtil.realPath(examFile.getFilePath()), file);
|
|
|
+
|
|
|
+ if (examFile.getExamFileType() == ExamFileType.PAPER) {
|
|
|
+ if(StringUtils.isBlank(examFile.getPaperId())) {
|
|
|
+ throw new StatusException("错误的旧数据,请重新生成一次文件");
|
|
|
}
|
|
|
+ downloadAudio(examFile.getPaperId(), examFile, downloadDir, orgId);
|
|
|
}
|
|
|
- /*
|
|
|
- * Map<String, String> finishedPaperIdMap =
|
|
|
- * extractConfig.getFinishedPaperIdMap(); Set<Entry<String, String>> entrySet =
|
|
|
- * finishedPaperIdMap.entrySet(); Iterator<Entry<String, String>> iterator =
|
|
|
- * entrySet.iterator(); while (iterator.hasNext()) { Entry<String, String> entry
|
|
|
- * = iterator.next(); String groupCode = entry.getKey(); String paperId =
|
|
|
- * entry.getValue(); if (groupCode.equals(examFile.getGroupCode())) {
|
|
|
- * downloadAudio(paperId, examFile, downloadDir, orgName); } }
|
|
|
- */
|
|
|
}
|
|
|
}
|
|
|
+ // 创建压缩文件名称
|
|
|
+ String zipFileName = exportModel.getExamId();
|
|
|
+ // 将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
|
|
|
+ FileDisposeUtil.fileToZip(downloadDir, downZipDir, zipFileName);
|
|
|
+ // 下载zip文件到客户端
|
|
|
+ FileDisposeUtil.downloadFile(zipFileName + ".zip", downZipDir + File.separator + zipFileName + ".zip",
|
|
|
+ response);
|
|
|
+ } finally {
|
|
|
+ // 删除文件夹
|
|
|
+ FileUtils.deleteQuietly(new File(downloadDir));
|
|
|
+ FileUtils.deleteQuietly(new File(downZipDir));
|
|
|
}
|
|
|
- // 创建压缩文件名称
|
|
|
- String zipFileName = exportModel.getExamId();
|
|
|
- // 将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
|
|
|
- FileDisposeUtil.fileToZip(downloadDir, downZipDir, zipFileName);
|
|
|
- // 下载zip文件到客户端
|
|
|
- FileDisposeUtil.downloadFile(zipFileName + ".zip", downZipDir + File.separator + zipFileName + ".zip",
|
|
|
- response);
|
|
|
- // 删除文件夹
|
|
|
- FileUtils.deleteQuietly(new File(downloadDir));
|
|
|
- FileUtils.deleteQuietly(new File(downZipDir));
|
|
|
}
|
|
|
|
|
|
/**
|