|
@@ -14,6 +14,8 @@ import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.support.fss.FssFactory;
|
|
|
+import cn.com.qmth.examcloud.support.fss.model.FssFileInfo;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -60,12 +62,9 @@ import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamStageCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.excel.ExcelExportUtil;
|
|
|
-import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
import cn.com.qmth.examcloud.support.helper.IdentityNumberHelper;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import cn.com.qmth.examcloud.web.security.ResourceManager;
|
|
|
|
|
|
/**
|
|
@@ -76,8 +75,6 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(AsyncExportServiceImpl.class);
|
|
|
|
|
|
- private static final String TASK_EXPORT_DIR = "task_export";
|
|
|
-
|
|
|
@Autowired
|
|
|
private ExportTaskService exportTaskService;
|
|
|
|
|
@@ -153,7 +150,8 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
// 导出文件的存储路径
|
|
|
Long examId = examStudentInfoList.get(0).getExamId();
|
|
|
ExamSettingsCacheBean exam = CacheHelper.getExamSettings(examId);
|
|
|
- final String filePath = String.format("/%s/%s/%s/%s/%s_考试进度详情.xlsx", TASK_EXPORT_DIR, req.getRootOrgId(),
|
|
|
+
|
|
|
+ final String filePath = String.format("/task_export/%s/%s/%s/%s_考试进度详情.xlsx", req.getRootOrgId(),
|
|
|
dateDir(), randomUUID(), exam.getName());
|
|
|
String tempFilePath = systemConfig.getTempDataDir() + File.separator + filePath;
|
|
|
File tempFile = new File(tempFilePath);
|
|
@@ -170,13 +168,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
ExcelExportUtil.exportExcel(ExamStudentExcel.class, examRecords, out);
|
|
|
|
|
|
// 上传至文件服务器
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setRootOrgId(String.valueOf(req.getRootOrgId()));
|
|
|
- env.setRelativePath(filePath);
|
|
|
- YunPathInfo oss = FileStorageUtil.saveFile(TASK_EXPORT_DIR, env, tempFile, null);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, tempFile, null);
|
|
|
|
|
|
- LOG.info("asyncExportExamScheduling finished... " + oss.getRelativePath());
|
|
|
- exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, oss.getRelativePath());
|
|
|
+ LOG.info("asyncExportExamScheduling finished... " + result.getFilePath());
|
|
|
+ exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, result.getFilePath());
|
|
|
} catch (Exception e) {
|
|
|
LOG.error("asyncExportExamScheduling error... " + e);
|
|
|
exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "上传至文件服务器异常");
|
|
@@ -253,7 +248,8 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
}
|
|
|
// 导出文件的存储路径
|
|
|
String examName = examRecords.get(0).getExamName();
|
|
|
- final String filePath = String.format("/%s/%s/%s/%s/%s_考试明细.xlsx", TASK_EXPORT_DIR, req.getRootOrgId(),
|
|
|
+
|
|
|
+ final String filePath = String.format("/task_export/%s/%s/%s/%s_考试明细.xlsx", req.getRootOrgId(),
|
|
|
dateDir(), randomUUID(), examName);
|
|
|
String tempFilePath = systemConfig.getTempDataDir() + File.separator + filePath;
|
|
|
File tempFile = new File(tempFilePath);
|
|
@@ -270,13 +266,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
ExcelExportUtil.exportExcel(ExamRecordInfo.class, examRecords, out);
|
|
|
|
|
|
// 上传至文件服务器
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setRootOrgId(String.valueOf(req.getRootOrgId()));
|
|
|
- env.setRelativePath(filePath);
|
|
|
- YunPathInfo oss = FileStorageUtil.saveFile(TASK_EXPORT_DIR, env, tempFile, null);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, tempFile, null);
|
|
|
|
|
|
- LOG.info("asyncExportExamRecordDetails finished... " + oss.getRelativePath());
|
|
|
- exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, oss.getRelativePath());
|
|
|
+ LOG.info("asyncExportExamRecordDetails finished... " + result.getFilePath());
|
|
|
+ exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, result.getFilePath());
|
|
|
} catch (Exception e) {
|
|
|
LOG.info("asyncExportExamRecordDetails error... " + e.getMessage());
|
|
|
exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "上传至文件服务器异常");
|
|
@@ -333,7 +326,8 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
}
|
|
|
// 导出文件的存储路径
|
|
|
String examName = examScores.get(0).getExamName();
|
|
|
- final String filePath = String.format("/%s/%s/%s/%s/%s_成绩统计.xlsx", TASK_EXPORT_DIR, req.getRootOrgId(),
|
|
|
+
|
|
|
+ final String filePath = String.format("/task_export/%s/%s/%s/%s_成绩统计.xlsx", req.getRootOrgId(),
|
|
|
dateDir(), randomUUID(), examName);
|
|
|
String tempFilePath = systemConfig.getTempDataDir() + File.separator + filePath;
|
|
|
File tempFile = new File(tempFilePath);
|
|
@@ -349,13 +343,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
ExcelExportUtil.exportExcel(ExamScoreInfo.class, examScores, out);
|
|
|
|
|
|
// 上传至文件服务器
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setRootOrgId(String.valueOf(req.getRootOrgId()));
|
|
|
- env.setRelativePath(filePath);
|
|
|
- YunPathInfo oss = FileStorageUtil.saveFile(TASK_EXPORT_DIR, env, tempFile, null);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, tempFile, null);
|
|
|
|
|
|
- LOG.info("asyncExportExamScoreStatistics finished... " + oss.getRelativePath());
|
|
|
- exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, oss.getRelativePath());
|
|
|
+ LOG.info("asyncExportExamScoreStatistics finished... " + result.getFilePath());
|
|
|
+ exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, result.getFilePath());
|
|
|
} catch (Exception e) {
|
|
|
LOG.info("asyncExportExamScoreStatistics error... " + e.getMessage());
|
|
|
exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "上传至文件服务器异常");
|
|
@@ -398,7 +389,8 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
}
|
|
|
// 导出文件的存储路径
|
|
|
String examName = auditInfos.get(0).getExamName();
|
|
|
- final String filePath = String.format("/%s/%s/%s/%s/%s_监考已审.xlsx", TASK_EXPORT_DIR, req.getRootOrgId(),
|
|
|
+
|
|
|
+ final String filePath = String.format("/task_export/%s/%s/%s/%s_监考已审.xlsx", req.getRootOrgId(),
|
|
|
dateDir(), randomUUID(), examName);
|
|
|
String tempFilePath = systemConfig.getTempDataDir() + File.separator + filePath;
|
|
|
File tempFile = new File(tempFilePath);
|
|
@@ -415,13 +407,10 @@ public class AsyncExportServiceImpl implements AsyncExportService {
|
|
|
ExcelExportUtil.exportExcel(ExamAuditInfo.class, auditInfos, out);
|
|
|
|
|
|
// 上传至文件服务器
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setRootOrgId(String.valueOf(req.getRootOrgId()));
|
|
|
- env.setRelativePath(filePath);
|
|
|
- YunPathInfo oss = FileStorageUtil.saveFile(TASK_EXPORT_DIR, env, tempFile, null);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, tempFile, null);
|
|
|
|
|
|
- LOG.info("asyncExportExamAuditList finished... " + oss.getRelativePath());
|
|
|
- exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, oss.getRelativePath());
|
|
|
+ LOG.info("asyncExportExamAuditList finished... " + result.getFilePath());
|
|
|
+ exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.SUCCESS, null, result.getFilePath());
|
|
|
} catch (Exception e) {
|
|
|
LOG.info("asyncExportExamAuditList error... " + e.getMessage());
|
|
|
exportTaskService.updateExportTaskStatus(taskId, ExportTaskStatus.ERROR, "上传至文件服务器异常");
|