From c5a9b01abbf88fa97d766325e86198e4effc6225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E5=A4=A7=E9=94=90?= <1070211640@qq.com> Date: Mon, 6 May 2024 09:40:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E5=90=8D=E5=AD=97=E6=B7=BB=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/platform/domain/Experiment.java | 2 ++ .../java/com/ruoyi/platform/domain/Image.java | 2 ++ .../com/ruoyi/platform/domain/Workflow.java | 2 ++ .../ruoyi/platform/mapper/ExperimentDao.java | 6 +++- .../ExperimentInstanceStatusTask.java | 10 +++++-- .../platform/service/DatasetService.java | 2 +- .../platform/service/ExperimentService.java | 3 ++ .../platform/service/WorkflowService.java | 3 ++ .../service/impl/ExperimentServiceImpl.java | 24 +++++++++++++++ .../service/impl/WorkflowServiceImpl.java | 30 +++++++++++++++++++ .../ExperimentDaoMapper.xml | 9 ++++++ 11 files changed, 88 insertions(+), 5 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Experiment.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Experiment.java index 831302b7..01118a23 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Experiment.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Experiment.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.ruoyi.common.core.web.domain.BaseEntity; +import com.ruoyi.platform.annotations.CheckDuplicate; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -28,6 +29,7 @@ public class Experiment implements Serializable { @ApiModelProperty(value = "主键") private Integer id; @ApiModelProperty(value = "名称") + @CheckDuplicate private String name; @ApiModelProperty(value = "工作流ID") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Image.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Image.java index 981289a1..d3b97185 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Image.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Image.java @@ -2,6 +2,7 @@ package com.ruoyi.platform.domain; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.ruoyi.platform.annotations.CheckDuplicate; import io.swagger.annotations.ApiModelProperty; import java.util.Date; @@ -25,6 +26,7 @@ public class Image implements Serializable { * 镜像名称 */ @ApiModelProperty(value = "名称") + @CheckDuplicate private String name; @ApiModelProperty(value = "镜像描述") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java index 487f7653..97ac1eba 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; +import com.ruoyi.platform.annotations.CheckDuplicate; import com.ruoyi.platform.handler.BaseMetaObjectHandler; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -33,6 +34,7 @@ public class Workflow extends BaseMetaObjectHandler implements Serializable { private Long id; @ApiModelProperty(value = "工作流名称") + @CheckDuplicate private String name; @ApiModelProperty(value = "流水线描述") diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentDao.java index d1db8828..6a24e02e 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentDao.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentDao.java @@ -1,5 +1,6 @@ package com.ruoyi.platform.mapper; +import com.ruoyi.platform.domain.Dataset; import com.ruoyi.platform.domain.Experiment; import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.Pageable; @@ -80,6 +81,9 @@ public interface ExperimentDao { */ int deleteById(Integer id); - List queryByExperiment(@Param("experiment")Experiment experiment); + List queryByExperiment(@Param("experiment") Experiment experiment); + + Experiment findByName(@Param("name") String name); + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java index c1bfa662..b7ea8648 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/scheduling/ExperimentInstanceStatusTask.java @@ -30,6 +30,7 @@ public class ExperimentInstanceStatusTask { private ExperimentInsDao experimentInsDao; private List experimentIds = new ArrayList<>(); + @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 public void executeExperimentInsStatus() throws IOException { // 首先查到所有非终止态的实验实例 @@ -47,15 +48,16 @@ public class ExperimentInstanceStatusTask { } if (!StringUtils.equals(oldStatus,experimentIns.getStatus())){ experimentIns.setUpdateTime(new Date()); + // 线程安全的添加操作 synchronized (experimentIds) { - experimentIds.add(experimentIns.getExperimentId()); // 线程安全的添加操作 + experimentIds.add(experimentIns.getExperimentId()); } updateList.add(experimentIns); - } experimentInsDao.update(experimentIns); } + } if (updateList.size() > 0){ experimentInsDao.insertOrUpdateBatch(updateList); @@ -85,11 +87,13 @@ public class ExperimentInstanceStatusTask { updateExperiments.add(experiment); } } + if (!updateExperiments.isEmpty()) { experimentDao.insertOrUpdateBatch(updateExperiments); for (int index = 0; index < updateExperiments.size(); index++) { + // 线程安全的删除操作 synchronized (experimentIds) { - experimentIds.remove(index); // 线程安全的删除操作 + experimentIds.remove(index); } } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java index 0f8cc707..edfe8cbe 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/DatasetService.java @@ -79,7 +79,7 @@ DatasetService { List getDatasetVersions(Integer datasetId) throws Exception; String insertDatasetAndVersion(DatasetVo datasetVo) throws Exception; - public void checkDeclaredName(Dataset insert) throws Exception; + void checkDeclaredName(Dataset insert) throws Exception; ResponseEntity downloadAllDatasetFiles(Integer datasetId, String version) throws Exception; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java index 44af21bc..67e60ac2 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java @@ -1,6 +1,7 @@ package com.ruoyi.platform.service; import com.ruoyi.platform.domain.Experiment; +import com.ruoyi.platform.domain.Workflow; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.http.ResponseEntity; @@ -75,4 +76,6 @@ public interface ExperimentService { ResponseEntity showExperimentConfig(Experiment experiment); List queryByWorkflowId(Long id); + + void checkDeclaredName(Experiment insert) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java index 41397348..772c9bd6 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java @@ -1,6 +1,7 @@ package com.ruoyi.platform.service; import com.fasterxml.jackson.core.JsonProcessingException; +import com.ruoyi.platform.domain.Dataset; import com.ruoyi.platform.domain.Workflow; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -64,6 +65,8 @@ public interface WorkflowService { Workflow duplicateWorkflow(Long id); + void checkDeclaredName(Workflow insert) throws Exception; + /** * 按流水线id保存 * diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java index 3cef14d1..3eed94e1 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java @@ -1,6 +1,7 @@ package com.ruoyi.platform.service.impl; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.platform.annotations.CheckDuplicate; import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.ExperimentIns; import com.ruoyi.platform.domain.Workflow; @@ -25,6 +26,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; +import java.lang.reflect.Field; import java.util.*; /** @@ -317,6 +319,28 @@ public class ExperimentServiceImpl implements ExperimentService { return experimentDao.queryByExperiment(experiment); } + public void checkDeclaredName(Experiment insert) throws Exception { + Experiment existingExperiment = experimentDao.findByName(insert.getName()); + + if (existingExperiment != null) { + // 检查找到的流水线是否与要插入的流水线相同 + if (insert.getId() != null && insert.getId().equals(existingExperiment.getId())) { + // 这是相同的流水线,更新操作中没有重复名称问题 + return; + } + // 现在我们知道还有另一个具有相同名称的流水线 + Field[] fields = Experiment.class.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); // 使私有字段可访问 + if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) { + // 如果字段是“name”并且标记了CheckDuplicate注解 + CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class); + throw new Exception("重复的实验名称: " + insert.getName() + ". " + annotation.message()); + } + } + } + } + diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index 59cb170d..d09312dc 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.platform.service.impl; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.platform.annotations.CheckDuplicate; +import com.ruoyi.platform.domain.Dataset; import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.Workflow; import com.ruoyi.platform.mapper.WorkflowDao; @@ -18,6 +20,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.lang.reflect.Field; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -191,7 +194,34 @@ public class WorkflowServiceImpl implements WorkflowService { } return null; + + } + public void checkDeclaredName(Workflow insert) throws Exception { + List existingWorkflowList = workflowDao.queryByName(insert.getName()); + + Workflow existingWorkflow = existingWorkflowList.stream().findFirst().orElse(null); + if (existingWorkflow != null) { + // 检查找到的流水线是否与要插入的流水线相同 + if (insert.getId() != null && insert.getId().equals(existingWorkflow.getId())) { + // 这是相同的流水线,更新操作中没有重复名称问题 + return; + } + // 现在我们知道还有另一个具有相同名称的流水线 + Field[] fields = Workflow.class.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); // 使私有字段可访问 + if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) { + // 如果字段是“name”并且标记了CheckDuplicate注解 + CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class); + throw new Exception("重复的流水线名称: " + insert.getName() + ". " + annotation.message()); + } + } + } + } + + + } diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml index c39dcd9e..80a53eb1 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml @@ -24,6 +24,14 @@ where id = #{id} and state = 1 + + + + insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) From 9756ff0886d09d49f7371f4e6bb0042ba964f5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E5=A4=A7=E9=94=90?= <1070211640@qq.com> Date: Mon, 6 May 2024 14:40:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experiment/ExperimentController.java | 4 ++-- .../workflow/WorkflowController.java | 2 +- .../workspace/WorkspaceController.java | 22 +++++++++++++++++++ .../ruoyi/platform/mapper/WorkflowDao.java | 4 ++++ .../platform/service/ExperimentService.java | 4 ++-- .../platform/service/WorkflowService.java | 2 +- .../platform/service/WorkspaceService.java | 11 ++++++++++ .../service/impl/ExperimentServiceImpl.java | 7 +++--- .../service/impl/WorkflowServiceImpl.java | 7 +++--- .../service/impl/WorkspaceServiceImpl.java | 7 ++++++ .../managementPlatform/WorkflowDaoMapper.xml | 8 +++++++ 11 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java index cc8fff85..230b77a4 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java @@ -79,7 +79,7 @@ public class ExperimentController extends BaseController { */ @PostMapping @ApiOperation("新增实验") - public GenericsAjaxResult add(@RequestBody Experiment experiment) { + public GenericsAjaxResult add(@RequestBody Experiment experiment) throws Exception { return genericsSuccess(this.experimentService.insert(experiment)); } @@ -131,7 +131,7 @@ public class ExperimentController extends BaseController { */ @PostMapping("/addAndRunExperiment") @ApiOperation("实验创建页面确定并运行") - public GenericsAjaxResult addAndRunExperiment(@RequestBody Experiment experiment) { + public GenericsAjaxResult addAndRunExperiment(@RequestBody Experiment experiment) throws Exception { return genericsSuccess(this.experimentService.addAndRunExperiment(experiment)); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java index 359b3dfc..eec963b2 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java @@ -79,7 +79,7 @@ public class WorkflowController extends BaseController { */ @PostMapping @ApiOperation("新增流水线") - public GenericsAjaxResult add(@RequestBody Workflow workflow) { + public GenericsAjaxResult add(@RequestBody Workflow workflow) throws Exception { return genericsSuccess(this.workflowService.insert(workflow)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java new file mode 100644 index 00000000..b5e0a4c7 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java @@ -0,0 +1,22 @@ +package com.ruoyi.platform.controller.workspace; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("workspace") +@Api("工作空间管理") +public class WorkspaceController extends BaseController { + + @GetMapping("/overview") + @ApiOperation("运行概览") + public AjaxResult queryById(@PathVariable("id") Integer id) { + return AjaxResult.success(this.datasetService.queryById(id)); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java index c870a17f..4dd7135c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java @@ -1,5 +1,6 @@ package com.ruoyi.platform.mapper; +import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.Workflow; import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.Pageable; @@ -87,5 +88,8 @@ public interface WorkflowDao { * @return 对象列表 */ List queryByName(@Param("name") String name); + + Workflow findByName(@Param("name") String name); + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java index 67e60ac2..4f79f527 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java @@ -40,7 +40,7 @@ public interface ExperimentService { * @param experiment 实例对象 * @return 实例对象 */ - Experiment insert(Experiment experiment); + Experiment insert(Experiment experiment) throws Exception; /** * 修改数据 @@ -60,7 +60,7 @@ public interface ExperimentService { String removeById(Integer id) throws Exception; Experiment runExperiment(Integer id) throws Exception; - Experiment addAndRunExperiment(Experiment experiment); + Experiment addAndRunExperiment(Experiment experiment) throws Exception; /** * 分页查询实验状态 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java index 772c9bd6..935a8918 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java @@ -37,7 +37,7 @@ public interface WorkflowService { * @param workflow 实例对象 * @return 实例对象 */ - Workflow insert(Workflow workflow); + Workflow insert(Workflow workflow) throws Exception; /** * 修改数据 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java new file mode 100644 index 00000000..7d805951 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java @@ -0,0 +1,11 @@ +package com.ruoyi.platform.service; + +/** + * (workspace)服务接口 + * + * @author Xidaray + * @since 2024-5-06 14:38:07 + */ +public class WorkspaceService { + +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java index 3eed94e1..56eb44ba 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java @@ -132,8 +132,9 @@ public class ExperimentServiceImpl implements ExperimentService { * @return 实例对象 */ @Override - public Experiment insert(Experiment experiment) { + public Experiment insert(Experiment experiment) throws Exception { LoginUser loginUser = SecurityUtils.getLoginUser(); + checkDeclaredName(experiment); experiment.setCreateBy(loginUser.getUsername()); experiment.setUpdateBy(loginUser.getUsername()); experiment.setUpdateTime(new Date()); @@ -231,7 +232,7 @@ public class ExperimentServiceImpl implements ExperimentService { //这里全局参数是一个json数组,需要转换成一个list List> params = JacksonUtil.parseJSONStr2MapList(StringUtils.isEmpty(experiment.getGlobalParam()) ? "[]" : experiment.getGlobalParam()); runReqMap.put("params", params); - //// 实验字段的Map,不要写成一行! + //// 实验字段的Map,不要写成一行!否则会返回null Map experimentMap = new HashMap<>(); experimentMap.put("name", "experiment-"+experiment.getId()); runReqMap.put("experiment", experimentMap); @@ -281,7 +282,7 @@ public class ExperimentServiceImpl implements ExperimentService { } @Override - public Experiment addAndRunExperiment(Experiment experiment) { + public Experiment addAndRunExperiment(Experiment experiment) throws Exception { // 第一步: 调用add方法插入实验记录到数据库 Experiment newExperiment = this.insert(experiment); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index d09312dc..18b487f5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -91,8 +91,9 @@ public class WorkflowServiceImpl implements WorkflowService { * @return 实例对象 */ @Override - public Workflow insert(Workflow workflow) { + public Workflow insert(Workflow workflow) throws Exception { LoginUser loginUser = SecurityUtils.getLoginUser(); + checkDeclaredName(workflow); workflow.setCreateBy(loginUser.getUsername()); workflow.setUpdateBy(loginUser.getUsername()); workflow.setUpdateTime(new Date()); @@ -199,9 +200,7 @@ public class WorkflowServiceImpl implements WorkflowService { } public void checkDeclaredName(Workflow insert) throws Exception { - List existingWorkflowList = workflowDao.queryByName(insert.getName()); - - Workflow existingWorkflow = existingWorkflowList.stream().findFirst().orElse(null); + Workflow existingWorkflow = workflowDao.findByName(insert.getName()); if (existingWorkflow != null) { // 检查找到的流水线是否与要插入的流水线相同 if (insert.getId() != null && insert.getId().equals(existingWorkflow.getId())) { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java new file mode 100644 index 00000000..d9362433 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java @@ -0,0 +1,7 @@ +package com.ruoyi.platform.service.impl; + +import com.ruoyi.platform.service.ModelsService; + +public class WorkspaceServiceImpl implements ModelsService { + +} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml index c1c6bb9e..89572ab2 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/WorkflowDaoMapper.xml @@ -185,5 +185,13 @@ + + + From 025700354836c7fc9ea56d6c90735886c657e543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E5=A4=A7=E9=94=90?= <1070211640@qq.com> Date: Mon, 6 May 2024 17:32:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E6=A6=82=E8=A7=88=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workspace/WorkspaceController.java | 15 +++- .../platform/mapper/ExperimentInsDao.java | 12 +++ .../ruoyi/platform/mapper/WorkflowDao.java | 14 +++- .../service/ExperimentInsService.java | 2 + .../platform/service/WorkspaceService.java | 14 +++- .../impl/ExperimentInsServiceImpl.java | 30 +++++++- .../service/impl/WorkspaceServiceImpl.java | 73 ++++++++++++++++++- .../ExperimentInsDaoMapper.xml | 10 +++ .../managementPlatform/WorkflowDaoMapper.xml | 7 ++ 9 files changed, 170 insertions(+), 7 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java index b5e0a4c7..da180dec 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java @@ -2,6 +2,9 @@ package com.ruoyi.platform.controller.workspace; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import com.ruoyi.platform.service.JupyterService; +import com.ruoyi.platform.service.WorkspaceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.GetMapping; @@ -9,14 +12,20 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.util.Map; + @RestController @RequestMapping("workspace") @Api("工作空间管理") public class WorkspaceController extends BaseController { + @Resource + private WorkspaceService workspaceService; + @GetMapping("/overview") - @ApiOperation("运行概览") - public AjaxResult queryById(@PathVariable("id") Integer id) { - return AjaxResult.success(this.datasetService.queryById(id)); + @ApiOperation("得到运行概览") + public GenericsAjaxResult> getOverview() { + return genericsSuccess(this.workspaceService.getOverview()); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentInsDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentInsDao.java index c5f13883..58642324 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentInsDao.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ExperimentInsDao.java @@ -39,6 +39,14 @@ public interface ExperimentInsDao { */ long count(@Param("experimentIns") ExperimentIns experimentIns); + /* + 统计实验实例总数 + + + @return 总行数 + */ +// long experimentInsCount(String status); + /** * 新增数据 * @@ -89,6 +97,10 @@ public interface ExperimentInsDao { */ List getByExperimentId(Integer experimentId); + List getLatestInsList(); + + + List queryByExperiment(@Param("experimentIns") ExperimentIns experimentIns); List queryByExperimentId(Integer id); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java index 4dd7135c..e54f6789 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/WorkflowDao.java @@ -33,13 +33,25 @@ public interface WorkflowDao { List queryAllByLimit(@Param("workflow") Workflow workflow, @Param("pageable") Pageable pageable); /** - * 统计总行数 + * 统计总行数 实体作为筛选条件 * * @param workflow 查询条件 * @return 总行数 */ long count(@Param("workflow") Workflow workflow); + + /** + * 统计流水线总数 + * + * + * @return 总行数 + */ + long workflowCount(); + + + + /** * 新增数据 * diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java index 1940fd2d..e8020161 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java @@ -103,4 +103,6 @@ public interface ExperimentInsService { * @return */ List queryByExperimentIsNotTerminated(); + + Map countByStatus(); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java index 7d805951..21c59fc2 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java @@ -1,11 +1,23 @@ package com.ruoyi.platform.service; +import java.util.Map; + /** * (workspace)服务接口 * * @author Xidaray * @since 2024-5-06 14:38:07 */ -public class WorkspaceService { +public interface WorkspaceService { + + + + /** + * 得到工作空间数据概览 + * + * @return 概览数据 + */ + Map getOverview(); + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java index 14c2997d..09bb0dea 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java @@ -1,7 +1,6 @@ package com.ruoyi.platform.service.impl; import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.ExperimentIns; import com.ruoyi.platform.mapper.ExperimentDao; import com.ruoyi.platform.mapper.ExperimentInsDao; @@ -62,6 +61,15 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { this.minioUtil = minioUtil; } + public enum ExperimentInsStatus { + Running, + Succeeded, + Pending, + Failed, + Terminated + } + + /** * 通过ID查询单条数据 * @@ -533,6 +541,26 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { return experimentInsDao.queryByExperimentIsNotTerminated(); } + @Override + public Map countByStatus() { + // 创建一个用于存储状态计数的映射 + Map statusCountMap = new HashMap<>(); + + // 遍历枚举中的所有状态 + for (ExperimentInsStatus status : ExperimentInsStatus.values()) { + ExperimentIns experimentIns = new ExperimentIns(); + experimentIns.setStatus(status.toString()); // 设置实例的状态为枚举中的状态 + + // 查询具有相同状态的实例数量 + Long count = experimentInsDao.count(experimentIns); + + // 将状态及其对应的实例数量放入映射中 + statusCountMap.put(status.toString(), count); + } + + return statusCountMap; + } + private boolean isTerminatedState(ExperimentIns ins) throws IOException { // 定义终止态的列表,例如 "Succeeded", "Failed" 等 String status = ins.getStatus(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java index d9362433..a45781a0 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java @@ -1,7 +1,78 @@ package com.ruoyi.platform.service.impl; +import com.ruoyi.platform.domain.ExperimentIns; +import com.ruoyi.platform.mapper.*; +import com.ruoyi.platform.service.ExperimentInsService; import com.ruoyi.platform.service.ModelsService; +import com.ruoyi.platform.service.WorkflowService; +import com.ruoyi.platform.service.WorkspaceService; +import lombok.val; +import org.springframework.stereotype.Service; -public class WorkspaceServiceImpl implements ModelsService { +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service("WorkspaceService") +public class WorkspaceServiceImpl implements WorkspaceService { + + + @Resource + private WorkflowService workflowService; + @Resource + private WorkflowDao workflowDao; + @Resource + private ExperimentDao experimentDao; + + @Resource + private ExperimentInsDao experimentInsDao; + + @Resource + private ExperimentInsService experimentInsService; + + @Resource + private ModelsService modelsService; + @Resource + private ModelsDao modelsDao; + + @Resource + private DatasetDao datasetDao; + + @Resource + private ImageDao imageDao; + + @Resource + private ComponentDao componentDao; + + + + + @Override + public Map getOverview() { + Map resMap = new HashMap(); + + // 获取流水线数量 + Long workflowCount = workflowDao.workflowCount(); + resMap.put("workflowCount", workflowCount); + + // 获取运行中实验实例数量 + List experimentInsList = experimentInsService.queryByExperimentIsNotTerminated(); + if (experimentInsList!=null&&!experimentInsList.isEmpty()) { + Integer experimentInsCount = experimentInsList.size(); + resMap.put("runningExperimentInsCount", experimentInsCount); + }else{ + resMap.put("runningExperimentInsCount", 0); + } + //得到最近的三条实例记录,放进返回map + List latestExperimentInsList = experimentInsDao.getLatestInsList(); + if (latestExperimentInsList != null && !latestExperimentInsList.isEmpty()) { + resMap.put("latestExperimentInsList", latestExperimentInsList); + } + + Map statusMap = experimentInsService.countByStatus(); + resMap.put("experimentInsStatus", statusMap); + + return resMap; + } } diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentInsDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentInsDaoMapper.xml index 6ed73cdb..71dace3e 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentInsDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentInsDaoMapper.xml @@ -45,6 +45,16 @@ limit 5 + + + + + + + insert into workflow(name, description, dag, global_param, create_by, create_time, update_by, update_time,state) From a6e13f7895b9f83b1100b6d9193daa3a150b741c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E5=A4=A7=E9=94=90?= <1070211640@qq.com> Date: Tue, 7 May 2024 14:38:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feature:=E6=96=B0=E5=A2=9E=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E7=A9=BA=E9=97=B4AI=E8=B5=84=E4=BA=A7=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workspace/WorkspaceController.java | 13 +++-- .../ruoyi/platform/domain/ExperimentIns.java | 9 ++++ .../platform/service/WorkspaceService.java | 1 + .../impl/ExperimentInsServiceImpl.java | 4 +- .../service/impl/WorkspaceServiceImpl.java | 47 +++++++++++++++++-- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java index da180dec..541ed8b5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workspace/WorkspaceController.java @@ -7,10 +7,7 @@ import com.ruoyi.platform.service.JupyterService; import com.ruoyi.platform.service.WorkspaceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Map; @@ -28,4 +25,12 @@ public class WorkspaceController extends BaseController { public GenericsAjaxResult> getOverview() { return genericsSuccess(this.workspaceService.getOverview()); } + + @GetMapping("/assetCount") + @ApiOperation("得到AI资产计数") + public GenericsAjaxResult> getAssetCount(@RequestParam(value = "isPublic", + defaultValue = "true") Boolean isPublic) { + return genericsSuccess(this.workspaceService.getAssetCount(isPublic)); + } + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ExperimentIns.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ExperimentIns.java index 9fce8bbe..78926ebf 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ExperimentIns.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ExperimentIns.java @@ -71,6 +71,11 @@ public class ExperimentIns implements Serializable { private Integer state; + + @ApiModelProperty(value = "实验实例对应的流水线ID") + private Long workflowId; + + public ExperimentIns() { } @@ -201,5 +206,9 @@ public class ExperimentIns implements Serializable { this.state = state; } + public Long getWorkflowId() {return workflowId;} + + public void setWorkflowId(Long workflowId) {this.workflowId = workflowId;} + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java index 21c59fc2..5fdf8998 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkspaceService.java @@ -20,4 +20,5 @@ public interface WorkspaceService { Map getOverview(); + Map getAssetCount(Boolean isPublic); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java index 09bb0dea..940c4a02 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java @@ -543,7 +543,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { @Override public Map countByStatus() { - // 创建一个用于存储状态计数的映射 + // 创建一个用于存储状态计数的map Map statusCountMap = new HashMap<>(); // 遍历枚举中的所有状态 @@ -571,8 +571,6 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { //如果跟node_status里面不一样,就要去更新node_status的信息 String nodesStatus = ins.getNodesStatus(); Map nodeMap = JsonUtils.jsonToMap(nodesStatus); - - String keyStartsWithWorkflow = nodeMap.keySet().stream() .filter(key -> key.startsWith("workflow-")) .findFirst() diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java index a45781a0..b5392261 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkspaceServiceImpl.java @@ -1,12 +1,13 @@ package com.ruoyi.platform.service.impl; -import com.ruoyi.platform.domain.ExperimentIns; +import com.ruoyi.platform.domain.*; import com.ruoyi.platform.mapper.*; import com.ruoyi.platform.service.ExperimentInsService; import com.ruoyi.platform.service.ModelsService; import com.ruoyi.platform.service.WorkflowService; import com.ruoyi.platform.service.WorkspaceService; import lombok.val; +import org.checkerframework.checker.units.qual.C; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -58,7 +59,7 @@ public class WorkspaceServiceImpl implements WorkspaceService { // 获取运行中实验实例数量 List experimentInsList = experimentInsService.queryByExperimentIsNotTerminated(); - if (experimentInsList!=null&&!experimentInsList.isEmpty()) { + if (experimentInsList!=null && !experimentInsList.isEmpty()) { Integer experimentInsCount = experimentInsList.size(); resMap.put("runningExperimentInsCount", experimentInsCount); }else{ @@ -67,12 +68,50 @@ public class WorkspaceServiceImpl implements WorkspaceService { //得到最近的三条实例记录,放进返回map List latestExperimentInsList = experimentInsDao.getLatestInsList(); if (latestExperimentInsList != null && !latestExperimentInsList.isEmpty()) { + for (ExperimentIns experimentIns : latestExperimentInsList){ + Integer experimentId = experimentIns.getExperimentId(); + Experiment experiment = this.experimentDao.queryById(experimentId); + //拿到对应的流水线id + Long correspondingWorkflowId = experiment.getWorkflowId(); + experimentIns.setWorkflowId(correspondingWorkflowId); + } resMap.put("latestExperimentInsList", latestExperimentInsList); } - Map statusMap = experimentInsService.countByStatus(); resMap.put("experimentInsStatus", statusMap); - return resMap; } + + @Override + public Map getAssetCount(Boolean isPublic) { + Map assetCountMap = new HashMap(); + int availableRange = isPublic ? 1 : 0; + //统计数据集数量 + Dataset dataset = new Dataset(); + dataset.setAvailableRange(availableRange); + Integer datasetCount = (int) this.datasetDao.count(dataset); + assetCountMap.put("dataset", datasetCount); + //统计模型数量 + Models models = new Models(); + models.setAvailableRange(availableRange); + Integer modelCount = (int) this.modelsDao.count(models); + assetCountMap.put("model", modelCount); + //统计镜像数量 + Image image = new Image(); + image.setImageType(availableRange); + Integer imageCount = (int) this.imageDao.count(image); + assetCountMap.put("image", imageCount); + //统计组件数量 + Component component = new Component(); + Integer componentCount = (int) this.componentDao.count(component); + assetCountMap.put("component", componentCount); + //统计流水线数量 + Workflow workflow = new Workflow(); + Integer workflowCount = (int) this.workflowDao.count(workflow); + assetCountMap.put("workflow", workflowCount); + + return assetCountMap; + } + + }