package cn.cecep.talroad.controller;

import cn.cecep.talroad.common.core.web.controller.BasesController;
import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.service.ITCodStationService;
import cn.cecep.talroad.vo.TCodStationVo;
import cn.cecep.talroad.vo.query.FindSequenceDataQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 大气环境、水环境站点Controller 控制层
 */
@Api(tags = "大气环境、水环境站点")
@RestController
@RequestMapping("/station")
public class TCodStationController extends BasesController {
    @Autowired
    private ITCodStationService tCodStationService;

    @ApiOperation(value = "查询大气环境、水环境站点")
    @GetMapping("/list")
    public AjaxResults<List<TCodStationVo>> list(TCodStationVo.SearchVo searchVo) {
        List<TCodStationVo> list = tCodStationService.getStationList(searchVo);
        return AjaxResults.success(list);
    }

    @ApiOperation(value = "获取大气环境站点详细信息")
    @PostMapping(value = "/detail/air/{id}")
    public AjaxResults<TCodStationVo.Air> airStationDetail(@PathVariable("id") String id) {
        TCodStationVo.Air air = tCodStationService.getAirStationDetail(id);
        return AjaxResults.success(air);
    }

    @ApiOperation(value = "获取水环境站点详细信息")
    @PostMapping(value = "/detail/water/{id}")
    public AjaxResults<TCodStationVo.Water> waterStationDetail(@PathVariable("id") String id) {
        TCodStationVo.Water water = tCodStationService.getWaterStationDetail(id);
        return AjaxResults.success(water);
    }

    @ApiOperation(value = "查询大气环境站点")
    @PostMapping(value = "/findStationPullData")
    public AjaxResults<List<Map<String, Object>>> findStationPullData() {
        List<Map<String, Object>> stationPullData = tCodStationService.findStationPullData();
        return AjaxResults.success(stationPullData);
    }

    @ApiOperation(value = "查询大气环境时间分布特征")
    @PostMapping(value = "/findSequenceData")
    public AjaxResults<Map<String, Object>> findSequenceData(@RequestBody FindSequenceDataQuery findSequenceDataQuery) {
        Map<String, Object> stationPullData = tCodStationService.findSequenceData(findSequenceDataQuery);
        return AjaxResults.success(stationPullData);
    }

    @ApiOperation(value = "大气环境大屏-唐山市区县排名")
    @GetMapping(value = "/stationRank")
    public AjaxResults<List<Map<String, Object>>> stationRank(String factorName, String monitorTime) {
        List<Map<String, Object>> rankList = tCodStationService.stationRank(factorName, monitorTime);
        return AjaxResults.success(rankList);
    }
}
