|
@@ -250,10 +250,7 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
@Override
|
|
|
public Map<String, Object> executeExportPaperAndCardLogic(Map<String, Object> map) {
|
|
|
String zipLocalRootPath = null;
|
|
|
- File zipFile = null;
|
|
|
- List<File> sourceFileList = null;
|
|
|
try {
|
|
|
- sourceFileList = new ArrayList<>();
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
|
|
|
|
Long time = System.currentTimeMillis();
|
|
@@ -267,8 +264,7 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
stringJoiner.add("卷库查询批量下载试卷包").add(SystemConstant.ZIP_PREFIX);
|
|
|
|
|
|
String zipDirName = FileUtil.replaceSplit(stringJoiner.toString());
|
|
|
- zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
|
- zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
|
+ zipLocalRootPath = FileUtil.getFileTempDirPath(true);
|
|
|
|
|
|
List<ExamTaskDetailDto> examTasks = (List<ExamTaskDetailDto>) map.get("examTasks");
|
|
|
for (ExamTaskDetailDto examTask : examTasks) {
|
|
@@ -303,7 +299,6 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
if (Objects.nonNull(attachment)) {
|
|
|
String fileName = dirPath + "卷" + examTaskDetail.getSerialNumber() + SystemConstant.HYPHEN + "试卷" + SystemConstant.HYPHEN + name + attachment.getType();
|
|
|
File paperFile = fileUploadService.downloadFile(attachment, fileName);
|
|
|
- sourceFileList.add(paperFile);
|
|
|
}
|
|
|
}
|
|
|
// 题卡
|
|
@@ -322,7 +317,6 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
localFile.createNewFile();
|
|
|
}
|
|
|
FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
|
|
|
- sourceFileList.add(localFile);
|
|
|
|
|
|
// PDF文件
|
|
|
String pdfFilePathName = dirPath + "卷" + examTaskDetail.getSerialNumber() + SystemConstant.HYPHEN + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
|
|
@@ -334,7 +328,6 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
pdfFile.createNewFile();
|
|
|
}
|
|
|
HtmlToPdfUtil.convert(htmlFilePathName, pdfFilePathName, "8K".equals(examCard.getPageSize()) ? PageSizeEnum.K8 : PageSizeEnum.valueOf(examCard.getPageSize()));
|
|
|
- sourceFileList.add(pdfFile);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -342,7 +335,7 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
}
|
|
|
}
|
|
|
SysUser sysUser = sysUserService.getById(tbTask.getCreateId());
|
|
|
- JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName, new String(Base64Util.decode(sysUser.getPassword())));
|
|
|
+ JSONObject jsonObject = FileUtil.uploadEncryptZip(zipLocalRootPath, zipDirName, new String(Base64Util.decode(sysUser.getPassword())));
|
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
|
map.put(SystemConstant.DATA_COUNT, examTasks.size());
|
|
|
} catch (Exception e) {
|
|
@@ -353,17 +346,9 @@ public class DownloadLogicServiceImpl implements DownloadLogicService {
|
|
|
ResultUtil.error(e.getMessage());
|
|
|
}
|
|
|
} finally {
|
|
|
- if (Objects.nonNull(zipFile)) {
|
|
|
- zipFile.delete();
|
|
|
- }
|
|
|
if (Objects.nonNull(zipLocalRootPath)) {
|
|
|
FileUtil.deleteDirectory(zipLocalRootPath);
|
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
|
- for (File file : sourceFileList) {
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
return map;
|
|
|
}
|