package com.gyee.runeconomy.controller.WindDirection;

import com.alibaba.fastjson.JSONObject;
import com.gyee.runeconomy.dto.result.JsonResult;
import com.gyee.runeconomy.dto.result.ResultCode;
import com.gyee.runeconomy.service.WindDirection.WindDirectionService;
import com.gyee.runeconomy.service.WindDirection.WindMachineJsService;
import com.gyee.runeconomy.service.WindDirection.WindMachineService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@CrossOrigin
@RequestMapping("/winddirecton")
public class WindDirectionController {
    @Resource
    private WindDirectionService windDirectionService;
    @Resource
    private WindMachineService windMachineService;
    @Resource
    private WindMachineJsService windMachineJsService;
    /***
     * 风速风向频次玫瑰图
     * @return
     */
    @GetMapping("/roses")
    public JSONObject fsRoses(String wtid,String kssj,String jssj) throws Exception {
        Object o = windDirectionService.fxRoses(wtid, kssj, jssj);
        return JsonResult.successData(ResultCode.SUCCESS, o);
    }

    /**
     * 对风偏差分析图

     * @return
     */
    @GetMapping("/deviation/ratio")
    public JSONObject fsDeviationRatio(String wtid,String kssj,String jssj) throws ParseException {

        Object o = windDirectionService.windDeviationRatio(wtid, kssj, jssj);
        return JsonResult.successData(ResultCode.SUCCESS, o);
    }

    /**
     * 单机偏差分析

     * @return
     */
    @GetMapping("/machine")
    public JSONObject Deviationmachine(String wpid,int year) throws Exception {

        Object o = windMachineService.machine(wpid,year);
        return JsonResult.successData(ResultCode.SUCCESS, o);
    }

    /**
     * 气象单机偏差分析

     * @return
     */
    @GetMapping("/weatherMachine")
    public JSONObject weathermachine(String wpid,int year) throws Exception {

        Object o = windMachineService.weathermachine(wpid,year);
        return JsonResult.successData(ResultCode.SUCCESS, o);
    }

    /**
     * 单机偏差分析计算

     * @return
     */
    @GetMapping("/machinejs")
    public JSONObject Deviationmachinejs(String wpid,String time) throws Exception {

        Object o = windMachineJsService.machine(wpid,time);
        return JsonResult.successData(ResultCode.SUCCESS, o);
    }
}
