import request from './request'

// 看板
export const getDashboardSummary = () => request.get('/dashboard/summary')

// 物料跟踪
export const getCoils = params => request.get('/material/coils', { params })
export const getCoil = coilNo => request.get(`/material/coils/${coilNo}`)
export const createCoil = data => request.post('/material/coils', data)
export const updateCoil = (coilNo, data) => request.put(`/material/coils/${coilNo}`, data)
export const getTracking = params => request.get('/material/tracking', { params })

// 实绩管理
export const getProductionRecords = params => request.get('/production/', { params })
export const createProductionRecord = data => request.post('/production/', data)
export const updateProductionRecord = (id, data) => request.put(`/production/${id}`, data)

// 计划管理
export const getPlans = params => request.get('/plan/', { params })
export const createPlan = data => request.post('/plan/', data)
export const updatePlan = (id, data) => request.put(`/plan/${id}`, data)
export const confirmPlan = id => request.patch(`/plan/${id}/confirm`)

// 停机管理
export const getDowntimeCategories = () => request.get('/downtime/categories')
export const getDowntimeRecords = params => request.get('/downtime/', { params })
export const createDowntime = data => request.post('/downtime/', data)
export const updateDowntime = (id, data) => request.put(`/downtime/${id}`, data)

// 设备管理
export const getEquipments = params => request.get('/equipment/', { params })
export const createEquipment = data => request.post('/equipment/', data)
export const updateEquipment = (id, data) => request.put(`/equipment/${id}`, data)
export const getEquipmentMaintenance = (id, params) => request.get(`/equipment/${id}/maintenance`, { params })
export const createMaintenance = data => request.post('/equipment/maintenance', data)

// 报文监控
export const getMessageLogs = params => request.get('/message/logs', { params })
export const getMessageLog = id => request.get(`/message/logs/${id}`)

// 工艺预测模型
export const predictAcidSpeed  = data => request.post('/prediction/acid-speed', data)
export const predictTension     = data => request.post('/prediction/tension', data)
export const predictQuality     = data => request.post('/prediction/quality', data)
export const predictConsumption = data => request.post('/prediction/consumption', data)

// 模型校准
export const getCalibration         = ()     => request.get('/prediction/calibration')
export const calibrateAcidSpeed     = data   => request.post('/prediction/calibration/acid-speed', data)
export const calibrateTension       = data   => request.post('/prediction/calibration/tension', data)
export const calibrateQuality       = data   => request.post('/prediction/calibration/quality', data)
export const resetCalibration       = model  => request.post(`/prediction/calibration/reset/${model}`)

// 设备巡检
export const getInspectionLocations = () => request.get('/inspection/locations')
export const createInspectionLocation = data => request.post('/inspection/locations', data)
export const getInspectionRecords = params => request.get('/inspection/records', { params })
export const createInspectionRecord = data => request.post('/inspection/records', data)

// 质量管理
export const getQualityList    = params => request.get('/quality/', { params })
export const createQuality     = data   => request.post('/quality/', data)
export const updateQuality     = (id, data) => request.put(`/quality/${id}`, data)
export const getQualitySummary = ()     => request.get('/quality/summary')
