Advanced Manufacturing and Production Quickstart Guide

Welcome to the Advanced Manufacturing and Production Quickstart Guide for Stateset One. This guide provides a comprehensive walkthrough of Stateset’s Manufacturing and Production APIs, including Maintenance and Kitting modules. You’ll learn how to set up your environment, utilize core and advanced features, optimize your manufacturing processes, and integrate with other systems for seamless operations.

Table of Contents

  1. Introduction
  2. Core Concepts
  3. Setting Up Your Environment
  4. Advanced API Usage
  5. Manufacturing Process Optimization
  6. Error Handling and Logging
  7. Real-time Production Monitoring
  8. Integration with Other Systems
  9. Performance Optimization
  10. Security Best Practices
  11. Troubleshooting and Maintenance
  12. Conclusion

Introduction

Stateset One offers a robust REST and GraphQL API designed to streamline and enhance your manufacturing and production workflows. This guide delves into the Manufacturing & Production module, exploring advanced features and best practices to help you achieve efficient and optimized production management.

Key Objects in the Manufacturing & Production Module

  • Purchase Orders
  • Bill of Materials (BOM)
  • Work Orders
  • Manufacturing Orders
  • Picks
  • Cycle Counts
  • Waste and Scrap
  • Machines
  • Maintenance
  • Kitting
  • Inventory

Core Concepts

Before diving into the API usage, it’s essential to understand the foundational concepts that underpin Stateset’s Manufacturing and Production capabilities:

  • Bill of Materials (BOM): A detailed list of raw materials, components, and assemblies required to manufacture a product.
  • Work Orders: Instructions for producing a certain quantity of a product, often associated with specific BOMs.
  • Manufacturing Orders: Orders derived from work orders that track the actual production process.
  • Picks: The process of collecting and preparing materials needed for production or shipment.
  • Cycle Counts: Periodic inventory audits to ensure accuracy between physical stock and recorded data.
  • Waste and Scrap Management: Tracking and managing production waste to optimize efficiency.
  • Machine Management: Monitoring and maintaining production machinery to ensure optimal performance.
  • Maintenance: Scheduling and executing maintenance tasks to prevent machine downtime.
  • Kitting: Assembling individual components into kits for production or shipment.

Setting Up Your Environment

To begin leveraging Stateset’s Manufacturing and Production capabilities, follow these initial setup steps.

1. Sign Up for Stateset One

2. Generate an API Key

  • After signing in, navigate to the Stateset Cloud Console to generate a new API key. This key will authenticate your API requests.

3. Install the Stateset Node.js SDK

Integrate Stateset’s SDK into your project to simplify API interactions.

Using npm:

npm install stateset-node

Using yarn:

yarn add stateset-node

4. Set Up Environment Variables

Store your API key securely using environment variables.

export STATESET_API_KEY=your_api_key_here

5. Initialize the Stateset Client

Initialize the Stateset client in your application using the generated API key.

import { stateset } from 'stateset-node';

// Initialize with your API key
const client = new stateset(process.env.STATESET_API_KEY);

// Verify connection
async function verifyConnection() {
  try {
    const status = await client.system.healthCheck();
    console.log('Connection status:', status);
  } catch (error) {
    console.error('Failed to connect:', error);
  }
}

verifyConnection();

Advanced API Usage

This section explores the advanced functionalities of Stateset’s Manufacturing and Production APIs, including Bills of Materials, Work Orders, Picks, Cycle Counts, Waste and Scrap Management, Machine Management, Maintenance, and Kitting.

Bills of Materials (BOM)

Manage your product’s components and assemblies efficiently.

Creating and Managing Bills of Materials (BOM)

// Create a new Bill of Materials
const newBOM = await client.billofmaterials.create({
  name: 'Advanced Widget BOM',
  description: 'Bill of Materials for our advanced widget',
  product_id: 'prod_123456',
  version: '1.0',
  components: [
    { item_id: 'item_001', quantity: 2, unit: 'pcs' },
    { item_id: 'item_002', quantity: 1, unit: 'kg' },
    { item_id: 'item_003', quantity: 0.5, unit: 'l' }
  ]
});

console.log('New BOM created:', newBOM);

// Update a Bill of Materials
const updatedBOM = await client.billofmaterials.update('bom_ODkRWQtx9NVsRX', {
  version: '1.1',
  components: [
    { item_id: 'item_001', quantity: 3, unit: 'pcs' },
    { item_id: 'item_002', quantity: 1.2, unit: 'kg' },
    { item_id: 'item_003', quantity: 0.6, unit: 'l' }
  ]
});

