| @@ -140,10 +140,11 @@ public class DatasetController { | |||||
| * | * | ||||
| * @return 上传结果 | * @return 上传结果 | ||||
| */ | */ | ||||
| @CrossOrigin(origins = "*", allowedHeaders = "*") | |||||
| @PostMapping("/upload") | @PostMapping("/upload") | ||||
| @ApiOperation(value = "上传数据集", notes = "根据数据集版本表id上传数据集文件,并将信息存入数据库。") | @ApiOperation(value = "上传数据集", notes = "根据数据集版本表id上传数据集文件,并将信息存入数据库。") | ||||
| public AjaxResult uploadDataset(@RequestParam("files") MultipartFile[] files, @RequestParam("dataset_id") Integer datasetId) throws Exception { | |||||
| return AjaxResult.success(this.datasetService.uploadDataset(files,datasetId)); | |||||
| public AjaxResult uploadDataset(@RequestParam("file") MultipartFile[] files) throws Exception { | |||||
| return AjaxResult.success(this.datasetService.uploadDataset(files)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -129,8 +129,8 @@ public class ModelsController { | |||||
| @PostMapping("/upload") | @PostMapping("/upload") | ||||
| @ApiOperation(value = "上传模型", notes = "根据模型id上传模型文件,并将信息存入数据库。") | @ApiOperation(value = "上传模型", notes = "根据模型id上传模型文件,并将信息存入数据库。") | ||||
| public AjaxResult uploadModels(@RequestParam("files") MultipartFile[] files, @RequestParam("models_id") Integer modelsId) throws Exception { | |||||
| return AjaxResult.success(this.modelsService.uploadModels(files,modelsId)); | |||||
| public AjaxResult uploadModels(@RequestParam("file") MultipartFile[] files, @RequestParam("models_id") Integer modelsId) throws Exception { | |||||
| return AjaxResult.success(this.modelsService.uploadModels(files)); | |||||
| } | } | ||||
| @@ -0,0 +1,11 @@ | |||||
| package com.ruoyi.platform.controller.tensorBoard; | |||||
| import io.swagger.annotations.Api; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| @RestController | |||||
| @RequestMapping("tensorBoard") | |||||
| @Api("流水线管理") | |||||
| public class tensorBoard { | |||||
| } | |||||
| @@ -72,7 +72,7 @@ DatasetService { | |||||
| ResponseEntity<InputStreamResource> downloadDataset(Integer id); | ResponseEntity<InputStreamResource> downloadDataset(Integer id); | ||||
| List<Map<String, String>> uploadDataset(MultipartFile[] files, Integer id) throws Exception; | |||||
| List<Map<String, String>> uploadDataset(MultipartFile[] files) throws Exception; | |||||
| Map uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception; | Map uploadDatasetPipeline(DatasetVersion datasetVersion) throws Exception; | ||||
| @@ -70,7 +70,7 @@ public interface ModelsService { | |||||
| List<Map<String, String>> uploadModels(MultipartFile[] files, Integer id) throws Exception; | |||||
| List<Map<String, String>> uploadModels(MultipartFile[] files) throws Exception; | |||||
| Map uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception; | Map uploadModelsPipeline(ModelsVersion modelsVersion) throws Exception; | ||||
| @@ -12,6 +12,7 @@ import com.ruoyi.platform.service.DatasetVersionService; | |||||
| import com.ruoyi.platform.utils.BeansUtils; | import com.ruoyi.platform.utils.BeansUtils; | ||||
| import com.ruoyi.platform.utils.FileUtil; | import com.ruoyi.platform.utils.FileUtil; | ||||
| import com.ruoyi.platform.utils.MinioUtil; | import com.ruoyi.platform.utils.MinioUtil; | ||||
| import com.ruoyi.platform.vo.DatasetVersionVo; | |||||
| import com.ruoyi.platform.vo.DatasetVo; | import com.ruoyi.platform.vo.DatasetVo; | ||||
| import com.ruoyi.system.api.model.LoginUser; | import com.ruoyi.system.api.model.LoginUser; | ||||
| import io.minio.MinioClient; | import io.minio.MinioClient; | ||||
| @@ -216,20 +217,13 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| * 上传数据集 | * 上传数据集 | ||||
| * | * | ||||
| * @param files 文件 | * @param files 文件 | ||||
| * @param id 注意是dataset_version表的主键 | |||||
| * @param version | |||||
| * @return 是否成功 | * @return 是否成功 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<Map<String, String>> uploadDataset(MultipartFile[] files, Integer id) throws Exception { | |||||
| public List<Map<String, String>> uploadDataset(MultipartFile[] files) throws Exception { | |||||
| List<Map<String, String>> results = new ArrayList<>(); | List<Map<String, String>> results = new ArrayList<>(); | ||||
| // 验证模型是否存在 | |||||
| Dataset dataset = this.datasetDao.queryById(id); | |||||
| if (dataset == null) { | |||||
| throw new Exception("未找到模型记录"); | |||||
| } | |||||
| for (MultipartFile file:files){ | for (MultipartFile file:files){ | ||||
| if (file.isEmpty()) { | if (file.isEmpty()) { | ||||
| throw new Exception("文件为空,无法上传"); | throw new Exception("文件为空,无法上传"); | ||||
| @@ -243,7 +237,7 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| String fileName = file.getOriginalFilename(); | String fileName = file.getOriginalFilename(); | ||||
| Date createTime = new Date(); | Date createTime = new Date(); | ||||
| String timestamp = new SimpleDateFormat("yyyyMMdd-HHmmss").format(createTime); | String timestamp = new SimpleDateFormat("yyyyMMdd-HHmmss").format(createTime); | ||||
| String objectName = "datasets/" + username + "/" + dataset.getName() + "/" + timestamp + "/" + fileName; | |||||
| String objectName = "datasets/" + username + "/" + timestamp + "/" + fileName; | |||||
| // 上传文件到MinIO并将记录新增到数据库中 | // 上传文件到MinIO并将记录新增到数据库中 | ||||
| try (InputStream inputStream = file.getInputStream()) { | try (InputStream inputStream = file.getInputStream()) { | ||||
| @@ -327,6 +321,11 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String insertDatasetAndVersion(DatasetVo datasetVo) throws Exception { | public String insertDatasetAndVersion(DatasetVo datasetVo) throws Exception { | ||||
| List<DatasetVersionVo> datasetVersionVos = datasetVo.getDatasetVersionVos(); | |||||
| if (datasetVersionVos==null||datasetVersionVos.size()==0){ | |||||
| throw new Exception("数据集版本信息错误"); | |||||
| } | |||||
| Dataset dataset = new Dataset(); | Dataset dataset = new Dataset(); | ||||
| dataset.setName(datasetVo.getName()); | dataset.setName(datasetVo.getName()); | ||||
| dataset.setDescription(datasetVo.getDescription()); | dataset.setDescription(datasetVo.getDescription()); | ||||
| @@ -337,17 +336,21 @@ public class DatasetServiceImpl implements DatasetService { | |||||
| if (datasetInsert == null){ | if (datasetInsert == null){ | ||||
| throw new Exception("新增数据集失败"); | throw new Exception("新增数据集失败"); | ||||
| } | } | ||||
| DatasetVersion datasetVersion = new DatasetVersion(); | |||||
| datasetVersion.setDatasetId(datasetInsert.getId()); | |||||
| datasetVersion.setVersion(datasetVo.getVersion()); | |||||
| datasetVersion.setUrl(datasetVo.getUrl()); | |||||
| datasetVersion.setFileName(datasetVo.getFileName()); | |||||
| datasetVersion.setFileSize(datasetVo.getFileSize()); | |||||
| datasetVersion.setAvailableCluster(datasetVo.getAvailableCluster()); | |||||
| DatasetVersion datasetVersionInsert = datasetVersionService.insert(datasetVersion); | |||||
| if (datasetVersionInsert == null) { | |||||
| throw new Exception("新增数据集版本失败"); | |||||
| for (DatasetVersionVo datasetVersionVo :datasetVersionVos){ | |||||
| DatasetVersion datasetVersion = new DatasetVersion(); | |||||
| datasetVersion.setDatasetId(datasetInsert.getId()); | |||||
| datasetVersion.setVersion(datasetVo.getVersion()); | |||||
| datasetVersion.setUrl(datasetVersionVo.getUrl()); | |||||
| datasetVersion.setFileName(datasetVersionVo.getFileName()); | |||||
| datasetVersion.setFileSize(datasetVersionVo.getFileSize()); | |||||
| datasetVersion.setAvailableCluster(datasetVo.getAvailableCluster()); | |||||
| DatasetVersion datasetVersionInsert = datasetVersionService.insert(datasetVersion); | |||||
| if (datasetVersionInsert == null) { | |||||
| throw new Exception("新增数据集版本失败"); | |||||
| } | |||||
| } | } | ||||
| return "新增数据集成功"; | return "新增数据集成功"; | ||||
| } | } | ||||
| @@ -208,19 +208,14 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| * 上传模型 | * 上传模型 | ||||
| * | * | ||||
| * @param files 文件 | * @param files 文件 | ||||
| * @param id 模型id | |||||
| * @return 是否成功 | * @return 是否成功 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<Map<String, String>> uploadModels(MultipartFile[] files, Integer id) throws Exception { | |||||
| public List<Map<String, String>> uploadModels(MultipartFile[] files) throws Exception { | |||||
| List<Map<String, String>> results = new ArrayList<>(); | List<Map<String, String>> results = new ArrayList<>(); | ||||
| // 验证模型是否存在 | |||||
| Models models = this.modelsDao.queryById(id); | |||||
| if (models == null) { | |||||
| throw new Exception("未找到模型记录"); | |||||
| } | |||||
| for (MultipartFile file:files){ | for (MultipartFile file:files){ | ||||
| if (file.isEmpty()) { | if (file.isEmpty()) { | ||||
| @@ -235,7 +230,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| String fileName = file.getOriginalFilename(); | String fileName = file.getOriginalFilename(); | ||||
| Date createTime = new Date(); | Date createTime = new Date(); | ||||
| String timestamp = new SimpleDateFormat("yyyyMMdd-HHmmss").format(createTime); | String timestamp = new SimpleDateFormat("yyyyMMdd-HHmmss").format(createTime); | ||||
| String objectName = "models/" + username + "/" + models.getName() + "/" + timestamp + "/" + fileName; | |||||
| String objectName = "models/" + username + "/" + timestamp + "/" + fileName; | |||||
| // 上传文件到MinIO并将记录新增到数据库中 | // 上传文件到MinIO并将记录新增到数据库中 | ||||
| try (InputStream inputStream = file.getInputStream()) { | try (InputStream inputStream = file.getInputStream()) { | ||||
| @@ -0,0 +1,51 @@ | |||||
| package com.ruoyi.platform.vo; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import java.io.Serializable; | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| public class DatasetVersionVo implements Serializable { | |||||
| /** | |||||
| * 数据集存储地址 | |||||
| */ | |||||
| @ApiModelProperty(name = "url") | |||||
| private String url; | |||||
| /** | |||||
| * 文件名 | |||||
| */ | |||||
| @ApiModelProperty(name = "file_name") | |||||
| private String fileName; | |||||
| /** | |||||
| * 文件大小 | |||||
| */ | |||||
| @ApiModelProperty(name = "file_size") | |||||
| private String fileSize; | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| public String getFileName() { | |||||
| return fileName; | |||||
| } | |||||
| public void setFileName(String fileName) { | |||||
| this.fileName = fileName; | |||||
| } | |||||
| public String getFileSize() { | |||||
| return fileSize; | |||||
| } | |||||
| public void setFileSize(String fileSize) { | |||||
| this.fileSize = fileSize; | |||||
| } | |||||
| } | |||||
| @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.List; | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||||
| public class DatasetVo implements Serializable { | public class DatasetVo implements Serializable { | ||||
| @@ -29,21 +30,7 @@ public class DatasetVo implements Serializable { | |||||
| */ | */ | ||||
| @ApiModelProperty(name = "version") | @ApiModelProperty(name = "version") | ||||
| private String version; | private String version; | ||||
| /** | |||||
| * 数据集存储地址 | |||||
| */ | |||||
| @ApiModelProperty(name = "url") | |||||
| private String url; | |||||
| /** | |||||
| * 文件名 | |||||
| */ | |||||
| @ApiModelProperty(name = "file_name") | |||||
| private String fileName; | |||||
| /** | |||||
| * 文件大小 | |||||
| */ | |||||
| @ApiModelProperty(name = "file_size") | |||||
| private String fileSize; | |||||
| private List<DatasetVersionVo> datasetVersionVos; | |||||
| /** | /** | ||||
| * 可用集群 | * 可用集群 | ||||
| */ | */ | ||||
| @@ -98,28 +85,12 @@ public class DatasetVo implements Serializable { | |||||
| this.version = version; | this.version = version; | ||||
| } | } | ||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| public String getFileName() { | |||||
| return fileName; | |||||
| } | |||||
| public void setFileName(String fileName) { | |||||
| this.fileName = fileName; | |||||
| } | |||||
| public String getFileSize() { | |||||
| return fileSize; | |||||
| public List<DatasetVersionVo> getDatasetVersionVos() { | |||||
| return datasetVersionVos; | |||||
| } | } | ||||
| public void setFileSize(String fileSize) { | |||||
| this.fileSize = fileSize; | |||||
| public void setDatasetVersionVos(List<DatasetVersionVo> datasetVersionVos) { | |||||
| this.datasetVersionVos = datasetVersionVos; | |||||
| } | } | ||||
| public String getAvailableCluster() { | public String getAvailableCluster() { | ||||