package com.usky.demo.service;

import com.usky.common.core.bean.ApiResult;
import com.usky.common.mybatis.core.CrudService;
import com.usky.demo.domain.*;
import com.usky.demo.service.vo.SuperTableVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author ya
 * @since 2024-07-29
 */
public interface QueryTdengineDataService extends CrudService<QueryTdengineData> {


    // 对内接口  begin
    List<LastInnerResultVO> tdengineLast(LastInnerQueryVO requestVO);
    List<HistorysInnerResultVO> tdengineHistory(HistorysInnerRequestVO requestVO);
    // 对内接口  end
    List<Map<String, Object>> getAllDeviceRealTime();

    void createSuperTableAndColumn(SuperTableDTO superTableDTO);

    void addSuperTableColumn(String superTableName,Fields fields);

    void dropSuperTableColumn(String superTableName, Fields fields);

    void addSuperTableTag(String superTableName, Fields fields);

    void dropSuperTableTag(String superTableName, Fields fields);

    List<SuperTableDescribeVO> describeSuperOrSubTable(String tableName);

    /**
     * 能耗分项汇总：按设备计算 LAST(identifier)-FIRST(identifier) 后求和
     */
    EnergyItemSumResultVO sumEnergyItemDiff(EnergyItemSumQueryVO requestVO);

    /**
     * 能耗分项趋势：按时间粒度 INTERVAL 聚合，返回 time/value 列表
     */
    EnergyItemTrendResultVO sumEnergyItemTrend(EnergyItemTrendQueryVO requestVO);

    /**
     * 从 CSV 解析并导入设备子表时序：INSERT INTO _{deviceUuid} (ts, p) VALUES ...
     */
    ApiResult<DeviceCsvImportResultVO> importDeviceCsv(String deviceUuid, MultipartFile file);
}