console.log('BOM updated:', updatedBOM);

// Get BOM details
const bomDetails = await client.billofmaterials.get('bom_ODkRWQtx9NVsRX');
console.log('BOM Details:', bomDetails);

// List BOMs with pagination and filtering
const bomList = await client.billofmaterials.list({
  limit: 100,
  offset: 0,
  product_id: 'prod_123456'
});
console.log('List of BOMs:', bomList);

Work Orders and Manufacturing Orders

Track and manage production instructions and their execution.

Creating and Managing Work Orders

// Create a Work Order
const workOrder = await client.workorder.create({
  type: 'production',
  status: 'planned',
  priority: 'high',
  number: 'WO-2024-001',
  site: 'main_factory',
  bill_of_material_number: 'BOM-2024-001',
  work_order_line_items: [
    { item_id: 'item_001', quantity: 100 },
    { item_id: 'item_002', quantity: 50 }
  ]
});

console.log('Work Order created:', workOrder);

Creating and Managing Manufacturing Orders

// Create a Manufacturing Order from a Work Order
const manufacturingOrder = await client.manufacturingorder.create({
  type: 'production',
  status: 'in_progress',
  priority: 'high',
  number: 'MO-2024-001',
  site: 'main_factory',
  work_order_number: workOrder.number,
  manufacturing_order_line_items: workOrder.work_order_line_items
});

console.log('Manufacturing Order created:', manufacturingOrder);

// Update Manufacturing Order status
const updatedMO = await client.manufacturingorder.update(manufacturingOrder.id, {
  status: 'completed'
});

console.log('Manufacturing Order updated:', updatedMO);

// Get Manufacturing Order details with line items
const moDetails = await client.manufacturingorder.get(manufacturingOrder.id, {
  include: ['manufacturing_order_line_items']
});

console.log('Manufacturing Order Details:', moDetails);

Picks

Manage the collection and preparation of materials for production or shipment.

Creating and Managing Picks

// Create a new Pick
const newPick = await client.picks.create({
  work_order_id: 'wo_123456',
  status: 'pending',
  picker_id: 'user_789',
  items: [
    { inventory_item_id: 'inv_001', quantity: 10 },
    { inventory_item_id: 'inv_002', quantity: 5 }
  ]
});

console.log('New Pick created:', newPick);

// Update a Pick status
const updatedPick = await client.picks.update(newPick.id, {
  status: 'in_progress'
});

console.log('Pick status updated:', updatedPick);

// Complete a Pick
const completedPick = await client.picks.complete(newPick.id, {
  completed_items: [
    { inventory_item_id: 'inv_001', quantity: 10 },
    { inventory_item_id: 'inv_002', quantity: 4 } // One item short
  ]
});

console.log('Pick completed:', completedPick);

// Get Pick details
const pickDetails = await client.picks.get(newPick.id);
console.log('Pick Details:', pickDetails);

// List Picks with filtering
const picksList = await client.picks.list({
  status: 'pending',
  work_order_id: 'wo_123456'
});

console.log('List of Picks:', picksList);

Cycle Counts

Conduct periodic inventory audits to ensure data accuracy.

Managing Cycle Counts

// Schedule a new Cycle Count
const newCycleCount = await client.cycleCounts.create({
  scheduled_date: '2024-10-01',
  location_id: 'loc_456',
  items: ['inv_001', 'inv_002', 'inv_003']
});

console.log('New Cycle Count scheduled:', newCycleCount);

// Update Cycle Count results
const updatedCycleCount = await client.cycleCounts.update(newCycleCount.id, {
  status: 'completed',
  results: [
    { inventory_item_id: 'inv_001', expected: 100, actual: 98 },
    { inventory_item_id: 'inv_002', expected: 50, actual: 50 },
    { inventory_item_id: 'inv_003', expected: 75, actual: 74 }
  ]
});

console.log('Cycle Count updated:', updatedCycleCount);

// Get Cycle Count details
const cycleCountDetails = await client.cycleCounts.get(newCycleCount.id);
console.log('Cycle Count Details:', cycleCountDetails);

// List Cycle Counts
const cycleCountsList = await client.cycleCounts.list({
  status: 'scheduled',
  from_date: '2024-09-01',
  to_date: '2024-12-31'
});

console.log('List of Cycle Counts:', cycleCountsList);

Waste and Scrap Management

Track and manage production waste to optimize efficiency and reduce costs.

Managing Waste and Scrap

