package com.gyee.runeconomy.controller;

import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.vo.ProEconEquipmentInfoDay4Vo;
import com.gyee.runeconomy.service.WindDeviationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/winddeviation")
@Api(value = "曲线对风偏差", tags = "曲线对风偏差")
public class WindDeviationController {


    @Resource
    private WindDeviationService windDeviationService;

    /**
     * 查询曲线对风偏差
     *
     * @return
     */
    @GetMapping("/getDeviationValue")
    @ResponseBody
    @ApiOperation(value = "曲线对风偏差", notes = "曲线对风偏差")
    public R getDeviationValue(
            @RequestParam(value = "wtId", required = true) String wtId,
            @RequestParam(value = "recorddate", required = true) String recorddate) throws Exception {

        Map<String, Object> result = windDeviationService.getDeviationValue(wtId, recorddate);

        if (StringUtils.isNotNull(result)) {
            return R.data(ResultMsg.ok(result));
        } else {
            return R.error(ResultMsg.error());
        }
    }

    /**
     * 查询区间曲线偏差率
     *
     * @return
     */
    @GetMapping("/queryEquipmentInfoDay4")
    @ResponseBody
    @ApiOperation(value = "查询区间曲线偏差率", notes = "查询区间曲线偏差率")
    public R queryEquipmentInfoDay4(
            @RequestParam(value = "wpId", required = true) String wpId,
            @RequestParam(value = "recorddate", required = true) String recorddate) throws Exception {

        List<ProEconEquipmentInfoDay4Vo> result = windDeviationService.queryEquipmentInfoDay4(wpId, recorddate);

        if (StringUtils.isNotNull(result)) {
            return R.data(ResultMsg.ok(result));
        } else {
            return R.error(ResultMsg.error());
        }
    }

}
