package com.gyee.runeconomy.controller.performacompare;


import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProEconWtPowerCurveFitting;
import com.gyee.runeconomy.service.performacompare.EquipmentPerformaCompareService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 * 单机新能比较 前端控制器
 * </p>
 *
 * @author wang
 * @since 2022-11-22
 */
@RestController
@RequestMapping("//performa-compare")
@Api(value = "单机新能比较", tags = "单机新能比较")
public class EquipmentPerformaCompareController {


    @Autowired
    private EquipmentPerformaCompareService equipmentPerformaCompareService;


    /**
     * 单机横向对比列表
     *
     * @param type           风场 -1 ；光伏 -2
     * @param dateType       日 1；月 2； 年 3
     * @param windturbineIds 设别ids
     * @param date           日期
     * @return
     */
    @GetMapping("/equipment-performa-compare")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public R daydjhxdbtop(
            @RequestParam(value = "type", required = true) String type,
            @RequestParam(value = "dateType", required = true) String dateType,
            @RequestParam(value = "windturbineIds", required = true) String windturbineIds,
            @RequestParam(value = "date", required = true) String date) {

        List<Object> objects = null;
        try {
            objects = equipmentPerformaCompareService.getEquipmentPerformaCompareList(dateType, windturbineIds, date, type);
            return R.data(ResultMsg.ok(objects));
        } catch (Exception e) {
            return R.data(ResultMsg.error());
        }

    }


    /**
     * 实际拟合曲线
     *
     * @param windturbineIds
     * @return
     */
    @GetMapping("curve-fitting")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public R getWtPowerCurveFittingList(
            @RequestParam(value = "windturbineIds", required = true) String windturbineIds) {

        Map<String, List<ProEconWtPowerCurveFitting>> map = null;
        try {
            map = equipmentPerformaCompareService.getgroupProEconWtPowerCurveFittingList(windturbineIds);
            return R.data(ResultMsg.ok(map));
        } catch (Exception e) {
            e.printStackTrace();
            return R.error(ResultMsg.error());
        }


    }


}
