package com.jiayue.ipfcst.common.data.repository;

import com.jiayue.ipfcst.common.data.entity.Nwp;
import com.jiayue.ipfcst.common.data.entity.NwpHis;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * nwp数据仓储
 *
 * @author zzy
 * @version 1.0
 * @since 2019/9/26 11:23
 */
public interface NwpHisRepository extends BaseRepository<NwpHis, Integer> {

	/**
	 * 根据时间段删除当日凌晨零点以后生成的NWP史期数据
	 *
	 * @param startTime 开始时间
	 * @param endTime   结束时间
	 */
	@Modifying
	@Query(value = "delete from NwpHis t where t.genDate >= CURRENT_DATE and t.preTime >=?1 and t.preTime<=?2")
	void deleteToday(Long startTime, Long endTime);

	/**
	 * 按时间段查询数据
	 *
	 * @param startTime
	 * @param endTime
	 */
	List<Nwp> findByPreTimeBetween(Long startTime, Long endTime);


	List<NwpHis> findByPreTimeBetweenAndForecastHowLongAgo(Long startTime,Long endTIme,Integer ago);
}
