Browse Source

Merge branch 'dev' of https://gitlink.org.cn/ci4s/ci4sManagement-cloud into mybranch

tags/v20240126^2
YaHoo94 2 years ago
parent
commit
f6e6d75a8a
3 changed files with 50 additions and 11 deletions
  1. +8
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/Experiment.java
  2. +20
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  3. +22
    -9
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml

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

@@ -33,6 +33,8 @@ public class Experiment implements Serializable {
*/
@ApiModelProperty(name = "global_param")
private String globalParam;

private String statusList;
/**
* 简介
*/
@@ -100,7 +102,13 @@ public class Experiment implements Serializable {
this.globalParam = globalParam;
}

public String getStatusList() {
return statusList;
}

public void setStatusList(String statusList) {
this.statusList = statusList;
}

public String getCreateBy() {
return createBy;


+ 20
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java View File

@@ -1,6 +1,7 @@
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;
@@ -80,13 +81,17 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
@Override
public List<ExperimentIns> getByExperimentId(Integer experimentId) throws IOException {
List<ExperimentIns> experimentInsList = experimentInsDao.getByExperimentId(experimentId);

//搞个标记,当状态改变才去改表
boolean flag = false;
List<ExperimentIns> result = new ArrayList<ExperimentIns>();
if (experimentInsList!=null&&experimentInsList.size()>0) {
for (ExperimentIns experimentIns : experimentInsList) {
//当原本状态为null或非终止态时才调用argo接口
if (experimentIns != null && (StringUtils.isEmpty(experimentIns.getStatus())) || !isTerminatedState(experimentIns)) {
experimentIns = this.queryStatusFromArgo(experimentIns);
if (!flag){
flag = true;
}
//只有当新状态是终止态时才更新数据库
if (isTerminatedState(experimentIns)) {
//同时更新各个节点
@@ -97,6 +102,17 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
}
}

if (flag) {
List<String> statusList = new ArrayList<String>();
// 更新实验状态列表
for (int i=0;i<result.size();i++){
statusList.add(result.get(i).getStatus());
}
Experiment experiment = experimentDao.queryById(experimentId);
experiment.setStatusList(statusList.toString().substring(1, statusList.toString().length()-1));
experimentDao.update(experiment);
}

return result;

}
@@ -267,7 +283,9 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
if (!StringUtils.equals(experimentIns.getStatus(),"Terminated")) {
experimentIns.setStatus(StringUtils.isNotEmpty((String) status.get("phase"))?(String) status.get("phase"):"Pending");
}

if (StringUtils.equals(experimentIns.getStatus(),"Error")) {
experimentIns.setStatus("Failed");
}

return experimentIns;



+ 22
- 9
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ExperimentDaoMapper.xml View File

@@ -7,6 +7,7 @@
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="workflowId" column="workflow_id" jdbcType="INTEGER"/>
<result property="globalParam" column="global_param" jdbcType="VARCHAR"/>
<result property="statusList" column="status_list" jdbcType="VARCHAR"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@@ -18,7 +19,7 @@
<!--查询单个-->
<select id="queryById" resultMap="ExperimentMap">
select
id, name,workflow_id, global_param, description, create_by, create_time, update_by, update_time, state
id, name,workflow_id, global_param, status_list,status_list, description, create_by, create_time, update_by, update_time, state
from experiment
where id = #{id} and state = 1
</select>
@@ -26,7 +27,7 @@
<!--根据experiment查询-->
<select id="queryByExperiment" resultMap="ExperimentMap">
select
id,name, workflow_id, global_param, description, create_by, create_time, update_by, update_time, state
id,name, workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state
from experiment
<where>
state = 1
@@ -42,6 +43,9 @@
<if test="experiment.globalParam != null and experiment.globalParam != ''">
and global_param = #{experiment.globalParam}
</if>
<if test="experiment.statusList != null and experiment.statusList != ''">
status_list = #{experiment.statusList},
</if>
<if test="experiment.description != null and experiment.description != ''">
and description = #{experiment.description}
</if>
@@ -63,7 +67,7 @@
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="ExperimentMap">
select
id,name, workflow_id, global_param, description, create_by, create_time, update_by, update_time, state
id,name, workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state
from experiment
<where>
state = 1
@@ -79,6 +83,9 @@
<if test="experiment.globalParam != null and experiment.globalParam != ''">
and global_param = #{experiment.globalParam}
</if>
<if test="experiment.statusList != null and experiment.statusList != ''">
status_list = #{experiment.statusList},
</if>
<if test="experiment.description != null and experiment.description != ''">
and description = #{experiment.description}
</if>
@@ -117,6 +124,9 @@
<if test="experiment.globalParam != null and experiment.globalParam != ''">
and global_param = #{experiment.globalParam}
</if>
<if test="experiment.statusList != null and experiment.statusList != ''">
status_list = #{experiment.statusList},
</if>
<if test="experiment.description != null and experiment.description != ''">
and description = #{experiment.description}
</if>
@@ -137,24 +147,24 @@

<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into experiment(name,workflow_id, global_param, description, create_by, create_time, update_by, update_time, state)
values (#{name},#{workflowId}, #{globalParam}, #{description}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{state})
insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state)
values (#{name},#{workflowId}, #{globalParam},#{statusList}, #{description}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{state})
</insert>

<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into experiment(name,workflow_id, global_param, description, create_by, create_time, update_by, update_time, state)
insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.workflowId}, #{entity.globalParam}, #{entity.description}, #{entity.createBy}, #{entity.createTime},
(#{entity.name},#{entity.workflowId}, #{entity.globalParam},#{entity.statusList}, #{entity.description}, #{entity.createBy}, #{entity.createTime},
#{entity.updateBy}, #{entity.updateTime}, #{entity.state})
</foreach>
</insert>

<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into experiment(name,workflow_id, global_param, description, create_by, create_time, update_by, update_time, state)
insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name},#{entity.workflowId}, #{entity.globalParam}, #{entity.description}, #{entity.createBy}, #{entity.createTime},
(#{entity.name},#{entity.workflowId}, #{entity.globalParam}, #{entity.statusList}, #{entity.description}, #{entity.createBy}, #{entity.createTime},
#{entity.updateBy}, #{entity.updateTime}, #{entity.state})
</foreach>
on duplicate key update
@@ -182,6 +192,9 @@
<if test="globalParam != null and globalParam != ''">
global_param = #{globalParam},
</if>
<if test="statusList != null and statusList != ''">
status_list = #{statusList},
</if>
<if test="description != null and description != ''">
description = #{description},
</if>


Loading…
Cancel
Save