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
- Introduction
- Core Concepts
- Setting Up Your Environment
- Advanced API Usage
- Manufacturing Process Optimization
- Error Handling and Logging
- Real-time Production Monitoring
- Integration with Other Systems
- Performance Optimization
- Security Best Practices
- Troubleshooting and Maintenance
- 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:
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';
const client = new stateset(process.env.STATESET_API_KEY);
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)
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);
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);
const bomDetails = await client.billofmaterials.get('bom_ODkRWQtx9NVsRX');
console.log('BOM Details:', bomDetails);
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
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
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);
const updatedMO = await client.manufacturingorder.update(manufacturingOrder.id, {
status: 'completed'
});
console.log('Manufacturing Order updated:', updatedMO);
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
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);
const updatedPick = await client.picks.update(newPick.id, {
status: 'in_progress'
});
console.log('Pick status updated:', updatedPick);
const completedPick = await client.picks.complete(newPick.id, {
completed_items: [
{ inventory_item_id: 'inv_001', quantity: 10 },
{ inventory_item_id: 'inv_002', quantity: 4 }
]
});
console.log('Pick completed:', completedPick);
const pickDetails = await client.picks.get(newPick.id);
console.log('Pick Details:', pickDetails);
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
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);
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);
const cycleCountDetails = await client.cycleCounts.get(newCycleCount.id);
console.log('Cycle Count Details:', cycleCountDetails);
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
const wasteRecord = await client.wasteAndScrap.create({
manufacturing_order_id: 'mo_789012',
item_id: 'inv_001',
quantity: 5,
type: 'scrap',
reason: 'Quality control rejection',
recorded_by: 'user_123'
});
console.log('Waste/Scrap recorded:', wasteRecord);
const updatedWasteRecord = await client.wasteAndScrap.update(wasteRecord.id, {
quantity: 6,
reason: 'Quality control rejection - updated count'
});
console.log('Waste/Scrap record updated:', updatedWasteRecord);
const wasteDetails = await client.wasteAndScrap.get(wasteRecord.id);
console.log('Waste/Scrap Details:', wasteDetails);
const wasteList = await client.wasteAndScrap.list({
manufacturing_order_id: 'mo_789012',
type: 'scrap'
});
console.log('List of Waste/Scrap records:', wasteList);
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
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);
const updatedMachine = await client.machines.update(newMachine.id, {
status: 'maintenance'
});
console.log('Machine status updated:', updatedMachine);
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);
const machineDetails = await client.machines.get(newMachine.id);
console.log('Machine Details:', machineDetails);
const machinesList = await client.machines.list({
status: 'operational',
type: 'CNC'
});
console.log('List of Machines:', machinesList);
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
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);
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);
const maintenanceDetails = await client.maintenance.get(newMaintenanceTask.id);
console.log('Maintenance Task Details:', maintenanceDetails);
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
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);
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);
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);
const kitDetails = await client.kitting.get(newKit.id);
console.log('Kit Details:', kitDetails);
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) {
return ['A1', 'B2', 'C3'];
}
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) {
return `Implement process improvement for ${wasteReason}`;
}
async function createWasteReductionTask(reason, action) {
await client.maintenance.create({
machine_id: 'all_machines',
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}`);
await logToExternalService({
level: 'error',
message: error.message,
stack: error.stack,
timestamp: new Date().toISOString()
});
await notifyProductionManager(error);
throw error;
}
}
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
-
API Connection Failures
- Solution: Verify API key validity, check network connectivity, and ensure the API endpoint is correct.
-
Data Inconsistencies
- Solution: Implement regular cycle counts and reconcile inventory data with physical stock.
-
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.