package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.service.ForecastPowerUltraShortTermHisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 超短期预测历史信息restful接口
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/7 10:12
 */
@RestController
@Slf4j
public class ForecastPowerUltraShortTermHisController {
  private final ForecastPowerUltraShortTermHisService forecastPowerUltraShortTermHisService;
  @Autowired
  public ForecastPowerUltraShortTermHisController(ForecastPowerUltraShortTermHisService forecastPowerUltraShortTermHisService){
    this.forecastPowerUltraShortTermHisService = forecastPowerUltraShortTermHisService;
  }

  /**
   * 按时间查询历史预测超短期 yh
   * @param startTime 开始时间
   * @param endTime 结束时间
   * @return 结果集
   */
  @GetMapping(value = "/forecastUltraPowerShortTermHis/{startTime}/{endTime}/{ago}")
  public ResponseVO findByForecastTimeBetween(@PathVariable("startTime") Long startTime,
                                              @PathVariable("endTime") Long endTime,
                                              @PathVariable("endTime") Integer ago){
    Map<String,Object> map = new HashMap<>();
    try{
      map = forecastPowerUltraShortTermHisService.findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTime(startTime,endTime,ago);
      return ResponseVO.success(map);
    }catch(Exception e){
      e.printStackTrace();
      return ResponseVO.fail(e.toString());
    }
  }


  /**
   * 查询超短期16个点的信息 tl
   * @param startTime 开始时间
   * @return 结果集
   */
  @GetMapping(value = "/findByForecastRealTimeUltraShortTerm16/{startTime}")
  public ResponseVO findByForecastRealTimeUltraShortTerm16(@PathVariable("startTime") Long startTime){
    Map<String,Object> map = new HashMap<>();
    try{
      map = forecastPowerUltraShortTermHisService.findByForecastRealTimeUltraShortTerm16(startTime);
      return ResponseVO.success(map);
    }catch(Exception e){
      e.printStackTrace();
      return ResponseVO.fail(e.toString());
    }
  }



}
