package com.ho.td.mapper;

import com.ho.common.tools.vo.req.PointData;
import com.ho.common.tools.vo.req.StationHomeRespVo;
import com.ho.common.tools.vo.req.StatisticsCurve;
import com.ho.datacollect.api.vo.req.StatisticsRespVO;
import com.ho.datacollect.api.vo.req.add.TdBase;
import com.ho.datacollect.api.vo.req.add.TdDeviceAddReq;
import com.ho.td.api.entity.inverter.InverterTimingGenerate;
import com.ho.td.api.entity.query.TdBaseTimeQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description DeviceSimpleMapper
 * @Author xueweizhi
 * @Date 2023/3/16 09:30
 */
@Mapper
public interface DeviceSimpleMapper {

    //插入
    int insertDeviceSimple(TdDeviceAddReq device);

    int insertDeviceSimpleNew(TdDeviceAddReq device);

    List<StatisticsCurve> queryPointTableSimple(TdBaseTimeQuery query, String tableName);

    List<PointData> queryPointDataShowSimple(TdBaseTimeQuery query, String tableName);
    /**
     * 根据字段名称和时间按时间倒序取最后一条
     * @param tableName 表名后缀
     * @param colName 字段名称
     * @param time 时间
     * @return
     */
    BigDecimal queryOneByTime(String tableName, String colName, Date time);

    /**
     * 根据时间获取字段名称最大的值
     * @param tableName
     * @param colName
     * @param beginTime
     * @param time
     * @return
     */
    BigDecimal queryMaxOneByTime(String tableName, String colName, Date beginTime,Date time);

    /**
     * 根据时间获取字段名称最大的值
     * @param tableName
     * @param colName
     * @param time
     * @return
     */
    BigDecimal queryHisMaxOneByTime(String tableName, String colName, Date time);

    /**
     * 统计字段数量
     * @param query
     * @param tableName
     * @return
     */
    int countPointTableSimple(TdBaseTimeQuery query, String tableName);

    StationHomeRespVo selectBeginTime(String col, String tableName, Long beginLong);

    List<StationHomeRespVo> selectAll(TdBaseTimeQuery query, String tableName);

    List<StationHomeRespVo> selectEndPoint(TdBaseTimeQuery query, String tableName);

    StationHomeRespVo selectEnd(String col, String tableName,Long endLong);

    List<Map<String,Object>> selectAllValue(TdBase query, String tableName);

    int countPointAllSimple(TdBase query, String tableName);

    /**
     * 根据时间获取字段名称最小的值
     * @param tableName
     * @param colName
     * @param beginTime
     * @param time
     * @return
     */
    BigDecimal queryMinOneByTime(String tableName, String colName, Date beginTime,Date time);

    //查第一条数的时间
    Date selectFirstRecord(@Param("tableName") String tableName);

    //按条件查询采样率
    List<StatisticsRespVO> selectInterval(@Param("tdBase") TdBase tdBase,
                                          @Param("colName") String colName,
                                          @Param("intervalTime") String s);

    InverterTimingGenerate selectFirst(@Param("tbNameSuffix") String tbNameSuffix,
                                       @Param("beginTime") Long beginTime, @Param("endTime") Long endTime,
                                       @Param("orderType") String orderType,@Param("colName") String colName);

    List<StatisticsRespVO> selectLastRecord(TdBase tdBase, @Param("colName") String colName, @Param("time") Long time);

    StationHomeRespVo selectOneValue(String tableName, TdBaseTimeQuery query);

    StationHomeRespVo selectColFirst(String col, String tableName, Long beginLong);

    List<StationHomeRespVo> selectColAll(TdBaseTimeQuery query, String tableName);

    StationHomeRespVo selectColEnd(String col, String tableName,Long endLong);

    List<StatisticsCurve> queryMeasure(TdBaseTimeQuery query, String tableName);
}
