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.TransferDbReq;
import com.ho.td.api.entity.inverter.InverterTimingGenerate;
import com.ho.td.api.entity.query.ResultData;
import com.ho.td.api.entity.query.TdBaseTimeQuery;
import com.ho.td.api.entity.query.UpdateTdReq;
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 DeviceComplexMapper
 * @Author xueweizhi
 * @Date 2023/3/16 09:30
 */
@Mapper
public interface DeviceComplexMapper {

    //插入
    int insertDeviceComplex(TdDeviceAddReq device);

    int insertDeviceComplex1(TdDeviceAddReq device);

    int insertDeviceComplex2(TdDeviceAddReq device);

    int insertDeviceComplex3(TdDeviceAddReq device);

    int insertDeviceComplex4(TdDeviceAddReq device);

    int insertDeviceComplex5(TdDeviceAddReq device);

    int insertDeviceComplex6(TdDeviceAddReq device);

    int insertDeviceComplex7(TdDeviceAddReq device);

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

    List<PointData> queryPointDataShowComplex(TdBaseTimeQuery query, String tableName);

    /**
     * 统计总条数
     * @param query
     * @param tableName
     * @return
     */
    int countQueryPointDataShowComplex(TdBaseTimeQuery query, String tableName);

    int countPointAllComplex(TdBase query, String tableName);

    BigDecimal queryOneByTime(String tableName, String colName, Date time);

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

    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);

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

    /**
     * 根据时间获取字段名称最小的值
     * @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);

    List<ResultData> getData(UpdateTdReq updateTdReq);

    void setData(@Param("resultData") ResultData resultData);

    int modifyData(@Param("resultData") ResultData resultData);

    StationHomeRespVo selectOneValue(String tableName, TdBaseTimeQuery query);
}