// Record Waste or Scrap
const wasteRecord = await client.wasteAndScrap.create({
  manufacturing_order_id: 'mo_789012',
  item_id: 'inv_001',
  quantity: 5,
  type: 'scrap', // or 'waste'
  reason: 'Quality control rejection',
  recorded_by: 'user_123'
});

console.log('Waste/Scrap recorded:', wasteRecord);

// Update Waste or Scrap record
const updatedWasteRecord = await client.wasteAndScrap.update(wasteRecord.id, {
  quantity: 6,
  reason: 'Quality control rejection - updated count'
});

console.log('Waste/Scrap record updated:', updatedWasteRecord);

// Get Waste or Scrap details
const wasteDetails = await client.wasteAndScrap.get(wasteRecord.id);
console.log('Waste/Scrap Details:', wasteDetails);

// List Waste and Scrap records
const wasteList = await client.wasteAndScrap.list({
  manufacturing_order_id: 'mo_789012',
  type: 'scrap'
});

console.log('List of Waste/Scrap records:', wasteList);

// Generate Waste and Scrap report
const wasteReport = await client.wasteAndScrap.generateReport({
  from_date: '2024-01-01',
  to_date: '2024-12-31',
  groupBy: 'item'
});

console.log('Waste/Scrap Report:', wasteReport);

Machine Management

Monitor and maintain production machinery to ensure optimal performance and minimize downtime.

Managing Machines

// Register a new Machine
const newMachine = await client.machines.create({
  name: 'CNC Mill 001',
  type: 'CNC',
  model: 'HAAS VF-2',
  status: 'operational',
  location_id: 'loc_789'
});

console.log('New Machine registered:', newMachine);

// Update Machine status
const updatedMachine = await client.machines.update(newMachine.id, {
  status: 'maintenance'
});

console.log('Machine status updated:', updatedMachine);

// Log Machine runtime
const runtimeLog = await client.machines.logRuntime(newMachine.id, {
  start_time: '2024-10-01T08:00:00Z',
  end_time: '2024-10-01T16:00:00Z',
  work_order_id: 'wo_456789'
});

console.log('Machine runtime logged:', runtimeLog);

// Get Machine details
const machineDetails = await client.machines.get(newMachine.id);
console.log('Machine Details:', machineDetails);

// List Machines
const machinesList = await client.machines.list({
  status: 'operational',
  type: 'CNC'
});

console.log('List of Machines:', machinesList);

// Schedule Machine maintenance
const maintenanceTask = await client.machines.scheduleMaintenance(newMachine.id, {
  scheduled_date: '2024-11-15',
  type: 'preventive',
  description: 'Annual servicing'
});

console.log('Maintenance Task scheduled:', maintenanceTask);

Maintenance Management

Ensure machines are regularly maintained to prevent unexpected breakdowns and extend their lifespan.

Managing Maintenance Tasks

// Schedule a new Maintenance Task
const newMaintenanceTask = await client.maintenance.create({
  machine_id: 'machine_123456',
  scheduled_date: '2024-11-20',
  type: 'preventive',
  description: 'Quarterly inspection and lubrication'
});

console.log('New Maintenance Task scheduled:', newMaintenanceTask);

// Update Maintenance Task
const updatedMaintenanceTask = await client.maintenance.update(newMaintenanceTask.id, {
  status: 'completed',
  actual_date: '2024-11-20',
  notes: 'All tasks completed successfully'
});

console.log('Maintenance Task updated:', updatedMaintenanceTask);

// Get Maintenance Task details
const maintenanceDetails = await client.maintenance.get(newMaintenanceTask.id);
console.log('Maintenance Task Details:', maintenanceDetails);

// List Maintenance Tasks
const maintenanceList = await client.maintenance.list({
  status: 'scheduled',
  from_date: '2024-10-01',
  to_date: '2024-12-31'
});

console.log('List of Maintenance Tasks:', maintenanceList);

Kitting Management

Assemble individual components into kits for production or shipment, ensuring efficiency and accuracy.

Managing Kitting Processes

// Create a new Kit
const newKit = await client.kitting.create({
  name: 'Widget Assembly Kit',
  description: 'Kit containing all components for Widget Assembly',
  kit_items: [
    { item_id: 'item_001', quantity: 2 },
    { item_id: 'item_002', quantity: 1 },
    { item_id: 'item_003', quantity: 0.5 }
  ],
  production_order_id: 'po_654321'
});

console.log('New Kit created:', newKit);

