import request from '@/config/axios'

// 生产工艺数据 VO
export interface ProcessDataVO {
  id?: number
  createTime?: Date
  // 前处理
  pretreatmentVoltage?: number
  pretreatmentCurrent?: number
  pretreatmentWaterPressure?: number
  pretreatmentAirPressure?: number
  pretreatmentTemperature?: number
  pretreatmentViscosity?: number
  pretreatmentLiquidLevel?: number
  pretreatmentStatus?: string
  // 蒸发
  evaporationVoltage?: number
  evaporationCurrent?: number
  evaporationWaterPressure?: number
  evaporationAirPressure?: number
  evaporationCalibrationPressure?: number
  evaporationTemperature?: number
  evaporationConcentration?: number
  evaporationStatus?: string
  // 杀菌
  sterilizationPressure?: number
  sterilizationSpeed?: number
  sterilizationTemp?: number
  sterilizationCoolingTemp?: number
  sterilizationTankLevel?: number
  sterilizationStatus?: string
  // 灌装
  fillingSteamPressure?: number
  fillingAirPressure?: number
  fillingTemp?: number
  fillingSpeed?: number
  fillingStatus?: string
}

// 趋势数据 VO
export interface ProcessTrendVO {
  times: string[]
  pretreatmentVoltage: number[]
  pretreatmentCurrent: number[]
  pretreatmentTemperature: number[]
  pretreatmentLiquidLevel: number[]
  evaporationTemperature: number[]
  evaporationConcentration: number[]
  sterilizationTemp: number[]
  sterilizationCoolingTemp: number[]
  sterilizationTankLevel: number[]
  fillingTemp: number[]
  fillingSpeed: number[]
}

// 获取最新工艺数据
export const getLatestProcessData = async () => {
  return await request.get({ url: '/mes/process/latest' })
}

// 获取工艺数据分页
export const getProcessDataPage = async (params: any) => {
  return await request.get({ url: '/mes/process/page', params })
}

// 获取趋势数据
export const getTrendData = async (params: { beginTime?: string; endTime?: string }) => {
  return await request.get({ url: '/mes/process/trend', params })
}

// 获取工艺数据详情
export const getProcessData = async (id: number) => {
  return await request.get({ url: '/mes/process/get', params: { id } })
}

// 创建工艺数据
export const createProcessData = async (data: ProcessDataVO) => {
  return await request.post({ url: '/mes/process/create', data })
}

// 更新工艺数据
export const updateProcessData = async (data: ProcessDataVO) => {
  return await request.put({ url: '/mes/process/update', data })
}

// 删除工艺数据
export const deleteProcessData = async (id: number) => {
  return await request.delete({ url: '/mes/process/delete', params: { id } })
}
