|
@@ -925,25 +925,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
throw ExceptionResultEnum.ERROR.exception("数组id为空");
|
|
throw ExceptionResultEnum.ERROR.exception("数组id为空");
|
|
}
|
|
}
|
|
|
|
|
|
- //查询examDetail
|
|
|
|
-// List<ExamDetail> examDetailList = examDetailService.listByIds(Arrays.asList(arraysParams.getIds()));
|
|
|
|
List<ExamDetailPdfDownloadDto> examDetailList = examDetailService.findPdfDownload(Arrays.asList(arraysParams.getIds()));
|
|
List<ExamDetailPdfDownloadDto> examDetailList = examDetailService.findPdfDownload(Arrays.asList(arraysParams.getIds()));
|
|
if (!CollectionUtils.isEmpty(examDetailList)) {
|
|
if (!CollectionUtils.isEmpty(examDetailList)) {
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
|
Long time = System.currentTimeMillis();
|
|
Long time = System.currentTimeMillis();
|
|
- if (Objects.nonNull(dictionaryConfig.fssLocalFileDomain()) && !StringUtils.isBlank(dictionaryConfig.fssLocalFileDomain().getConfig())) {
|
|
|
|
- stringJoiner = stringJoiner.add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
|
|
|
|
- zipLocalRootPath = dictionaryConfig.fssLocalFileDomain().getConfig() + File.separator + time;
|
|
|
|
- } else {
|
|
|
|
- stringJoiner = stringJoiner.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
|
- zipLocalRootPath = dictionaryConfig.fssPublicDomain().getConfig() + File.separator + time;
|
|
|
|
- }
|
|
|
|
- StringJoiner dirName = SystemConstant.getDirName(UploadFileEnum.FILE, true);
|
|
|
|
- dirName.add(SystemConstant.getNanoId()).add(SystemConstant.ZIP_PREFIX);
|
|
|
|
- zipFile = new File(stringJoiner.toString() + dirName.toString());
|
|
|
|
- if (!zipFile.getParentFile().exists()) {
|
|
|
|
- zipFile.getParentFile().mkdirs();
|
|
|
|
|
|
+ boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("");
|
|
|
|
+ if (!oss && Objects.nonNull(dictionaryConfig.fssLocalFileDomain()) && !StringUtils.isBlank(dictionaryConfig.fssLocalFileDomain().getConfig())) {
|
|
|
|
+ stringJoiner.add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
|
|
}
|
|
}
|
|
|
|
+ stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
|
|
+ stringJoiner.add("印刷任务管理_批量下载PDF_" + time).add(SystemConstant.ZIP_PREFIX);
|
|
|
|
+
|
|
|
|
+ String zipDirName = stringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
|
|
|
|
+ zipFile = SystemConstant.getFileTempDirVar(SystemConstant.ZIP_PREFIX);
|
|
|
|
+ zipLocalRootPath = zipFile.getParent() + File.separator + time;
|
|
|
|
|
|
sourceFileList = new ArrayList<>(examDetailList.size() * 5);
|
|
sourceFileList = new ArrayList<>(examDetailList.size() * 5);
|
|
for (ExamDetailPdfDownloadDto e : examDetailList) {
|
|
for (ExamDetailPdfDownloadDto e : examDetailList) {
|
|
@@ -996,19 +991,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
- Zip4jUtil.zipEncryptFile(zipFile.getPath(), zipLocalRootPath, SystemConstant.ZIP_ENCRYPT_PWD);
|
|
|
|
- String ossDirName = dirName.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- boolean oss = dictionaryConfig.sysDomain().isOss();
|
|
|
|
- if (oss) {//上传至oss
|
|
|
|
- fileStoreUtil.ossUpload(ossDirName, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(ossDirName).getFssType());
|
|
|
|
- jsonObject.put(SystemConstant.PATH, ossDirName);
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
|
- } else {
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
|
|
|
|
- jsonObject.put(SystemConstant.PATH, stringJoiner + ossDirName);
|
|
|
|
- }
|
|
|
|
- jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
|
|
|
+ JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1021,12 +1004,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
ResultUtil.error(e.getMessage());
|
|
ResultUtil.error(e.getMessage());
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
- if (Objects.nonNull(zipLocalRootPath)) {
|
|
|
|
- ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss() && Objects.nonNull(zipFile)) {
|
|
|
|
|
|
+ if (Objects.nonNull(zipFile)) {
|
|
zipFile.delete();
|
|
zipFile.delete();
|
|
}
|
|
}
|
|
|
|
+ ConvertUtil.delFolder(zipLocalRootPath);
|
|
|
|
+ if (!CollectionUtils.isEmpty(sourceFileList)) {
|
|
|
|
+ for (File file : sourceFileList) {
|
|
|
|
+ file.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
@@ -1040,24 +1026,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
private File getJsonFile(JSONObject jsonObject, String pathName) throws Exception {
|
|
private File getJsonFile(JSONObject jsonObject, String pathName) throws Exception {
|
|
- File file = null;
|
|
|
|
|
|
+ File file = SystemConstant.getFileTempDirVar(pathName, null);
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
- StringJoiner stringJoinerPdf = new StringJoiner("");
|
|
|
|
- if (Objects.nonNull(dictionaryConfig.fssLocalFileDomain()) && !StringUtils.isBlank(dictionaryConfig.fssLocalFileDomain().getConfig())) {
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
|
|
|
|
- } else {
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
|
- }
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(pathName);
|
|
|
|
if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
- file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PDF_PATH), stringJoinerPdf.toString(), UploadFileEnum.PDF.getFssType());
|
|
|
|
|
|
+ file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PDF_PATH), file, UploadFileEnum.PDF.getFssType());
|
|
} else {
|
|
} else {
|
|
- file = new File(stringJoinerPdf.toString());
|
|
|
|
- if (!file.exists()) {
|
|
|
|
- file.getParentFile().mkdirs(); //目标文件目录不存在的话需要创建目录
|
|
|
|
- file.createNewFile();
|
|
|
|
- }
|
|
|
|
- IOUtils.copy(new FileInputStream((String) jsonObject.get(SystemConstant.PDF_PATH)), new FileOutputStream(file));
|
|
|
|
|
|
+ FileCopyUtils.copy(new File((String) jsonObject.get(SystemConstant.PDF_PATH)), file);
|
|
}
|
|
}
|
|
return file;
|
|
return file;
|
|
}
|
|
}
|
|
@@ -1065,7 +1039,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
/**
|
|
/**
|
|
* 获取附件文件
|
|
* 获取附件文件
|
|
*
|
|
*
|
|
- * @param pathName
|
|
|
|
|
|
+ * @param attachment
|
|
* @param pathName
|
|
* @param pathName
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
@@ -1073,25 +1047,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
private File getAttachmentFile(BasicAttachment attachment, String pathName) throws Exception {
|
|
private File getAttachmentFile(BasicAttachment attachment, String pathName) throws Exception {
|
|
File file = null;
|
|
File file = null;
|
|
if (Objects.nonNull(attachment) && Objects.nonNull(attachment.getPath())) {
|
|
if (Objects.nonNull(attachment) && Objects.nonNull(attachment.getPath())) {
|
|
|
|
+ file = SystemConstant.getFileTempDirVar(pathName, null);
|
|
JSONObject jsonObject = JSONObject.parseObject(attachment.getPath());
|
|
JSONObject jsonObject = JSONObject.parseObject(attachment.getPath());
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
|
|
- StringJoiner stringJoinerPdf = new StringJoiner("");
|
|
|
|
- if (Objects.nonNull(dictionaryConfig.fssLocalFileDomain()) && !StringUtils.isBlank(dictionaryConfig.fssLocalFileDomain().getConfig())) {
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
|
|
|
|
- } else {
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(dictionaryConfig.fssPublicDomain().getConfig()).add(File.separator);
|
|
|
|
- }
|
|
|
|
- stringJoinerPdf = stringJoinerPdf.add(pathName);
|
|
|
|
if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
|
|
- file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), stringJoinerPdf.toString(), uploadFileEnum.getFssType());
|
|
|
|
|
|
+ file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), file, uploadFileEnum.getFssType());
|
|
} else {
|
|
} else {
|
|
- file = new File(stringJoinerPdf.toString());
|
|
|
|
- if (!file.exists()) {
|
|
|
|
- file.getParentFile().mkdirs(); //目标文件目录不存在的话需要创建目录
|
|
|
|
- file.createNewFile();
|
|
|
|
- }
|
|
|
|
- IOUtils.copy(new FileInputStream((String) jsonObject.get(SystemConstant.PATH)), new FileOutputStream(file));
|
|
|
|
|
|
+ FileCopyUtils.copy(new File((String) jsonObject.get(SystemConstant.PATH)), file);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return file;
|
|
return file;
|
|
@@ -1946,7 +1909,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
stringJoiner = SystemConstant.getDirName(stringJoiner, UploadFileEnum.FILE, true);
|
|
stringJoiner.add("下载管理_批量下载_" + System.currentTimeMillis()).add(SystemConstant.ZIP_PREFIX);
|
|
stringJoiner.add("下载管理_批量下载_" + System.currentTimeMillis()).add(SystemConstant.ZIP_PREFIX);
|
|
|
|
|
|
- String dirNameTmp = stringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
|
|
|
|
|
|
+ String zipDirName = stringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
|
|
zipFile = SystemConstant.getFileTempDirVar(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
|
|
zipFile = SystemConstant.getFileTempDirVar(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
|
|
zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
|
|
zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
|
|
|
|
|
|
@@ -2163,23 +2126,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
}
|
|
}
|
|
count = count + courseCount;
|
|
count = count + courseCount;
|
|
}
|
|
}
|
|
- Zip4jUtil.zipEncryptFile(zipFile.getPath(), zipLocalRootPath, SystemConstant.ZIP_ENCRYPT_PWD);
|
|
|
|
-
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- jsonObject.put(SystemConstant.PATH, dirNameTmp);
|
|
|
|
- String zipFileMd5 = DigestUtils.md5Hex(new FileInputStream(zipFile));
|
|
|
|
- if (oss) {//上传至oss
|
|
|
|
- fileStoreUtil.ossUpload(dirNameTmp, zipFile, zipFileMd5, fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
|
|
|
|
- } else {
|
|
|
|
- if (Objects.nonNull(dictionaryConfig.fssLocalPdfDomain()) && !StringUtils.isBlank(dictionaryConfig.fssLocalPdfDomain().getConfig())) {
|
|
|
|
- fileStoreUtil.localUpload(dirNameTmp, new FileInputStream(zipFile), zipFileMd5, LocalCatalogEnum.LOCAL_PDF);
|
|
|
|
- } else {
|
|
|
|
- fileStoreUtil.ossUpload(dirNameTmp, zipFile, zipFileMd5, fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
|
|
|
|
- }
|
|
|
|
- jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
|
|
|
|
- }
|
|
|
|
- jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
|
|
|
|
|
|
+ JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
tbTask.setResultFilePath(jsonObject.toJSONString());
|
|
map.put("count", count);
|
|
map.put("count", count);
|
|
map.put("specialSuccessMessage", specialSuccessMessage);
|
|
map.put("specialSuccessMessage", specialSuccessMessage);
|