优化审批数据推送展示内容和数据下载
This commit is contained in:
@@ -163,6 +163,13 @@ public class SystemOperate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||||
|
String outputFileName = "总结3.docx";
|
||||||
|
String encodeFileName = URLEncoder.encode(outputFileName, "UTF-8");
|
||||||
|
encodeFileName = encodeFileName.replaceAll("\\+", "%20");
|
||||||
|
System.out.printf("encodeFileName:%s\n", encodeFileName);
|
||||||
|
}
|
||||||
|
|
||||||
public static void destroyProcess(Process process) {
|
public static void destroyProcess(Process process) {
|
||||||
process.destroy();
|
process.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public interface IMinioService {
|
|||||||
* @param encodedFileName
|
* @param encodedFileName
|
||||||
* @param contentType
|
* @param contentType
|
||||||
*/
|
*/
|
||||||
void streamFile(String objectName, String bucketName, HttpServletResponse response, String encodedFileName, String contentType)throws Exception ;
|
void streamFile(String objectName, String bucketName, HttpServletResponse response, String originalName, String contentType)throws Exception ;
|
||||||
|
|
||||||
InputStream getMinioInputStream(String objectName, String bucketName);
|
InputStream getMinioInputStream(String objectName, String bucketName);
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@@ -1302,8 +1303,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
// 从MinIO下载文件
|
// 从MinIO下载文件
|
||||||
String encodedFileName = URLEncoder.encode(fileMetadataInfo.getOriginalName(), StandardCharsets.UTF_8);
|
minioService.streamFile(fileObjectKey, fileMetadataInfo.getBucketName(), response, fileMetadataInfo.getOriginalName(), "");
|
||||||
minioService.streamFile(fileObjectKey, fileMetadataInfo.getBucketName(), response, encodedFileName, "");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("下载文件失败", e);
|
log.error("下载文件失败", e);
|
||||||
try {
|
try {
|
||||||
@@ -1573,7 +1573,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
tempFileMetadataInfo.setAnalysisDirectionId(req.getAnalysisDirectionId());
|
tempFileMetadataInfo.setAnalysisDirectionId(req.getAnalysisDirectionId());
|
||||||
tempFileMetadataInfo.setRemarks(req.getRemarks());
|
tempFileMetadataInfo.setRemarks(req.getRemarks());
|
||||||
tempFileMetadataInfo.setSimulationPoolInfoList(req.getSimulationPoolInfoList());
|
tempFileMetadataInfo.setSimulationPoolInfoList(req.getSimulationPoolInfoList());
|
||||||
|
tempFileMetadataInfo.setCreateTime(fileMetadataInfo.getCreateTime());
|
||||||
|
tempFileMetadataInfo.setUpdateTime(fileMetadataInfo.getCreateTime());
|
||||||
|
tempFileMetadataInfo.setUpdateTime(LocalDateTime.now());
|
||||||
fileMetadataInfo.setTempMetadata(JSONObject.toJSONString(tempFileMetadataInfo));
|
fileMetadataInfo.setTempMetadata(JSONObject.toJSONString(tempFileMetadataInfo));
|
||||||
|
fileMetadataInfo.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
//发起审批
|
//发起审批
|
||||||
FileApproveRequestBuilder updateFileMetaIntoApproveRequestBuilder = FileApproveRequestBuilder.builder()
|
FileApproveRequestBuilder updateFileMetaIntoApproveRequestBuilder = FileApproveRequestBuilder.builder()
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ public class MinioService implements IMinioService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void streamFile(String objectName, String bucketName, HttpServletResponse response, String encodedFileName, String contentType) throws Exception {
|
public void streamFile(String objectName, String bucketName, HttpServletResponse response, String originalName, String contentType) throws Exception {
|
||||||
StatObjectResponse stat = minioClient.statObject(
|
StatObjectResponse stat = minioClient.statObject(
|
||||||
StatObjectArgs.builder()
|
StatObjectArgs.builder()
|
||||||
.bucket(getBucketName(bucketName))
|
.bucket(getBucketName(bucketName))
|
||||||
@@ -445,15 +445,17 @@ public class MinioService implements IMinioService {
|
|||||||
.build());
|
.build());
|
||||||
ReadableByteChannel inChannel = Channels.newChannel(stream);
|
ReadableByteChannel inChannel = Channels.newChannel(stream);
|
||||||
WritableByteChannel outChannel = Channels.newChannel(response.getOutputStream())) {
|
WritableByteChannel outChannel = Channels.newChannel(response.getOutputStream())) {
|
||||||
|
|
||||||
|
|
||||||
|
String encodeFileName = URLEncoder.encode(originalName, "UTF-8");
|
||||||
|
encodeFileName = encodeFileName.replaceAll("\\+", "%20");
|
||||||
|
response.reset();
|
||||||
String mediaType = org.apache.commons.lang3.StringUtils.isBlank(contentType) ?
|
String mediaType = org.apache.commons.lang3.StringUtils.isBlank(contentType) ?
|
||||||
MediaType.APPLICATION_OCTET_STREAM_VALUE : contentType;
|
MediaType.APPLICATION_OCTET_STREAM_VALUE : contentType;
|
||||||
response.setContentType(mediaType);
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=\"" + encodeFileName + "\";filename*=utf-8");
|
||||||
String encodeFileName = URLEncoder.encode(encodedFileName, "UTF-8");
|
response.addHeader("Content-Length", "" + fileSize);
|
||||||
encodeFileName = encodeFileName.replaceAll("\\+", "%20");
|
response.addHeader("Content-Type", mediaType);
|
||||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=\"" + encodeFileName + "\";filename*=utf-8");
|
|
||||||
response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
|
|
||||||
response.addHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
|
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(minioConfig.getDirectMemory() <= NumberConstants.ZERO ?
|
ByteBuffer buffer = ByteBuffer.allocateDirect(minioConfig.getDirectMemory() <= NumberConstants.ZERO ?
|
||||||
DEFAULT_BUFFER_SIZE : minioConfig.getDirectMemory());
|
DEFAULT_BUFFER_SIZE : minioConfig.getDirectMemory());
|
||||||
|
|||||||
Reference in New Issue
Block a user