package com.gyee.frame.controller.scatter;

import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.custom.DataVo;
import com.gyee.frame.service.WinddirectionService;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.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.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

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

@Controller
@RequestMapping("/winddirection")
@Api(value = "风向图表", tags = "风向图表")
public class WinddirectionController {

    @Resource
    private WinddirectionService winddirectionService;


    @PostMapping("/getWinddirection")
    @ResponseBody
    @ApiOperation(value = "风向图表", notes = "风向图表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})

    public AjaxResult getWinddirection(String wpId, String recorddate) throws Exception {

        List<DataVo> vos = new ArrayList<DataVo>();
        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(recorddate)) {

             vos =winddirectionService.winddirectionAjax(wpId,DateUtils.parseStrtoDate(recorddate));

        }

        if (null != vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        }

    }


}
