import request from '@/utils/request'

// 查询库存列表
export function listInventoryCount(query) {
  return request({
    url: '/inventory/inventory/listCount',
    method: 'get',
    params: query
  })
}

// 查询库存列表
export function listInventory(query) {
  return request({
    url: '/inventory/inventory/list',
    method: 'get',
    params: query
  })
}

// 查询库存详细
export function getInventory(id) {
  return request({
    url: '/inventory/inventory/' + id,
    method: 'get'
  })
}

// 新增库存
export function addInventory(data) {
  return request({
    url: '/inventory/inventory',
    method: 'post',
    data: data
  })
}

// 批量新增库存
export function batchAddInventory(data){
    return request({
        url: '/inventory/inventory/batchAdd',
        method: 'post',
        data: data
    })
}

// 修改库存
export function updateInventory(data) {
  return request({
    url: '/inventory/inventory',
    method: 'put',
    data: data
  })
}

// 删除库存
export function delInventory(id) {
  return request({
    url: '/inventory/inventory/' + id,
    method: 'delete'
  })
}

// 批量删除库存
export function delInventoryByIds(ids) {
  return request({
    url: '/inventory/inventory/' + ids,
    method: 'delete'
  })
}

export function listInventoryByMaterialId(params) {
  return request({
    url: '/inventory/inventory/listByMaterialId',
    method: 'post',
    // 改为data传递JSON对象，适配后端实体类接收
    data: params
    // 若后端仍要求用params（URL参数）传递，保留下面这行，注释上面的data
    // params: params
  })
}


export function Ship(data) {
  return request({
    url: '/inventory/inventory/ship',
    method: 'post',
    data: data
  })
}
// 导出库存列表
export function exportInventory(query) {
  return request({
    url: '/inventory/inventory/export',
    method: 'post',
    params: query
  })
}

// 查询库存明细列表（根据物料标识及检索条件）
export function listInventoryDetail(query) {
  return request({
    url: '/inventory/inventory/detailList',
    method: 'get',
    params: query
  })
}

// 统计库存物料超出预警值
export function exceedWarnValue() {
  return request({
    url: '/inventory/inventory/exceed',
    method: 'get'
  })
}
export function inventoryTopTenByAmount() {
  return request({
    url: '/inventory/inventory/inventoryTopTenByAmount',
    method: 'post'
  })
}
export function inventoryTopTenByQuantity() {
  return request({
    url: '/inventory/inventory/inventoryTopTenByQuantity',
    method: 'post'
  })
}
