feat:查询需求待办附件/算例结果归档/编辑报告上传报告结果/任务文件查询修改
This commit is contained in:
@@ -603,4 +603,10 @@ public class DataFileController implements IDataFeignClient {
|
||||
return IDataFileService.queryFileIdByNodeId(queryFileIdReq);
|
||||
}
|
||||
|
||||
@PostMapping("/copyFileToTask")
|
||||
@Operation(summary = "复制关键结果文件到task下", description = "复制关键结果文件到task下")
|
||||
public SdmResponse copyFileToTask(@RequestBody CopyFileToTaskReq req) {
|
||||
return IDataFileService.copyFileToTask(req);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sdm.data.service;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.data.CopyFileToTaskReq;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.entity.resp.data.BatchAddFileInfoResp;
|
||||
@@ -336,6 +337,8 @@ public interface IDataFileService {
|
||||
|
||||
SdmResponse<List<BatchAddFileInfoResp>> batchAddFileInfo(UploadFilesReq req);
|
||||
|
||||
SdmResponse copyFileToTask(CopyFileToTaskReq req);
|
||||
|
||||
SdmResponse<ChunkUploadMinioFileResp> chunkUploadToMinio(ChunkUploadMinioFileReq req);
|
||||
|
||||
SdmResponse chunkUploadCallback(KnowledgeCallBackReq req);
|
||||
|
||||
@@ -76,6 +76,8 @@ public interface IMinioService {
|
||||
void renameFile(String oldObjectName, String newObjectName, String bucketName);
|
||||
|
||||
|
||||
void copyFile(String oldObjectName, String newObjectName, String bucketName);
|
||||
|
||||
/**
|
||||
* 从MinIO下载文件
|
||||
* @param objectName 文件名(objectKey)
|
||||
|
||||
@@ -2,13 +2,15 @@ package com.sdm.data.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||
import com.sdm.common.entity.req.export.FileAnalysisExportExcelFormat;
|
||||
import com.sdm.common.entity.req.export.FileAnalysisExportExcelParam;
|
||||
import com.sdm.common.entity.req.export.TaskAnalysisExportExcelParam;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.utils.FileSizeUtils;
|
||||
import com.sdm.common.utils.PageUtils;
|
||||
import com.sdm.common.utils.SystemOperate;
|
||||
import com.sdm.data.bo.ExportOperate;
|
||||
@@ -33,6 +35,7 @@ import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -75,6 +78,10 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
return PageUtils.getJsonObjectSdmResponse(new ArrayList<>(), new PageInfo<>());
|
||||
}
|
||||
}
|
||||
// 查询层级是task 只查task目录下的直系文件
|
||||
if (NodeTypeEnum.TASK.getValue().equals(getSimulationTaskFileReq.getLevel())) {
|
||||
return getTaskLevelFile(getSimulationTaskFileReq, queryBigFileReq);
|
||||
}
|
||||
|
||||
// 2. 调用大文件查询服务
|
||||
SdmResponse<PageDataResp<List<FileStorage>>> searchResult = dataStorageAnalysis.listBigFile(queryBigFileReq);
|
||||
@@ -103,6 +110,27 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
return PageUtils.getJsonObjectSdmResponse(finalResultList, pageInfo);
|
||||
}
|
||||
|
||||
private SdmResponse<PageDataResp<List<SimulationTaskResultCurveResp>>> getTaskLevelFile(GetSimulationTaskFileReq req, QueryBigFileReq queryBigFileReq) {
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfoList = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getParentId, queryBigFileReq.getDirId())
|
||||
.eq(FileMetadataInfo::getFileType, req.getFileBizType())
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.list();
|
||||
PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfoList);
|
||||
long total = page.getTotal();
|
||||
|
||||
List<SimulationTaskResultCurveResp> resultCurveRespList = fileMetadataInfoList.stream().map(i -> {
|
||||
SimulationTaskResultCurveResp resultCurveResp = new SimulationTaskResultCurveResp();
|
||||
BeanUtils.copyProperties(i,resultCurveResp);
|
||||
resultCurveResp.setFormatFileSize(FileSizeUtils.formatFileSize(BigDecimal.valueOf(i.getFileSize())));
|
||||
return resultCurveResp;
|
||||
}).toList();
|
||||
|
||||
PageInfo<SimulationTaskResultCurveResp> page1 = new PageInfo<>(resultCurveRespList);
|
||||
page1.setTotal(total);
|
||||
return PageUtils.getJsonObjectSdmResponse(resultCurveRespList, page1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse getCSVData(List<Long> fileIds) {
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.sdm.common.entity.constants.PermConstants;
|
||||
import com.sdm.common.entity.enums.*;
|
||||
import com.sdm.common.entity.pojo.task.TaskBaseInfo;
|
||||
import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.data.CopyFileToTaskReq;
|
||||
import com.sdm.common.entity.req.project.SpdmNodeListReq;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.entity.req.system.UserListReq;
|
||||
@@ -1028,6 +1029,37 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse copyFileToTask(CopyFileToTaskReq req) {
|
||||
// 源文件
|
||||
FileMetadataInfo sourceMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, req.getSourceFileId()).one();
|
||||
if (ObjectUtils.isEmpty(sourceMetadataInfo)) {
|
||||
return SdmResponse.failed("源文件不存在");
|
||||
}
|
||||
boolean hasWritePermission = fileUserPermissionService.hasFilePermission(sourceMetadataInfo.getId(), ThreadLocalContext.getUserId(), FilePermissionEnum.WRITE);
|
||||
if (!hasWritePermission) {
|
||||
return SdmResponse.failed("没有写入权限");
|
||||
}
|
||||
|
||||
String oldDirMinioObjectKey = sourceMetadataInfo.getObjectKey();
|
||||
// 要挪到的task文件夹
|
||||
FileMetadataInfo targetParentMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getParentUuid()).one();
|
||||
// 新的路径名
|
||||
String newDirMinioObjectKey = getDirMinioObjectKey(targetParentMetadataInfo.getObjectKey() + sourceMetadataInfo.getOriginalName());
|
||||
|
||||
try {
|
||||
minioService.copyFile(oldDirMinioObjectKey, newDirMinioObjectKey,sourceMetadataInfo.getBucketName());
|
||||
// 创建目录元数据并保存到数据库
|
||||
FileMetadataInfo fileInfo = createFileMetadata(newDirMinioObjectKey, sourceMetadataInfo.getOriginalName(), sourceMetadataInfo.getFileType(),
|
||||
null, null, null, targetParentMetadataInfo.getId(), sourceMetadataInfo.getFileSize());
|
||||
fileMetadataInfoService.save(fileInfo);
|
||||
return SdmResponse.success("复制文件成功");
|
||||
} catch (Exception e) {
|
||||
log.error("复制文件失败", e);
|
||||
throw new RuntimeException("复制文件失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse zipFiles(ZipFilesReq req) {
|
||||
return null;
|
||||
|
||||
@@ -1296,6 +1296,11 @@ public class SystemFileIDataFileServiceImpl implements IDataFileService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse copyFileToTask(CopyFileToTaskReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 未实现,勿使用
|
||||
@Override
|
||||
public SdmResponse chunkUploadCallback(KnowledgeCallBackReq req) {
|
||||
|
||||
@@ -381,6 +381,41 @@ public class MinioService implements IMinioService {
|
||||
}
|
||||
}
|
||||
|
||||
public void copyFile(String oldObjectName, String newObjectName, String bucketName) {
|
||||
try {
|
||||
bucketName = getBucketName(bucketName);
|
||||
// 参数校验
|
||||
if (!StringUtils.hasText(oldObjectName)) {
|
||||
throw new IllegalArgumentException("原文件名不能为空");
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(newObjectName)) {
|
||||
throw new IllegalArgumentException("新文件名不能为空");
|
||||
}
|
||||
|
||||
// 检查原文件是否存在
|
||||
StatObjectResponse stat = minioClient.statObject(
|
||||
StatObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(oldObjectName)
|
||||
.build());
|
||||
|
||||
// 复制文件到新名称
|
||||
minioClient.copyObject(
|
||||
CopyObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(newObjectName)
|
||||
.source(CopySource.builder()
|
||||
.bucket(bucketName)
|
||||
.object(oldObjectName)
|
||||
.build())
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
log.error("复制文件失败: 从 {} 到 {}", oldObjectName, newObjectName, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从MinIO下载文件
|
||||
|
||||
Reference in New Issue
Block a user