forked from ci4s/ci4sManagement
返回状态列表方法实现
This commit is contained in:
parent
0025f2fe30
commit
daff3a2dc6
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.platform.mapper;
|
||||
|
||||
import com.ruoyi.platform.entity.ExperimentIns;
|
||||
import com.ruoyi.platform.domain.ExperimentIns;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
|
|
@ -80,5 +80,13 @@ public interface ExperimentInsDao {
|
|||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据实验ID查找所有具有相同ID的实例,并将它们添加到实验列表中
|
||||
*
|
||||
* @param experimentId 实验ID
|
||||
* @return 实例列表
|
||||
*/
|
||||
List<ExperimentIns> getByExperimentId(Integer experimentId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.ruoyi.platform.service;
|
||||
|
||||
import com.ruoyi.platform.domain.ExperimentIns;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (ExperimentIns)表服务接口
|
||||
*
|
||||
|
|
@ -19,6 +22,16 @@ public interface ExperimentInsService {
|
|||
*/
|
||||
ExperimentIns queryById(Integer id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据实验ID查找所有具有相同ID的实例,并将它们添加到实验列表中
|
||||
*
|
||||
* @param experimentId 实验id,不是实例id
|
||||
* @return 实例列表
|
||||
*/
|
||||
List<ExperimentIns> getByExperimentId(Integer experimentId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public interface ExperimentService {
|
|||
|
||||
Experiment addAndRunExperiment(Experiment experiment);
|
||||
|
||||
String queryStatus(String namespace, String name);
|
||||
String queryStatusFromArgo(String namespace, String name);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.platform.service.impl;
|
||||
|
||||
import com.ruoyi.platform.domain.ExperimentIns;
|
||||
import com.ruoyi.platform.mapper.ExperimentInsDao;
|
||||
import com.ruoyi.platform.service.ExperimentInsService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
|
|
@ -7,6 +9,7 @@ import org.springframework.data.domain.PageRequest;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (ExperimentIns)表服务实现类
|
||||
|
|
@ -30,6 +33,17 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
|||
return this.experimentInsDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实验ID查找所有具有相同ID的实例,并将它们添加到实验列表中
|
||||
*
|
||||
* @param experimentId 实验ID
|
||||
* @return 实验列表
|
||||
*/
|
||||
@Override
|
||||
public List<ExperimentIns> getByExperimentId(Integer experimentId) {
|
||||
return experimentInsDao.getByExperimentId(experimentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.platform.service.impl;
|
||||
|
||||
import com.ruoyi.platform.domain.Experiment;
|
||||
import com.ruoyi.platform.domain.ExperimentIns;
|
||||
import com.ruoyi.platform.domain.Workflow;
|
||||
import com.ruoyi.platform.mapper.ExperimentDao;
|
||||
import com.ruoyi.platform.service.ExperimentInsService;
|
||||
|
|
@ -17,6 +18,7 @@ import org.springframework.data.domain.PageImpl;
|
|||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -72,13 +74,36 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
return new PageImpl<>(this.experimentDao.queryAllByLimit(experiment, pageRequest), pageRequest, total);
|
||||
}
|
||||
|
||||
public Page<Experiment> queryByPage(Experiment experiment, PageRequest pageRequest) {
|
||||
long total = this.experimentDao.count(experiment);
|
||||
List<Experiment> experimentList =this.experimentDao.queryAllByLimit(experiment, pageRequest);
|
||||
for (Experiment experiment1 : experimentList) {
|
||||
|
||||
/**
|
||||
* 分页查询实验状态
|
||||
*
|
||||
* @param experiment 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
public Page<Experiment> selectStatus(Experiment experiment, PageRequest pageRequest) {
|
||||
List<Experiment> experimentList = this.experimentDao.queryAllByLimit(experiment, pageRequest);
|
||||
|
||||
// 存储所有实验的ID列表
|
||||
List<Integer> experimentIds = new ArrayList<>();
|
||||
//对于每一个从Experiment表中查询出来的id,可能有多个实例,每个实例的实验id是不同的
|
||||
for (Experiment exp: experimentList) {
|
||||
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(exp.getId());
|
||||
for (ExperimentIns experimentIns: experimentInsList) {
|
||||
if (!(StringUtils.equals(experimentIns.getStatus(),"success") || StringUtils.equals(experimentIns.getStatus(),"failed"))) {
|
||||
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
||||
experimentIns.setStatus(status);
|
||||
this.experimentInsService.update(experimentIns);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
exp.setExperimentInsList(experimentInsList);
|
||||
}
|
||||
return new PageImpl<>(, pageRequest, total);
|
||||
|
||||
return new PageImpl<>(experimentList);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -189,16 +214,17 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String queryStatus(String namespace, String name) {
|
||||
String url = argoUrl + argoWorkflowStatus + "?namespace=" + namespace + "&name=" + name;
|
||||
String res = HttpUtils.sendGet();
|
||||
if (res == null || StringUtils.isEmpty(res)) {
|
||||
throw new RuntimeException("Failed to query workflow status.");
|
||||
}
|
||||
Map<String, Object> resMap = JsonUtils.jsonToMap(res);
|
||||
Map<String, Object> data = (Map<String, Object>) resMap.get("data");
|
||||
|
||||
Map<String, Object> metadata = (Map<String, Object>) data.get("metadata");
|
||||
return (String) metadata.get("status");
|
||||
public String queryStatusFromArgo(String namespace, String name) {
|
||||
// String url = argoUrl + argoWorkflowStatus + "?namespace=" + namespace + "&name=" + name;
|
||||
// //String res = HttpUtils.sendGet();
|
||||
// if (res == null || StringUtils.isEmpty(res)) {
|
||||
// throw new RuntimeException("Failed to query workflow status.");
|
||||
// }
|
||||
// Map<String, Object> resMap = JsonUtils.jsonToMap(res);
|
||||
// Map<String, Object> data = (Map<String, Object>) resMap.get("data");
|
||||
//
|
||||
// Map<String, Object> metadata = (Map<String, Object>) data.get("metadata");
|
||||
// return (String) metadata.get("status");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
<result property="state" column="state" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="ExperimentInsMap">
|
||||
select idexperiment_idargo_ins_nameargo_ins_nsstatuscreate_bycreate_timeupdate_byupdate_timestate
|
||||
|
|
@ -22,6 +26,13 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询列表-->
|
||||
<select id="getByExperimentId" resultMap="ExperimentInsMap">
|
||||
select id,experiment_id,argo_ins_name,argo_ins_ns,status,create_by,create_time,update_by,update_time,state
|
||||
from experiment_ins
|
||||
where experiment_id = #{experiment_id} order by create_time limit 5
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="ExperimentInsMap">
|
||||
select
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.web.controller.experiment;
|
||||
|
||||
import com.ruoyi.platform.domain.ExperimentIns;
|
||||
import com.ruoyi.platform.service.ExperimentInsService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
|
@ -46,6 +47,8 @@ public class ExperimentInsController {
|
|||
return ResponseEntity.ok(this.experimentInsService.queryById(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
package com.ruoyi.platform.dao;
|
||||
|
||||
import com.ruoyi.platform.entity.ExperimentIns;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (ExperimentIns)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-11-09 09:48:36
|
||||
*/
|
||||
public interface ExperimentInsDao {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
ExperimentIns queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param experimentIns 查询条件
|
||||
* @param pageable 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<ExperimentIns> queryAllByLimit(ExperimentIns experimentIns, @Param("pageable") Pageable pageable);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param experimentIns 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(ExperimentIns experimentIns);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param experimentIns 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(ExperimentIns experimentIns);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<ExperimentIns> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<ExperimentIns> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<ExperimentIns> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<ExperimentIns> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param experimentIns 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(ExperimentIns experimentIns);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
package com.ruoyi.platform.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (ExperimentIns)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-11-09 09:48:36
|
||||
*/
|
||||
public class ExperimentIns implements Serializable {
|
||||
private static final long serialVersionUID = 623464560240790680L;
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 实验ID
|
||||
*/
|
||||
private Integer experimentId;
|
||||
/**
|
||||
* argo返回name
|
||||
*/
|
||||
private String argoInsName;
|
||||
/**
|
||||
* argo返回命名空间
|
||||
*/
|
||||
private String argoInsNs;
|
||||
/**
|
||||
* 实例运行状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 0,失效 1生效
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getExperimentId() {
|
||||
return experimentId;
|
||||
}
|
||||
|
||||
public void setExperimentId(Integer experimentId) {
|
||||
this.experimentId = experimentId;
|
||||
}
|
||||
|
||||
public String getArgoInsName() {
|
||||
return argoInsName;
|
||||
}
|
||||
|
||||
public void setArgoInsName(String argoInsName) {
|
||||
this.argoInsName = argoInsName;
|
||||
}
|
||||
|
||||
public String getArgoInsNs() {
|
||||
return argoInsNs;
|
||||
}
|
||||
|
||||
public void setArgoInsNs(String argoInsNs) {
|
||||
this.argoInsNs = argoInsNs;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue