package com.ruoyi.platform.service;

import com.ruoyi.platform.domain.ExperimentIns;
import com.ruoyi.platform.vo.LogRequestVo;
import com.ruoyi.platform.vo.PodLogVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * (ExperimentIns)表服务接口
 *
 * @author makejava
 * @since 2023-11-07 15:08:23
 */
public interface ExperimentInsService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    ExperimentIns queryById(Integer id) throws IOException;



    /**
     * 根据实验ID查找所有具有相同ID的实例，并将它们添加到实验列表中
     *
     * @param experimentId 实验id，不是实验实例id
     * @return 实例列表
     */
    List<ExperimentIns> getByExperimentId(Integer experimentId) throws IOException;

    /**
     * 分页查询
     *
     * @param experimentIns 筛选条件
     * @param pageRequest   分页对象
     * @return 查询结果
     */
    Page<ExperimentIns> queryByPage(ExperimentIns experimentIns, PageRequest pageRequest) throws IOException;

    /**
     * 新增数据
     *
     * @param experimentIns 实例对象
     * @return 实例对象
     */
    ExperimentIns insert(ExperimentIns experimentIns);

    /**
     * 修改数据
     *
     * @param experimentIns 实例对象
     * @return 实例对象
     */
    ExperimentIns update(ExperimentIns experimentIns) throws IOException;



    /**
     * 逻辑删除数据
     */
    String removeById(Integer id);
    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */

    String batchDelete(List<Integer> ids);

    boolean deleteById(Integer id);


    List<ExperimentIns> queryByExperimentId(Integer id);


    ExperimentIns queryStatusFromArgo(ExperimentIns ins);

    boolean terminateExperimentIns(Integer id) throws Exception;

    /**
     * 查询实验实例日志
     *
     * @return 运行日志
     */
    String showExperimentInsLog(Integer id, String componentId);

    List getNodeResult(Integer id, String nodeId) throws Exception;

    Map<String, Object> getRealtimeWorkflowLog(LogRequestVo logRequest);

    Map<String, Object> getRealtimePodLog(String podName, String startTime);

    String getRealtimePodLogFromPod(PodLogVo podLogVo);

    /**
     * 查询非终止态的实例
     *
     */
    List<ExperimentIns> queryByExperimentIsNotTerminated();

    Map<String, Long> countByStatus();

    void updateExperimentStatus(Integer experimentId);
}
