import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SubtaskInstanceVO, SubtaskInstanceForm, SubtaskInstanceId, SubtaskInstanceIds, SubtaskInstanceQuery } from '@/api/wcs/subtaskInstance/types';

/**
 * 查询agv任务列表
 * @param query
 * @returns {*}
 */

export const listSubtaskInstance = (query?: SubtaskInstanceQuery): AxiosPromise<SubtaskInstanceVO[]> => {
  return request({
    url: '/wcs/subtaskInstance/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询agv任务详细
 * @param id
 */
export const getSubtaskInstance = (id: SubtaskInstanceId): AxiosPromise<SubtaskInstanceVO> => {
  return request({
    url: '/wcs/subtaskInstance/' + id,
    method: 'get'
  });
};

/**
 * 批量查询agv任务详细
 * @param ids
 */
export const getSubtaskInstanceByIds = (ids: SubtaskInstanceIds): AxiosPromise<SubtaskInstanceVO[]> => {
  return request({
    url: '/wcs/subtaskInstance/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计agv任务数量
 * @param query
 */
export const countSubtaskInstance = (query?: SubtaskInstanceQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/subtaskInstance/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的agv任务
 * @param query
 */
export const existsSubtaskInstance = (query?: SubtaskInstanceQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/subtaskInstance/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增agv任务
 * @param data
 */
export const addSubtaskInstance = (data: SubtaskInstanceForm) => {
  return request({
    url: '/wcs/subtaskInstance',
    method: 'post',
    data: data
  });
};

/**
 * 修改agv任务
 * @param data
 */
export const updateSubtaskInstance = (data: SubtaskInstanceForm) => {
  return request({
    url: '/wcs/subtaskInstance',
    method: 'put',
    data: data
  });
};

/**
 * 删除agv任务
 * @param id
 */
export const delSubtaskInstance = (id: SubtaskInstanceId | SubtaskInstanceIds) => {
  return request({
    url: '/wcs/subtaskInstance/' + id,
    method: 'delete'
  });
};
