import request from '@/utils/request'

// 查询工序计划主列表
export function listOperationPlanningMain(query) {
  return request({
    url: '/system/operationPlanningMain/list',
    method: 'get',
    params: query
  })
}

// 查询工序计划主详细
export function getOperationPlanningMain(id) {
  return request({
    url: '/system/operationPlanningMain/' + id,
    method: 'get'
  })
}

// 新增工序计划主
export function addOperationPlanningMain(data) {
  return request({
    url: '/system/operationPlanningMain',
    method: 'post',
    data: data
  })
}

// 修改工序计划主
export function updateOperationPlanningMain(data) {
  return request({
    url: '/system/operationPlanningMain',
    method: 'put',
    data: data
  })
}

// 删除工序计划主
export function delOperationPlanningMain(id) {
  return request({
    url: '/system/operationPlanningMain/' + id,
    method: 'delete'
  })
}

export function cascadeListOperationPlanningMain(query) {
  return request({
    url: '/system/operationPlanningMain/cascadeList',
    method: 'get',
    params: query
  })
}

export function updateOperationPlanningMainOperators(data) {
  return request({
    url: '/system/operationPlanningMain/updateOperators',
    method: 'put',
    data: data
  })
}

export function syncOperationPlanningMain(data) {
  return request({
    url: '/system/operationPlanningMain/sync',
    method: 'post',
    data: data
  })
}

export function queryFromK3OperationPlanningMain(query) {
  return request({
    url: '/system/operationPlanningMain/queryFromK3',
    method: 'get',
    params: query
  })
}

// 产能分析
export function getCapacityAnalysisApi(query) {
  return request({
    url: '/system/material/buildCapacity',
    method: 'get',
    params: query
  })
}

// 产能分析：获取生产令号下拉选项
export function getProductionOrderNoOptions(query) {
  return request({
    url: '/system/plan/productionOrderNoOptions',
    method: 'get',
    params: query
  })
}

// 产能分析：导出
export function exportCapacityAnalysisApi(query) {
  return request({
    url: '/system/material/buildCapacity/export',
    method: 'post',
    params: query,
    responseType: 'blob'
  })
}

// 产能分析：根据生产令号模糊查询带出产品信息
export function selectByProCode(productionOrderNo) {
  return request({
    url: '/system/plan/selectByProCode',
    method: 'post',
    params: { productionOrderNo }
  })
}
