package com.gyee.runeconomy.controller.Forecast;

import com.gyee.runeconomy.dto.AjaxResult;
import com.gyee.runeconomy.service.Forecast.ForecastService;
import com.gyee.runeconomy.service.Forecast.NewForecastService;
import com.gyee.runeconomy.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.Map;

@Controller
@RequestMapping("/Forecast")
@Api(value = "短期预测", tags = "短期预测")
public class ForecastController {

    @Autowired
    private ForecastService forecastService;
    @Autowired
    private NewForecastService newForecastService;

    @GetMapping("/short")
    @ResponseBody
    @ApiOperation(value = "单场站", notes = "单场站")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wpId", value = "场站编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "beginDate", value = "开始时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = true, dataType = "string", paramType = "query")
    })

    public AjaxResult forecast(String wpId, String beginDate, String endDate) throws Exception {


        Map<String, Object> resultList = new LinkedHashMap<>();
        if (StringUtils.notEmp(wpId)) {
            resultList = newForecastService.getcockpit(wpId, beginDate, endDate);
        }

        if (null != resultList) {
            return AjaxResult.successData(200, resultList);
        } else {
            return AjaxResult.error(500, "操作失败");
        }

    }

    @GetMapping("/shorttype")
    @ResponseBody
    @ApiOperation(value = "所有场站", notes = "所有场站")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "beginDate", value = "开始时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "结束时间", required = true, dataType = "string", paramType = "query")
    })

    public AjaxResult forecasttype(String beginDate, String endDate, String type) throws Exception {


        Map<String, Object> resultList = new LinkedHashMap<>();

        resultList = forecastService.getcockpittype(beginDate, endDate, type);

        if (null != resultList) {
            return AjaxResult.successData(200, resultList);
        } else {
            return AjaxResult.error(500, "操作失败");
        }

    }


}
