package com.gyee.wisdom.alarm.sharding.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.sharding.entity.AlarmHistory;
import com.gyee.wisdom.alarm.sharding.entity.AlarmSnap;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;

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


@Mapper
public interface AlarmSnapMapper extends BaseMapper<AlarmSnap> {


    List<AlarmSnap> queryAll(@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("isopened") Integer isopened,
                             @Param("keyword") String keyword,
                             @Param("starttime") Date startTime,
                             @Param("endtime") Date endTime) throws Exception;

    IPage<AlarmSnap> pageQueryAll(Page page,
                                 @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("isopened") Integer isopened,
                                 @Param("keyword") String keyword,
                                 @Param("starttime") Date startTime,
                                 @Param("endtime") Date endTime)throws Exception;


    int batchInsert(List<AlarmSnap> list);

    void batchUpdate(List<AlarmSnap> list);

    AlarmSnap findByWindturbineIdAndAlertValue(@Param("windturbineid")String windturbineid,
                                               @Param("alertvalue")int alertvalue);

    AlarmSnap findByStationIdAndAlertValue(@Param("stationid")String stationId,
                                           @Param("alertvalue")int alertvalue);

    AlarmSnap findByTestingpointkey(@Param("testingpointkey")String testingpointkey);

    List<AlarmSnap> getTopNumAlarm(@Param("category1") String category1,
                                   @Param("topnum")int topnum);

    List<AlarmSnap>  getRecentAlarm(@Param("category1") String category1,
                                    @Param("lastupdatetime") Date lastUpdateTime);

}

