import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FileInfo } from './types';

//分页查询数据集列表
export function getTestDataset(queryParams:any) {
  return request({
    url: '/modeltrain/testdataset/getTestDataset',
    method: 'post',
    params: queryParams
  });
}
//查询数据集列表
export function getTestDatasetAll(queryParams:any) {
  return request({
    url: '/modeltrain/testdataset/getTestDatasetAll',
    method: 'post',
    params: queryParams
  });
}
//查询数据集列表
export function queryPointGroup(queryParams:any) {
  return request({
    url: '/modeltrain/testdataset/queryPointGroup',
    method: 'post',
    params: queryParams
  });
}

//删除模型
export function delTestDataset(data:any) {
  return request({
    url: '/modeltrain/testdataset/delTestDataset',
    method: 'post',
    data: data
  });
}
//删除点位
export function delPoint(data:any) {
  return request({
    url: '/modeltrain/testdataset/delPoint',
    method: 'post',
    data: data
  });
}
//批量修改点位
export function updatePoint(data:any) {
  return request({
    url: '/modeltrain/testdataset/updatePoint',
    method: 'post',
    data: data
  });
}
//批量修改点位
export function uploadPoint(data:any) {
  return request({
    url: '/modeltrain/testdataset/uploadPoint',
    method: 'post',
    data: data
  });
}



//批量修改点位
export function delPointGroup(queryParams:any) {
  return request({
    url: '/modeltrain/testdataset/delPointGroup',
    method: 'post',
    params: queryParams
  });
}
//另存为文件
export function exportPointGroup(queryParams:any) {
  return request({
    url: '/modeltrain/testdataset/exportPointGroup',
    method: 'post',
    params: queryParams,
    responseType: 'arraybuffer'
  });
}


/**
 * 上传文件
 *
 * @param file
 */
export function uploadCsvFile(file: File): AxiosPromise<FileInfo> {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/modeltrain/testdataset/uploadFile',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

//查询实时点位列表
export function getRealTimePoint(queryParams:any) {
  return request({
    url: '/modeltrain/onlinedata/getRealTimePoint',
    method: 'post'
  });
}
//查询实时点位列表
export function openRealTimePoint(queryParams:any) {
  return request({
    url: '/modeltrain/onlinedata/openRealTimePoint',
    method: 'post',
    params: queryParams,
  });
}

