import { CustomeGroupQueryModel, StationsQueryParam, TAireadModel, TAireadQueryParam, UnitQueryParam } from '@/types'
import request from '@/until/request'

/**
 * 获取数据列表
 * @param page TAireadQueryParam
 */
 const QueryTAireadByCondition = (data: TAireadQueryParam) =>
 request({
     url: '/TAireadAction/findAllTAireadByCondition',
     method: 'post',
     data: data
 })


/**
 * 获取数据列表
 * @param page TAireadQueryParam
 */
const QueryTAireadListByDevice = (data: TAireadQueryParam) =>
    request({
        url: '/TAireadAction/list/' + data.deviceSn + '/' + data.startTime + '/' + data.endTime + '/' + data.page + '/' + data.rows,
        method: 'get'
    })

/**
* 获取数据列表
* @param page TAireadQueryParam
*/
const QueryTAireadListByStation = (data: TAireadQueryParam) =>
    request({
        url: '/TAireadAction/listByStationcode/' + data.stationCode + '/' + data.startTime + '/' + data.endTime + '/' + data.page + '/' + data.rows,
        method: 'get'
    })

/**
 * 根据单位代码获取下属设备每条最新数据
 * @param date 
 * @returns 
 */
const QueryLatestDataByStation = (date: UnitQueryParam) =>
    request({
        url: '/TAireadAction/findLatestDataByStationCodes/' + date.type + '/' + date.code + '/' + date.page + '/' + date.rows,
        method: 'get'
    })

/**
 * 根据遥测站点串获取最新数据
 * @param date 
 * @returns 
 */
const QueryLatestTAireadByStationCodes = (data: StationsQueryParam) =>
    request({
        url: '/TAireadAction/findLatestTAireadByStationCodes/' + data.stationCodes + '/' + data.page + '/' + data.rows,
        method: 'get'
    })

    /**
 * 根据遥测站点串获取最新数据(按遥测站编码排序)
 * @param date 
 * @returns 
 */
const QueryLatestTAireadSortStationCodes = (data: StationsQueryParam) =>
request({
    url: '/TAireadAction/findLatestTAireadSortStationCodes/' + data.stationCodes + '/' + data.page + '/' + data.rows,
    method: 'get'
})
//findTAireadListByVersion

/**
 * 查询所有站点最新数据，根据各版本号进行过滤
 * @param data
 */
 const QueryTAireadListByVersion = (data: CustomeGroupQueryModel) =>
 request({
     url: '/TAireadAction/findTAireadListByVersion',
     method: 'post',
     data: data
 })

 /**
 * 获取数据列表
 * @param page TAireadQueryParam
 */
const QueryLatestTAireadByDeviceSn = (deviceSn: string) =>
request({
    url: '/TAireadAction/findLatestTAireadByDeviceSn/' + deviceSn,
    method: 'get'
})

export default {
    QueryTAireadListByDevice,
    QueryTAireadListByStation,
    QueryLatestDataByStation,
    QueryLatestTAireadByStationCodes,
    QueryLatestTAireadSortStationCodes,
    QueryTAireadByCondition,
    QueryTAireadListByVersion,
    QueryLatestTAireadByDeviceSn
}