import request from '@/config/axios'

// 计量器具-证书管理 VO
export interface IotMeasureCertVO {
  id: number // 主键id
  type: string // 证书类型
  classify: string // 证书类别
  certBelong: string // 证书所属公司/个人
  certOrg: string // 证书颁发机构
  certStandard: string // 证书标准
  certIssue: Date // 证书颁发时间
  certExpire: Date // 证书有效期
  noticeBefore: number // 到期前提醒
  certPic: string // 证书图片上传
  remark: string // 备注
  deptId: number // 部门id
}

// 计量器具-证书管理 API
export const IotMeasureCertApi = {
  // 查询计量器具-证书管理分页
  getIotMeasureCertPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-measure-cert/page`, params })
  },

  // 查询计量器具-证书管理详情
  getIotMeasureCert: async (id: number) => {
    return await request.get({ url: `/rq/iot-measure-cert/get?id=` + id })
  },

  // 新增计量器具-证书管理
  createIotMeasureCert: async (data: IotMeasureCertVO) => {
    return await request.post({ url: `/rq/iot-measure-cert/create`, data })
  },

  // 修改计量器具-证书管理
  updateIotMeasureCert: async (data: IotMeasureCertVO) => {
    return await request.put({ url: `/rq/iot-measure-cert/update`, data })
  },

  // 删除计量器具-证书管理
  deleteIotMeasureCert: async (id: number) => {
    return await request.delete({ url: `/rq/iot-measure-cert/delete?id=` + id })
  },

  // 导出计量器具-证书管理 Excel
  exportIotMeasureCert: async (params) => {
    return await request.download({ url: `/rq/iot-measure-cert/export-excel`, params })
  },
  // 统计
  getIotMeasureCertStatistics: async (id) => {
    return await request.get({ url: `/rq/iot-measure-cert/stat?deptId=${id}` })
  }
}

// 资质证书
export const IotCertificateApi = {
  // 获得证书分页
  getCertificateList: async (params) => {
    return await request.get({ url: `/rq/qhse-org-cert/page`, params })
  },
  // 删除证书
  deleteCertificate: async (id) => {
    return await request.delete({ url: `/rq/qhse-org-cert/delete?id=` + id })
  },
  // 新增证书
  createCertificate: async (data) => {
    return await request.post({ url: `/rq/qhse-org-cert/create`, data })
  },
  // 修改证书
  updateCertificate: async (data) => {
    return await request.put({ url: `/rq/qhse-org-cert/update`, data })
  },
  // 导出证书 Excel
  exportCertificate: async (params) => {
    return await request.download({ url: `/rq/qhse-org-cert/export-excel`, params })
  },
  //统计
  getCertificateStatistics: async (id) => {
    return await request.get({ url: `/rq/qhse-org-cert/stat?deptId=${id}` })
  }
}

// 计量器具台账 VO
export const IotInstrumentApi = {
  // 获得计量器具台账分页
  getInstrumentList: async (params) => {
    return await request.get({ url: `rq/iot-measure-book/page`, params })
  },
  // 删除计量器具台账
  deleteInstrument: async (id) => {
    return await request.delete({ url: `/rq/iot-measure-book/delete?id=` + id })
  },
  // 更新计量器具台账
  updateInstrument: async (data) => {
    return await request.put({ url: `/rq/iot-measure-book/update`, data })
  },
  // 新增计量器具台账
  createInstrument: async (data) => {
    return await request.post({ url: `/rq/iot-measure-book/create`, data })
  },
  // 导出计量器具台账 Excel
  exportInstrument: async (params) => {
    return await request.download({ url: `/rq/iot-measure-book/export-excel`, params })
  },
  //统计
  getInstrumentStatistics: async (id) => {
    return await request.get({ url: `/rq/iot-measure-book/stat?deptId=${id}` })
  }
}

// 计量器具-检测校准明细 VO
export interface IotMeasureDetectVO {
  id: number // 主键id
  measureId: number // 计量器具id
  detectDate: string // 检测/校准日期
  detectOrg: string // 检测/校准机构
  detectContent: string // 检测/校准内容
  validityPeriod: Date // 检测/校准有效期
  detectAmount: number // 校准金额
  deptId: number // 部门id
}

// 计量器具-检测校准明细 API
export const IotMeasureDetectApi = {
  // 查询计量器具-检测校准明细分页
  getIotMeasureDetectPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-measure-detect/page`, params })
  },

  // 查询计量器具-检测校准明细详情
  getIotMeasureDetect: async (id: number) => {
    return await request.get({ url: `/rq/iot-measure-detect/get?id=` + id })
  },

  // 新增计量器具-检测校准明细
  createIotMeasureDetect: async (data: IotMeasureDetectVO) => {
    return await request.post({ url: `/rq/iot-measure-detect/create`, data })
  },

  // 修改计量器具-检测校准明细
  updateIotMeasureDetect: async (data: IotMeasureDetectVO) => {
    return await request.put({ url: `/rq/iot-measure-detect/update`, data })
  },

  // 删除计量器具-检测校准明细
  deleteIotMeasureDetect: async (id: number) => {
    return await request.delete({ url: `/rq/iot-measure-detect/delete?id=` + id })
  },

  // 导出计量器具-检测校准明细 Excel
  exportIotMeasureDetect: async (params) => {
    return await request.download({ url: `/rq/iot-measure-detect/export-excel`, params })
  }
}

