import request from '@/config/axios'

let globalController = new AbortController()

export const cancelAllRequests = async () => {
  globalController.abort()
  globalController = new AbortController()
}

// 设备台账 API
export const IotStatApi = {
  getCompleteRate: async (params) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/completeRate`, params })
  },
  getMainDay: async () => {
    return await request.get({ url: `/rq/stat/main/day` })
  },
  getOrderSeven: async (params?: any) => {
    return await request.get({ url: `/rq/stat/rh/order/` + params })
  },
  getRepairRigWork: async (params: any) => {
    return await request.get({ url: `/rq/stat/ry/dailyReport/` + params })
  },
  getRyHiZjDailyReports: async () => {
    return await request.get({ url: `/rq/stat/ry/hiZjDailyReports` })
  },
  getRyHiXjDailyReports: async () => {
    return await request.get({ url: `/rq/stat/ry/hiXjDailyReports` })
  },
  getOrderYwcb: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/ywcb/` + params })
  },
  getRigFinished: async () => {
    return await request.get({ url: `/rq/stat/ry/dailyReport/rigFinished` })
  },
  getMainWeek: async () => {
    return await request.get({ url: `/rq/stat/main/week` })
  },
  getMainMonth: async () => {
    return await request.get({ url: `/rq/stat/main/month` })
  },
  getMainTotal: async () => {
    return await request.get({ url: `/rq/stat/main/total` })
  },
  getMainStatus: async () => {
    return await request.get({ url: `/rq/stat/main/status` })
  },
  getInspectDay: async () => {
    return await request.get({ url: `/rq/stat/inspect/day` })
  },
  getInspectWeek: async () => {
    return await request.get({ url: `/rq/stat/inspect/week` })
  },
  getInspectMonth: async () => {
    return await request.get({ url: `/rq/stat/inspect/month` })
  },
  getInspectTotal: async () => {
    return await request.get({ url: `/rq/stat/inspect/total` })
  },
  getInspectStatus: async (params: any) => {
    return await request.get({ url: `/rq/stat/inspect/status`, params })
  },
  getInspectStatuss: async (params: any, dept: any) => {
    return await request.get({ url: `/rq/stat/inspect/statuss/` + dept, params })
  },
  getInspectZjxjCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/home/ry/count/zjxj`, params })
  },
  getInspectLayerWellCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/rd/device/workloadStatistics`, params })
  },
  getInspectRate: async (params: any) => {
    return await request.get({ url: `/rq/stat/ry/device/totalUtilizationRate`, params })
  },
  getProject: async (params: any) => {
    return await request.get({ url: `/rq/stat/project/` + params })
  },
  getInspectTodayStatus: async () => {
    return await request.get({ url: `/rq/stat/inspect/today/status` })
  },
  getInspectDeviceStatus: async (params: any) => {
    return await request.get({ url: `/rq/stat/inspect/device`, params })
  },
  getInspectItemStatus: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order-detail/status`, params })
  },
  getMaintenanceDay: async () => {
    return await request.get({ url: `/rq/stat/maintenance/day` })
  },
  getMaintenanceWeek: async () => {
    return await request.get({ url: `/rq/stat/maintenance/week` })
  },
  getMaintenanceMonth: async () => {
    return await request.get({ url: `/rq/stat/maintenance/month` })
  },
  getMaintenanceTotal: async () => {
    return await request.get({ url: `/rq/stat/maintenance/total` })
  },
  getMaintenanceStatus: async (params?: any) => {
    return await request.get({ url: `/rq/stat/maintenance/status/` + params })
  },
  getRhZql: async (params: any) => {
    return await request.get({ url: `/rq/stat/year/total/gas/` + params })
  },
  getRhZqlTotal: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/zql`, params })
  },
  getRhZqlGases: async (params: any) => {
    return await request.get({ url: `/rq/stat/year/total/gases/` + params })
  },
  getRhZqlToday: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/zql/today/` + params })
  },
  getRhZqlDaily: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/zql/daily/` + params })
  },
  getMaintenanceTodayStatus: async () => {
    return await request.get({ url: `/rq/stat/maintenance/today/status` })
  },
  getMaintenanceType: async () => {
    return await request.get({ url: `/rq/stat/maintenance/type` })
  },
  getDeviceInfoChart: async (deviceCode: any, identifier: any, begin: string, end: string) => {
    return await request.get({
      url:
        `/rq/stat/td/chart/` +
        deviceCode +
        '/' +
        identifier +
        '?beginTime=' +
        begin +
        '&endTime=' +
        end,
      signal: globalController.signal
    })
  },

  getDeviceInfoChartly: async (deviceCode: any, identifier: any, begin: string, end: string) => {
    return await request.get({
      url:
        `/rq/stat/td/chart/ly/` +
        deviceCode +
        '/' +
        identifier +
        '?beginTime=' +
        begin +
        '&endTime=' +
        end,
      signal: globalController.signal
    })
  },

  getDeviceCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/home/device/count/` + params })
  },
  getAbnormalDevice: async (params: any) => {
    return await request.get({ url: `/rq/stat/inspect/exception/device` + params })
  },
  getOutliers: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order-detail/report/status` + params })
  },
  getRhRate: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/device/utilizationRate`, params })
  },
  exportRhDashboard: async (params: any) => {
    return await request.download({ url: `/rq/stat/exportRhDashboard`, params })
  },
  getRhTotalUtilizationRate: async (params: any) => {
    return await request.get({ url: `/rq/stat/rh/device/totalUtilizationRate`, params })
  },
  getRhSevenDayUtilization: async () => {
    return await request.get({ url: `/rq/stat/rh/device/sevenDayUtilization` })
  },
  getRhSixMonthUtilization: async () => {
    return await request.get({ url: `/rq/stat/rh/device/sixMonthUtilization` })
  },
  getRdSevenDayUtilization: async () => {
    return await request.get({ url: `/rq/stat/rd/device/sevenDayUtilization` })
  },
  getRdSixMonthUtilization: async () => {
    return await request.get({ url: `/rq/stat/rd/device/sixMonthUtilization` })
  },
  getRyRate: async (params: any) => {
    return await request.get({ url: `/rq/stat/ry/device/utilizationRate`, params })
  },
  getRdRate: async (params: any) => {
    return await request.get({ url: `/rq/stat/rd/device/utilizationRate`, params })
  },
  getRhTeamRate: async (params: any) => {
    return await request.get({ url: `rq/stat/rh/device/teamUtilizationRate`, params })
  },
  getRyTeamRate: async (params: any) => {
    return await request.get({ url: `rq/stat/ry/device/teamUtilizationRate`, params })
  },
  getRyProductionBriefs: async (params: any) => {
    return await request.get({ url: `/pms/iot-ry-daily-report/productionBriefs`, params })
  },
  getRyNptCount: async (params: any) => {
    return await request.get({ url: `/rq/stat/ry/device/nptCount`, params })
  },
  getRdNptCount: async (params: any) => {
    return await request.get({ url: `/rq/stat/rd/device/productionAbnormality`, params })
  },
  getRdTeamRate: async (params: any) => {
    return await request.get({ url: `rq/stat/rd/device/teamUtilizationRate`, params })
  },

  getMaintainCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/home/maintain/count/` + params })
  },
  getMainWorkCount: async () => {
    return await request.get({ url: `/rq/stat/home/work/count` })
  },
  getInspectCount: async () => {
    return await request.get({ url: `/rq/stat/home/inspect/count` })
  },
  getDeviceStatusCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/home/device/status/` + params })
  },

  getDeviceTypeCount: async (params?: any) => {
    return await request.get({ url: `/rq/stat/home/device/type/` + params })
  },
  getDeptCount: async () => {
    return await request.get({ url: `/rq/stat/home/dept` })
  },
  getSafeCount: async () => {
    return await request.get({ url: `/rq/stat/home/safe` })
  },
  getSafeCount1: async (deptId: number) => {
    return await request.get({ url: `/rq/qhse-safe-day/get/dept/` + deptId, params: { deptId } })
  },
  getMttr: async () => {
    return await request.get({ url: `/rq/stat/mttr` })
  },
  getMaterial: async () => {
    return await request.get({ url: `/pms/iot-outbound/materials/top` })
  },
  getDeptStatistics: async (params: any) => {
    return await request.get({ url: `/rq/iot-opeation-fill/getCount`, params })
  },
  getDevSta: async (params: any) => {
    return await request.get({ url: `/rq/iot-opeation-fill/getDeviceCount`, params })
  },
  getRdWorkload: async (params: any) => {
    return await request.get({ url: `/pms/iot-rd-daily-report/summaryStatistics`, params })
  },
  getRdWorkloadYear: async (params: any) => {
    return await request.get({ url: `/pms/iot-rd-daily-report/workloadKanban`, params })
  },
  getUtilization: async (params: any) => {
    return await request.get({ url: `/rq/stat/rd/device/utilizationRates`, params })
  },
  getWhl: async () => {
    return await request.get({ url: `/rq/report/rd/whl` })
  },
  getDeviceException: async (params: any) => {
    return await request.get({ url: `/rq/stat/inspect/exception/device`, params })
  },
  getStatusException: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order-detail/report/status`, params })
  },
  getProductionException: async (params: any) => {
    return await request.get({ url: `/pms/iot-rd-daily-report/abnormalAlert`, params })
  },
  getConstructionBriefing: async () => {
    return await request.get({ url: `/pms/iot-rd-daily-report/constructionBriefing` })
  },
  getRdRecentWbcs: async () => {
    return await request.get({ url: `/rq/stat/recent/wbcs/rd` })
  },
  getRdNewClassify: async () => {
    return await request.get({ url: `/rq/stat/new/classify` })
  },

  // 瑞都看板（新）
  // 获取ssoToken
  getSsoToken: async () => {
    return await request.get({ url: `/rq/iot-fine-report/createSsoToken` })
  }
}
