diff --git a/bonus-modules/bonus-ai/pom.xml b/bonus-modules/bonus-ai/pom.xml index 3adb592..228b4a6 100644 --- a/bonus-modules/bonus-ai/pom.xml +++ b/bonus-modules/bonus-ai/pom.xml @@ -5,7 +5,7 @@ com.bonus bonus-modules - 24.7.1 + 24.9.0-SNAPSHOT 4.0.0 diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/controller/DataSetController.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/controller/DataSetController.java index 4e090ae..6cb39db 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/controller/DataSetController.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/controller/DataSetController.java @@ -2,15 +2,19 @@ package com.bonus.ai.controller; import com.bonus.ai.domain.*; import com.bonus.ai.service.DataSetService; +import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; -import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.system.api.RemoteFileService; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @author bonus @@ -18,20 +22,23 @@ import java.util.List; @RestController @RequestMapping("/dataSet") @Slf4j -public class DataSetController { +public class DataSetController extends BaseController { @Resource private DataSetService dataSetService; + @Resource + private RemoteFileService remoteFileService; + /** * 根据数据集 ID 查询对应的数据集信息。 * * @param datasetId 数据集的唯一标识符 * @return 返回指定数据集 ID 对应的 DataSetEntity 对象 */ - @PostMapping("/getDatasetById") - public AjaxResult getDatasetById(Long datasetId) { - return null; + @GetMapping("/getDatasetById/{datasetId}") + public AjaxResult getDatasetById(@PathVariable Long datasetId) { + return dataSetService.getDatasetById(datasetId); } /** @@ -40,9 +47,26 @@ public class DataSetController { * @param entity 包含查询条件的 DataSetEntity 对象 * @return 返回所有符合条件的数据集的集合 */ - @PostMapping("/getAllDatasets") - public AjaxResult getAllDatasets(DataSetEntity entity) { - return null; + @GetMapping("/getAllDatasets") + public TableDataInfo getAllDatasets(DataSetEntity entity) { + try { + startPage(); + List allDatasets = dataSetService.getAllDatasets(entity); + return getDataTable(allDatasets); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + + /** + * 查询所有的数据集信息。 + * + * @return 返回所有符合条件的数据集的集合 + */ + @GetMapping("/getDatasets") + public AjaxResult getDatasets() { + return AjaxResult.success(dataSetService.getAllDatasets(null)); } /** @@ -52,8 +76,8 @@ public class DataSetController { * @return 返回插入操作影响的行数(成功插入的记录数,通常为 1) */ @PostMapping("/insertDataset") - public AjaxResult insertDataset(DataSetEntity entity) { - return null; + public AjaxResult insertDataset(@RequestBody DataSetEntity entity) { + return dataSetService.insertDataset(entity); } /** @@ -63,8 +87,8 @@ public class DataSetController { * @return 返回更新操作影响的行数(成功更新的记录数,通常为 1) */ @PostMapping("/updateDataset") - public AjaxResult updateDataset(DataSetEntity entity) { - return null; + public AjaxResult updateDataset(@RequestBody DataSetEntity entity) { + return dataSetService.updateDataset(entity); } /** @@ -73,9 +97,9 @@ public class DataSetController { * @param datasetId 数据集的唯一标识符 * @return 返回删除操作影响的行数(成功删除的记录数,通常为 1) */ - @PostMapping("/deleteDataset") - public AjaxResult deleteDataset(Long datasetId) { - return null; + @DeleteMapping("/deleteDataset/{datasetId}") + public AjaxResult deleteDataset(@PathVariable Long datasetId) { + return dataSetService.deleteDataset(datasetId); } /** @@ -84,9 +108,9 @@ public class DataSetController { * @param categoryId 类别的唯一标识符 * @return 返回指定类别 ID 对应的 DataSetCategoryEntity 对象 */ - @PostMapping("/getCategoryById") - public AjaxResult getCategoryById(Long categoryId) { - return null; + @GetMapping("/getCategoryById/{categoryId}") + public AjaxResult getCategoryById(@PathVariable Long categoryId) { + return dataSetService.getCategoryById(categoryId); } /** @@ -96,7 +120,7 @@ public class DataSetController { * @return 返回所有符合条件的类别的列表 */ @PostMapping("/getCategories") - public AjaxResult getCategories(DataSetCategoryEntity entity) { + public AjaxResult getCategories(@RequestBody DataSetCategoryEntity entity) { return dataSetService.getCategories(entity); } @@ -107,8 +131,8 @@ public class DataSetController { * @return 返回插入操作影响的行数(成功插入的记录数,通常为 1) */ @PostMapping("/insertCategory") - public AjaxResult insertCategory(DataSetCategoryEntity entity) { - return null; + public AjaxResult insertCategory(@RequestBody DataSetCategoryEntity entity) { + return dataSetService.insertCategory(entity); } /** @@ -118,8 +142,8 @@ public class DataSetController { * @return 返回更新操作影响的行数(成功更新的记录数,通常为 1) */ @PostMapping("/updateCategory") - public AjaxResult updateCategory(DataSetCategoryEntity entity) { - return null; + public AjaxResult updateCategory(@RequestBody DataSetCategoryEntity entity) { + return dataSetService.updateCategory(entity); } /** @@ -128,9 +152,9 @@ public class DataSetController { * @param categoryId 要删除的类别的唯一标识符 * @return 返回删除操作影响的行数(成功删除的记录数,通常为 1) */ - @PostMapping("/deleteCategory") - public AjaxResult deleteCategory(Long categoryId) { - return null; + @DeleteMapping("/deleteCategory/{categoryId}") + public AjaxResult deleteCategory(@PathVariable Long categoryId) { + return dataSetService.deleteCategory(categoryId); } /** @@ -150,9 +174,16 @@ public class DataSetController { * @param entity 查询条件 * @return 数据集文件列表 */ - @PostMapping("/getAllFiles") - public AjaxResult getAllFiles(DataSetFileEntity entity) { - return null; + @GetMapping("/getAllFiles") + public TableDataInfo getAllFiles(DataSetFileEntity entity) { + try { + startPage(); + List allFiles = dataSetService.getAllFiles(entity); + return getDataTable(allFiles); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); } /** @@ -162,8 +193,8 @@ public class DataSetController { * @return 影响的行数 */ @PostMapping("/insertFile") - public AjaxResult insertFile(DataSetFileEntity entity) { - return null; + public AjaxResult insertFile(@RequestBody DataSetFileEntity entity) { + return dataSetService.insertFile(entity); } /** @@ -173,19 +204,19 @@ public class DataSetController { * @return 影响的行数 */ @PostMapping("/updateFile") - public AjaxResult updateFile(DataSetFileEntity datasetFile) { - return null; + public AjaxResult updateFile(@RequestBody DataSetFileEntity datasetFile) { + return dataSetService.updateFile(datasetFile); } /** * 根据 ID 删除数据集文件(逻辑删除) * - * @param fileId 文件 ID + * @param fileIds 文件 ID * @return 影响的行数 */ - @PostMapping("/deleteFile") - public AjaxResult deleteFile(Long fileId) { - return null; + @DeleteMapping("/deleteFile/{fileIds}") + public AjaxResult deleteFile(@PathVariable Long[] fileIds) { + return dataSetService.deleteFile(fileIds); } /** @@ -194,8 +225,8 @@ public class DataSetController { * @param taskId 任务 ID * @return 数据集任务实体 */ - @PostMapping("/getTaskById") - public AjaxResult getTaskById(Long taskId) { + @GetMapping("/getTaskById/{taskId}") + public AjaxResult getTaskById(@PathVariable Long taskId) { return null; } @@ -205,9 +236,16 @@ public class DataSetController { * @param entity 查询条件 * @return 数据集任务列表 */ - @PostMapping("/getAllTasks") - public AjaxResult getAllTasks(DataSetTaskEntity entity) { - return null; + @GetMapping("/getAllTasks") + public TableDataInfo getAllTasks(DataSetTaskEntity entity) { + try { + startPage(); + List list = dataSetService.getAllTasks(entity); + return getDataTable(list); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); } /** @@ -217,8 +255,8 @@ public class DataSetController { * @return 影响的行数 */ @PostMapping("/insertTask") - public AjaxResult insertTask(DataSetTaskEntity entity) { - return null; + public AjaxResult insertTask(@RequestBody DataSetTaskEntity entity) { + return dataSetService.insertTask(entity); } /** @@ -228,8 +266,8 @@ public class DataSetController { * @return 影响的行数 */ @PostMapping("/updateTask") - public AjaxResult updateTask(DataSetTaskEntity datasetTask) { - return null; + public AjaxResult updateTask(@RequestBody DataSetTaskEntity datasetTask) { + return dataSetService.updateTask(datasetTask); } /** @@ -238,9 +276,9 @@ public class DataSetController { * @param taskId 任务 ID * @return 影响的行数 */ - @PostMapping("/deleteTask") - public AjaxResult deleteTask(Long taskId) { - return null; + @DeleteMapping("/deleteTask/{taskId}") + public AjaxResult deleteTask(@PathVariable Long taskId) { + return dataSetService.deleteTask(taskId); } /** @@ -249,9 +287,9 @@ public class DataSetController { * @param logId 日志 ID * @return 数据集日志实体 */ - @PostMapping("/getLogById") - public AjaxResult getLogById(Long logId) { - return null; + @PostMapping("/getLogById/{logId}") + public AjaxResult getLogById(@PathVariable Long logId) { + return dataSetService.getLogById(logId); } /** @@ -260,42 +298,179 @@ public class DataSetController { * @param entity 查询条件 * @return 数据集日志列表 */ - @PostMapping("/getAllLogs") - public AjaxResult getAllLogs(DataSetLogEntity entity) { - return null; + @GetMapping("/getAllLogs") + public TableDataInfo getAllLogs(DataSetLogEntity entity) { + try { + startPage(); + List list = dataSetService.getAllLogs(entity); + return getDataTable(list); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + + + /** + * 根据 ID 查询模型 + * + * @param modelId 模型管理 ID + * @return 模型管理实体 + */ + @GetMapping("/getModelsById/{modelId}") + public AjaxResult getModelsById(@PathVariable Long modelId) { + return dataSetService.getModelsById(modelId); } /** - * 插入新的日志 + * 查询所有模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param entity 查询条件 + * @return 模型管理列表 */ - @PostMapping("/insertLog") - public AjaxResult insertLog(DataSetLogEntity log) { - return null; + @GetMapping("/getAllModels") + public TableDataInfo getAllModels(AiModelEntity entity) { + try { + startPage(); + List list = dataSetService.getAllModels(entity); + return getDataTable(list); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); } /** - * 更新日志信息 + * 查询所有模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @return 模型管理列表 */ - @PostMapping("/updateLog") - public AjaxResult updateLog(DataSetLogEntity log) { - return null; + @GetMapping("/getModelsList") + public AjaxResult getModelsList() { + return AjaxResult.success(dataSetService.getAllModels(null)); } /** - * 根据 ID 删除日志 + * 插入新的模型 * - * @param logId 日志 ID + * @param entity 模型实体 * @return 影响的行数 */ - @PostMapping("/deleteLog") - public AjaxResult deleteLog(Long logId) { - return null; + @PostMapping("/insertModel") + public AjaxResult insertModel(@RequestBody AiModelEntity entity) { + return dataSetService.insertModel(entity); + } + + /** + * 更新模型实体 + * + * @param entity 模型实体 + * @return 影响的行数 + */ + @PostMapping("/updateModel") + public AjaxResult updateModel(@RequestBody AiModelEntity entity) { + return dataSetService.updateModel(entity); + } + + /** + * 根据 ID 删除模型 + * + * @param modelIds 模型 ID + * @return 影响的行数 + */ + @DeleteMapping("/deleteModel/{modelIds}") + public AjaxResult deleteModel(@PathVariable Long[] modelIds) { + return dataSetService.deleteModel(modelIds); + } + + /** + * 根据 ID 查询算法评价 + * + * @param algorithmId 算法评价 ID + * @return 算法评价实体 + */ + @GetMapping("/getAlgorithmById/{algorithmId}") + public AjaxResult getAlgorithmById(@PathVariable Long algorithmId) { + return dataSetService.getAlgorithmById(algorithmId); + } + + /** + * 查询所有算法评价 + * + * @param entity 查询条件 + * @return 算法评价列表 + */ + @GetMapping("/getAllAlgorithms") + public TableDataInfo getAllAlgorithms(DataSetAlgorithm entity) { + try { + startPage(); + List list = dataSetService.getAllAlgorithms(entity); + return getDataTable(list); + } catch (Exception e) { + log.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + + /** + * 插入新的算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + @PostMapping("/insertAlgorithm") + public AjaxResult insertAlgorithm(@RequestBody DataSetAlgorithm entity) { + return dataSetService.insertAlgorithm(entity); + } + + /** + * 更新算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + @PostMapping("/updateAlgorithm") + public AjaxResult updateAlgorithm(@RequestBody DataSetAlgorithm entity) { + return dataSetService.updateAlgorithm(entity); + } + + /** + * 根据 ID 删除算法评价 + * + * @param algorithmIds 算法评价 ID + * @return 影响的行数 + */ + @DeleteMapping("/deleteAlgorithm/{algorithmIds}") + public AjaxResult deleteAlgorithm(@PathVariable Long[] algorithmIds) { + return dataSetService.deleteAlgorithm(algorithmIds); + } + + + // 处理多个文件上传 + @PostMapping("/uploadImgFiles") + public AjaxResult uploadImgFiles(@RequestParam("files") MultipartFile[] files, @RequestParam("datasetId") Long datasetId) { + if (ObjectUtils.isEmpty(files)) { + return AjaxResult.error("请选择文件"); + } + try { + AjaxResult ajaxResult = remoteFileService.uploadFile(files); + if (ajaxResult.isSuccess()) { + List> data = (List>) ajaxResult.get("data"); + for (Map map : data) { + DataSetFileEntity entity = new DataSetFileEntity(); + entity.setFileAddress(map.get("url")); + entity.setDatasetId(datasetId); + entity.setFileName(map.get("name")); + dataSetService.insertFile(entity); + } + return AjaxResult.success(); + } else { + return AjaxResult.error("上传文件失败"); + } + + } catch (Exception e) { + return AjaxResult.error(); + } } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/AiModelEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/AiModelEntity.java new file mode 100644 index 0000000..23d1b1d --- /dev/null +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/AiModelEntity.java @@ -0,0 +1,73 @@ +package com.bonus.ai.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @author bonus + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AiModelEntity extends BaseEntity { + /** + * 模型唯一id + */ + private Long modelId; + /** + * 模型名称 + */ + private String modelName; + /** + * 模型版本 + */ + private String modelVersion; + /** + * 分任务类型id + */ + private Long subTaskTypeId; + /** + * 模型类型 + */ + private String modelType; + /** + * 数据集 + */ + private Long dataSetId; + /** + * 数据集名称 + */ + private String dataSetName; + /** + * 推理语言 + */ + private String inferLanguage; + /** + * 模型格式 + */ + private String modelFormat; + /** + * 部署要求 + */ + private String deployRequirement; + /** + * 模型相对地址 + */ + private String modelAddress; + /** + * 使用手册相对地址 + */ + private String userGuide; + /** + * 描述 + */ + private String description; + /** + * 算法选择 + */ + private String algorithm; +} diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetAlgorithm.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetAlgorithm.java new file mode 100644 index 0000000..d6da180 --- /dev/null +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetAlgorithm.java @@ -0,0 +1,40 @@ +package com.bonus.ai.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DataSetAlgorithm extends BaseEntity { + /** + * 主键 + */ + private Long algorithmId; + /** + * 模型id + */ + private Long modelId; + /** + * 模型名称 + */ + private String modelName; + /** + * 样本数 + */ + private int validationSampleCount; + /** + * 准确数 + */ + private int correctCount; + /** + * 漏检数 + */ + private int missedDetectionCount; + /** + * 识别速度 + */ + private String recognitionSpeed; +} diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetCategoryEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetCategoryEntity.java index fc10634..1027c97 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetCategoryEntity.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetCategoryEntity.java @@ -35,7 +35,7 @@ public class DataSetCategoryEntity implements Serializable { /** * 创建人 */ - private String createdBy; + private Long createdBy; /** * 描述 */ @@ -62,6 +62,8 @@ public class DataSetCategoryEntity implements Serializable { */ private Date updateTime; - /** 子菜单 */ + /** + * 子菜单 + */ private List children = new ArrayList(); } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetEntity.java index 8d25bde..34bd6a3 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetEntity.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetEntity.java @@ -1,7 +1,9 @@ package com.bonus.ai.domain; +import com.bonus.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; @@ -11,10 +13,11 @@ import java.util.Date; * @author bonus * 数据集表 */ +@EqualsAndHashCode(callSuper = true) @Data @AllArgsConstructor @NoArgsConstructor -public class DataSetEntity implements Serializable { +public class DataSetEntity extends BaseEntity { /** * 数据集id */ @@ -35,28 +38,28 @@ public class DataSetEntity implements Serializable { * 数据集描述 */ private String description; - /** - * 记录创建者 - */ - private Long createBy; /** * 记录创建人姓名 */ private String createName; - /** - * 记录创建时间 - */ - private Date createTime; - /** - * 记录更新者 - */ - private String updateBy; /** * 记录更新者姓名 */ private String updateName; /** - * 记录更新时间 + * 样本类型id */ - private Date updateTime; + private Long categoryId; + /** + * 样本类型名称 + */ + private String categoryName; + /** + * 样本数量 + */ + private int num; + /** + * 文件地址 + */ + private String filePath; } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetFileEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetFileEntity.java index 561b4db..37279dc 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetFileEntity.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetFileEntity.java @@ -1,19 +1,17 @@ package com.bonus.ai.domain; +import com.bonus.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import java.io.Serializable; -import java.util.Date; - /** * @author bonus */ @Data @AllArgsConstructor @NoArgsConstructor -public class DataSetFileEntity implements Serializable { +public class DataSetFileEntity extends BaseEntity { /** * 数据集文件唯一标识符 */ @@ -46,29 +44,15 @@ public class DataSetFileEntity implements Serializable { * 文件描述信息 */ private String description; - /** - * 记录创建者 - */ - private Long createBy; /** * 记录创建人姓名 */ private String createName; - /** - * 记录创建时间 - */ - private Date createTime; - /** - * 记录更新者 - */ - private String updateBy; /** * 记录更新者姓名 */ private String updateName; - /** - * 记录更新时间 - */ - private Date updateTime; + + private Long[] fileIds; } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetLogEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetLogEntity.java index bd946fd..71f6fb1 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetLogEntity.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetLogEntity.java @@ -1,5 +1,6 @@ package com.bonus.ai.domain; +import com.bonus.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -12,7 +13,7 @@ import java.util.Date; @Data @AllArgsConstructor @NoArgsConstructor -public class DataSetLogEntity { +public class DataSetLogEntity extends BaseEntity { /** * 日志唯一标识符 */ diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetTaskEntity.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetTaskEntity.java index ec0078f..ef9214b 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetTaskEntity.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/domain/DataSetTaskEntity.java @@ -1,5 +1,6 @@ package com.bonus.ai.domain; +import com.bonus.common.core.web.domain.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -13,7 +14,7 @@ import java.util.Date; @Data @AllArgsConstructor @NoArgsConstructor -public class DataSetTaskEntity implements Serializable { +public class DataSetTaskEntity extends BaseEntity implements Serializable { /** * 任务唯一标识符 */ @@ -21,7 +22,7 @@ public class DataSetTaskEntity implements Serializable { /** * 任务类型和状态关联 ID */ - private Long typeStatusId; + private Long datasetId; /** * 任务归属人 */ @@ -34,28 +35,36 @@ public class DataSetTaskEntity implements Serializable { * 描述 */ private String description; - /** - * 记录创建者 - */ - private Long createBy; /** * 记录创建人姓名 */ private String createName; - /** - * 记录创建时间 - */ - private Date createTime; - /** - * 记录更新者 - */ - private String updateBy; /** * 记录更新者姓名 */ private String updateName; /** - * 记录更新时间 + * 任务名称 */ - private Date updateTime; + private String taskName; + /** + * 开始时间 + */ + private Date startTime; + /** + * 结束时间 + */ + private Date endTime; + /** + * 任务状态 + */ + private String status; + /** + * 紧急程度 + */ + private String level; + /** + * 完成进度 + */ + private int num; } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/mapper/DataSetMapper.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/mapper/DataSetMapper.java index 62cd0b7..0c87544 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/mapper/DataSetMapper.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/mapper/DataSetMapper.java @@ -133,7 +133,7 @@ public interface DataSetMapper { * @param fileId 文件 ID * @return 影响的行数 */ - int deleteFile(Long fileId); + int deleteFile(Long[] fileId); /** * 根据 ID 查询任务信息 @@ -201,18 +201,82 @@ public interface DataSetMapper { int insertLog(DataSetLogEntity log); /** - * 更新日志信息 + * 根据 ID 查询模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param modelId 模型管理 ID + * @return 模型管理实体 */ - int updateLog(DataSetLogEntity log); + AiModelEntity getModelsById(Long modelId); /** - * 根据 ID 删除日志 + * 查询所有模型 * - * @param logId 日志 ID + * @param entity 查询条件 + * @return 模型管理列表 + */ + List getAllModels(AiModelEntity entity); + + /** + * 插入新的模型 + * + * @param entity 模型实体 * @return 影响的行数 */ - int deleteLog(Long logId); + int insertModel(AiModelEntity entity); + + /** + * 更新模型实体 + * + * @param entity 模型实体 + * @return 影响的行数 + */ + int updateModel(AiModelEntity entity); + + /** + * 根据 ID 删除模型 + * + * @param modelIds 模型 ID + * @return 影响的行数 + */ + int deleteModel(Long[] modelIds); + + /** + * 根据 ID 查询算法评价 + * + * @param algorithmId 算法评价 ID + * @return 算法评价实体 + */ + DataSetAlgorithm getAlgorithmById(Long algorithmId); + + /** + * 查询所有算法评价 + * + * @param entity 查询条件 + * @return 算法评价列表 + */ + List getAllAlgorithms(DataSetAlgorithm entity); + + /** + * 插入新的算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + int insertAlgorithm(DataSetAlgorithm entity); + + /** + * 更新算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + int updateAlgorithm(DataSetAlgorithm entity); + + /** + * 根据 ID 删除算法评价 + * + * @param algorithmIds 算法评价 ID + * @return 影响的行数 + */ + int deleteAlgorithm(Long[] algorithmIds); } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/DataSetService.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/DataSetService.java index 99d496f..ff7fa73 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/DataSetService.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/DataSetService.java @@ -3,6 +3,8 @@ package com.bonus.ai.service; import com.bonus.ai.domain.*; import com.bonus.common.core.web.domain.AjaxResult; +import java.util.List; + /** * @author bonus @@ -23,7 +25,7 @@ public interface DataSetService { * @param entity 包含查询条件的 DataSetEntity 对象 * @return 返回所有符合条件的数据集的集合 */ - AjaxResult getAllDatasets(DataSetEntity entity); + List getAllDatasets(DataSetEntity entity); /** * 插入新的数据集到数据库。 @@ -103,7 +105,7 @@ public interface DataSetService { * @param entity 查询条件 * @return 数据集文件列表 */ - AjaxResult getAllFiles(DataSetFileEntity entity); + List getAllFiles(DataSetFileEntity entity); /** * 插入新的数据集文件 @@ -127,7 +129,7 @@ public interface DataSetService { * @param fileId 文件 ID * @return 影响的行数 */ - AjaxResult deleteFile(Long fileId); + AjaxResult deleteFile(Long[] fileId); /** * 根据 ID 查询任务信息 @@ -143,7 +145,7 @@ public interface DataSetService { * @param entity 查询条件 * @return 数据集任务列表 */ - AjaxResult getAllTasks(DataSetTaskEntity entity); + List getAllTasks(DataSetTaskEntity entity); /** * 插入新的任务 @@ -184,29 +186,85 @@ public interface DataSetService { * @param entity 查询条件 * @return 数据集日志列表 */ - AjaxResult getAllLogs(DataSetLogEntity entity); + List getAllLogs(DataSetLogEntity entity); /** - * 插入新的日志 + * 根据 ID 查询模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param modelId 模型管理 ID + * @return 模型管理实体 */ - AjaxResult insertLog(DataSetLogEntity log); + AjaxResult getModelsById(Long modelId); /** - * 更新日志信息 + * 查询所有模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param entity 查询条件 + * @return 模型管理列表 */ - AjaxResult updateLog(DataSetLogEntity log); + List getAllModels(AiModelEntity entity); /** - * 根据 ID 删除日志 + * 插入新的模型 * - * @param logId 日志 ID + * @param entity 模型实体 * @return 影响的行数 */ - AjaxResult deleteLog(Long logId); + AjaxResult insertModel(AiModelEntity entity); + + /** + * 更新模型实体 + * + * @param entity 模型实体 + * @return 影响的行数 + */ + AjaxResult updateModel(AiModelEntity entity); + + /** + * 根据 ID 删除模型 + * + * @param modelIds 模型 ID + * @return 影响的行数 + */ + AjaxResult deleteModel(Long[] modelIds); + + /** + * 根据 ID 查询算法评价 + * + * @param algorithmId 算法评价 ID + * @return 算法评价实体 + */ + AjaxResult getAlgorithmById(Long algorithmId); + + /** + * 查询所有算法评价 + * + * @param entity 查询条件 + * @return 算法评价列表 + */ + List getAllAlgorithms(DataSetAlgorithm entity); + + /** + * 插入新的算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + AjaxResult insertAlgorithm(DataSetAlgorithm entity); + + /** + * 更新算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + AjaxResult updateAlgorithm(DataSetAlgorithm entity); + + /** + * 根据 ID 删除算法评价 + * + * @param algorithmIds 算法评价 ID + * @return 影响的行数 + */ + AjaxResult deleteAlgorithm(Long[] algorithmIds); } diff --git a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/impl/DataSetServiceImpl.java b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/impl/DataSetServiceImpl.java index 5ea6dd3..7234600 100644 --- a/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/impl/DataSetServiceImpl.java +++ b/bonus-modules/bonus-ai/src/main/java/com/bonus/ai/service/impl/DataSetServiceImpl.java @@ -4,15 +4,19 @@ import com.bonus.ai.domain.*; import com.bonus.ai.mapper.DataSetMapper; import com.bonus.ai.service.DataSetService; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; /** * @author bonus */ @Service +@Slf4j public class DataSetServiceImpl implements DataSetService { @Resource private DataSetMapper mapper; @@ -25,7 +29,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult getDatasetById(Long datasetId) { - return null; + try { + DataSetEntity entity = mapper.getDatasetById(datasetId); + return AjaxResult.success(entity); + } catch (Exception e) { + return AjaxResult.error("获取数据失败"); + } } /** @@ -35,8 +44,8 @@ public class DataSetServiceImpl implements DataSetService { * @return 返回所有符合条件的数据集的集合 */ @Override - public AjaxResult getAllDatasets(DataSetEntity entity) { - return null; + public List getAllDatasets(DataSetEntity entity) { + return mapper.getAllDatasets(entity); } /** @@ -47,7 +56,13 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult insertDataset(DataSetEntity entity) { - return null; + try { + entity.setCreateBy(String.valueOf(SecurityUtils.getUserId())); + int i = mapper.insertDataset(entity); + return i > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败"); + } catch (Exception e) { + return AjaxResult.error("新增失败"); + } } /** @@ -58,7 +73,13 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult updateDataset(DataSetEntity entity) { - return null; + try { + entity.setUpdateBy(String.valueOf(SecurityUtils.getUserId())); + int i = mapper.updateDataset(entity); + return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改成功"); + } catch (Exception e) { + return AjaxResult.error("修改失败"); + } } /** @@ -69,7 +90,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult deleteDataset(Long datasetId) { - return null; + try { + int i = mapper.deleteDataset(datasetId); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } } /** @@ -80,7 +106,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult getCategoryById(Long categoryId) { - return null; + try { + DataSetCategoryEntity entity = mapper.getCategoryById(categoryId); + return AjaxResult.success(entity); + } catch (Exception e) { + return AjaxResult.error("获取数据失败"); + } } /** @@ -107,7 +138,17 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult insertCategory(DataSetCategoryEntity entity) { - return null; + try { + entity.setCreatedBy(SecurityUtils.getUserId()); + int i = mapper.insertCategory(entity); + if (i > 0) { + return AjaxResult.success("新增成功"); + } else { + return AjaxResult.error("新增失败"); + } + } catch (Exception e) { + return AjaxResult.error("新增失败"); + } } /** @@ -118,7 +159,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult updateCategory(DataSetCategoryEntity entity) { - return null; + try { + int i = mapper.updateCategory(entity); + return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); + } catch (Exception e) { + return AjaxResult.error("修改失败"); + } } /** @@ -129,7 +175,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult deleteCategory(Long categoryId) { - return null; + try { + int i = mapper.deleteCategory(categoryId); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } } /** @@ -150,8 +201,8 @@ public class DataSetServiceImpl implements DataSetService { * @return 数据集文件列表 */ @Override - public AjaxResult getAllFiles(DataSetFileEntity entity) { - return null; + public List getAllFiles(DataSetFileEntity entity) { + return mapper.getAllFiles(entity); } /** @@ -162,7 +213,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult insertFile(DataSetFileEntity entity) { - return null; + try { + int i = mapper.insertFile(entity); + return i > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败"); + } catch (Exception e) { + return AjaxResult.error("新增失败"); + } } /** @@ -173,7 +229,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult updateFile(DataSetFileEntity datasetFile) { - return null; + try { + int i = mapper.updateFile(datasetFile); + return i > 0 ? AjaxResult.success("移动成功") : AjaxResult.error("移动失败"); + } catch (Exception e) { + return AjaxResult.error("移动失败"); + } } /** @@ -183,8 +244,13 @@ public class DataSetServiceImpl implements DataSetService { * @return 影响的行数 */ @Override - public AjaxResult deleteFile(Long fileId) { - return null; + public AjaxResult deleteFile(Long[] fileId) { + try { + int i = mapper.deleteFile(fileId); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } } /** @@ -205,8 +271,8 @@ public class DataSetServiceImpl implements DataSetService { * @return 数据集任务列表 */ @Override - public AjaxResult getAllTasks(DataSetTaskEntity entity) { - return null; + public List getAllTasks(DataSetTaskEntity entity) { + return mapper.getAllTasks(entity); } /** @@ -217,7 +283,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult insertTask(DataSetTaskEntity entity) { - return null; + try { + int i = mapper.insertTask(entity); + return i > 0 ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败"); + } catch (Exception e) { + return AjaxResult.error("添加失败"); + } } /** @@ -228,7 +299,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult updateTask(DataSetTaskEntity datasetTask) { - return null; + try { + int i = mapper.updateTask(datasetTask); + return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); + } catch (Exception e) { + return AjaxResult.error("修改失败"); + } } /** @@ -239,7 +315,12 @@ public class DataSetServiceImpl implements DataSetService { */ @Override public AjaxResult deleteTask(Long taskId) { - return null; + try { + int i = mapper.deleteTask(taskId); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } } /** @@ -260,40 +341,163 @@ public class DataSetServiceImpl implements DataSetService { * @return 数据集日志列表 */ @Override - public AjaxResult getAllLogs(DataSetLogEntity entity) { - return null; + public List getAllLogs(DataSetLogEntity entity) { + return mapper.getAllLogs(entity); } /** - * 插入新的日志 + * 根据 ID 查询模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param modelId 模型管理 ID + * @return 模型管理实体 */ @Override - public AjaxResult insertLog(DataSetLogEntity log) { - return null; + public AjaxResult getModelsById(Long modelId) { + try { + AiModelEntity entity = mapper.getModelsById(modelId); + return AjaxResult.success(entity); + } catch (Exception e) { + return AjaxResult.error("获取数据失败"); + } } /** - * 更新日志信息 + * 查询所有模型 * - * @param log 数据集日志实体 - * @return 影响的行数 + * @param entity 查询条件 + * @return 模型管理列表 */ @Override - public AjaxResult updateLog(DataSetLogEntity log) { - return null; + public List getAllModels(AiModelEntity entity) { + return mapper.getAllModels(entity); } /** - * 根据 ID 删除日志 + * 插入新的模型 * - * @param logId 日志 ID + * @param entity 模型实体 * @return 影响的行数 */ @Override - public AjaxResult deleteLog(Long logId) { - return null; + public AjaxResult insertModel(AiModelEntity entity) { + try { + entity.setCreateBy(SecurityUtils.getUsername()); + int i = mapper.insertModel(entity); + return i > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败"); + } catch (Exception e) { + return AjaxResult.error("新增失败"); + } + } + + /** + * 更新模型实体 + * + * @param entity 模型实体 + * @return 影响的行数 + */ + @Override + public AjaxResult updateModel(AiModelEntity entity) { + try { + int i = mapper.updateModel(entity); + return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); + } catch (Exception e) { + return AjaxResult.error("修改失败"); + } + } + + /** + * 根据 ID 删除模型 + * + * @param modelIds 模型 ID + * @return 影响的行数 + */ + @Override + public AjaxResult deleteModel(Long[] modelIds) { + try { + int i = mapper.deleteModel(modelIds); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + return AjaxResult.error("删除失败"); + } + } + + /** + * 根据 ID 查询算法评价 + * + * @param algorithmId 算法评价 ID + * @return 算法评价实体 + */ + @Override + public AjaxResult getAlgorithmById(Long algorithmId) { + try { + DataSetAlgorithm algorithmById = mapper.getAlgorithmById(algorithmId); + return AjaxResult.success(algorithmById); + } catch (Exception e) { + log.debug(e.getMessage()); + return AjaxResult.error("获取数据失败"); + } + } + + /** + * 查询所有算法评价 + * + * @param entity 查询条件 + * @return 算法评价列表 + */ + @Override + public List getAllAlgorithms(DataSetAlgorithm entity) { + return mapper.getAllAlgorithms(entity); + } + + /** + * 插入新的算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + @Override + public AjaxResult insertAlgorithm(DataSetAlgorithm entity) { + try { + entity.setCreateBy(SecurityUtils.getUsername()); + int i = mapper.insertAlgorithm(entity); + return i > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败"); + } catch (Exception e) { + log.debug(e.getMessage()); + return AjaxResult.error("新增失败"); + } + } + + /** + * 更新算法评价 + * + * @param entity 算法评价实体 + * @return 影响的行数 + */ + @Override + public AjaxResult updateAlgorithm(DataSetAlgorithm entity) { + try { + int i = mapper.updateAlgorithm(entity); + return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); + } catch (Exception e) { + log.debug(e.getMessage()); + return AjaxResult.error("修改失败"); + } + } + + /** + * 根据 ID 删除算法评价 + * + * @param algorithmIds 算法评价 ID + * @return 影响的行数 + */ + @Override + public AjaxResult deleteAlgorithm(Long[] algorithmIds) { + try { + int i = mapper.deleteAlgorithm(algorithmIds); + return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败"); + } catch (Exception e) { + log.debug(e.getMessage()); + return AjaxResult.error("删除失败"); + } } } diff --git a/bonus-modules/bonus-ai/src/main/resources/mapper/ai/DataSetMapper.xml b/bonus-modules/bonus-ai/src/main/resources/mapper/ai/DataSetMapper.xml index 7cf74c6..b542d8d 100644 --- a/bonus-modules/bonus-ai/src/main/resources/mapper/ai/DataSetMapper.xml +++ b/bonus-modules/bonus-ai/src/main/resources/mapper/ai/DataSetMapper.xml @@ -3,22 +3,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + - - - - + + + + + + + - INSERT INTO ai_dataset (dataset_name, sub_task_type_id, description, create_by, create_time, - update_by, update_time) - VALUES (#{datasetName}, #{subTaskTypeId}, #{description}, #{createBy}, #{createTime}, #{updateBy}, - #{updateTime}) + INSERT INTO ai_dataset (dataset_name, sub_task_type_id, description, create_by, + update_by, category_id) + VALUES (#{datasetName}, #{subTaskTypeId}, #{description}, #{createBy}, #{updateBy}, #{categoryId}) - + INSERT INTO ai_dataset_category (category_name, parent_id, enabled, created_by, description) + VALUES (#{categoryName}, #{parentId}, #{enabled}, #{createdBy}, #{description}) - + INSERT INTO ai_dataset_file (file_name, dataset_id, file_address, is_audited, is_labeled) + VALUE (#{fileName}, #{datasetId}, #{fileAddress}, #{isAudited}, #{isLabeled}) - + INSERT INTO ai_dataset_task (dataset_id, task_owner, description, create_by, + task_name, start_time, end_time, status, level) + VALUES (#{datasetId}, #{task_owner}, #{description}, #{create_by}, #{taskName}, #{startTime}, #{endTime}, + #{status}, #{level}); + + INSERT INTO ai_model (model_name, model_version, sub_task_type_id, + infer_language, model_format, deploy_requirement, model_address, + user_guide, description, create_by, + algorithm, dataSetId, model_type) + VALUES (#{modelName}, #{modelVersion}, #{subTaskTypeId}, #{inferLanguage}, #{modelFormat}, + #{deployRequirement}, #{modelAddress}, #{userGuide}, #{description}, #{createBy}, #{algorithm}, + #{dataSetId}, #{modelType}); + + + + INSERT INTO ai_dataset_algorithm(model_id, validationSampleCount, correctCount, missedDetectionCount, + recognitionSpeed, + create_by) VALUE (#{modelId}, #{validationSampleCount}, #{correctCount}, + #{missedDetectionCount}, #{recognitionSpeed}, #{createBy}) + - description = #{description}, - update_by = #{updateBy}, - update_time = #{updateTime} + description = #{description}, + update_by = #{updateBy}, + category_id = #{categoryId} WHERE dataset_id = #{datasetId} - - - + UPDATE ai_dataset_file + SET dataset_id = #{datasetId}, + update_by = #{updateBy} + WHERE file_id IN + + #{fileId} + - + UPDATE ai_dataset_file + SET del_flag = '1' + WHERE file_id IN + + #{fileId} + - + UPDATE ai_dataset_task + SET level = #{level} + WHERE task_id = #{taskId} - - + UPDATE ai_dataset_task + SET del_flag = '1' + WHERE task_id = #{taskId} - - + + UPDATE ai_model + set model_name = #{modelName}, + model_version = #{modelVersion}, + infer_language = #{inferLanguage}, + model_format = #{modelFormat}, + deploy_requirement = #{deployRequirement}, + model_address = #{modelAddress}, + user_guide =#{userGuide}, + model_type = #{modelType}, + dataSetId = #{dataSetId}, + algorithm = #{algorithm} + WHERE model_id = #{modelId} - - + + UPDATE ai_model + SET del_flag ='1' + where model_id in + + #{modelId} + + + + UPDATE ai_dataset_algorithm + set model_id =#{modelId}, + validationSampleCount = #{validationSampleCount}, + correctCount = #{correctCount}, + missedDetectionCount = #{missedDetectionCount}, + recognitionSpeed = #{recognitionSpeed} + WHERE algorithm_id = #{algorithmId} + + + UPDATE ai_dataset_algorithm + SET del_flag ='1' + where algorithm_id in + + #{algorithmId} +