package com.gyee.wisdom.alarm.schedule.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gyee.wisdom.alarm.schedule.entity.AlarmHistory;
import com.gyee.wisdom.alarm.schedule.entity.FaultWarning;
import com.gyee.wisdom.alarm.schedule.model.AlarmHistoryInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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


@Mapper
public interface AlarmHisotryMapper extends BaseMapper<AlarmHistory> {

    void singleInsert(@Param("tbName") String tableName, @Param("item") AlarmHistory alarmHistory);

    void batchInsert(@Param("tbName") String tableName, @Param("list") List<AlarmHistory> alarmHistories);

    IPage<AlarmHistoryInfo> pageQueryAll(Page page,
                                         @Param("tbName") String tableName,
                                         @Param("stid")String stationId,
                                         @Param("wtid") String windturbineId,
                                         @Param("category1") String category1,
                                         @Param("category2") String category2,
                                         @Param("rank") String rank,
                                         @Param("modelid") String modelid,
                                         @Param("snapid") Long snapid,
                                         @Param("messagetype") Integer messagetype,
                                         @Param("keyword") String keyword,
                                         @Param("starttime") Date startTime,
                                         @Param("endtime") Date endTime);

    IPage<AlarmHistoryInfo> pageQueryAll2(Page page,
                                         @Param("yearmonth") String yearmonth,
                                         @Param("stid")String stationId,
                                         @Param("wtid") String windturbineId,
                                         @Param("category1") String category1,
                                         @Param("category2") String category2,
                                         @Param("rank") String rank,
                                         @Param("modelid") String modelid,
                                         @Param("snapid") Long snapid,
                                         @Param("messagetype") Integer messagetype,
                                         @Param("keyword") String keyword,
                                         @Param("starttime") Date startTime,
                                         @Param("endtime") Date endTime);

    int selectSnapCount(@Param("tbName") String tableName,
                        @Param("snapid") Long snapid,
                        @Param("starttime") Date startTime,
                        @Param("endtime") Date endTime);



    List<FaultWarning> selectHistoryAlarmSnapAndWarning(
            @Param("tbName") String tableName,
            @Param("starttime") Date startTime,
            @Param("endtime") Date endTime);
    //定时创建历史报警表
    void timedCreatTable(@Param("stationname")String stationname,@Param("yearmonth")String yearmonth,@Param("tablespace") String ts);
    void timedAlterTable(@Param("stationname")String stationname,@Param("yearmonth")String yearmonth,@Param("tablespace") String ts);
    void timedCreatAlerttimeIndex(@Param("stationname")String stationname,@Param("yearmonth")String yearmonth,@Param("tablespace") String ts);
    void timedCreatSnapidIndex(@Param("stationname")String stationname,@Param("yearmonth")String yearmonth,@Param("tablespace") String ts);
    int isHasTable(@Param("stationname")String stationname,@Param("yearmonth")String yearmonth);
}