// Update a Kit
const updatedKit = await client.kitting.update(newKit.id, {
  kit_items: [
    { item_id: 'item_001', quantity: 3 },
    { item_id: 'item_002', quantity: 1.2 },
    { item_id: 'item_003', quantity: 0.6 }
  ]
});

console.log('Kit updated:', updatedKit);

// Complete a Kit
const completedKit = await client.kitting.complete(newKit.id, {
  completed_items: [
    { item_id: 'item_001', quantity: 3 },
    { item_id: 'item_002', quantity: 1 },
    { item_id: 'item_003', quantity: 0.5 }
  ],
  notes: 'One item short on item_002'
});

console.log('Kit completed:', completedKit);

// Get Kit details
const kitDetails = await client.kitting.get(newKit.id);
console.log('Kit Details:', kitDetails);

// List Kits with filtering
const kitsList = await client.kitting.list({
  status: 'pending',
  production_order_id: 'po_654321'
});

console.log('List of Kits:', kitsList);

Manufacturing Process Optimization

Optimize your manufacturing processes using strategies such as Just-in-Time (JIT) manufacturing, Overall Equipment Effectiveness (OEE) tracking, and advanced features like Pick Route Optimization, Predictive Maintenance, and Waste Reduction.

1. Implement Just-in-Time (JIT) Manufacturing

Optimize inventory levels and production timing to reduce waste and improve efficiency.

async function optimizeJITProduction(productId) {
  const salesData = await getSalesData(productId);
  const leadTime = await getSupplierLeadTime(productId);
  const safetyStock = calculateSafetyStock(salesData);

  const reorderPoint = calculateReorderPoint(salesData, leadTime, safetyStock);
  const economicOrderQuantity = calculateEOQ(salesData, setupCost, holdingCost);

  await updateProductionParameters(productId, {
    reorder_point: reorderPoint,
    economic_order_quantity: economicOrderQuantity
  });

  console.log('JIT Production parameters optimized.');
}

function calculateReorderPoint(salesData, leadTime, safetyStock) {
  const averageDailyDemand = calculateAverageDailyDemand(salesData);
  return (averageDailyDemand * leadTime) + safetyStock;
}

function calculateEOQ(salesData, setupCost, holdingCost) {
  const annualDemand = calculateAnnualDemand(salesData);
  return Math.sqrt((2 * annualDemand * setupCost) / holdingCost);
}

2. Implement Overall Equipment Effectiveness (OEE) Tracking

Monitor and improve manufacturing productivity by tracking availability, performance, and quality.

async function calculateOEE(manufacturingOrderId) {
  const mo = await client.manufacturingorder.get(manufacturingOrderId);
  const plannedProductionTime = calculatePlannedProductionTime(mo);
  const actualProductionTime = calculateActualProductionTime(mo);
  const idealCycleTime = getIdealCycleTime(mo.product_id);
  const totalPieces = mo.quantity;
  const goodPieces = await getGoodPiecesCount(manufacturingOrderId);

  const availability = actualProductionTime / plannedProductionTime;
  const performance = (idealCycleTime * totalPieces) / actualProductionTime;
  const quality = goodPieces / totalPieces;

  const oee = availability * performance * quality;

  await client.manufacturingorder.update(manufacturingOrderId, { oee });

  console.log(`OEE for Manufacturing Order ${manufacturingOrderId}:`, oee);
  return oee;
}

3. Optimize Pick Routes

Improve picking efficiency by optimizing the route pickers take through the warehouse.

async function optimizePickRoutes(pickId) {
  const pick = await client.picks.get(pickId);
  const warehouseLayout = await getWarehouseLayout();

  const optimizedRoute = calculateOptimalRoute(pick.items, warehouseLayout);

  await client.picks.update(pickId, {
    optimized_route: optimizedRoute
  });

  console.log('Pick routes optimized:', optimizedRoute);
  return optimizedRoute;
}

function calculateOptimalRoute(items, warehouseLayout) {
  // Implement route optimization algorithm
  // This could use techniques like the traveling salesman problem (TSP) heuristics
  // Placeholder for actual implementation
  return ['A1', 'B2', 'C3']; // Example route
}

4. Predictive Maintenance for Machines

Use machine runtime data to predict when maintenance will be needed, preventing unexpected downtime.

