import request from '@/config/axios'

// 瑞恒日报 VO
export interface IotRhDailyReportVO {
  createTime: number
  id: number // 主键id
  deptId: number // 施工队伍id
  projectId: number // 项目id
  taskId: number // 任务id
  projectClassification: string // 项目类别(钻井 修井 注氮 酸化压裂... )
  relocationDays: number // 搬迁安装天数
  designInjection: number // 设计注气量
  transitTime: number // 运行时效
  dailyGasInjection: number // 当日注气量(万方)
  dailyWaterInjection: number // 当日注水量(方)
  dailyInjectGasTime: number // 当日注气时间(H)
  dailyInjectWaterTime: number // 当日注水时间(H)
  dailyPowerUsage: number // 当日用电量(kWh)
  nonProductionTime: number // 非生产时间(H)
  nptReason: string // 非生产时间原因
  constructionStartDate: Date // 施工开始日期
  constructionEndDate: Date // 施工结束日期
  productionStatus: string // 当日生产情况生产动态
  nextPlan: string // 下步工作计划
  constructionStatus: number // 施工状态(动迁 准备 施工 完工)
  personnel: string // 人员情况
  capacity: number // 产能
  totalGasInjection: number // 累计注气量(万方)
  totalWaterInjection: number // 累计注水量(方)
  cumulativeCompletion: number // 累计完工井次
  extProperty: string // 不同专业公司的扩展属性值
  sort: number // 排序值
  remark: string // 备注
  status: number // 状态(0启用 1禁用)
  processInstanceId: string // 流程实例id
  auditStatus: number // 审批状态 未提交、审批中、审批通过、审批不通过、已取消
}

export interface IotRhDailyReportTotalWorkloadVO {
  totalFuelConsumption?: number
  totalPowerConsumption?: number
  totalWaterInjection?: number
  totalGasInjection?: number
  totalN2GasInjection?: number
  totalNaturalGasInjection?: number
  utilizationRate?: number
}

// 瑞恒日报 API
export const IotRhDailyReportApi = {
  // 查询瑞恒日报分页
  getIotRhDailyReportPage: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/page`, params })
  },

  getIotRhDailyReportTeamPage: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/teamReports`, params })
  },

  getIotRhDailyReportWellPage: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/wellReports`, params })
  },

  getIotRhDailyReportSummary: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/statistics`, params })
  },

  getIotRhDailyReportSummaryPolyline: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/polylineStatistics`, params })
  },

  nptStatistics: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/nptStatistics`, params })
  },

  // 累计工作量统计
  totalWorkload: async (params: any): Promise<IotRhDailyReportTotalWorkloadVO> => {
    return await request.get({ url: `/pms/iot-rh-daily-report/totalWorkload`, params })
  },

  // 按照日期查询瑞恒日报统计数据 已填报 未填报 数量
  rhDailyReportStatistics: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/rhDailyReportStatistics`, params })
  },

  exportRhDailyReportStatistics: async (params: any) => {
    return await request.download({
      url: `/pms/iot-rh-daily-report/exportStatistics`,
      params
    })
  },

  // 按照日期查询瑞恒日报统计数据 未填报队伍明细
  rhUnReportDetails: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/rhUnReportDetails`, params })
  },

  // 查询项目任务实际进度列表
  taskActualProgress: async (params: any) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/taskActualProgress`, params })
  },

  // 查询瑞恒日报详情
  getIotRhDailyReport: async (id: number) => {
    return await request.get({ url: `/pms/iot-rh-daily-report/get?id=` + id })
  },

  // 新增瑞恒日报
  createIotRhDailyReport: async (data: IotRhDailyReportVO) => {
    return await request.post({ url: `/pms/iot-rh-daily-report/create`, data })
  },

  // 修改瑞恒日报
  updateIotRhDailyReport: async (data: IotRhDailyReportVO) => {
    return await request.put({ url: `/pms/iot-rh-daily-report/update`, data })
  },

  approvalIotRhDailyReport: async (data: { id: number; auditStatus: 20 | 30; opinion: string }) => {
    return await request.put({ url: `/pms/iot-rh-daily-report/approval`, data })
  },

  // 删除瑞恒日报
  deleteIotRhDailyReport: async (id: number) => {
    return await request.delete({ url: `/pms/iot-rh-daily-report/delete?id=` + id })
  },

  // 导出瑞恒日报 Excel
  exportIotRhDailyReport: async (params) => {
    return await request.download({ url: `/pms/iot-rh-daily-report/export-excel`, params })
  },
  exportIotRhDailyReportWell: async (params) => {
    return await request.download({ url: `/pms/iot-rh-daily-report/exportSingleWells`, params })
  },
  exportIotRhDailyReportTeam: async (params) => {
    return await request.download({ url: `/pms/iot-rh-daily-report/exportSingleTeams`, params })
  }
}
