package com.gyee.runeconomy.controller.monitor;/*
@author   谢生杰
@date   2023/5/11-9:25
*/

import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProBasicWeatherStation;
import com.gyee.runeconomy.service.monitor.AnemometerTowerService;
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("/tower")
@Api(value = "测风塔", tags = "测风塔")
public class AnemometerTowerController {
    @Resource
    private AnemometerTowerService anemometerTowerService;


    /**
     * 测风塔数据
     *
     * @return
     */
    @GetMapping("/info")
    @ResponseBody
    @ApiOperation(value = "数据信息", notes = "数据信息")
    public R info(@RequestParam(value = "weatherid", required = true) String weatherid) throws Exception {

        Map<String, Double> resultMap = anemometerTowerService.info(weatherid);
        if (StringUtils.isNotNull(resultMap)) {
            return R.data(ResultMsg.ok(resultMap));
        } else {
            return R.error(ResultMsg.error());
        }
    }


    /**
     * 根据场站查询测风塔
     *
     * @return
     */
    @GetMapping("/towerByWp")
    @ResponseBody
    @ApiOperation(value = "根据场站查询测风塔", notes = "根据场站查询测风塔")
    public R towerByWp(@RequestParam(value = "wpid", required = true) String wpid) throws Exception {

        List<ProBasicWeatherStation> resultList = anemometerTowerService.towerByWp(wpid);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList));
        } else {
            return R.error(ResultMsg.error());
        }
    }


}
