package com.usky.vpp.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.vpp.service.VppResponseMonitorService;
import com.usky.vpp.service.vo.ResponseCompareVO;
import com.usky.vpp.service.vo.ResponseLoadAnalysisVO;
import com.usky.vpp.service.vo.ResponseMonitorTreeNodeVO;
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;

import java.util.List;

/**
 * 响应监控接口（虚拟电厂驾驶舱）
 * <p>网关前缀: /prod-api/service-vpp/response-monitor</p>
 */
@RestController
@RequestMapping("/response-monitor")
public class ResponseMonitorController {

    @Autowired
    private VppResponseMonitorService responseMonitorService;

    /**
     * 左侧资源树（客户 → 站点）
     */
    @GetMapping("/tree")
    public ApiResult<List<ResponseMonitorTreeNodeVO>> tree(
            @RequestParam(value = "keyword", required = false) String keyword) {
        return ApiResult.success(responseMonitorService.getResourceTree(keyword));
    }

    /**
     * 负荷分析：四曲线 + 用电量统计表
     */
    @GetMapping("/load-analysis")
    public ApiResult<ResponseLoadAnalysisVO> loadAnalysis(
            @RequestParam("siteId") Long siteId,
            @RequestParam(value = "date", required = false) String date,
            @RequestParam(value = "eventId", required = false) Long eventId) {
        return ApiResult.success(responseMonitorService.getLoadAnalysis(siteId, date, eventId));
    }

    /**
     * 对比分析：多站点实际负荷曲线对比
     */
    @GetMapping("/compare")
    public ApiResult<ResponseCompareVO> compare(
            @RequestParam("siteIds") String siteIds,
            @RequestParam(value = "date", required = false) String date) {
        return ApiResult.success(responseMonitorService.compare(siteIds, date));
    }
}
