package com.xzzn.ems.mapper;

import java.util.List;
import com.xzzn.ems.domain.EmsStrategyRunning;
import com.xzzn.ems.domain.vo.StrategyRunningVo;
import org.apache.ibatis.annotations.Param;

/**
 * 策略运行Mapper接口
 *
 * @author xzzn
 * @date 2025-07-10
 */
public interface EmsStrategyRunningMapper
{
    /**
     * 查询策略运行
     *
     * @param id 策略运行主键
     * @return 策略运行
     */
    public EmsStrategyRunning selectEmsStrategyRunningById(Long id);

    /**
     * 查询策略运行列表
     *
     * @param emsStrategyRunning 策略运行
     * @return 策略运行集合
     */
    public List<EmsStrategyRunning> selectEmsStrategyRunningList(EmsStrategyRunning emsStrategyRunning);

    /**
     * 新增策略运行
     *
     * @param emsStrategyRunning 策略运行
     * @return 结果
     */
    public int insertEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);

    /**
     * 修改策略运行
     *
     * @param emsStrategyRunning 策略运行
     * @return 结果
     */
    public int updateEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);

    /**
     * 删除策略运行
     *
     * @param id 策略运行主键
     * @return 结果
     */
    public int deleteEmsStrategyRunningById(Long id);

    /**
     * 批量删除策略运行
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteEmsStrategyRunningByIds(Long[] ids);

    // 获取站点运行策略列表
    public List<StrategyRunningVo> getRunningList(String siteId);

    // 停止策略
    public int stopEmsStrategyRunning(Long id);

    // 根据主策略id、辅助策略id、siteId 获取运行策略
    public EmsStrategyRunning selectEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);

    // 更新站点策略为运行
    public void updateStatusRunning(@Param("siteId") String siteId,@Param("status") String status);

    // 获取运行中的策略
    public List<StrategyRunningVo> getPendingPollerStrategy(String siteId);

    // 获取正在运行的策略
    public EmsStrategyRunning getRunningStrategy(String siteId);
    // 获取已存在并且状态为：未启用和已暂停的最晚一条策略，
    public EmsStrategyRunning getPendingStrategy(String siteId);
}
