package com.gyee.runeconomy.controller.monitor;/*
@author   谢生杰
@date   2023/4/12-8:39
*/

import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay5;
import com.gyee.runeconomy.service.monitor.StationMonitorService;
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("/station")
@Api(value = "场站监视", tags = "场站监视")
public class StationMonitorController {
    @Resource
    private StationMonitorService stationMonitorService;

    /**
     * 场站数据
     *
     * @return
     */
    @GetMapping("/caldata")
    @ResponseBody
    @ApiOperation(value = "场站信息", notes = "场站信息")
    public R caldata(@RequestParam(value = "wpid", required = true) String wpid) throws Exception {

        Map<String, Object> resultMap = stationMonitorService.caldata(wpid);
        if (StringUtils.isNotNull(resultMap)) {
            return R.data(ResultMsg.ok(resultMap));
        } else {
            return R.error(ResultMsg.error());
        }
    }


    /**
     * 场站每日电量
     *
     * @return
     */
    @GetMapping("/hisdata")
    @ResponseBody
    @ApiOperation(value = "场站每日电量", notes = "场站每日电量")
    public R hisdata(@RequestParam(value = "wpid", required = true) String wpid) throws Exception {

        List<ProEconPowerstationInfoDay5> resultList = stationMonitorService.hisdata(wpid);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList));
        } else {
            return R.error(ResultMsg.error());
        }
    }
}
