新增根据word模版生成word方法;新增质量管理相关接口;优化,修改HSE管理相关代码逻辑

This commit is contained in:
lcj
2025-04-17 17:40:24 +08:00
parent 86745097ca
commit 3a8538fc6a
35 changed files with 2788 additions and 86 deletions

View File

@ -3,6 +3,7 @@ package org.dromara.common.oss.core;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil;
import org.dromara.common.core.constant.Constants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.file.FileUtils;
@ -31,6 +32,7 @@ import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.function.Consumer;
@ -235,6 +237,41 @@ public class OssClient {
return tempFilePath;
}
/**
* 下载文件从 Amazon S3 到临时目录
*
* @param path 文件在 Amazon S3 中的对象键
* @param fileName 文件名
* @param filePath 文件路径
* @return 下载后的文件在本地的临时路径
* @throws OssException 如果下载失败,抛出自定义异常
*/
public String fileDownload(String path, String fileName, String filePath) {
// 构建临时文件
Path targetDir = Paths.get(filePath);
try {
if (Files.notExists(targetDir)) {
Files.createDirectories(targetDir);
}
} catch (IOException e) {
throw new ServiceException("无法创建目标目录: " + targetDir + e);
}
// 拼出本地完整路径
Path destinationPath = targetDir.resolve(fileName);
// 使用 S3TransferManager 下载文件
FileDownload downloadFile = transferManager.downloadFile(
x -> x.getObjectRequest(
y -> y.bucket(properties.getBucketName())
.key(removeBaseUrl(path))
.build())
.addTransferListener(LoggingTransferListener.create())
.destination(destinationPath)
.build());
// 等待文件下载操作完成
downloadFile.completionFuture().join();
return filePath + "/" + fileName;
}
/**
* 下载文件从 Amazon S3 到 输出流
*