Browse Source

流水线模板优化

dev-opt-homepage
chenzhihang 1 year ago
parent
commit
530cfdf324
12 changed files with 191 additions and 425 deletions
  1. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java
  2. +14
    -18
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java
  3. +7
    -172
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Component.java
  4. +0
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java
  5. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java
  6. +6
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java
  7. +41
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java
  8. +6
    -4
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  9. +40
    -35
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java
  10. +11
    -173
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ComponentVo.java
  11. +48
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/WorkflowVo.java
  12. +16
    -16
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ComponentDaoMapper.xml

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentController.java View File

@@ -40,7 +40,7 @@ public class ExperimentController extends BaseController {
*/
@GetMapping
@ApiOperation("分页查询")
public GenericsAjaxResult<Page<Experiment>> queryByPage(Experiment experiment, int page, int size) {
public GenericsAjaxResult<Page<Experiment>> queryByPage(Experiment experiment, int page, int size) throws IOException {
PageRequest pageRequest = PageRequest.of(page,size);
return genericsSuccess(this.experimentService.queryByPage(experiment, pageRequest));
}


+ 14
- 18
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/workflow/WorkflowController.java View File

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.platform.domain.Workflow;
import com.ruoyi.platform.service.WorkflowService;
import com.ruoyi.platform.vo.WorkflowVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
@@ -11,6 +12,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
* DAG workflow(Workflow)表控制层
@@ -24,9 +26,6 @@ import javax.annotation.Resource;
public class WorkflowController extends BaseController {





/**
* 服务对象
*/
@@ -36,14 +35,14 @@ public class WorkflowController extends BaseController {
/**
* 分页查询
*
* @param workflow 筛选条件
* @param workflow 筛选条件
* @return 查询结果
*/
@GetMapping
@ApiOperation("分页查询")
public GenericsAjaxResult<Page<Workflow>> queryByPage(Workflow workflow, int page, int size) {
PageRequest pageRequest = PageRequest.of(page,size);
return genericsSuccess(this.workflowService.queryByPage(workflow, pageRequest));
PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.workflowService.queryByPage(workflow, pageRequest));
}


@@ -56,7 +55,7 @@ public class WorkflowController extends BaseController {
@GetMapping("name/{name}")
@ApiOperation("按流水线名字模糊查询流水线")
public GenericsAjaxResult<Page<Workflow>> queryByName(@PathVariable("name") String name) {
return genericsSuccess(this.workflowService.queryByName(name));
return genericsSuccess(this.workflowService.queryByName(name));
}

/**
@@ -67,8 +66,8 @@ public class WorkflowController extends BaseController {
*/
@GetMapping("{id}")
@ApiOperation("根据id查询单条数据")
public GenericsAjaxResult<Workflow> queryById(@PathVariable("id") Long id) {
return genericsSuccess(this.workflowService.queryById(id));
public GenericsAjaxResult<WorkflowVo> queryById(@PathVariable("id") Long id) throws IOException {
return genericsSuccess(this.workflowService.queryById(id));
}

/**
@@ -80,7 +79,7 @@ public class WorkflowController extends BaseController {
@PostMapping
@ApiOperation("新增流水线")
public GenericsAjaxResult<Workflow> add(@RequestBody Workflow workflow) throws Exception {
return genericsSuccess(this.workflowService.insert(workflow));
return genericsSuccess(this.workflowService.insert(workflow));
}


@@ -92,8 +91,8 @@ public class WorkflowController extends BaseController {
*/
@ApiOperation("复制流水线记录")
@PostMapping("duplicate/{id}")
public GenericsAjaxResult<Workflow> duplicateWorkflow(@PathVariable("id") Long id) {
return genericsSuccess(this.workflowService.duplicateWorkflow(id));
public GenericsAjaxResult<Workflow> duplicateWorkflow(@PathVariable("id") Long id) throws IOException {
return genericsSuccess(this.workflowService.duplicateWorkflow(id));
}

/**
@@ -116,14 +115,11 @@ public class WorkflowController extends BaseController {
*/
@PutMapping
@ApiOperation("编辑流水线")
public GenericsAjaxResult<Workflow> edit(@RequestBody Workflow workflow) throws Exception {
return genericsSuccess(this.workflowService.update(workflow));
public GenericsAjaxResult<WorkflowVo> edit(@RequestBody WorkflowVo workflowVo) throws Exception {
return genericsSuccess(this.workflowService.update(workflowVo));
}

/**
*
*
*
* 删除数据
*
* @param id 主键
@@ -132,7 +128,7 @@ public class WorkflowController extends BaseController {
@DeleteMapping("{id}")
@ApiOperation("删除流水线")
public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) throws Exception {
return genericsSuccess(this.workflowService.removeById(id));
return genericsSuccess(this.workflowService.removeById(id));
}

}


+ 7
- 172
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Component.java View File

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
@@ -16,6 +17,7 @@ import java.util.Date;
* @since 2023-12-14 11:17:00
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@Data
public class Component implements Serializable {
private static final long serialVersionUID = -56592844039218605L;
/**
@@ -43,7 +45,7 @@ public class Component implements Serializable {
*/
@JsonProperty("image")
@ApiModelProperty(name = "image" ,value = "镜像")
private String images;
private String image;
/**
* 工作目录
*/
@@ -54,6 +56,10 @@ public class Component implements Serializable {
*/
@ApiModelProperty(name = "command" , value = "启动命令")
private String command;

@ApiModelProperty(name = "run_args" , value = "启动命令")
private String runArgs;

/**
* 环境变量
*/
@@ -135,175 +141,4 @@ public class Component implements Serializable {
*/
@ApiModelProperty(name = "state" , value = "状态")
private Integer state;



public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getCategoryId() {
return categoryId;
}

public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}

public String getComponentName() {
return componentName;
}

public void setComponentName(String componentName) {
this.componentName = componentName;
}

public String getComponentLabel() {
return componentLabel;
}

public void setComponentLabel(String componentLabel) {
this.componentLabel = componentLabel;
}

public String getImages() {
return images;
}

public void setImages(String images) {
this.images = images;
}

public String getWorkingDirectory() {
return workingDirectory;
}

public void setWorkingDirectory(String workingDirectory) {
this.workingDirectory = workingDirectory;
}

public String getCommand() {
return command;
}

public void setCommand(String command) {
this.command = command;
}

public String getEnvVirables() {
return envVirables;
}

public void setEnvVirables(String envVirables) {
this.envVirables = envVirables;
}

public String getResourcesStandard() {
return resourcesStandard;
}

public void setResourcesStandard(String resourcesStandard) {
this.resourcesStandard = resourcesStandard;
}

public String getControlStrategy() {
return controlStrategy;
}

public void setControlStrategy(String controlStrategy) {
this.controlStrategy = controlStrategy;
}

public String getMountPath() {
return mountPath;
}

public void setMountPath(String mountPath) {
this.mountPath = mountPath;
}

public String getInParameters() {
return inParameters;
}

public void setInParameters(String inParameters) {
this.inParameters = inParameters;
}

public String getOutParameters() {
return outParameters;
}

public void setOutParameters(String outParameters) {
this.outParameters = outParameters;
}

public int getAvailableRange() {
return availableRange;
}

public void setAvailableRange(int availableRange) {
this.availableRange = availableRange;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}


public String getIconPath() {
return iconPath;
}

public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}

public String getCreateBy() {
return createBy;
}

public void setCreateBy(String createBy) {
this.createBy = createBy;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public String getUpdateBy() {
return updateBy;
}

public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}

public Date getUpdateTime() {
return updateTime;
}

public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}

public Integer getState() {
return state;
}

public void setState(Integer state) {
this.state = state;
}
}

+ 0
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Workflow.java View File

@@ -21,7 +21,6 @@ import java.util.Date;
* @author makejava
* @since 2023-10-18 14:17:10
*/
@Component
@Table(name = "workflow")
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@ApiModel("流水线对象")


+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentService.java View File

@@ -32,7 +32,7 @@ public interface ExperimentService {
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<Experiment> queryByPage(Experiment experiment, PageRequest pageRequest);
Page<Experiment> queryByPage(Experiment experiment, PageRequest pageRequest) throws IOException;

/**
* 新增数据


+ 6
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/WorkflowService.java View File

@@ -3,9 +3,12 @@ package com.ruoyi.platform.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.platform.domain.Dataset;
import com.ruoyi.platform.domain.Workflow;
import com.ruoyi.platform.vo.WorkflowVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import java.io.IOException;

/**
* DAG workflow(Workflow)表服务接口
*
@@ -20,7 +23,7 @@ public interface WorkflowService {
* @param id 主键
* @return 实例对象
*/
Workflow queryById(Long id);
WorkflowVo queryById(Long id) throws IOException;

/**
* 分页查询
@@ -45,7 +48,7 @@ public interface WorkflowService {
* @param workflow 实例对象
* @return 实例对象
*/
Workflow update(Workflow workflow) throws Exception;
WorkflowVo update(WorkflowVo workflowVo) throws Exception;

/**
* 通过主键删除数据
@@ -62,7 +65,7 @@ public interface WorkflowService {
*/
Page<Workflow> queryByName(String name);

Workflow duplicateWorkflow(Long id);
Workflow duplicateWorkflow(Long id) throws IOException;

void checkDeclaredName(Workflow insert) throws Exception;



+ 41
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ComponentServiceImpl.java View File

@@ -7,11 +7,13 @@ import com.ruoyi.platform.domain.Component;
import com.ruoyi.platform.service.ComponentService;
import com.ruoyi.platform.mapper.ComponentDao;
import com.ruoyi.platform.utils.ConvertUtil;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.vo.ComponentVo;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.domain.SysDictData;
import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
@@ -72,7 +74,45 @@ public class ComponentServiceImpl implements ComponentService {
Map map = new HashMap();
map.put("key", entry.getKey());
map.put("name", categorys.get(0).getDictLabel());
map.put("value", entry.getValue());

List<ComponentVo> componentVos = new ArrayList<>();

for (Component component : entry.getValue()) {
ComponentVo componentVo = new ComponentVo();
BeanUtils.copyProperties(component, componentVo);

Map<String, Object> taskInfo = new HashMap<>();
if (StringUtils.isNotEmpty(component.getImage())) {
taskInfo.put("image", JsonUtils.jsonToMap(component.getImage()));
}
if (StringUtils.isNotEmpty(component.getWorkingDirectory())) {
taskInfo.put("working_directory", JsonUtils.jsonToMap(component.getWorkingDirectory()));
}
if (StringUtils.isNotEmpty(component.getCommand())) {
taskInfo.put("command", JsonUtils.jsonToMap(component.getCommand()));
}
if (StringUtils.isNotEmpty(component.getRunArgs())) {
taskInfo.put("run_args", JsonUtils.jsonToMap(component.getRunArgs()));
}
if (StringUtils.isNotEmpty(component.getResourcesStandard())) {
taskInfo.put("resources_standard", JsonUtils.jsonToMap(component.getResourcesStandard()));
}
componentVo.setTaskInfo(taskInfo);
if (StringUtils.isNotEmpty(component.getEnvVirables())) {
componentVo.setEnvVirables(JsonUtils.jsonToMap(component.getEnvVirables()));
}
if (StringUtils.isNotEmpty(component.getControlStrategy())) {
componentVo.setControlStrategy(JsonUtils.jsonToMap(component.getControlStrategy()));
}
if (StringUtils.isNotEmpty(component.getInParameters())) {
componentVo.setInParameters(JsonUtils.jsonToMap(component.getInParameters()));
}
if (StringUtils.isNotEmpty(component.getOutParameters())) {
componentVo.setOutParameters(JsonUtils.jsonToMap(component.getOutParameters()));
}
componentVos.add(componentVo);
}
map.put("value", componentVos);
result.add(map);
}
return result;


+ 6
- 4
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java View File

@@ -17,6 +17,7 @@ import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.utils.YamlUtils;
import com.ruoyi.platform.vo.ModelsVo;
import com.ruoyi.platform.vo.NewDatasetVo;
import com.ruoyi.platform.vo.WorkflowVo;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.collections4.MapUtils;
@@ -102,13 +103,13 @@ public class ExperimentServiceImpl implements ExperimentService {
* @return 查询结果
*/
@Override
public Page<Experiment> queryByPage(Experiment experiment, PageRequest pageRequest) {
public Page<Experiment> queryByPage(Experiment experiment, PageRequest pageRequest) throws IOException {
List<Experiment> experimentList = this.experimentDao.queryAllByLimit(experiment, pageRequest);
long total = this.experimentDao.count(experiment);
// 存储所有实验的ID列表,查询实验对应的流水线
for (Experiment exp : experimentList) {
Long workflowId = exp.getWorkflowId();
Workflow correspondingWorkflow = this.workflowService.queryById(workflowId);
WorkflowVo correspondingWorkflow = this.workflowService.queryById(workflowId);
String workflowName = correspondingWorkflow.getName();
exp.setWorkflowName(workflowName);
}
@@ -221,12 +222,13 @@ public class ExperimentServiceImpl implements ExperimentService {
if (experiment == null) {
System.out.println("No experiment");
}
Workflow workflow = workflowService.queryById(experiment.getWorkflowId());
WorkflowVo workflow = workflowService.queryById(experiment.getWorkflowId());
if (workflow == null) {
throw new RuntimeException("流水线不存在,请先创建流水线");
}

String dag = workflow.getDag();
String dag = JsonUtils.mapToJson(workflow.getDag());

// 调argo转换接口
try {
String convertRes = HttpUtils.sendPost(argoUrl + argoConvert, dag);


+ 40
- 35
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java View File

@@ -12,11 +12,14 @@ import com.ruoyi.platform.mapper.WorkflowDao;
import com.ruoyi.platform.service.ExperimentService;
import com.ruoyi.platform.service.WorkflowService;
import com.ruoyi.platform.utils.HttpUtils;
import com.ruoyi.platform.utils.JacksonUtil;
import com.ruoyi.platform.utils.JsonUtils;
import com.ruoyi.platform.utils.MinioUtil;
import com.ruoyi.platform.vo.WorkflowVo;
import com.ruoyi.system.api.constant.Constant;
import com.ruoyi.system.api.model.LoginUser;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@@ -66,8 +69,15 @@ public class WorkflowServiceImpl implements WorkflowService {
* @return 实例对象
*/
@Override
public Workflow queryById(Long id) {
return this.workflowDao.queryById(id);
public WorkflowVo queryById(Long id) throws IOException {
Workflow workflow = this.workflowDao.queryById(id);
WorkflowVo workflowVo = new WorkflowVo();
BeanUtils.copyProperties(workflow, workflowVo);
if (StringUtils.isNotEmpty(workflow.getDag())) {
workflowVo.setDag(JsonUtils.jsonToMap(workflow.getDag()));
}
workflowVo.setGlobalParam(JacksonUtil.parseJSONStr2MapList(workflow.getGlobalParam()));
return workflowVo;
}

public WorkflowDao getWorkflowDao() {
@@ -118,7 +128,11 @@ public class WorkflowServiceImpl implements WorkflowService {
* @return 实例对象
*/
@Override
public Workflow update(Workflow workflow) throws Exception {
public WorkflowVo update(WorkflowVo workflowVo) throws Exception {
Workflow workflow = new Workflow();
BeanUtils.copyProperties(workflowVo, workflow);
workflow.setDag(JacksonUtil.toJSONString(workflowVo.getDag()));
workflow.setGlobalParam(JsonUtils.objectToJson(workflowVo.getGlobalParam()));
LoginUser loginUser = SecurityUtils.getLoginUser();
checkDeclaredName(workflow);
workflow.setUpdateBy(loginUser.getUsername());
@@ -175,9 +189,9 @@ public class WorkflowServiceImpl implements WorkflowService {


@Override
public Workflow duplicateWorkflow(Long id) {
public Workflow duplicateWorkflow(Long id) throws IOException {
//先去查找数据库中存在的数据
Workflow workflow = this.queryById(id);
WorkflowVo workflow = this.queryById(id);
if (workflow != null) {
try {
Workflow duplicateWorkflow = new Workflow();
@@ -187,7 +201,7 @@ public class WorkflowServiceImpl implements WorkflowService {
throw new RuntimeException("流水线名称大于最大长度");
}

String oldDag = workflow.getDag();
String oldDag = JsonUtils.mapToJson(workflow.getDag());
// 创建请求数据的Json(map)
Map<String, Object> requestData = new HashMap<>();
requestData.put("data", oldDag);
@@ -206,7 +220,7 @@ public class WorkflowServiceImpl implements WorkflowService {
}
duplicateWorkflow.setDag(newDag);
duplicateWorkflow.setDescription(workflow.getDescription());
duplicateWorkflow.setGlobalParam(workflow.getGlobalParam());
duplicateWorkflow.setGlobalParam(JsonUtils.objectToJson(workflow.getGlobalParam()));
return this.insert(duplicateWorkflow);
} catch (Exception e) {
throw new RuntimeException("复制流水线失败: " + e.getMessage(), e);
@@ -322,7 +336,12 @@ public class WorkflowServiceImpl implements WorkflowService {

public void saveImageWorkFlow(Map<String, Object> image, Long workflowId, String workflowName) throws Exception {
try {
String imageUrl = (String) image.get("url");
String imageUrl;
if (StringUtils.isNotEmpty((String) image.get("default"))) {
imageUrl = (String) image.get("default");
} else {
imageUrl = (String) image.get("showValue");
}
String[] imageSplit = imageUrl.split(":");
String tagName = imageSplit[1];
ImageVersion imageVersion = imageVersionDao.queryByUrl(imageUrl);
@@ -342,24 +361,16 @@ public class WorkflowServiceImpl implements WorkflowService {
}

public void saveCodeWorkFlow(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> code_config = (Map<String, Object>) inParameters.get("--code_config");
String value = (String) code_config.get("value");
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) valueMap.get("id")), null, Constant.Asset_Type_Code);
} catch (IOException e) {
throw new Exception("代码配置参数有误:" + e);
}
Map<String, Object> code_config = (Map<String, Object>) inParameters.get("--code_config");
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) code_config.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), null, Constant.Asset_Type_Code);
}

public void saveDatasetWorkFlow(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> dataset = (Map<String, Object>) inParameters.get("--dataset");
String value = (String) dataset.get("value");
if (!value.startsWith("{{")) {
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((String) valueMap.get("id")), (String) valueMap.get("version"), Constant.Asset_Type_Dataset);
}
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) dataset.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), (String) value.get("version"), Constant.Asset_Type_Dataset);
} catch (Exception e) {
throw new Exception("数据集参数有误:" + e);
}
@@ -368,9 +379,8 @@ public class WorkflowServiceImpl implements WorkflowService {
public void saveDatasetWorkFlow1(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> dataset = (Map<String, Object>) inParameters.get("--dataset_id");
String value = (String) dataset.get("value");
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((String) valueMap.get("id")), null, Constant.Asset_Type_Dataset);
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) dataset.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), null, Constant.Asset_Type_Dataset);
} catch (Exception e) {
throw new Exception("数据集参数有误:" + e);
}
@@ -379,11 +389,8 @@ public class WorkflowServiceImpl implements WorkflowService {
public void saveModelWorkFlow(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> model = (Map<String, Object>) inParameters.get("--model_name");
String value = (String) model.get("value");
if (StringUtils.isNotEmpty(value) && !value.startsWith("{{")) {
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((String) valueMap.get("id")), (String) valueMap.get("version"), Constant.Asset_Type_Model);
}
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) model.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), (String) value.get("version"), Constant.Asset_Type_Model);
} catch (Exception e) {
throw new Exception("模型参数有误:" + e);
}
@@ -392,9 +399,8 @@ public class WorkflowServiceImpl implements WorkflowService {
public void saveModelWorkFlow1(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> model = (Map<String, Object>) inParameters.get("--model_id");
String value = (String) model.get("value");
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((String) valueMap.get("id")), null, Constant.Asset_Type_Model);
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) model.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), null, Constant.Asset_Type_Model);
} catch (Exception e) {
throw new Exception("模型参数有误:" + e);
}
@@ -403,9 +409,8 @@ public class WorkflowServiceImpl implements WorkflowService {
public void saveServiceWorkFlow(Map<String, Object> inParameters, Long workflowId, String workflowName) throws Exception {
try {
Map<String, Object> service = (Map<String, Object>) inParameters.get("--service_name");
String value = (String) service.get("value");
Map<String, Object> valueMap = JsonUtils.jsonToMap(value);
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) valueMap.get("id")), null, Constant.Asset_Type_Service);
LinkedHashMap<String, Object> value = (LinkedHashMap<String, Object>) service.get("value");
insertAssetWorkFlow(workflowId, workflowName, Long.valueOf((Integer) value.get("id")), null, Constant.Asset_Type_Service);
} catch (Exception e) {
throw new Exception("服务参数有误:" + e);
}


+ 11
- 173
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ComponentVo.java View File

@@ -3,11 +3,14 @@ package com.ruoyi.platform.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@Data
public class ComponentVo implements Serializable {
private static final long serialVersionUID = -56592844039218605L;
/**
@@ -26,32 +29,17 @@ public class ComponentVo implements Serializable {
* 组件面板名
*/
private String componentLabel;
/**
* 镜像
*/
@JsonProperty("image")
private String images;
/**
* 工作目录
*/
private String workingDirectory;
/**
* 启动命令
*/
private String command;

private Map<String, Object> taskInfo;

/**
* 环境变量
*/
@JsonProperty("env_variables")
private Object envVirables;
/**
* 资源规格
*/
private String resourcesStandard;
private Map<String, Object> envVirables;
/**
* 控制策略
*/
private String controlStrategy;
private Map<String, Object> controlStrategy;
/**
* 挂载路径
*/
@@ -59,11 +47,11 @@ public class ComponentVo implements Serializable {
/**
* 输入参数
*/
private Object inParameters;
private Map<String, Object> inParameters;
/**
* 输出参数
*/
private Object outParameters;
private Map<String, Object> outParameters;
/**
* 描述
*/
@@ -89,155 +77,5 @@ public class ComponentVo implements Serializable {
*/
private Integer state;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getCategoryId() {
return categoryId;
}

public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}

public String getComponentName() {
return componentName;
}

public void setComponentName(String componentName) {
this.componentName = componentName;
}

public String getComponentLabel() {
return componentLabel;
}

public void setComponentLabel(String componentLabel) {
this.componentLabel = componentLabel;
}

public String getImages() {
return images;
}

public void setImages(String images) {
this.images = images;
}

public String getWorkingDirectory() {
return workingDirectory;
}

public void setWorkingDirectory(String workingDirectory) {
this.workingDirectory = workingDirectory;
}

public String getCommand() {
return command;
}

public void setCommand(String command) {
this.command = command;
}

public Object getEnvVirables() {
return envVirables;
}

public void setEnvVirables(Object envVirables) {
this.envVirables = envVirables;
}

public String getResourcesStandard() {
return resourcesStandard;
}

public void setResourcesStandard(String resourcesStandard) {
this.resourcesStandard = resourcesStandard;
}

public String getControlStrategy() {
return controlStrategy;
}

public void setControlStrategy(String controlStrategy) {
this.controlStrategy = controlStrategy;
}

public String getMountPath() {
return mountPath;
}

public void setMountPath(String mountPath) {
this.mountPath = mountPath;
}

public Object getInParameters() {
return inParameters;
}

public void setInParameters(Object inParameters) {
this.inParameters = inParameters;
}

public Object getOutParameters() {
return outParameters;
}

public void setOutParameters(Object outParameters) {
this.outParameters = outParameters;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getCreateBy() {
return createBy;
}

public void setCreateBy(String createBy) {
this.createBy = createBy;
}

public Date getCreateTime() {
return createTime;
}

public void setCreateTime(Date createTime) {
this.createTime = createTime;
}

public String getUpdateBy() {
return updateBy;
}

public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}

public Date getUpdateTime() {
return updateTime;
}

public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}

public Integer getState() {
return state;
}

public void setState(Integer state) {
this.state = state;
}
private String iconPath;
}

+ 48
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/WorkflowVo.java View File

@@ -0,0 +1,48 @@
package com.ruoyi.platform.vo;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.ruoyi.platform.annotations.CheckDuplicate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@ApiModel("流水线对象")
public class WorkflowVo {
@ApiModelProperty(value = "ID")
private Long id;

@ApiModelProperty(value = "工作流名称")
@CheckDuplicate
private String name;

@ApiModelProperty(value = "流水线描述")
private String description;

@ApiModelProperty(value = "DAG图")
private Map<String, Object> dag;

@ApiModelProperty(value = "全局参数")
private List<Map<String, Object>> globalParam;

@ApiModelProperty(value = "创建者")
private String createBy;

@ApiModelProperty(value = "创建时间")
private Date createTime;

@ApiModelProperty(value = "更新者")
private String updateBy;

@ApiModelProperty(value = "更新时间")
private Date updateTime;

@ApiModelProperty(value = "状态,0失效,1生效")
private Integer state;
}

+ 16
- 16
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ComponentDaoMapper.xml View File

@@ -7,7 +7,7 @@
<result property="categoryId" column="category_id" jdbcType="INTEGER"/>
<result property="componentName" column="component_name" jdbcType="VARCHAR"/>
<result property="componentLabel" column="component_label" jdbcType="VARCHAR"/>
<result property="images" column="images" jdbcType="VARCHAR"/>
<result property="image" column="image" jdbcType="VARCHAR"/>
<result property="workingDirectory" column="working_directory" jdbcType="VARCHAR"/>
<result property="command" column="command" jdbcType="VARCHAR"/>
<result property="envVirables" column="env_virables" jdbcType="VARCHAR"/>
@@ -29,7 +29,7 @@
<!--查询单个-->
<select id="queryById" resultMap="ComponentMap">
select
id,category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state
id,category_id,component_name,component_Label,image,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state
from component
where id = #{id} and state = 1
</select>
@@ -43,7 +43,7 @@
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="ComponentMap">
select
id,category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state
id,category_id,component_name,component_Label,image,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state
from component
<where>
state = 1
@@ -59,8 +59,8 @@
<if test="component.componentLabel != null and component.componentLabel != ''">
and component_label = #{component.componentLabel}
</if>
<if test="component.images != null and component.images != ''">
and images = #{component.images}
<if test="component.image != null and component.image != ''">
and image = #{component.image}
</if>
<if test="component.workingDirectory != null and component.workingDirectory != ''">
and working_directory = #{component.workingDirectory}
@@ -132,8 +132,8 @@
<if test="component.componentLabel != null and component.componentLabel != ''">
and component_label = #{component.componentLabel}
</if>
<if test="component.images != null and component.images != ''">
and images = #{component.images}
<if test="component.image != null and component.image != ''">
and image = #{component.image}
</if>
<if test="component.workingDirectory != null and component.workingDirectory != ''">
and working_directory = #{component.workingDirectory}
@@ -197,26 +197,26 @@

<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into component(category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
values (#{component.categoryId},#{component.componentName},#{component.componentLabel},#{component.images},#{component.workingDirectory},#{component.command},#{component.envVirables},#{component.resourcesStandard},#{component.controlStrategy},#{component.mountPath},#{component.inParameters},#{component.outParameters},#{component.availableRange},#{component.description},#{component.iconPath},#{component.createBy},#{component.createTime},#{component.updateBy},#{component.updateTime},#{component.state})
insert into component(category_id,component_name,component_Label,image,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
values (#{component.categoryId},#{component.componentName},#{component.componentLabel},#{component.image},#{component.workingDirectory},#{component.command},#{component.envVirables},#{component.resourcesStandard},#{component.controlStrategy},#{component.mountPath},#{component.inParameters},#{component.outParameters},#{component.availableRange},#{component.description},#{component.iconPath},#{component.createBy},#{component.createTime},#{component.updateBy},#{component.updateTime},#{component.state})
</insert>

<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into component(category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
insert into component(category_id,component_name,component_Label,image,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.categoryId},#{entity.componentName},#{entity.componentLabel},#{entity.images},#{entity.workingDirectory},#{entity.command},#{entity.envVirables},#{entity.resourcesStandard},#{entity.controlStrategy},#{entity.mountPath},#{entity.inParameters},#{entity.outParameters},#{entity.availableRange},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
(#{entity.categoryId},#{entity.componentName},#{entity.componentLabel},#{entity.image},#{entity.workingDirectory},#{entity.command},#{entity.envVirables},#{entity.resourcesStandard},#{entity.controlStrategy},#{entity.mountPath},#{entity.inParameters},#{entity.outParameters},#{entity.availableRange},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
</foreach>
</insert>

<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into component(category_id,component_name,component_Label,images,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
insert into component(category_id,component_name,component_Label,image,working_directory,command,env_virables,resources_standard,control_strategy,mount_path,in_parameters,out_parameters,available_range,description,icon_path,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.categoryId},#{entity.componentName},#{entity.componentLabel},#{entity.images},#{entity.workingDirectory},#{entity.command},#{entity.envVirables},#{entity.resourcesStandard},#{entity.controlStrategy},#{entity.mountPath},#{entity.inParameters},#{entity.outParameters},#{entity.availableRange},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
(#{entity.categoryId},#{entity.componentName},#{entity.componentLabel},#{entity.image},#{entity.workingDirectory},#{entity.command},#{entity.envVirables},#{entity.resourcesStandard},#{entity.controlStrategy},#{entity.mountPath},#{entity.inParameters},#{entity.outParameters},#{entity.availableRange},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
</foreach>
on duplicate key update
category_id = values(category_id)component_name = values(component_name)component_id = values(component_id)images = values(images)working_directory = values(working_directory)command = values(command)env_virables = values(env_virables)resources_standard = values(resources_standard)control_strategy = values(control_strategy)mount_path = values(mount_path)in_parameters = values(in_parameters)out_parameters = values(out_parameters)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
category_id = values(category_id)component_name = values(component_name)component_id = values(component_id)image = values(image)working_directory = values(working_directory)command = values(command)env_virables = values(env_virables)resources_standard = values(resources_standard)control_strategy = values(control_strategy)mount_path = values(mount_path)in_parameters = values(in_parameters)out_parameters = values(out_parameters)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
</insert>

<!--通过主键修改数据-->
@@ -235,8 +235,8 @@ category_id = values(category_id)component_name = values(component_name)componen
<if test="component.componentLabel != null and component.componentLabel != ''">
component_label = #{component.componentLabel},
</if>
<if test="component.images != null and component.images != ''">
images = #{component.images},
<if test="component.image != null and component.image != ''">
image = #{component.image},
</if>
<if test="component.workingDirectory != null and component.workingDirectory != ''">
working_directory = #{component.workingDirectory},


Loading…
Cancel
Save