package com.huimv.produce.warning.dao.repo;

import com.huimv.produce.warning.dao.entity.BaseWarningInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BaseWarningInfoRepo extends JpaRepository<BaseWarningInfoEntity, Integer>, JpaSpecificationExecutor<BaseWarningInfoEntity> {

    @Query(nativeQuery = true,value = "SELECT count(*) total FROM base_warning_info WHERE farm_id=?1 AND level=?2")
    List<Object[]> countThirdClassAlarm(Integer farmId, Integer classInt);

    //查询今天所有报警记录
    @Query(nativeQuery = true,value ="SELECT * FROM base_warning_info where farm_id=?1 AND DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(?2,'%Y-%m-%d')")
    List<BaseWarningInfoEntity> findTodayAllAlarm(Integer farmId, String todayText);
}