package com.usky.vpp.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.vpp.service.VppDashboardService;
import com.usky.vpp.service.vo.DashboardCurveVO;
import com.usky.vpp.service.vo.DashboardMapVO;
import com.usky.vpp.service.vo.DashboardSummaryVO;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

/**
 * 虚拟电厂 - 运行管理监控大屏
 * <p>网关前缀: /prod-api/service-vpp</p>
 */
@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private VppDashboardService vppDashboardService;

    /**
     * 大屏汇总 KPI
     * <p>租户隔离；削峰/填谷/补贴/当年调控/社会效益/收益排名仅统计已结束事件。</p>
     */
    @GetMapping("/summary")
    public ApiResult<DashboardSummaryVO> summary() {
        return ApiResult.success(vppDashboardService.getSummary());
    }

    /**
     * 地图站点点位（含经纬度与装机容量）
     */
    @GetMapping("/map")
    public ApiResult<DashboardMapVO> mapResources() {
        return ApiResult.success(vppDashboardService.getMap());
    }

    /**
     * 当日用电负荷曲线（基础功率 vs 负荷功率）
     *
     * @param date 统计日期 yyyy-MM-dd，默认当天
     */
    @GetMapping("/curve")
    public ApiResult<DashboardCurveVO> curve(@RequestParam(value = "date", required = false) String date) {
        return ApiResult.success(vppDashboardService.getCurve(date));
    }
}
