import {
  BaseListResult,
  GetDeadProductsListParams,
  GetReserveWarningListParams,
  DeadProductsListData,
  ReserveWarningListData,
  GetStockListParams,
  StockListData,
  GetGSInterfaceListParams,
  GSInterfaceData,
  GetProductionRequisitionListParams,
  ProductionRequisitionListData,
  GetSellOrderListParams,
  SellOrderListData,
  GetRelocationOrderListParams,
  RelocationOrderListData,
  BaseResult,
  GetDeleteLogListParams,
  DeleteLogListData,
  GetGSErrorLogListParams,
  GSErrorListData,
  GetOtherInParams,
  OtherInListData,
  GetOtherOutParams,
} from '@models';
import {request} from './request';

const BASE_URL = '/queryList';

/** 呆滞品查询 */
export function getDeadProductsList(
  data: GetDeadProductsListParams,
  signal?: AbortSignal,
): BaseListResult<DeadProductsListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/dullGoods`,
    data,
    signal,
  });
}

/** 物料储量预警查询 */
export function getReserveWarningList(
  data: GetReserveWarningListParams,
  signal?: AbortSignal,
): BaseListResult<ReserveWarningListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/reserveWarnings`,
    data,
    signal,
  });
}

/** 库存查询 */
export function getStockList(
  data: GetStockListParams,
  signal?: AbortSignal,
): BaseListResult<StockListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/storageLocation`,
    data,
    signal,
  });
}

/** gs接口日志查询 */
export function getGSInterfaceList(
  data: GetGSInterfaceListParams,
  signal?: AbortSignal,
): BaseListResult<GSInterfaceData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getAccess`,
    data,
    signal,
  });
}

/** 导出接口日志 */
export function exportGSInterface(data: GetGSInterfaceListParams) {
  return request({
    method: 'GET',
    url: `${BASE_URL}/onOffExcel`,
    data,
  });
}

/** 生产领用查询 */
export function getProductionRequisitionList(
  data: GetProductionRequisitionListParams,
  signal?: AbortSignal,
): BaseListResult<ProductionRequisitionListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getAskGoods`,
    data,
    signal,
  });
}

/** 生产领用导出 */
export function exportProductionRequisitionList(
  data: GetProductionRequisitionListParams,
): any {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getAskGoodsExcel`,
    data,
    skipError: true,
  });
}

/** 删除生产领料单 */
export function delProductionRequisition(id: string): BaseResult {
  return request({
    method: 'DELETE',
    url: `/askGoods/delAskGoods`,
    data: {id},
  });
}

/** 非生产领用查询 */
export function getUnproductionRequisitionList(
  data: GetProductionRequisitionListParams,
  signal?: AbortSignal,
): BaseListResult<ProductionRequisitionListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getInvite`,
    data,
    signal,
  });
}

/** 非生产领用导出 */
export function exportUnproductionRequisitionList(
  data: GetProductionRequisitionListParams,
): BaseListResult<ProductionRequisitionListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getInviteExcel`,
    data,
    skipError: true,
  });
}

/** 删除非生产领用 */
export function delUnProductionRequisition(id: string): BaseResult {
  return request({
    method: 'DELETE',
    data: {id},
    url: '/invite/delAskGoods',
  });
}

/** 查询销售单 */
export function getSellOrderList(
  data: GetSellOrderListParams,
  signal?: AbortSignal,
): BaseListResult<SellOrderListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getDelivery`,
    data,
    signal,
  });
}

/** 删除销售单 */
export function deleSellOrder(id: string): BaseResult {
  return request({
    method: 'DELETE',
    url: `/delivery/delDelivery`,
    data: {id},
  });
}

/** 导出销售单 */
export function exportSellOrderList(data: GetSellOrderListParams): any {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getDeliveryExcel`,
    data,
    skipError: true,
  });
}

/** 移库单 */
export function getRelocationOrderList(
  data: GetRelocationOrderListParams,
  signal?: AbortSignal,
): BaseListResult<RelocationOrderListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getWarehouseTransfer`,
    data,
    signal,
  });
}

/**  删除移库单 */
export function deleRelocationOrder(id: string): BaseResult {
  return request({
    method: 'DELETE',
    url: '/warehouseTransfer/delWarehouseTransfer',
    data: {id},
  });
}

/** 导出移库单 */
export function exportRelocationOrderList(
  data: GetRelocationOrderListParams,
): BaseListResult<RelocationOrderListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getWarehouseTransferExcel`,
    data,
    skipError: true,
  });
}

/** 获取单据删除日志 */
export function getDeleteLogList(
  data: GetDeleteLogListParams,
  signal?: AbortSignal,
): BaseListResult<DeleteLogListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getLogData`,
    data,
    signal,
  });
}

/** 导出呆滞品 */
export function exportDeadproduct(data: GetDeadProductsListParams): any {
  return request({
    method: 'GET',
    data,
    url: `${BASE_URL}/dullGoodsExport`,
  });
}

/** 导出储量预警 */
export function exportWarning(data: GetReserveWarningListParams): any {
  return request({
    method: 'GET',
    data,
    url: `${BASE_URL}/reserveWarningsExport`,
  });
}

/** 导出储量预警 */
export function exportStockList(data: GetStockListParams): any {
  return request({
    method: 'GET',
    data,
    url: `${BASE_URL}/exportStorageLocation`,
  });
}

/** 导出单据删除日志 */
export function exportOrderDeleteList(data: GetDeleteLogListParams): any {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getLogDataExcel`,
    data,
  });
}

/** gs错误日志 */
export function getGSErrorInterface(
  data: GetGSErrorLogListParams,
  signal?: AbortSignal,
): BaseListResult<GSErrorListData> {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getErrorList`,
    data,
    signal,
  });
}

/** 导出gs错误日志 */
export function exportGSErrorInterface(data: GetGSErrorLogListParams) {
  return request({
    method: 'GET',
    url: `${BASE_URL}/getErrorExcel`,
    data,
  });
}

/** 其他入库 */
export function getOtherIn(
  data: GetOtherInParams,
  signal?: AbortSignal,
): BaseListResult<OtherInListData> {
  return request({
    method: 'GET',
    data,
    url: `${BASE_URL}/getOtherReceivingGoods`,
    signal,
  });
}

/** 其他出库 */
export function getOtherOut(
  data: GetOtherOutParams,
  signal?: AbortSignal,
): BaseListResult<any> {
  return request({
    method: 'GET',
    data,
    url: `${BASE_URL}/getOtherShipments`,
    signal,
  });
}

/** 删除其他入库 */
export function deleteOtherIn(id: string) {
  return request({
    method: 'DELETE',
    data: {id},
    url: '/warehousing/delOtherReceivingGoods',
  });
}

/** 删除其他出库 */
export function deleteOtherOut(id: string) {
  return request({
    method: 'DELETE',
    data: {id},
    url: '/warehousing/delOtherShipments',
  });
}
