Cargo-Planner Docs

Integracija

Jei jau turite skaitmeninius įrankius, skirtus valdyti, kas laikoma jūsų sandėlyje, arba kaip tvarkote klientų pakrovimo sąrašus, Cargo-Planner gali tai papildyti šiek tiek integracijos.

Cargo Library Sinchronizacija

Paprasčiausias būdas integruoti su jūsų dabartiniais įrankiais yra per Cargo Library. Visos Cargo-Planner licencijos apima Cargo Library, kuri iš esmės yra minimalus WMS arba išteklių planavimo sistema.

Turint ją nustatytą, lengva kurti naujus pakrovimo sąrašus mūsų internetinėje programoje, per sklandžius importus arba automatinį užbaigimą.

Šis metodas iš esmės gali būti vykdomas kaip CRON darbas arba kasdienė sinchronizacija, o Cargo-Planner pasirūpins visais UI aspektais kuriant pakrovimo sąrašą.

GIF of autocompleting a loadlist

Tačiau Cargo Library nustatymas rankiniu būdu gali būti gana sudėtingas uždavinys. Todėl palaikykime ją sinchronizuotą su bet kokiu įrankiu, kurį šiuo metu naudojate, šiek tiek kodo pagalba.

// Check the Getting Started page to find out how to create your token
const API_TOKEN = 'Token b123...';
const cargoes: CargoPlannerItem[] = [];

// let's pretend we have a source of items/cargoes that looks like this,
// where everything is defined in millimeters and grams.
const sourceItems = [
  {
    id: 511732,
    title: 'Basket Catcher',
    description: '...',
    length: 900,
    width: 900,
    height: 500,
    weight: 20000,
    inner_quantity: 1,
  },
  {
    id: 512789,
    title: 'Putters (10pcs)',
    description: '...',
    length: 210,
    width: 210,
    height: 150,
    weight: 1700,
    inner_quantity: 10,
  },
  // ... etc
];

// Our sourceItems is a little bit different
// from how it's represented in cargo-planner
// so we need to do some adaption of the data
for (let i = 0; i < sourceItems.length; i++) {
  let s = sourceItems[i];
  // we want both our ID and title stored as the name
  const title = `${s.id} - ${s.title}`;

  let cargo: CargoPlannerItem = {
    name: title,
    length_dim: 'MM',
    // Cargo-Planner doesn't accept grams, so we convert to kilograms
    weight_dim: 'KG',
    data: {
      label: title,
      l: s.length,
      w: s.width,
      h: s.height,
      wt: s.weight / 1000, // the weight conversion
      unit_qty: s.inner_quantity,
    },
  };
  cargoes.push(cargo);
}

// Before we create all the items we first want
// remove everything that exists in the cargo-library,
// so we won't have any duplicates.
// Let's use the cargo/truncate endpoint for this
fetch('https://api.cargo-planner.com/api/2/cargo/truncate/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: API_TOKEN,
  },
  body: JSON.stringify({ confirm: true }),
});

// And finally we bulk-create the list of cargoes
fetch('https://api.cargo-planner.com/api/2/cargo/bulk_create/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: API_TOKEN,
  },
  body: JSON.stringify(cargoes),
});

// simplified type definitions of what Cargo-Planner accepts
interface CargoPlannerItem {
  name: string;
  data: ItemData;
  length_dim: 'M' | 'DM' | 'CM' | 'MM' | 'FT' | 'IN';
  weight_dim: 'KG' | 'MT' | 'LB';
}
interface ItemData {
  label: string;
  l: number;
  w: number;
  h: number;
  wt: number;
  not_stackable?: boolean | null;
  not_rotatable?: boolean | null;
  tiltable?: boolean | null;
  bottom_only?: boolean | null;
  color?: string | null;
  qty?: number | null;
  unit_qty?: number | null;
}

Dabar mums nebereikės vėl naudoti Excel importų/eksportų, ir kito siuntinio planavimas bus daug greitesnis.

Tiesioginis pakrovimo sąrašų kūrimas

Jei norite kurti pakrovimo sąrašus tiesiogiai iš kitų įrankių, tai nėra labai skirtinga nuo ankstesnio pavyzdžio API užklausų atžvilgiu. Šį kartą mes visiškai praleisime Cargo Library ir eisime tiesiai prie naujo pakrovimo sąrašo.

Šio metodo trūkumas yra tas, kad prieš skambinant API jums reikia pasirinkti, ką siųsti, ir kiekvieno kiekį. Tai greičiausiai reikalaus šiek tiek UI.

// we are reusing the constants sourceItems and API_TOKEN
// from the previous example

let cargoes: ItemData[] = [];

// The conversion from sourceItem to Cargo-Planners representation
for (let i = 0; i < source.length; i++) {
  let s = source[i];
  // we want both our ID and title stored as the name
  const title = `${s.id} - ${s.title}`;

  let cargo: ItemData = {
    label: title,
    l: s.length,
    w: s.width,
    h: s.height,
    // the weight conversion from grams to kilograms
    wt: s.weight / 1000,
    unit_qty: s.inner_quantity,
    // we want to send 10 of each item
    qty: 10,
  };
  cargoes.push(cargo);
}

// And finally we create a loadlist
fetch('https://api.cargo-planner.com/api/2/loadlist/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: API_TOKEN,
  },
  body: JSON.stringify({
    name: 'Shipment 123',
    data: cargoes,
    etd: '2022-12-01',
    length_dim: 'MM',
    weight_dim: 'KG',
  }),
});

Naujas pakrovimo sąrašas bus matomas internetinėje programoje, tačiau atsakymas turės URL, tiesiogiai nukreipiantį į naują pakrovimo sąrašą.

Taip pat galima žengti dar vieną žingsnį toliau su Sukurti ir apskaičiuoti galutiniu tašku, tačiau tai reikalaus daugiau įvesties duomenų, tokių kaip kokius nustatymus ir įrangą naudoti.