package com.gyee.frame.mapper.auto;

import com.gyee.frame.model.auto.Alarmsnap;
import com.gyee.frame.model.auto.AlarmsnapExample;
import com.gyee.frame.model.auto.FaultInfo;
import com.gyee.frame.model.custom.TotalNumVo;
import com.gyee.frame.model.custom.TotalNumsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

public interface AlarmsnapMapper {
    @Select("SELECT h.id,h.faultTime,h.messageType,h.snapID,s.stationId,s.projectId,s.lineId,s.windturbineId,s.alertValue,s.rank," +
            "s.category1,s.category2,s.category3,s.isOpened,s.stationName,s.windturbineName,s.alertText,s.modelId" +
            "FROM faulthistory h left join faultsnap s on h.snapid = s.id" +
            "WHERE h.messageType = 1 and s.WINDTURBINEID=#{windturbineid}" +
            "  AND h.faultTime > #{starttime} AND h.faultTime < #{endtime} AND ROWNUM<#{row}" +
            "order by h.faultTime desc")
    List<FaultInfo>  getRecentFault(@Param("windturbineid") String wt,@Param("starttime") Date st,@Param("endtime") Date et,@Param("row") int r);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    long countByExample(AlarmsnapExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int deleteByExample(AlarmsnapExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int insert(Alarmsnap record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int insertSelective(Alarmsnap record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    List<Alarmsnap> selectByExample(AlarmsnapExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    Alarmsnap selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int updateByExampleSelective(@Param("record") Alarmsnap record, @Param("example") AlarmsnapExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int updateByExample(@Param("record") Alarmsnap record, @Param("example") AlarmsnapExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int updateByPrimaryKeySelective(Alarmsnap record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ALARMSNAP
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(Alarmsnap record);

    List<TotalNumsVo> getAlarmhistoryList(@Param("tname") String tname, @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<TotalNumVo> findAlertrulefailuresubMap();


}