import request from '@/config/axios'

// 巡检工单 VO
export interface IotInspectOrderVO {
  id: number // 主键id
  inspectOrderTitle: string // 巡检工单名
  inspectOrderCode: string // 巡检工单编码
  status: string // 巡检工单状态
  remark: string // 备注
  deptId: number // 部门id
  deviceIds: string // 设备id
  details: []
}

// 巡检工单 API
export const IotInspectOrderApi = {
  // 查询巡检工单分页
  getIotInspectOrderPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/page`, params })
  },
  getIotInspectDeviceStatusPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/device`, params })
  },
  getDeviceIotInspectOrderPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/device/page`, params })
  },

  // 查询巡检工单详情
  getIotInspectOrder: async (id: number): Promise<IotInspectOrderVO> => {
    return await request.get({ url: `/rq/iot-inspect-order/get?id=` + id })
  },
  orderReason: async (params: {}): Promise<any> => {
    return await request.post({ url: `/rq/iot-inspect-order/ignore`, params })
  },
  getIotInspectOrderDetail: async (id: number) => {
    return await request.get({ url: `/rq/iot-inspect-order/get/details?id=` + id })
  },
  // 新增巡检工单
  createIotInspectOrder: async (data: IotInspectOrderVO) => {
    return await request.post({ url: `/rq/iot-inspect-order/create`, data })
  },

  // 修改巡检工单
  updateIotInspectOrder: async (data: IotInspectOrderVO) => {
    return await request.put({ url: `/rq/iot-inspect-order/update`, data })
  },

  // 删除巡检工单
  deleteIotInspectOrder: async (id: number) => {
    return await request.delete({ url: `/rq/iot-inspect-order/delete?id=` + id })
  },

  // 导出巡检工单 Excel
  exportIotInspectOrder: async (params) => {
    return await request.download({ url: `/rq/iot-inspect-order/export-excel`, params })
  },
  //填写巡检工单
  writeIotInspectOrder: async (data: any, orderId) => {
    return await request.post({ url: `/rq/iot-inspect-order/write/` + orderId, data })
  },

  // 报表统计相关接口
  // 巡检工单列表
  getIotInspectOrderList: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/report/stat`, params })
  },
  // 异常设备数量
  getIotInspectOrderExceptionDeviceCount: async (params: any) => {
    return await request.get({ url: `/rq/stat/inspect/exception/device`, params })
  },
  // 巡检异常点数量
  getIotInspectOrderExceptionPointCount: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order-detail/report/status`, params })
  },
  // 设备状态接口
  getInspectItemStatus: async (params: any) => {
    return await request.get({ url: `/rq/stat/report/inspect/status`, params })
  },

  // 故障上报
  // 状态接口
  getFaultReportStatus: async (params: any) => {
    return await request.get({ url: `/rq/report/failure/status`, params })
  },
  // 列表接口
  getFaultReportList: async (params: any) => {
    return await request.get({ url: `/rq/report/failure/page`, params })
  },

  // 异常设备列表
  getExceptionDeviceList: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/exception/device`, params })
  },

  // 导出巡检报表 Excel
  exportInspectReport: async (params) => {
    return await request.download({ url: `/rq/iot-inspect-order/report/export-excel`, params })
  },

  // 异常巡检点导出 Excel
  exportExceptionPointInspectReport: async (params) => {
    return await request.download({
      url: `/rq/iot-inspect-order/report/exception/item/export-excel`,
      params
    })
  },

  //  异常设备导出 Excel
  exportExceptionDeviceInspectReport: async (params) => {
    return await request.download({
      url: `/rq/iot-inspect-order/report/exception/device/export-excel`,
      params
    })
  },

  // 故障报表导出 Excel
  exportFaultReport: async (params) => {
    return await request.download({ url: `/rq/report/failure/report/export-excel`, params })
  }
}
