package cn.wise.sc.energy.power.plant.business.repository;

import cn.wise.sc.energy.power.plant.business.domain.EventInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description: 事件记录仓储
 * @author: qh
 * @create: 2020-09-03 10:26
 **/
@Repository
public interface EventInfoRepository extends
        JpaRepository<EventInfo, Long>,
        JpaSpecificationExecutor<EventInfo> {

    /**
     * 查询报警点数统计
     *
     * @return list
     */
    @Query(value = "SELECT COUNT(e.alertStat) as count, e.alertStat, e.deviceId FROM EventInfo as e" +
            " where e.alertStat > 1 and e.alertStat < 5 GROUP BY e.alertStat,e.deviceId")
    List<Object[]> countAlert();
}