async function predictMaintenance(machineId) {
  const machine = await client.machines.get(machineId);
  const runtimeLogs = await client.machines.getRuntimeLogs(machineId, {
    from_date: getDateXMonthsAgo(6)
  });

  const maintenancePredictor = new MaintenancePredictor(machine.type, machine.model);
  const predictedMaintenanceDate = maintenancePredictor.predict(runtimeLogs);

  if (isWithinNextMonth(predictedMaintenanceDate)) {
    await client.machines.scheduleMaintenance(machineId, {
      scheduled_date: predictedMaintenanceDate,
      type: 'predictive',
      description: 'Maintenance based on usage patterns'
    });
    console.log('Predictive maintenance scheduled:', predictedMaintenanceDate);
  } else {
    console.log('No maintenance needed within the next month.');
  }

  return predictedMaintenanceDate;
}

function isWithinNextMonth(date) {
  const now = new Date();
  const nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate());
  return new Date(date) <= nextMonth;
}

5. Waste Reduction Strategy

Analyze waste and scrap data to identify areas for improvement and implement reduction strategies.

async function analyzeWastePatterns() {
  const wasteData = await client.wasteAndScrap.list({
    from_date: getDateXMonthsAgo(3)
  });

  const wasteByReason = groupBy(wasteData, 'reason');
  const topWasteReasons = getTopNByQuantity(wasteByReason, 5);

  for (const reason of topWasteReasons) {
    const recommendedAction = generateWasteReductionRecommendation(reason);
    await createWasteReductionTask(reason, recommendedAction);
    console.log(`Waste reduction task created for reason: ${reason}`);
  }

  return topWasteReasons;
}

function groupBy(data, key) {
  return data.reduce((acc, item) => {
    acc[item[key]] = (acc[item[key]] || 0) + item.quantity;
    return acc;
  }, {});
}

function getTopNByQuantity(groupedData, n) {
  return Object.entries(groupedData)
    .sort((a, b) => b[1] - a[1])
    .slice(0, n)
    .map(entry => entry[0]);
}

function generateWasteReductionRecommendation(wasteReason) {
  // Implement logic to generate recommendations based on waste reasons
  // This could involve machine learning models trained on historical data
  return `Implement process improvement for ${wasteReason}`;
}

async function createWasteReductionTask(reason, action) {
  await client.maintenance.create({
    machine_id: 'all_machines', // Placeholder: Adjust based on context
    scheduled_date: getNextWeekDate(),
    type: 'process_improvement',
    description: action
  });
}

function getNextWeekDate() {
  const date = new Date();
  date.setDate(date.getDate() + 7);
  return date.toISOString().split('T')[0];
}

Error Handling and Logging

Implement robust error handling and logging to ensure smooth operation of your manufacturing processes.

async function safeManufacturingOperation(operation) {
  try {
    const result = await operation();
    console.log(`Operation successful: ${JSON.stringify(result)}`);
    return result;
  } catch (error) {
    console.error(`Error in manufacturing operation: ${error.message}`);
    // Log to external logging service
    await logToExternalService({
      level: 'error',
      message: error.message,
      stack: error.stack,
      timestamp: new Date().toISOString()
    });
    // Notify relevant personnel
    await notifyProductionManager(error);
    throw error;
  }
}

// Usage Example
const newWorkOrder = await safeManufacturingOperation(() => 
  client.workorder.create({
    type: 'production',
    status: 'planned',
    priority: 'high',
    number: 'WO-2024-002'
  })
);

Troubleshooting and Maintenance

Maintain the health of your manufacturing and production systems by addressing common issues and performing regular maintenance.

Common Issues and Solutions

  1. API Connection Failures

    • Solution: Verify API key validity, check network connectivity, and ensure the API endpoint is correct.
  2. Data Inconsistencies

    • Solution: Implement regular cycle counts and reconcile inventory data with physical stock.
  3. Machine Downtime

    • Solution: Utilize predictive maintenance to foresee and prevent machine failures.

Regular Maintenance Tasks

  • System Updates: Keep your SDKs and dependencies up to date.
  • Data Backups: Regularly back up your data to prevent loss.
  • Performance Monitoring: Continuously monitor system performance and optimize as needed.

Support Resources


Conclusion

By following this Advanced Manufacturing and Production Quickstart Guide, you are now equipped to harness the full potential of Stateset’s Manufacturing and Production APIs, including Maintenance and Kitting. Implement these practices to enhance your production efficiency, maintain optimal inventory levels, ensure machine reliability, and streamline your manufacturing processes. For further assistance, refer to the support resources or engage with the Stateset community.


Feel free to customize this guide further based on your specific needs or to add more detailed sections as required. This structured approach ensures that users can seamlessly navigate through the setup, implementation, optimization, and maintenance phases of using Stateset’s Manufacturing and Production APIs.