package com.hw.tdengine.service;

import com.hw.tdengine.api.domain.*;
import com.hw.tdengine.api.domain.ems.TdSuperTableEmsSelectVo;

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

/**
 * @InterfaceName: ITdEngineService
 * @Author : xins
 * @Date :2023-08-28  13:14
 * @Description: TdEngineService接口
 * @Version :1.0
 */
public interface ITdEngineService {

    /**
     * @param databaseName
     * @description:创建数据库
     * @author xins
     * @date 2023-08-28 11:32
     */
    public void createDatabase(String databaseName) throws Exception;

    /**
     * @param databaseName
     * @param superTableName
     * @param firstFieldName
     * @param schemaFields
     * @param tagsFields
     * @description 创建超级表
     * @author xins
     * @date 2023-08-28 13:18
     */
    public void createSuperTable(String databaseName, String superTableName, String firstFieldName, List<TdFieldVo> schemaFields, List<TdFieldVo> tagsFields) throws Exception;

    /**
     * @param: databaseName
     * @param: superTableName
     * @param: tableName
     * @param: tagsFieldValues
     * @description 创建子表
     * @author xins
     * @date 2023-08-28 16:16
     */
    public void createTable(String databaseName, String superTableName, String tableName, List<TdField> tagsFieldValues) throws Exception;

    /**
     * @param: databaseName
     * @param: superTableName
     * @param: addFieldsVo
     * @description 增加超级表的列
     * @author xins
     * @date 2023-08-28 17:12
     */

    public void addSuperTableColumn(String databaseName,String superTableName, TdFieldVo addFieldsVo) throws Exception;

    /**
     * @param: databaseName
     * @param: superTableName
     * @param: modifyFieldsVo
     * @description 修改超级表列宽（只适用于nchar类型）
     * @author xins
     * @date 2023-10-11 9:02
     */
    public void modifySuperTableColumn(String databaseName, String superTableName, TdFieldVo modifyFieldsVo) throws Exception;

    /**
     * @param: databaseName
     * @param: superTableName
     * @param: dropFieldsVo
     * @description 删除超级表的列
     * @author xins
     * @date 2023-08-28 17:13
     */
    public void dropSuperTableColumn(String databaseName,String superTableName, TdField dropField) throws Exception;

    /**
     * @param: databaseName
     * @param: tableName
     * @param: tagName
     * @param: tagValue
     * @description 修改子表的tagValue
     * @author xins
     * @date 2023-08-30 11:03
     */
    public void alterTableTag(String databaseName,String tableName,String tagName,Object tagValue);
    /**
     * @param: databaseName
     * @param: tableName
     * @param: schemaFields
     * @description 插入数据
     * @author xins
     * @date 2023-08-29 10:10
     */
    public void insertTable(String databaseName,String tableName,List<TdField> schemaFields) throws Exception;

    /**
     * @param: tdSelectDto
     * @description 获取某个子表最新一条数据
     * @author xins
     * @date 2023-08-29 11:28
     * @return List<Map<Object>>
     */
    public List<Map<String, Object>> getLatestData(TdSelectDto tdSelectDto) throws Exception;

    /**
     * @return List<Map<String, Object>>
     * @param: tdSelectDto
     * @description 根据tagsname获取超级表最新信息，适用于设备汇总页面，先分页获取设备信息，再获取所有此物模型下的最新信息（冗余，但每页只获取一次，不需要每个设备都获取一次
     * *     如果需要根据时间周期获取最新的数据，则需要用select last_row()
     * @author xins
     * @date 2023-08-29 14:47
     */
    public List<Map<String, Object>> getLatestDataByTags(TdSuperTableSelectVo tdSuperTableSelectVo);

    /**
     * @param: tdHistorySelectDto
     * @description 获取历史数据
     * @author xins
     * @date 2023-08-29 15:52
     * @return List<Map<Object>>
     */
    public List<Map<String, Object>> getHistoryData(TdHistorySelectDto tdHistorySelectDto);

    /**
     * @param: tdHistorySelectDto
     * @description 获取历史数据总数量
     * @author xins
     * @date 2023-09-25 16:20
     * @return int
     */
    public int getCountOfHistoryData(TdHistorySelectDto tdHistorySelectDto);


    /**
     * @return List<Map <String,Object>>
     * @param: tdSuperTableEmsSelectVo
     * @description 获取超级表历史数据
     * @author xins
     * @date 2023-12-29 22:40
     */
    public List<Map<String, Object>> getSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);

    /**
     * @param: tdSuperTableEmsSelectVo
     * @description 获取超级表历史数据总数量
     * @author xins
     * @date 2023-12-29 22:40
     * @return int
     */
    public int getCountOfSuperTableHistoryData(TdSuperTableEmsSelectVo tdSuperTableEmsSelectVo);

    /**
     * 批量更新表的tag
     * @param alterTagVos
     */
    public void alterTableTags(List<AlterTagVo> alterTagVos);
//    void initSTableFrame(String msg) throws Exception;

//    List<Map<String, Object>> getRealtimeData(SelectVisualDto selectVisualDto);
//
//    List<Map<String, Object>> getAggregateData(SelectVisualDto selectVisualDto);
}
