fix:任务及文件操作日志记录&文件Tag传参改造
This commit is contained in:
@@ -136,7 +136,6 @@ public class DataFileController implements IDataFeignClient {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@SysLog("删除文件")
|
||||
@PostMapping("/delFile")
|
||||
@Operation(summary = "删除文件", description = "根据请求参数删除指定的文件(移入回收站)")
|
||||
public SdmResponse delFile(@RequestBody @Validated DelFileReq req) {
|
||||
@@ -414,7 +413,6 @@ public class DataFileController implements IDataFeignClient {
|
||||
* @return
|
||||
*/
|
||||
@AutoFillDictTags
|
||||
@SysLog("上传文件")
|
||||
@PostMapping(value = "/uploadFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(
|
||||
summary = "上传文件",
|
||||
|
||||
@@ -142,7 +142,6 @@ public class DataStorageAnalysisController {
|
||||
return dataStorageAnalysis.addUserQuota(addUserQuota);
|
||||
}
|
||||
// 查询用户配额
|
||||
@SysLog("查询用户配额")
|
||||
@PostMapping("/listUserQuota")
|
||||
@Operation(summary = "查询用户配额")
|
||||
public SdmResponse listUserQuota(@RequestBody ListUserQuotaReq listUserQuotaReq){
|
||||
|
||||
@@ -46,7 +46,6 @@ public class ModelTraningController {
|
||||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
@SysLog("获取模型列表")
|
||||
@PostMapping("/getModelList")
|
||||
@Operation(summary = "获取模型列表", description = "获取模型列表")
|
||||
public SdmResponse getModelList(@RequestBody QueryModelReq baseReq) {
|
||||
@@ -56,7 +55,6 @@ public class ModelTraningController {
|
||||
/**
|
||||
* 获取模型详情
|
||||
*/
|
||||
@SysLog("获取模型详情")
|
||||
@GetMapping("/getModelDetail")
|
||||
@Operation(summary = "获取模型详情", description = "获取模型详情")
|
||||
public SdmResponse getModelDetail(@RequestParam Long modelId) {
|
||||
@@ -104,7 +102,6 @@ public class ModelTraningController {
|
||||
/**
|
||||
* 获取训练数据输入输出特征设置详情
|
||||
*/
|
||||
@SysLog("获取训练数据输入输出特征设置详情")
|
||||
@GetMapping("/getTrainingDataInPutOutPutColumn")
|
||||
@Operation(summary = "获取训练数据输入输出特征设置详情", description = "获取训练数据输入输出特征设置详情")
|
||||
public SdmResponse getTrainingDataInPutOutPutColumn(@RequestParam Long modelId) {
|
||||
@@ -124,7 +121,6 @@ public class ModelTraningController {
|
||||
/**
|
||||
* 获取算法参数设置详情
|
||||
*/
|
||||
@SysLog("获取算法参数设置详情")
|
||||
@GetMapping("/getAlgorithmParam")
|
||||
@Operation(summary = "获取算法参数设置详情", description = "获取算法参数设置详情")
|
||||
public SdmResponse getAlgorithmParam(@RequestParam Long modelId) {
|
||||
@@ -146,7 +142,6 @@ public class ModelTraningController {
|
||||
*
|
||||
* @param modelId
|
||||
*/
|
||||
@SysLog("获取训练曲线和训练日志")
|
||||
@GetMapping("/getTrainingResult")
|
||||
@Operation(summary = "获取训练曲线和训练日志", description = "获取训练曲线和训练日志")
|
||||
public SdmResponse getTrainingResult(@RequestParam Long modelId) {
|
||||
@@ -166,7 +161,6 @@ public class ModelTraningController {
|
||||
/**
|
||||
* 进入模型预测页面,获取历史模型预测结果
|
||||
*/
|
||||
@SysLog("获取历史模型预测结果")
|
||||
@GetMapping("/getModelPredictResult")
|
||||
@Operation(summary = "进入模型预测页面,获取历史模型预测结果", description = "进入模型预测页面,获取历史模型预测结果")
|
||||
public SdmResponse getModelPredictResult(@RequestParam Long modelId) {
|
||||
|
||||
@@ -67,7 +67,6 @@ public class SimulationParameterLibraryController {
|
||||
/**
|
||||
* 获取仿真参数展示树
|
||||
*/
|
||||
@SysLog("获取仿真参数展示树")
|
||||
@GetMapping("/getSimulationParameterTree")
|
||||
@Operation(summary = "获取仿真参数展示树", description = "获取仿真参数展示树")
|
||||
public SdmResponse getSimulationParameterTree(@Parameter(description = "1:模型库/2:模型库分类/3:参数对象") @RequestParam(value = "type", required = false) Integer type, @Parameter(description = "传对应模型库id/模型库分类id/参数对象id,不传查所有的模型库") @RequestParam(value = "id", required = false) Long id) {
|
||||
@@ -77,7 +76,6 @@ public class SimulationParameterLibraryController {
|
||||
/**
|
||||
* 判断是否有参数对象
|
||||
*/
|
||||
@SysLog("判断是否有参数对象")
|
||||
@GetMapping("/hasParameterObject")
|
||||
@Operation(summary = "判断是否有参数对象", description = "判断是否有参数对象")
|
||||
public SdmResponse hasParameterObject(@Parameter(description = "1:模型库/2:模型库分类") @RequestParam(value = "type") Integer type, @Parameter(description = "传对应模型库id/模型库分类id") @RequestParam(value = "id") Long id) {
|
||||
@@ -112,7 +110,6 @@ public class SimulationParameterLibraryController {
|
||||
/**
|
||||
* 获取仿真参数库分类参数对象 和JSON数据
|
||||
*/
|
||||
@SysLog("获取仿真参数库分类参数对象")
|
||||
@GetMapping("/getSimulationParameterLibraryCategoryObject")
|
||||
@Operation(summary = "获取仿真参数库分类参数对象和JSON数据", description = "获取仿真参数库分类参数对象")
|
||||
public SdmResponse getSimulationParameterLibraryCategoryObject(@Parameter(description = "参数对象id") @RequestParam(value = "ObjectId") Long ObjectId) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
@@ -26,12 +27,17 @@ import com.sdm.common.entity.resp.data.*;
|
||||
import com.sdm.common.entity.resp.project.SimulationNodeResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysLogFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
||||
import com.sdm.common.feign.inter.project.ISimulationNodeFeignClient;
|
||||
import com.sdm.common.feign.inter.system.IApproveFeignClient;
|
||||
import com.sdm.common.feign.inter.system.ISysConfigFeignClient;
|
||||
import com.sdm.common.feign.inter.system.ISysLogFeignClient;
|
||||
import com.sdm.common.feign.inter.task.ISimuluationTaskPoolFeignClient;
|
||||
import com.sdm.common.log.CoreLogger;
|
||||
import com.sdm.common.log.constants.ModuleConstants;
|
||||
import com.sdm.common.log.constants.OperateTypeConstants;
|
||||
import com.sdm.common.log.dto.SysLogDTO;
|
||||
import com.sdm.common.utils.*;
|
||||
import com.sdm.common.utils.excel.ExcelUtil;
|
||||
import com.sdm.data.aop.PermissionCheckAspect;
|
||||
@@ -109,12 +115,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
private static final String FLOWABLE_SIMULATION_BASEDIR = "/home/simulation/";
|
||||
|
||||
@Value("${data.recycle.retention-days:7}")
|
||||
|
||||
|
||||
|
||||
|
||||
private Integer recycleRetentionDays;
|
||||
|
||||
@Autowired
|
||||
private ISysLogFeignClient sysLogFeignClient;
|
||||
|
||||
@Autowired
|
||||
private IFileMetadataInfoService fileMetadataInfoService;
|
||||
|
||||
@@ -824,6 +829,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
);
|
||||
}
|
||||
|
||||
// 记录删除日志
|
||||
saveTaskFileLog("删除了文件" + deleteFileMetadataInfo.getOriginalName(), OperateTypeConstants.DELETE, deleteFileMetadataInfo.getTaskId(), deleteFileMetadataInfo.getId());
|
||||
|
||||
// 非知识库文件:直接移入回收站 (Rename + Soft Delete)
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime expireAt = now.plusDays(recycleRetentionDays);
|
||||
@@ -1662,10 +1670,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
FileMetadataInfo targetParentMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, req.getParentDirId()).one();
|
||||
String originalName = sourceMetadataInfo.getOriginalName();
|
||||
|
||||
// 如果文件有后缀,则在文件名和后缀之间插入版本号
|
||||
int dotIndex = originalName.lastIndexOf('.');
|
||||
SdmResponse<String> versionedNameResponse = buildVersionedFileName(originalName);
|
||||
String modifiedFileName = versionedNameResponse.getData();
|
||||
|
||||
// 新的路径名
|
||||
String newDirMinioObjectKey = getFileMinioObjectKey(targetParentMetadataInfo.getObjectKey() + originalName.substring(0, dotIndex) + "_V1" + originalName.substring(dotIndex));
|
||||
String newDirMinioObjectKey = getFileMinioObjectKey(targetParentMetadataInfo.getObjectKey() + modifiedFileName);
|
||||
|
||||
// 把以前归档的过同名文件删除 保留最新的
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
@@ -1963,6 +1972,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
|
||||
List<BatchAddFileInfoResp> addFileInfoRespList = new ArrayList<>();
|
||||
|
||||
for (UploadFilesReq fileReq : req.getSourceFiles()) {
|
||||
SdmResponse<BatchAddFileInfoResp> handleResponse = handleBatchFileInfo(req, fileReq, dirMetadataInfo);
|
||||
if (!handleResponse.isSuccess()) {
|
||||
@@ -1970,9 +1980,41 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
addFileInfoRespList.add(handleResponse.getData());
|
||||
}
|
||||
batchSaveTaskFileLog(req.getTagReq(), req.getSourceFiles());
|
||||
return SdmResponse.success(addFileInfoRespList);
|
||||
}
|
||||
|
||||
private void batchSaveTaskFileLog(TagReq tagReq, List<UploadFilesReq> files) {
|
||||
List<SysLogDTO> logDTOList = new ArrayList<>();
|
||||
files.forEach(file -> {
|
||||
SysLogDTO logDTO = new SysLogDTO();
|
||||
logDTO.setTitle("上传了文件" + file.getFileName());
|
||||
logDTO.setModule(ModuleConstants.TASK);
|
||||
logDTO.setOperateType(OperateTypeConstants.UPLOAD);
|
||||
if (tagReq != null) {
|
||||
logDTO.setBusinessId(tagReq.getTaskId());
|
||||
}
|
||||
logDTO.setCreateBy(String.valueOf(ThreadLocalContext.getUserId()));
|
||||
logDTO.setTenantId(ThreadLocalContext.getTenantId());
|
||||
logDTOList.add(logDTO);
|
||||
});
|
||||
log.info("[MinioFileIDataFileServiceImpl] batchSaveTaskFileLog saveLog params:{}", JSON.toJSONString(logDTOList));
|
||||
sysLogFeignClient.batchSaveLog(logDTOList);
|
||||
}
|
||||
|
||||
private void saveTaskFileLog(String title, String operateType , String taskId, Long fileId) {
|
||||
SysLogDTO logDTO = new SysLogDTO();
|
||||
logDTO.setTitle(title);
|
||||
logDTO.setModule(ModuleConstants.TASK);
|
||||
logDTO.setOperateType(operateType);
|
||||
logDTO.setBusinessId(taskId);
|
||||
logDTO.setFileId(fileId);
|
||||
logDTO.setCreateBy(String.valueOf(ThreadLocalContext.getUserId()));
|
||||
logDTO.setTenantId(ThreadLocalContext.getTenantId());
|
||||
log.info("[MinioFileIDataFileServiceImpl] saveTaskFileLog saveLog params:{}", JSON.toJSONString(logDTO));
|
||||
sysLogFeignClient.saveLog(logDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -2136,6 +2178,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
createFilePermission(fileInfo.getId());
|
||||
triggerKnowledgeApproveIfNeeded(req, fileInfo, dirMetadataInfo);
|
||||
finalizeFileGroup(fileInfo);
|
||||
// 记录日志
|
||||
saveTaskFileLog("上传了文件" + fileInfo.getOriginalName(), OperateTypeConstants.PREVIEW, fileInfo.getTaskId(), fileInfo.getId());
|
||||
|
||||
return buildUploadSuccess(fileInfo);
|
||||
} catch (Exception e) {
|
||||
@@ -3340,6 +3384,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
KKFileViewURLFromMinioResp kkFileViewURLFromMinioResp = new KKFileViewURLFromMinioResp(minioPresignedUrl, encodeKKFileViewURL);
|
||||
// kkFileView已经二次开发,需要拼接 &lastModified=2025-10-13%2016:12:12
|
||||
|
||||
// 记录预览日志
|
||||
saveTaskFileLog("预览了" + fileMetadataInfo.getOriginalName(), OperateTypeConstants.PREVIEW, fileMetadataInfo.getTaskId(), fileId);
|
||||
return SdmResponse.success(kkFileViewURLFromMinioResp);
|
||||
}
|
||||
|
||||
@@ -3366,6 +3412,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
if (minioDownloadUrl == null) {
|
||||
return SdmResponse.failed("获取下载链接失败");
|
||||
}
|
||||
// 记录下载日志
|
||||
saveTaskFileLog("下载了" + fileMetadataInfo.getOriginalName(), OperateTypeConstants.DOWNLOAD, fileMetadataInfo.getTaskId(), fileId);
|
||||
MinioDownloadUrlResp resp = new MinioDownloadUrlResp(minioDownloadUrl, fileName);
|
||||
return SdmResponse.success(resp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user