package com.jiayue.ipfcst.console.service;

import com.jiayue.ipfcst.common.data.entity.*;
import com.jiayue.ipfcst.common.data.repository.ForecastPowerShortTermTwoRepository;
import com.jiayue.ipfcst.common.data.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
@Slf4j
public class ForecastPowerShortTermTwoService extends BaseService {

  @Autowired
  ForecastPowerShortTermTwoRepository forecastPowerShortTermTwoRepository;


  /**
   * 按时间段删除数据
   *
   * @param startTime
   * @param endTime
   * @param listDq
   */
  @Transactional(propagation = Propagation.REQUIRED)
  public void deleteBetweenAndGenTime(Long startTime, Long endTime, List<ForecastPowerShortTermTwo> listDq) {
    forecastPowerShortTermTwoRepository.deleteByForecastTimeBetween(startTime, endTime);
    //保存短期数据
    forecastPowerShortTermTwoRepository.saveAll(listDq);
  }


}
