/*
 * @Author: donghao donghao@supervision.ltd
 * @Date: 2025-06-10 17:36:23
 * @LastEditors: donghao donghao@supervision.ltd
 * @LastEditTime: 2025-06-11 11:00:17
 * @FilePath: \Web-Traffic-Police\src\api\dashboard.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @Author: donghao donghao@supervision.ltd
 * @Date: 2025-03-07 15:09:18
 * @LastEditors: donghao donghao@supervision.ltd
 * @LastEditTime: 2025-03-14 11:14:15
 * @FilePath: \5G-Loading-Bay-Web\src\api\dashboard.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 接口层

import request from "@/utils/request/instance";
import { config } from "@/config";

//TODO 定义响应类型

export const getDeviceStatusApi = (params: any) => {
  return request.get(`/api/v1/device/device/`, params);
};

// 撑杆检测
export const getAppearanceMonitorApi = (params: any) => {
  return request.get(`/api/v1/record/record/`, params);
};

// 删除检测
export const deleteAppearanceMonitorApi = (data: any) => {
  return request.delete(`/api/v1/record/record/${data.id}/`, data);
};

// 撑杆检测详情
export const getAppearanceMonitorDetailApi = (params: any) => {
  return request.get(`/api/v1/record/record_detail_list/`, params);
};

// 检测总量
export const getDataOverviewApi = (params: any) => {
  return request.get(`/api/v1/system/get_record_stats/`, params);
};

// 设备信息数据
export const getDeviceInfowApi = () => {
  return request.get(`/api/v1/system/get_device_stats/`);
};

// 检测问题分布数据
export const getRecordFaultApi = (params: any) => {
  return request.get(`/api/v1/system/get_record_fault_stats/`, params);
};

// 获取实时监控
export const getRealTimeApi = () => {
  return request.get(`/api/v1/record/get_latest_second_records/`);
};

// 设备状态打开实时监控
export const playRtspApi = (data: { url: string }) => {
  return request.post<LoginRes>(`/api/v1/common/play_rtsp/`, data, {
    showLoading: false, // 单独关闭loading
  });
};

// {
//   "code": 200,
//   "success": true,
//   "data": {
//       "process_id": 23432,
//       "host": "192.168.10.14:7001"
//   },
//   "errorMessage": ""
// } 

// 设备状态关闭实时监控
export const stopRtspApi = (data: { process_id: string | number }) => {
  return request.post<LoginRes>(`/api/v1/common/stop_rtsp/`, data, {
    showLoading: false, // 单独关闭loading
  });
};  

// 根据设备 ID 查询历史视频列表，支持日期时间过滤
export const getDeviceHistoryDetailApi = (params: {
  device_id: string | number;
  start_time: string;
  end_time: string;
}) => {
  return request.get(`/api/v1/device/device_history/`, params);
};

// 车辆管理
export const getVehiclManagementApi = (params: any) => {
  return request.get(`/api/v1/record/train_record/`, params);
};

// 外观检测故障前详情
export const getBeforeMonitorDetailApi = (params: any) => {
  return request.get(`/api/v1/record/before_arrive_record_list/`, params);
};
