|
@@ -13,6 +13,10 @@ import java.util.Map;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.*;
|
|
|
+import cn.com.qmth.examcloud.support.fss.FssFactory;
|
|
|
+import cn.com.qmth.examcloud.support.fss.FssHelper;
|
|
|
+import cn.com.qmth.examcloud.support.fss.model.FssFileInfo;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -29,11 +33,6 @@ import org.springframework.stereotype.Service;
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.FileDisposeUtil;
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.IdUtils;
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.IoUtils;
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExportTemplateType;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
|
|
@@ -75,11 +74,7 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailExp;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.dto.SubjectiveQuestionStructure;
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.config.SysProperty;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.util.ExportPaperUtil;
|
|
|
-import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import freemarker.template.Configuration;
|
|
|
import freemarker.template.Template;
|
|
|
|
|
@@ -130,12 +125,6 @@ public class ExportPaperAbstractService {
|
|
|
@Autowired
|
|
|
protected AudioTimeConfigRepo audioTimeConfigRepo;
|
|
|
|
|
|
- // @Autowired
|
|
|
- // protected QuesPkgPathRepo quesPkgPathRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysProperty sysProperty;
|
|
|
-
|
|
|
public static final String FILL_BLANK_QUESTION_FLAG = "###";
|
|
|
|
|
|
public static final String TEMP_FILE_EXP = "docxExport/";
|
|
@@ -374,18 +363,15 @@ public class ExportPaperAbstractService {
|
|
|
makeComputerTestPaperToJsonFile(extractConfig, computerTestPaper, jsonDirectoryPath);
|
|
|
// 将文件夹打包成zip压缩包放在docxExport下
|
|
|
FileDisposeUtil.fileToZip(jsonDirectoryPath, "docxExport", jsonDirectoryName);
|
|
|
+
|
|
|
// 上传zip压缩包到又拍云
|
|
|
File zipFile = new File(TEMP_FILE_EXP + jsonDirectoryName + ZIP_SUFFIX);
|
|
|
- String zipUpyunFilePath = sysProperty.getUploadPath() + extractConfig.getOrgId() + "/" + jsonDirectoryName
|
|
|
- + ZIP_SUFFIX;
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
-// upyun.writeFile(zipUpyunFilePath, zipFile, true);
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env=new FileStoragePathEnvInfo();
|
|
|
- env.setRelativePath(zipUpyunFilePath);
|
|
|
- YunPathInfo pi=FileStorageUtil.saveFile("computerTestFile", env, zipFile,null);
|
|
|
+
|
|
|
+ String zipPath = String.format(FileConstants.COMPUTER_TEST_FILE, extractConfig.getOrgId(), jsonDirectoryName + ZIP_SUFFIX);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(zipPath, zipFile, null);
|
|
|
+
|
|
|
// 保存数据库记录
|
|
|
- ExamFile examFile = new ExamFile(computerTestPaper, extractConfig, pi.getRelativePath(),
|
|
|
+ ExamFile examFile = new ExamFile(computerTestPaper, extractConfig, result.getFilePath(),
|
|
|
ExamFileType.COMPUTERTEST_PACKAGE, ZIP_SUFFIX);
|
|
|
examFile.setGroupCode(examPaper.getGroupCode());
|
|
|
examFileService.saveExamFile(examFile, accessUser);
|
|
@@ -488,9 +474,11 @@ public class ExportPaperAbstractService {
|
|
|
+ audio.getFileSuffixes();
|
|
|
oNum++;
|
|
|
}
|
|
|
- //通用存储
|
|
|
- FileDisposeUtil.saveUrlAs(FileStorageUtil.realPath(audio.getFileUrl()),
|
|
|
- jsonDirectoryPath + File.separator + audioFileName);
|
|
|
+
|
|
|
+ File audioFile = new File(jsonDirectoryPath + File.separator + audioFileName);
|
|
|
+
|
|
|
+ String filePath = FssHelper.fixFilePath(audio.getFileUrl());
|
|
|
+ FssFactory.getInstance().readFile(filePath, audioFile);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -512,14 +500,11 @@ public class ExportPaperAbstractService {
|
|
|
File file = new File(directory.getAbsoluteFile() + File.separator + paperFileName);
|
|
|
ExportPaperUtil.createPaperDocFile(accessUser.getRootOrgId(), paperExp, directory, paperFileName,
|
|
|
templateType);
|
|
|
- String paperFilePath = sysProperty.getUploadPath() + extractConfig.getOrgId() + "/" + paperFileName;
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
-// upyun.writeFile(paperFilePath, file, true);
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env=new FileStoragePathEnvInfo();
|
|
|
- env.setRelativePath(paperFilePath);
|
|
|
- YunPathInfo pi=FileStorageUtil.saveFile("paperOrAnswerFile", env, file,null);
|
|
|
- ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, pi.getRelativePath(), examFileType, DOCX_SUFFIX);
|
|
|
+
|
|
|
+ String paperFilePath = String.format(FileConstants.PAPER_OR_ANSWER_FILE, extractConfig.getOrgId(), paperFileName);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(paperFilePath, file, null);
|
|
|
+
|
|
|
+ ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, result.getFilePath(), examFileType, DOCX_SUFFIX);
|
|
|
examFile.setGroupCode(examPaper.getGroupCode());
|
|
|
examFile.setFileName(paperExp.getName()+"_"+extractConfig.getCourseName() + "_" + extractConfig.getCourseCode() + "_"
|
|
|
+ examFileType.getName() + "_" + examFile.getGroupCode() + DOCX_SUFFIX);
|
|
@@ -572,16 +557,10 @@ public class ExportPaperAbstractService {
|
|
|
try (FileOutputStream out = new FileOutputStream(file);) {
|
|
|
objectiveExcelExporter.write(objectiveFilename, objectiveQuestionStructureList, out);
|
|
|
|
|
|
- String objectiveFilePath = sysProperty.getUploadPath() + extractConfig.getOrgId() + "/" + objectiveFilename;
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
-// upyun.writeFile(objectiveFilePath, file, true);
|
|
|
-
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env=new FileStoragePathEnvInfo();
|
|
|
- env.setRelativePath(objectiveFilePath);
|
|
|
- YunPathInfo pi=FileStorageUtil.saveFile("objectiveQuestionStructures", env, file,null);
|
|
|
+ String objectiveFilePath = String.format(FileConstants.OBJECTIVE_QUESTION_STRUCTURES, extractConfig.getOrgId(), objectiveFilename);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(objectiveFilePath, file, null);
|
|
|
|
|
|
- ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, pi.getRelativePath(),
|
|
|
+ ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, result.getFilePath(),
|
|
|
ExamFileType.PAPER_STRUCTURE_OBJECTIVE, EXCEL_SUFFIX);
|
|
|
examFile.setGroupCode(examPaper.getGroupCode());
|
|
|
examFile.setFileName(extractConfig.getCourseName() + "_" + extractConfig.getCourseCode() + "_"
|
|
@@ -621,17 +600,10 @@ public class ExportPaperAbstractService {
|
|
|
try (FileOutputStream out = new FileOutputStream(file);) {
|
|
|
subjectiveExcelExporter.write(subjectiveFileName, subjectiveQuestionStructureList, out);
|
|
|
|
|
|
- String subjectiveFilePath = sysProperty.getUploadPath() + extractConfig.getOrgId() + "/"
|
|
|
- + subjectiveFileName;
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
-// upyun.writeFile(subjectiveFilePath, file, true);
|
|
|
-
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env=new FileStoragePathEnvInfo();
|
|
|
- env.setRelativePath(subjectiveFilePath);
|
|
|
- YunPathInfo pi=FileStorageUtil.saveFile("subjectiveQuestionStructures", env, file,null);
|
|
|
+ String subjectiveFilePath = String.format(FileConstants.SUBJECTIVE_QUESTION_STRUCTURES, extractConfig.getOrgId(), subjectiveFileName);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(subjectiveFilePath, file, null);
|
|
|
|
|
|
- ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, pi.getRelativePath(),
|
|
|
+ ExamFile examFile = new ExamFile(paperExp.getId(), extractConfig, result.getFilePath(),
|
|
|
ExamFileType.PAPER_STRUCTURE_SUBJECTIVE, EXCEL_SUFFIX);
|
|
|
examFile.setGroupCode(examPaper.getGroupCode());
|
|
|
examFile.setFileName(extractConfig.getCourseName() + "_" + extractConfig.getCourseCode() + "_"
|
|
@@ -886,8 +858,8 @@ public class ExportPaperAbstractService {
|
|
|
*/
|
|
|
public void downloadAudio(PaperExp paperExp, String zipFileName) {
|
|
|
// 先判断是否是音频试卷
|
|
|
- if (paperExp.getHasAudio() != null && paperExp.getHasAudio() == true) {
|
|
|
-// UpYun upyun = new UpYun(sysProperty.getBucketName(), sysProperty.getUserName(), sysProperty.getPassword());
|
|
|
+ if (paperExp.getHasAudio() != null && paperExp.getHasAudio()) {
|
|
|
+
|
|
|
// 取到所有大题
|
|
|
List<PaperDetailExp> paperDetailExps = paperExp.getPaperDetails();
|
|
|
if (paperDetailExps != null && paperDetailExps.size() > 0) {
|
|
@@ -904,9 +876,9 @@ public class ExportPaperAbstractService {
|
|
|
+ "_" + getAudioFileName(audio, unit, paperDetailExp);
|
|
|
File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator
|
|
|
+ audioFileName);
|
|
|
-// upyun.readFile(audio.getFileUrl(), file);
|
|
|
- //通用存储
|
|
|
- FileStorageUtil.saveUrlAs(FileStorageUtil.realPath(audio.getFileUrl()), file);
|
|
|
+
|
|
|
+ String filePath = FssHelper.fixFilePath(audio.getFileUrl());
|
|
|
+ FssFactory.getInstance().readFile(filePath, file);
|
|
|
}
|
|
|
}
|
|
|
}
|