id数据类型调整

This commit is contained in:
2025-10-31 13:48:13 +08:00
parent d259059620
commit e606a85203
13 changed files with 124 additions and 50 deletions

View File

@@ -55,48 +55,50 @@ public class Constants {
/**
* 模型文件
*/
@Schema(description = "模型文件",example = "1")
@Schema(description = "模型文件", example = "1")
MODEL_FILE(1),
/**
* 仿真报告
*/
@Schema(description = "仿真报告",example = "2")
@Schema(description = "仿真报告", example = "2")
REPORT_FILE(2),
/**
* 计算文件
*/
@Schema(description = "计算文件",example = "3")
@Schema(description = "计算文件", example = "3")
COMPUTE_FILE(3),
/**
* 曲线文件
*/
@Schema(description = "曲线文件",example = "4")
@Schema(description = "曲线文件", example = "4")
CURVE_FILE(4),
/**
* 云图文件
*/
@Schema(description = "云图文件",example = "5")
@Schema(description = "云图文件", example = "5")
CLOUD_FILE(5),
/**
* 项目文件
*/
@Schema(description = "项目 文件",example = "6")
@Schema(description = "项目 文件", example = "6")
PROJECT_FILE(6),
/**
* 学科文件
*/
@Schema(description = "学科 文件",example = "7")
@Schema(description = "学科 文件", example = "7")
DISCIPLINE_MAJOR_FILE(7);
int value;
FileType(int i) {
value = i;
}
public int getValue() {
return value;
}
@@ -107,39 +109,41 @@ public class Constants {
/**
* 知识库文件夹
*/
@Schema(description = "知识库文件夹",example = "1")
KNOWLEDGE_BASE_DIR("knowledge",1),
@Schema(description = "知识库文件夹", example = "1")
KNOWLEDGE_BASE_DIR("knowledge", 1),
/**
* 项目节点文件夹
*/
@Schema(description = "项目节点文件夹",example = "2")
PROJECT_NODE_DIR("projectNode",2),
@Schema(description = "项目节点文件夹", example = "2")
PROJECT_NODE_DIR("projectNode", 2),
/**
* 头像库文件夹
*/
@Schema(description = "头像库文件夹",example = "3")
AVATAR_DIR("avatar",3),
@Schema(description = "头像库文件夹", example = "3")
AVATAR_DIR("avatar", 3),
/**
* 仿真参数库文件夹
*/
@Schema(description = "仿真参数库文件夹",example = "4")
SIMULATION_PARAMETER_DIR("simulationParameter",4),
@Schema(description = "仿真参数库文件夹", example = "4")
SIMULATION_PARAMETER_DIR("simulationParameter", 4),
/**
* 训练模型文件夹
*/
@Schema(description = "训练模型文件",example = "5")
TRAIN_MODEL_DIR("trainModel",5);
@Schema(description = "训练模型文件", example = "5")
TRAIN_MODEL_DIR("trainModel", 5);
String dirName;
int value;
DirType(String dirName,int value) {
DirType(String dirName, int value) {
this.dirName = dirName;
this.value = value;
}
public int getValue() {
return value;
}
@@ -147,6 +151,16 @@ public class Constants {
public String getDirName() {
return dirName;
}
// 根据value获取对应的枚举
public static DirType getDirTypeByValue(int value) {
for (DirType dirType : values()) {
if (dirType.value == value) {
return dirType;
}
}
return null;
}
}
// 仿真参数库数据类型

View File

@@ -16,7 +16,7 @@ public class CreateDirReq {
@Schema(description = "文件夹名称")
private String dirName;
@Schema(description = "文件夹类型1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹")
@Schema(description = "文件夹类型DirType1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹")
private Integer dirType;
// 0相对路径1绝对路径

View File

@@ -16,13 +16,13 @@ public class FileMetadataInfoResp implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键ID")
private Integer id;
private Long id;
@Schema(description = "逻辑文件组ID同一文件的所有版本共享一个ID")
private Integer fileGroupId;
private Long fileGroupId;
@Schema(description = "版本号从1开始递增")
private Integer versionNo;
private Long versionNo;
@Schema(description = "是否最新版本1-是0-否")
private Boolean isLatest;
@@ -46,16 +46,16 @@ public class FileMetadataInfoResp implements Serializable {
private Boolean isRoot;
@Schema(description = "父文件ID")
private Integer parentId;
private Long parentId;
@Schema(description = "创建者ID")
private String creatorId;
private Long creatorId;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "更新者ID")
private String updaterId;
private Long updaterId;
@Schema(description = "更新时间")
private LocalDateTime updateTime;

View File

@@ -16,10 +16,10 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
@Autowired
private IDataFeignClient dataClient;
public SdmResponse<List<FileMetadataInfoResp>> listDir(Long parentDirId) {
public SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType,Long parentDirId) {
SdmResponse<List<FileMetadataInfoResp> > response;
try {
response = dataClient.listDir(parentDirId);
response = dataClient.listDir(dirType,parentDirId);
if (!response.isSuccess()) {
return SdmResponse.failed("创建文件夹失败");
}

View File

@@ -15,7 +15,7 @@ import java.util.List;
@FeignClient(name = "data")
public interface IDataFeignClient {
@GetMapping("/data/listDir")
SdmResponse<List<FileMetadataInfoResp>> listDir(@RequestParam(value = "parentDirId", required = false) Long parentDirId);
SdmResponse<List<FileMetadataInfoResp>> listDir( @RequestParam(value = "dirType") Integer dirType,@RequestParam(value = "parentDirId", required = false) Long parentDirId);
@PostMapping("/data/createDir")
SdmResponse createDir(@RequestBody @Validated CreateDirReq req);

View File

@@ -77,7 +77,7 @@ public class DataFileController implements IDataFeignClient {
*/
@PostMapping("/fileSearch")
@Operation(summary = "搜索文件", description = "根据搜索条件查找匹配的文件")
public SdmResponse fileSearch( @RequestBody @Validated FileSearchReq req) {
public SdmResponse fileSearch(@RequestBody @Validated FileSearchReq req) {
return IDataFileService.fileSearch(req);
}
@@ -152,6 +152,7 @@ public class DataFileController implements IDataFeignClient {
public SdmResponse updatePermission(@RequestBody @Validated UpdatePermissionReq req) {
return IDataFileService.updatePermission(req);
}
/**
* 获取文件用户的综合访问权限,该权限可以从祖先继承
*
@@ -265,7 +266,6 @@ public class DataFileController implements IDataFeignClient {
}
/**
* 上传文件
*
@@ -328,19 +328,19 @@ public class DataFileController implements IDataFeignClient {
@GetMapping("/listDir")
@Operation(summary = "获取文件夹列表", description = "获取文件夹列表")
@ApiResponse(content = @Content(mediaType = "application/json", schema = @Schema(implementation = FileMetadataInfo.class)))
public SdmResponse<List<FileMetadataInfoResp>> listDir(@Parameter(description = "父目录ID或路径") @RequestParam(value = "parentDirId", required = false) Long parentDirId) {
return IDataFileService.listDir(parentDirId);
public SdmResponse<List<FileMetadataInfoResp>> listDir(
@Parameter(name = "文件夹类型DirType1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹") @RequestParam(value = "dirType") Integer dirType
, @Parameter(description = "父目录ID或路径") @RequestParam(value = "parentDirId", required = false) Long parentDirId) {
return IDataFileService.listDir(dirType, parentDirId);
}
@PostMapping(value = "/uploadAvatar")
@Operation(summary = "上传头像", description = "上传头像")
public SdmResponse uploadAvatar(@RequestParam("avatar") MultipartFile avatar){
public SdmResponse uploadAvatar(@RequestParam("avatar") MultipartFile avatar) {
return IDataFileService.uploadAvatar(avatar);
}
// 图片预览
@GetMapping("/previewImage")
@Operation(summary = "图片预览", description = "图片预览")

View File

@@ -64,7 +64,7 @@ public class FileMetadataInfo implements Serializable {
@TableField("originalName")
private String originalName;
@ApiModelProperty(value = "文件夹数据类型仅文件夹有效data_type=2时非空")
@ApiModelProperty(value = "文件夹数据类型仅文件夹有效data_type=2时非空 1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹")
@TableField("dirType")
private Integer dirType;

View File

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -140,4 +142,14 @@ public class TrainingModel implements Serializable {
@ApiModelProperty(value = "说明")
@TableField("description")
private String description;
@ApiModelProperty(value = "创建时间")
@TableField("createTime")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
@TableField("updateTime")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -193,10 +193,12 @@ public interface IDataFileService {
/**
* 目录树查询
*
* @param dirType
* @param parentDirId 父目录ID
* @return 目录内容列表响应
*/
default SdmResponse<List<FileMetadataInfoResp>> listDir(Long parentDirId){
default SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType, Long parentDirId){
return null;
}

View File

@@ -51,6 +51,7 @@ import java.util.stream.Collectors;
@Service
public class MinioFileIDataFileServiceImpl implements IDataFileService {
private static final List<Constants.DirType> INIT_DIR = List.of(
Constants.DirType.KNOWLEDGE_BASE_DIR, Constants.DirType.PROJECT_NODE_DIR,
Constants.DirType.AVATAR_DIR, Constants.DirType.SIMULATION_PARAMETER_DIR, Constants.DirType.TRAIN_MODEL_DIR);
@@ -109,21 +110,42 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
*/
public SdmResponse<?> createRootDir(CreateDirReq req) {
if(ObjectUtils.isNull(req.getDirType())){
return SdmResponse.failed("请选择目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}
Constants.DirType dirTypeByValue = Constants.DirType.getDirTypeByValue(req.getDirType());
if (dirTypeByValue == null) {
return SdmResponse.failed("请选择正确的目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}
// 先检查根目录是否已存在
String rootDirMinioObjectKey = getDirMinioObjectKey(dirTypeByValue.getDirName());
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey);
// 检查目录是否已存在
if (!fileMetadataInfoByObjectKey.isPresent()) {
return SdmResponse.failed("知识库、项目根目录不存在,等待initSystemDirectory 初始化完成");
}
// 获取根目录的 id
FileMetadataInfo rootDirMetadataInfo = fileMetadataInfoByObjectKey.get();
Long rootDirId = rootDirMetadataInfo.getId();
String dirName = req.getDirName();
String dirMinioObjectKey = getDirMinioObjectKey(dirName);
String dirMinioObjectKey = getDirMinioObjectKey(rootDirMetadataInfo.getObjectKey()+dirName);
Long nodeId = req.getNodeId();
try {
// 检查目录是否已存在
if (getFileMetadataInfoByObjectKey(dirMinioObjectKey).isPresent()) {
return SdmResponse.failed("目录已存在");
return SdmResponse.failed("目录已存在");
}
// 在MinIO中创建目录
minioService.createDirectoryByObjectKey(dirMinioObjectKey);
// 创建目录元数据并保存到数据库
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirName, true, null, nodeId,req.getDirType());
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirName, false, rootDirId, nodeId,req.getDirType());
fileMetadataInfoService.save(dirInfo);
// 创建默认权限记录
@@ -180,7 +202,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
minioService.createDirectoryByObjectKey(childDirMinioObjectKey);
// 创建子目录元数据并保存到数据库
FileMetadataInfo dirInfo = createDirectoryMetadata(childDirMinioObjectKey, req.getDirName(), false, parDirId, req.getNodeId(),req.getDirType());
FileMetadataInfo dirInfo = createDirectoryMetadata(childDirMinioObjectKey, req.getDirName(), false, parDirId, req.getNodeId(),parDirInfo.getDirType());
fileMetadataInfoService.save(dirInfo);
// 创建默认权限记录
@@ -305,7 +327,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
return dirPath;
}
private static String dealFileMinioObjectKey(String filePath) {
private static String getFileMinioObjectKey(String filePath) {
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
@@ -774,7 +796,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
return SdmResponse.failed("文件名没有后缀");
}
String fileMinioObjectKey = dealFileMinioObjectKey(dirMetadataInfo.getObjectKey() + modifiedFileName);
String fileMinioObjectKey = getFileMinioObjectKey(dirMetadataInfo.getObjectKey() + modifiedFileName);
boolean hasUploadPermission = fileUserPermissionService.hasFilePermission(dirMetadataInfo.getId(), ThreadLocalContext.getUserId(), Constants.FilePermission.UPLOAD);
@@ -837,11 +859,31 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
}
@Override
public SdmResponse<List<FileMetadataInfoResp>> listDir(Long parentDirId) {
public SdmResponse<List<FileMetadataInfoResp>> listDir(Integer dirType, Long parentDirId) {
try {
if(ObjectUtils.isNull(dirType)){
return SdmResponse.failed("请选择目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}
Constants.DirType dirTypeByValue = Constants.DirType.getDirTypeByValue(dirType);
if (dirTypeByValue == null) {
return SdmResponse.failed("请选择正确的目录类型:1 知识库文件夹2 项目节点文件夹3 头像库文件夹4 仿真参数库文件夹,5 训练模型文件夹");
}
// 先检查根目录是否已存在
String rootDirMinioObjectKey = getDirMinioObjectKey(dirTypeByValue.getDirName());
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey);
// 检查目录是否已存在
if (!fileMetadataInfoByObjectKey.isPresent()) {
return SdmResponse.failed("知识库、项目根目录不存在,等待initSystemDirectory 初始化完成");
}
// 获取根目录的 id
Long rootDirId = fileMetadataInfoByObjectKey.get().getId();
LambdaQueryChainWrapper<FileMetadataInfo> fileMetadataInfoLambdaQueryChainWrapper = fileMetadataInfoService.lambdaQuery();
if (ObjectUtils.isEmpty(parentDirId)) {
fileMetadataInfoLambdaQueryChainWrapper.isNull(FileMetadataInfo::getParentId);
fileMetadataInfoLambdaQueryChainWrapper.eq(FileMetadataInfo::getDirType, dirType).eq(FileMetadataInfo::getParentId, rootDirId);
} else {
fileMetadataInfoLambdaQueryChainWrapper.eq(FileMetadataInfo::getParentId, parentDirId);
}
@@ -909,7 +951,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
}
// 处理历史版本objectkey= 1/test1_V1.txt originalName=test1.txt 替换为 newFileMinioObjectKey= 1/test1_V2.txt
newFileMinioObjectKey = dealFileMinioObjectKey(oldFileMinioObjectKey.substring(0, oldFileMinioObjectKey.lastIndexOf(fileMetadataInfo.getOriginalName().substring(0, fileMetadataInfo.getOriginalName().lastIndexOf('.')))) + modifiedFileName);
newFileMinioObjectKey = getFileMinioObjectKey(oldFileMinioObjectKey.substring(0, oldFileMinioObjectKey.lastIndexOf(fileMetadataInfo.getOriginalName().substring(0, fileMetadataInfo.getOriginalName().lastIndexOf('.')))) + modifiedFileName);
minioService.uploadFile(req.getFile(), newFileMinioObjectKey, null);
@@ -990,7 +1032,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
String newFilename = filenameWithoutSuffix + "_" + timestamp + "." + suffix;
// 再上传头像
String avatarMinioObjectKey = dealFileMinioObjectKey(avatarDirMetadataInfo.getObjectKey() + newFilename);
String avatarMinioObjectKey = getFileMinioObjectKey(avatarDirMetadataInfo.getObjectKey() + newFilename);
try {
minioService.uploadFile(avatar, avatarMinioObjectKey, null);
@@ -1051,7 +1093,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
String newFilename = filenameWithoutSuffix + "_" + timestamp + "." + suffix;
// 再上传仿真参数文件
String simulationParamMinioObjectKey = dealFileMinioObjectKey(SimulationParamDirMetadataInfo.getObjectKey() + newFilename);
String simulationParamMinioObjectKey = getFileMinioObjectKey(SimulationParamDirMetadataInfo.getObjectKey() + newFilename);
try {
minioService.uploadFile(paramFile, simulationParamMinioObjectKey, null);
@@ -1097,7 +1139,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
String newFilename = filenameWithoutSuffix + "_" + timestamp + "." + suffix;
// 再上传训练模型文件
String simulationParamMinioObjectKey = dealFileMinioObjectKey(trainModelDirMetadataInfo.getObjectKey() + newFilename);
String simulationParamMinioObjectKey = getFileMinioObjectKey(trainModelDirMetadataInfo.getObjectKey() + newFilename);
try {
minioService.uploadFile(trainModelFile, simulationParamMinioObjectKey, null);

View File

@@ -160,7 +160,7 @@ public class ModelServiceImpl implements IModelService {
@Override
public SdmResponse getModelList(BaseReq baseReq) {
PageHelper.startPage(baseReq.getCurrent(), baseReq.getSize());
List<TrainingModel> models = trainingModelService.list();
List<TrainingModel> models = trainingModelService.lambdaQuery().orderByDesc(TrainingModel::getCreateTime).list();
PageInfo<TrainingModel> page = new PageInfo<>(models);
return PageUtils.getJsonObjectSdmResponse(models, page);
}

View File

@@ -2,6 +2,7 @@ package com.sdm.project.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.Constants;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.req.data.CreateDirReq;
@@ -131,6 +132,7 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
createDirReq.setNodeId(demandId);
createDirReq.setParentNodeId(null);
createDirReq.setDirName(req.getDemandName());
createDirReq.setDirType(Constants.DirType.PROJECT_NODE_DIR.getValue());
log.info("创建需求时,调用创建文件夹的参数为:{}", createDirReq);
SdmResponse response = dataClientFeignClient.createDir(createDirReq);
log.info("创建需求时,调用创建文件夹的返回值为:{}", response);

View File

@@ -2,6 +2,7 @@ package com.sdm.project.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdm.common.common.Constants;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.constants.SystemConstants;
@@ -621,6 +622,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
createDirReq.setNodeId(nodeId);
createDirReq.setParentNodeId(ObjectUtils.isNotEmpty(parentNodeId) ? parentNodeId : null);
createDirReq.setDirName(dirName);
createDirReq.setDirType(Constants.DirType.PROJECT_NODE_DIR.getValue());
log.info("创建项目阶段时,调用创建文件夹的参数为:{}", createDirReq);
SdmResponse response = dataClientFeignClient.createDir(createDirReq);
log.info("创建项目阶段时,调用创建文件夹的返回值为:{}", response);