import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgvStatusVO, AgvStatusForm, AgvStatusId, AgvStatusIds, AgvStatusQuery } from '@/api/wcs/agvStatus/types';

/**
 * 查询AGV状态列表
 * @param query
 * @returns {*}
 */

export const listAgvStatus = (query?: AgvStatusQuery): AxiosPromise<AgvStatusVO[]> => {
  return request({
    url: '/wcs/agvStatus/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询AGV状态详细
 * @param robotcode
 */
export const getAgvStatus = (robotcode: AgvStatusId): AxiosPromise<AgvStatusVO> => {
  return request({
    url: '/wcs/agvStatus/' + robotcode,
    method: 'get'
  });
};

/**
 * 批量查询AGV状态详细
 * @param ids
 */
export const getAgvStatusByIds = (ids: AgvStatusIds): AxiosPromise<AgvStatusVO[]> => {
  return request({
    url: '/wcs/agvStatus/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计AGV状态数量
 * @param query
 */
export const countAgvStatus = (query?: AgvStatusQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/agvStatus/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的AGV状态
 * @param query
 */
export const existsAgvStatus = (query?: AgvStatusQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/agvStatus/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增AGV状态
 * @param data
 */
export const addAgvStatus = (data: AgvStatusForm) => {
  return request({
    url: '/wcs/agvStatus',
    method: 'post',
    data: data
  });
};

/**
 * 修改AGV状态
 * @param data
 */
export const updateAgvStatus = (data: AgvStatusForm) => {
  return request({
    url: '/wcs/agvStatus',
    method: 'put',
    data: data
  });
};

/**
 * 删除AGV状态
 * @param robotcode
 */
export const delAgvStatus = (robotcode: AgvStatusId | AgvStatusIds) => {
  return request({
    url: '/wcs/agvStatus/' + robotcode,
    method: 'delete'
  });
};