// 计量器具-使用记录 VO
export interface IotMeasureRecordVO {
  id: number // 主键id
  measureId: number // 计量器具id
  useDate: string // 使用日期
  useReason: string // 使用原因
  measureProject: string // 计量项目
  usePerson: string // 使用人
  userId: number // 使用人id
  deptId: number // 部门id
}

// 计量器具-使用记录 API
export const IotMeasureRecordApi = {
  // 查询计量器具-使用记录分页
  getIotMeasureRecordPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-measure-record/page`, params })
  },

  // 查询计量器具-使用记录详情
  getIotMeasureRecord: async (id: number) => {
    return await request.get({ url: `/rq/iot-measure-record/get?id=` + id })
  },

  // 新增计量器具-使用记录
  createIotMeasureRecord: async (data: IotMeasureRecordVO) => {
    return await request.post({ url: `/rq/iot-measure-record/create`, data })
  },

  // 修改计量器具-使用记录
  updateIotMeasureRecord: async (data: IotMeasureRecordVO) => {
    return await request.put({ url: `/rq/iot-measure-record/update`, data })
  },

  // 删除计量器具-使用记录
  deleteIotMeasureRecord: async (id: number) => {
    return await request.delete({ url: `/rq/iot-measure-record/delete?id=` + id })
  },

  // 导出计量器具-使用记录 Excel
  exportIotMeasureRecord: async (params) => {
    return await request.download({ url: `/rq/iot-measure-record/export-excel`, params })
  }
}

// 危险源管理
export const IotDangerApi = {
  // 获得危险源分页
  getDangerList: async (params) => {
    return await request.get({ url: `/rq/iot-danger-source/page`, params })
  },
  // 删除危险源
  deleteDanger: async (id) => {
    return await request.delete({ url: `/rq/iot-danger-source/delete?id=` + id })
  },
  // 添加危险源
  createDanger: async (data) => {
    return await request.post({ url: `/rq/iot-danger-source/create`, data })
  },
  // 修改危险源
  updateDanger: async (data) => {
    return await request.put({ url: `/rq/iot-danger-source/update`, data })
  },
  // 导出危险源 Excel
  exportDanger: async (params) => {
    return await request.download({ url: `/rq/iot-danger-source/export-excel`, params })
  },

  // 统计
  getDangerStatistics: async (id) => {
    return await request.get({ url: `/rq/iot-danger-source/stat?deptId=${id}` })
  }
}

// 环境因素识别
export const IotEnvironmentApi = {
  // 获得环境因素分页
  getEnvironmentList: async (params) => {
    return await request.get({ url: `/rq/iot-environment-recognize/page`, params })
  },
  // 删除环境因素
  deleteEnvironment: async (id) => {
    return await request.delete({ url: `/rq/iot-environment-recognize/delete?id=` + id })
  },

  // 添加环境因素
  createEnvironment: async (data) => {
    return await request.post({ url: `/rq/iot-environment-recognize/create`, data })
  },
  // 修改环境因素
  updateEnvironment: async (data) => {
    return await request.put({ url: `/rq/iot-environment-recognize/update`, data })
  },
  // 导出环境因素 Excel
  exportEnvironment: async (params) => {
    return await request.download({ url: `/rq/iot-environment-recognize/export-excel`, params })
  }
}

// 故障上报
export const IotFailureApi = {
  // 获得故障上报分页
  getFailureList: async (params) => {
    return await request.get({ url: `/rq/iot-accident-report/page`, params })
  },
  // 删除故障上报
  deleteFailure: async (id) => {
    return await request.delete({ url: `/rq/iot-accident-report/delete?id=` + id })
  },
  // 添加故障上报
  createFailure: async (data) => {
    return await request.post({ url: `/rq/iot-accident-report/create`, data })
  },
  // 导出
  exportFailure: async (params) => {
    return await request.download({ url: `/rq/iot-accident-report/export-excel`, params })
  },

  // 修改故障上报
  updateFailure: async (data) => {
    return await request.put({ url: `/rq/iot-accident-report/update`, data })
  },

  // 获取详情
  getFailure: async (id) => {
    return await request.get({ url: `/rq/iot-accident-report/get?id=` + id })
  }
}

// 上报审批
export const IotApprovalApi = {
  // 获得上报审批分页
  getApprovalList: async (params) => {
    return await request.get({ url: `/rq/iot-accident-report/approval/page`, params })
  },

  // 流转信息
  getApprovalProcess: async (id) => {
    return await request.get({ url: `/rq/iot-accident-report-process/page?accidentId=` + id })
  },

  // 添加上报审批
  createApproval: async (params) => {
    return await request.get({ url: `/rq/iot-accident-report/approval`, params })
  }
}

// 隐患排查
export const IotHiddenApi = {
  // 获得隐患排查分页
  getHiddenList: async (params) => {
    return await request.get({ url: `/rq/iot-hazard/page`, params })
  },
  // 删除隐患排查
  deleteHidden: async (id) => {
    return await request.delete({ url: `/rq/iot-hazard/delete?id=` + id })
  },
  // 添加隐患排查
  createHidden: async (data) => {
    return await request.post({ url: `/rq/iot-hazard/create`, data })
  },
  // 修改隐患排查
  updateHidden: async (data) => {
    return await request.put({ url: `/rq/iot-hazard/update`, data })
  },
  // 导出隐患排查 Excel
  exportHidden: async (params) => {
    return await request.download({ url: `/rq/iot-hazard/export-excel`, params })
  },
  // 整改
  rectifyHidden: async (data) => {
    return await request.put({ url: `/rq/iot-hazard/rectify`, data })
  },
  // 统计
  getHiddenStatistics: async (id) => {
    return await request.get({ url: `/rq/iot-hazard/stat?deptId=${id}` })
  }
}

// 隐患排查分类
export const IotHiddenTypeApi = {
  // 创建隐患排查分类
  createHiddenType: async (data) => {
    return await request.post({ url: `/rq/iot-hazard-type/create`, data })
  },
  // 删除隐患排查分类
  deleteHiddenType: async (id) => {
    return await request.delete({ url: `/rq/iot-hazard-type/delete?id=${id}` })
  },
  // 修改隐患排查分类
  updateHiddenType: async (data) => {
    return await request.put({ url: `/rq/iot-hazard-type/update`, data })
  },
  // 获取隐患排查分类
  getHiddenType: async (params) => {
    return await request.get({ url: `/rq/iot-hazard-type/list`, params })
  },
  // 获取上级分类
  getParentCategory: async () => {
    return await request.get({ url: `/rq/iot-hazard-type/simple-list` })
  },
  // 查询分类详情
  getHiddenClassify: async (id: number) => {
    return await request.get({ url: `/rq/iot-hazard-type/get?id=` + id })
  }
}

// SOC数据源分析
export const IotSocApi = {
  // 获得SOC数据源分析分页
  getSocList: async (params) => {
    return await request.get({ url: `/rq/iot-soc-source/page`, params })
  },
  // 删除SOC数据源分析
  deleteSoc: async (id) => {
    return await request.delete({ url: `/rq/iot-soc-source/delete?id=` + id })
  },
  // 获取上级分类
  getParentCategory: async () => {
    return await request.get({ url: `/rq/iot-soc-source/simple-list` })
  },
  // 查询SOC分类详情
  getSocClassify: async (id: number) => {
    return await request.get({ url: `/rq/iot-soc-source/get?id=` + id })
  },
  // 添加SOC数据源分析
  createSoc: async (data) => {
    return await request.post({ url: `/rq/iot-soc-source/create`, data })
  },
  // 修改SOC数据源分析
  updateSoc: async (data) => {
    return await request.put({ url: `/rq/iot-soc-source/update`, data })
  }
}

// SOC卡汇总
export const IotSocSummaryApi = {
  // 获得SOC卡汇总分页
  getIotSocSummaryPage: async (params) => {
    return await request.get({ url: `/rq/iot-soc-summary/page`, params })
  },
  // 删除SOC卡汇总
  deleteIotSocSummary: async (id) => {
    return await request.delete({ url: `/rq/iot-soc-summary/delete?id=` + id })
  },
  // 添加SOC卡汇总
  createIotSocSummary: async (data) => {
    return await request.post({ url: `/rq/iot-soc-summary/create`, data })
  },
  // 修改SOC卡汇总
  updateIotSocSummary: async (data) => {
    return await request.put({ url: `/rq/iot-soc-summary/update`, data })
  },
  // 导出SOC卡汇总 Excel
  exportIotSocSummary: async (params) => {
    return await request.download({ url: `/rq/iot-soc-summary/export-excel`, params })
  },
  // 获取详情
  getIotSocSummary: async (id) => {
    return await request.get({ url: `/rq/iot-soc-summary/get?id=` + id })
  },
  // SOC卡预览
  previewIotSocSummary: async (id) => {
    return await request.download({ url: `/rq/iot-soc-summary/safety-card/preview?id=${id}` })
  },
  // 下载SOC卡
  downloadIotSocSummary: async (id) => {
    return await request.download({ url: `/rq/iot-soc-summary/safety-card/download/${id}` })
  },
  // 统计
  // getSocSummaryStatistics: async (id) => {
  //   return await request.get({ url: `/rq/iot-soc-summary/stat?deptId=${id}` })
  // }
  getSocSummaryStatistics: async (params) => {
    return await request.get({ url: `/rq/iot-soc-summary/stat`, params })
  },

  // 获取统计子类
  getSocSummaryStatisticsChild: async (params) => {
    return await request.get({ url: `/rq/iot-soc-summary/stat/child`, params })
  }
}

// JSA 分析
export const QHSEJsaApi = {
  // 获得JSA分析分页
  getJsaList: async (params) => {
    return await request.get({ url: `/rq/qhse-jsa/page`, params })
  },
  // 删除JSA分析
  deleteJsa: async (id) => {
    return await request.delete({ url: `/rq/qhse-jsa/delete?id=` + id })
  },
  // 添加JSA分析
  createJsa: async (data) => {
    return await request.post({ url: `/rq/qhse-jsa/create`, data })
  },
  // 修改JSA分析
  updateJsa: async (data) => {
    return await request.put({ url: `/rq/qhse-jsa/update`, data })
  },
  // 导出JSA分析 Excel
  exportJsa: async (params) => {
    return await request.download({ url: `/rq/qhse-jsa/export-excel`, params })
  },
  // 获取详情
  getJsa: async (id) => {
    return await request.get({ url: `/rq/qhse-jsa/get?id=` + id })
  }
}

// PTW 管理
export const QHSEPtwApi = {
  // 获得PTW管理分页
  getPtwList: async (params) => {
    return await request.get({ url: `/rq/qhse-ptw/page`, params })
  },
  // 删除PTW管理
  deletePtw: async (id) => {
    return await request.delete({ url: `/rq/qhse-ptw/delete?id=` + id })
  },
  // 添加PTW管理
  createPtw: async (data) => {
    return await request.post({ url: `/rq/qhse-ptw/create`, data })
  },
  // 获取详情
  getPtw: async (id) => {
    return await request.get({ url: `/rq/qhse-ptw/get?id=` + id })
  },
  // 修改PTW管理
  updatePtw: async (data) => {
    return await request.put({ url: `/rq/qhse-ptw/update`, data })
  },
  // 导出PTW管理 Excel
  exportPtw: async (params) => {
    return await request.download({ url: `/rq/qhse-ptw/export-excel`, params })
  }
}

export const kanbanApi = {
  getKanban: async () => {
    return await request.get({ url: `/rq/qhse/stat/number` })
  },
  // 安全生产天数
  getSafeDay: async (id) => {
    return await request.get({ url: `rq/qhse-safe-day/get/dept/company?deptId=${id}` })
  }
}

// 证书人员
export const CertPersonApi = {
  // 获得证书人员分页
  getCertPersonList: async (params) => {
    return await request.get({ url: `/rq/qhse-cert-person/page`, params })
  }, // 删除证书人员
  deleteCertPerson: async (id) => {
    return await request.delete({ url: `/rq/qhse-cert-person/delete?id=` + id })
  },
  // 添加证书人员
  createCertPerson: async (data) => {
    return await request.post({ url: `/rq/qhse-cert-person/create`, data })
  },
  // 修改证书人员
  updateCertPerson: async (data) => {
    return await request.put({ url: `/rq/qhse-cert-person/update`, data })
  },
  // 导出证书人员 Excel
  exportCertPerson: async (params) => {
    return await request.download({ url: `/rq/qhse-cert-person/export-excel`, params })
  },
  // 获取详情
  getCertPerson: async (id) => {
    return await request.get({ url: `/rq/qhse-cert-person/get?id=` + id })
  }
}

// QHSE月报 API
export const QhseMonthReportApi = {
  // 查询QHSE月报分页
  getQhseMonthReportPage: async (params: any) => {
    return await request.get({ url: `/rq/qhse-month-report/page`, params })
  },

  // 查询QHSE月报详情
  getQhseMonthReport: async (id) => {
    return await request.get({ url: `/rq/qhse-month-report/get?id=` + id })
  },

  // 新增QHSE月报
  createQhseMonthReport: async (data) => {
    return await request.post({ url: `/rq/qhse-month-report/create`, data })
  },

  // 修改QHSE月报
  updateQhseMonthReport: async (data) => {
    return await request.put({ url: `/rq/qhse-month-report/update`, data })
  },

  // 删除QHSE月报
  deleteQhseMonthReport: async (id) => {
    return await request.delete({ url: `/rq/qhse-month-report/delete?id=` + id })
  },

  // 导出QHSE月报 Excel
  exportQhseMonthReport: async (params) => {
    return await request.download({ url: `/rq/qhse-month-report/export-excel`, params })
  }
}

// 月报汇总
export const QhseMonthReportSummaryApi = {
  // 获得QHSE月报汇总分页
  getQhseMonthReportSummaryList: async (params) => {
    return await request.get({ url: `/rq/qhse-month-report/page/year-month`, params })
  },

  // 获得QHSE月报汇总详情
  getQhseMonthReportSummary: async (params) => {
    return await request.get({ url: `/rq/qhse-month-report/page`, params })
  }
}

// 应检设备证书
export const InspectDeviceCertApi = {
  // 获得设备证书分页 rq/qhse-device-cert/create
  getInspectDeviceCertList: async (params) => {
    return await request.get({ url: `/rq/qhse-device-cert/page`, params })
  },
  // 删除设备证书
  deleteInspectDeviceCert: async (id) => {
    return await request.delete({ url: `/rq/qhse-device-cert/delete?id=` + id })
  },
  // 添加设备证书
  createInspectDeviceCert: async (data) => {
    return await request.post({ url: `/rq/qhse-device-cert/create`, data })
  },
  // 获取详情
  getInspectDeviceCert: async (id) => {
    return await request.get({ url: `/rq/qhse-device-cert/get?id=` + id })
  },
  // 修改设备证书
  updateInspectDeviceCert: async (data) => {
    return await request.put({ url: `/rq/qhse-device-cert/update`, data })
  },
  // 导出设备证书 Excel
  exportInspectDeviceCert: async (params) => {
    return await request.download({ url: `/rq/qhse-device-cert/export-excel`, params })
  },
  // 统计
  getInspectDeviceCertStat: async (id) => {
    return await request.get({ url: `/rq/qhse-device-cert/stat?deptId=${id}` })
  }
}

// 应急演练
export const EmergencyDrillApi = {
  // 获得应急演练分页
  getEmergencyDrillList: async (params) => {
    return await request.get({ url: `/rq/qhse-emergency-book/page`, params })
  },
  // 删除应急演练
  deleteEmergencyDrill: async (id) => {
    return await request.delete({ url: `/rq/qhse-emergency-book/delete?id=` + id })
  },
  // 添加应急演练
  createEmergencyDrill: async (data) => {
    return await request.post({ url: `/rq/qhse-emergency-book/create`, data })
  },
  // 获取详情
  getEmergencyDrill: async (id) => {
    return await request.get({ url: `/rq/qhse-emergency-book/get?id=` + id })
  },
  // 修改应急演练
  updateEmergencyDrill: async (data) => {
    return await request.put({ url: `/rq/qhse-emergency-book/update`, data })
  },
  // 导出应急演练 Excel
  exportEmergencyDrill: async (params) => {
    return await request.download({ url: `/rq/qhse-emergency-book/export-excel`, params })
  }
}

// 应急演练证书检测
export const EmergencyDrillCertApi = {
  // 获得应急演练证书检测分页
  getEmergencyDrillCertList: async (params) => {
    return await request.get({ url: `/rq/qhse-emergency-cert/page`, params })
  },
  // 删除应急演练证书检测
  deleteEmergencyDrillCert: async (id) => {
    return await request.delete({ url: `/rq/qhse-emergency-cert/delete?id=` + id })
  },
  // 添加应急演练证书检测
  createEmergencyDrillCert: async (data) => {
    return await request.post({ url: `/rq/qhse-emergency-cert/create`, data })
  },
  // 获取详情
  getEmergencyDrillCert: async (id) => {
    return await request.get({ url: `/rq/qhse-emergency-cert/get?id=` + id })
  },
  // 修改应急演练证书检测
  updateEmergencyDrillCert: async (data) => {
    return await request.put({ url: `/rq/qhse-emergency-cert/update`, data })
  },
  // 导出应急演练证书检测 Excel
  exportEmergencyDrillCert: async (params) => {
    return await request.download({ url: `/rq/qhse-emergency-cert/export-excel`, params })
  }
}

// 资料库
export const DataLibraryApi = {
  // 查询资料分页
  getIotInfoPage: async (params: any) => {
    return await request.get({ url: `/rq/qhse-info/page`, params })
  },
  // 查询资料库的子目录及文件
  getChildContentFile: async (params: any) => {
    return await request.post({ url: `/rq/qhse-info/child/content-file`, params })
  },
  getAllChildContentFile: async (params: any) => {
    return await request.post({ url: `/rq/qhse-info/all/content-file`, params })
  },
  getIotInfoFilePage: async (params: any) => {
    return await request.post({ url: `/rq/qhse-info/file/page`, params })
  },
  // 查询资料详情
  getIotInfo: async (id: number) => {
    return await request.get({ url: `/rq/qhse-info/get?id=` + id })
  },

  // 新增资料
  createIotInfo: async (data) => {
    return await request.post({ url: `/rq/qhse-info/create`, data })
  },

  // 修改资料
  updateIotInfo: async (data) => {
    return await request.put({ url: `/rq/qhse-info/update`, data })
  },

  // 删除资料
  deleteIotInfo: async (id: number) => {
    return await request.delete({ url: `/rq/qhse-info/delete?id=` + id })
  },

  // 导出资料 Excel
  exportIotInfo: async (params) => {
    return await request.download({ url: `/rq/qhse-info/export-excel`, params })
  },

  // 获得资料库目录分页
  getFileTreeList: async () => {
    return await request.get({ url: `/rq/qhse-file-tree/simple-list` })
  },

  // 新增目录
  createFileTree: async (data) => {
    return await request.post({ url: `/rq/qhse-file-tree/create`, data })
  },

  // 修改目录
  updateFileTree: async (data) => {
    return await request.put({ url: `/rq/qhse-file-tree/update`, data })
  },
  // 删除目录
  deleteFileTree: async (id: number) => {
    return await request.delete({ url: `/rq/qhse-file-tree/delete?id=` + id })
  },

  getParentIds: async (params: any) => {
    return await request.get({ url: `/rq/qhse-file-tree/ids/` + params })
  }
}
