/*
 * @Author: your name
 * @Date: 2024-06-03 09:29:50
 * @LastEditTime: 2024-09-24 13:34:34
 * @LastEditors: bogon
 * @Description: In User Settings Edit
 * @FilePath: /performance-test/src/api/performance。.js
 */
import request from "@/utils/request";
//分析选择某个图表类型
export function queryAnalysisTypeConfig(data) {
  return request({
    url: "/energy-manage-service/analysis/queryAnalysisTypeConfig",
    method: "get",
    params: data,
  });
}
//转换数据时间
export function queryDataTime(data) {
  return request({
    url: "/energy-manage-service/dataTransfer/queryDataTime",
    method: "get",
    params: data,
  });
}
//分析类型查询
export function queryAnalysisedType(data) {
  return request({
    url: "/energy-manage-service/analysis/queryAnalysisedType",
    method: "get",
    params: data,
  });
}
//风机机组编号查询
export function queryAnalysisedEngine(data) {
  return request({
    url: "/energy-manage-service/analysis/queryAnalysisedEngine",
    method: "get",
    params: data,
  });
}
//开启自动分析开关接口
export function onOffAutoAnalysis(data) {
  return request({
    url: "/energy-manage-service/analysis/onOffAutoAnalysis",
    method: "post",
    data,
  });
}
//自动生成批次名称
export function createBatchName(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/createBatchName",
    method: "post",
    data,
  });
}
//批次管理性能分析列表获取
export function getBatchMagList(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/batchList",
    method: "get",
    params: data,
  });
}
//批次管理新增
export function addFieldBatch(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/addFieldBatch",
    method: "post",
    data,
  });
}
//批次管理编辑
export function updateFieldBatch(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/updateFieldBatch",
    method: "post",
    data,
  });
}
//批次管理onOrOffFieldBatch更改状态
export function onOrOffFieldBatch(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/onOrOffFieldBatch",
    method: "post",
    data,
  });
}
//批次管理deleteFieldBatch 删除
export function deleteFieldBatch(data) {
  return request({
    url: "/energy-manage-service/windEnginBatch/deleteFieldBatch",
    method: "post",
    data,
  });
}
//批次管理获取关联风场接口
export function queryCodeNum() {
  return request({
    url: "/energy-manage-service/sysOrganizationAuth/queryCodeNum",
    method: "get",
  });
}
//获取性能分析评估接口
export function getAnalysisResultList(data) {
  return request({
    url: "/energy-manage-service/analysis/analysisResultList",
    method: "get",
    params: data,
  });
}
//性能分析异常描述列表 /analysisErr/analysisErrQuery
export function analysisErrQuery(data) {
  return request({
    url: "/energy-manage-service/analysisErr/analysisErrQuery",
    method: "get",
    params: data,
  });
}
// //异常描述列表 风机编号/api/wind/engine/group/getWindEngineGroupByUser
// export function getWindEngineGroupByUser(data) {
//   return request({
//     url: "/energy-manage-service/api/wind/engine/group/getWindEngineGroupByUser",
//     method: "get",
//     params: data,
//   });
// }

//异常描述列表 分析类型、风机号查询   入参batchCode 批次编号  /analysis/analysisEditQuery
export function analysisEditQuery(data) {
  return request({
    url: "/energy-manage-service/analysis/analysisEditQuery",
    method: "get",
    params: data,
  });
}
//异常描述列表 添加/analysis/analysisErrAdd
export function analysisErrAdd(data) {
  return request({
    url: "/energy-manage-service/analysisErr/analysisErrAdd",
    method: "post",
    data,
  });
}
//删除 异常描述列
export function analysisErrDel(data) {
  return request({
    url: "/energy-manage-service/analysisErr/analysisErrDel",
    method: "post",
    data,
  });
}
//编辑 异常描述列/analysisErr/analysisErrEdit
export function analysisErrEdit(data) {
  return request({
    url: "/energy-manage-service/analysisErr/analysisErrEdit",
    method: "post",
    data,
  });
}
//分析详情 接口/analysis/analysisDetail
export function analysisDetail(data) {
  return request({
    url: "/energy-manage-service/analysis/analysisDetail",
    method: "post",
    data,
  });
}
//分析详情  事件
export function analysis(data) {
  return request({
    url: "/energy-manage-service/analysis/analysis",
    method: "post",
    data,
  });
}
//新增 分析结果类型
//参数 batchCode 批次  analysisTypeCode  分析编号  commentTypeCode评论编号 commentTypeName 评论类型名称
// /analysisComment/addAnalysisCommentType
export function addAnalysisCommentType(data) {
  return request({
    url: "/energy-manage-service/analysisComment/addAnalysisCommentType",
    method: "post",
    data,
  });
}
//删除 分析结果类型 /analysisComment/delAnalysisCommentType 删除  入参 commentTypeCode评论编号
export function delAnalysisCommentType(data) {
  return request({
    url: "/energy-manage-service/analysisComment/delAnalysisCommentType",
    method: "post",
    data,
  });
}
//富文本但文件上传
export function uploadFile(data) {
  return request({
    url: "/energy-manage-service/api/check/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data,
  });
}
//富文本编辑，性能分析编辑描述
export function analysisCommentEdit(data) {
  return request({
    url: "/energy-manage-service/analysisComment/analysisCommentEdit",
    method: "post",
    data,
  });
}
//全部下载文件查询接口
//下载逻辑---先调用这个接口获取所有的分析类型，再循环这些类型下载（下载调用这个方法接口downloadFile）该类型下的所有分析文件
export function queryDownloadFile(data) {
  return request({
    url: "/energy-manage-service/analysis/queryDownloadFile",
    method: "get",
    params: data,
  });
}
//按分析类型对分析结果下载 (所有分析图表的下载)
export function downloadFile(data, onProgress) {
  return request({
    url: "/energy-manage-service/analysis/downloadFile",
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
    responseType: "blob", // 关键在这里，确保 Axios 返回 Blob 数据
    onDownloadProgress: (progressEvent) => {
      if (onProgress) {
        const percentCompleted = Math.round(
          (progressEvent.loaded * 100) / progressEvent.total
        );
        onProgress(percentCompleted);
      }
    },
  }).then((response) => response.data); // 返回数据中的 Blob;
}
//保存分析报告上传路径
export function saveReportBatch(data) {
  return request({
    url: "/energy-manage-service/analysisResultReport/saveReportBatch",
    method: "post",
    data,
  });
}
//

export function getRportType(data) {
  return request({
    url: "/energy-manage-service/analysisResultReport/getRportType",
    method: "get",
    params: data,
  });
}
