package com.usky.vpp.service;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * VPP 时序数据（TDengine）查询服务
 */
public interface VppTsdbQueryService {

    /**
     * 批量查询设备指标历史曲线
     *
     * @return deviceUuid -> metric -> time -> value
     */
    Map<String, Map<String, TreeMap<LocalDateTime, BigDecimal>>> queryDeviceMetricHistory(
            List<String> deviceUuids,
            LocalDateTime startTime,
            LocalDateTime endTime,
            List<String> metrics);

    /**
     * 批量查询设备最新指标值
     *
     * @return deviceUuid -> metric -> value
     */
    Map<String, Map<String, BigDecimal>> queryLatestMetrics(List<String> deviceUuids, List<String> metrics);

    /**
     * 多历史日同时段各时间点负荷求平均（原始/预测基线）。
     * <p>逐日调用 {@link #queryDeviceMetricHistory}（service-tsdb queryHistoryDeviceData）后在本模块聚合。</p>
     *
     * @return time(HH:mm) -> 平均负荷 kW
     */
    Map<String, BigDecimal> queryBaselineAvgByTimePoint(List<String> deviceUuids,
                                                        List<LocalDate> referenceDates,
                                                        LocalTime periodStart,
                                                        LocalTime periodEnd,
                                                        List<String> metrics,
                                                        Integer intervalMinutes,
                                                        BigDecimal correctionFactor);
}
