import request from '@/utils/request';

// 根据工艺路线编码获取工序
export async function getProcessByRoute (data) {
  const res = await request.post(
    '/main/producerouting/taskinstance/page',
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 根据生产版本获取工序
export async function getTaskListById (id) {
  const res = await request.get(`/main/produceversion/getTaskListById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// SAP-查询库存
export async function realTimeStorage (params) {
  const res = await request.get(`/sap/sync/realTimeStorage`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 根据生产版本ID查询bom子项列表
export async function bomSubListByVersionId (params) {
  const res = await request.get(
    `/main/produceversion/resource/bomSubListByVersionId/${params.versionId}/${params.taskInstanceId}`
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 工位
export async function factoryworkstation (params) {
  const res = await request.get(`/main/factoryworkstation/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
