import request from "@/utils/request";
import { AxiosPromise } from "axios";

// 查询测试类型
export function searhTestType(data?: object): AxiosPromise {
  return request({
    url: "/api/v1/test/engrExecute/selectTestType",
    method: "post",
    data: {},
  });
}

// 测试仪器配置列表查询
export function searchTestMachineConfig(engineeringId: string): AxiosPromise {
  return request({
    url: "/api/v1/test/instrument/list",
    method: "post",
    data: {
      engineeringIdList: [engineeringId],
      instrumentProperty: 2,
      pageSize: 100,
    },
  });
}

// 查询执行工程项目关联的全局数据
export function searchExcutingGlobalData(
  engineeringId: string,
  itemIds: string[]
): AxiosPromise {
  return request({
    url: "/api/v1/test/engrProject/selectInvolveGlobalData",
    method: "post",
    data: {
      engineeringId: engineeringId,
      projectIdList: itemIds,
    },
  });
}

// 查询执行工程项目关联的仪器配置
export function searchExcutingInstrumentConfig(
  engineeringId: string,
  itemIds: string[]
): AxiosPromise {
  return request({
    url: "/api/v1/test/engrProject/selectInvolveInstrConfig",
    method: "post",
    data: {
      engineeringId: engineeringId,
      projectIdList: itemIds,
    },
  });
}

//查询仪器的状态 调硬件接口
export function searchInstrumentStatus(devicesList: any[]): AxiosPromise {
  return request({
    url: "xxx",
    method: "post",
    data: {
      instrumentList: devicesList,
      instrumentListJson: JSON.stringify(devicesList),
    },
  });
}

// 开始执行测试项目
export function startExecuteProjects(data: object): AxiosPromise {
  return request({
    url: "/api/v1/test/engrExecute/add",
    method: "post",
    data: data,
  });
}

//停止正在执行的项目
export function stopExecuteProjects(id: string): AxiosPromise {
  return request({
    url: "/api/v1/test/engrExecute/endExecute",
    method: "post",
    data: {
      id: id,
    },
  });
}

// 查询执行统计数据  测试执行页面下边
export function searchExecuteStatistics(id?: string): AxiosPromise {
  return request({
    url: "/api/v1/test/engrExecute/selectExecuteStatistics",
    method: "post",
    data: {
      id: id,
    },
  });
}
