5210 lines
102 KiB
JavaScript
5210 lines
102 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Materials = db.materials;
|
|
|
|
const Suppliers = db.suppliers;
|
|
|
|
const Boms = db.boms;
|
|
|
|
const WorkOrders = db.work_orders;
|
|
|
|
const Machines = db.machines;
|
|
|
|
const QaInspections = db.qa_inspections;
|
|
|
|
const InventoryTransactions = db.inventory_transactions;
|
|
|
|
const InventoryLocations = db.inventory_locations;
|
|
|
|
const ProductionLines = db.production_lines;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MaterialsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Stainless Steel Sheet 304",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "SS304-2MM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "2mm stainless steel sheet for chassis and panels",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "Finished",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 14,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 3.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hazardous": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-05T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-06T09:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "ABS Injection Molding Resin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "ABS-IM-500",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "High impact ABS resin for molded components",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "Component",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "kg",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 1.95,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hazardous": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-06T08:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-07T09:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "M3 Hex Nut",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "HNUT-M3",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Standard M3 stainless steel hex nut",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "Finished",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "pc",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 0.02,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hazardous": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-07T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-08T09:40:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Control Board Assembly",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "CBA-V2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Electronics assembly for control unit",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "Raw",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "pc",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 21,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 45.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hazardous": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-08T09:20:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-09T10:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Industrial Solvent",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sku": "SOLV-IND-1L",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Cleaning solvent used in maintenance operations",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "Component",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit": "l",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 18,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cost": 8.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hazardous": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-09T08:40:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-10T10:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const SuppliersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Acme Metals Co",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_name": "Robert Finch",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "r.finch@acmemetals.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-555-0201",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "120 Industrial Way, Springfield",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 14,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-11-20T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-05T09:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Precision Plastics Ltd",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_name": "Linda Park",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "linda.park@precisionplastics.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-555-0202",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "42 Polymer Ave, Rivertown",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-01T09:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-08T10:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Global Fasteners",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_name": "Anil Gupta",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "anil.gupta@globalfasteners.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-555-0203",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "9 Bolt Street, Harbor City",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 7,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-10-15T07:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-02T08:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Electronic Assemblies Inc",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_name": "Sofia Ruiz",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "s.ruiz@elecassm.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-555-0204",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "300 Circuit Blvd, Tech Park",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 21,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-10T11:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-09T11:25:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "ChemSource",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_name": "Thomas Greene",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"contact_email": "thomas.greene@chemsource.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-555-0205",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "77 Lab Road, Greenfield",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"lead_time": 18,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-11-01T08:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-03T09:40:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const BomsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Chassis Assembly BOM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"version": "1.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"effective_from": new Date('2025-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Base chassis with external panels and fasteners",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Control Unit BOM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"version": "2.1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"effective_from": new Date('2024-12-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Includes PCB and standard fasteners",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-15T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "External Panel BOM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"version": "1.2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"effective_from": new Date('2024-11-20T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Panels cut from stainless steel sheet",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-11-20T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Packaging BOM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"version": "1.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"effective_from": new Date('2025-01-05T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Temporary packaging for pilot run",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-05T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Cleaning Kit BOM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"version": "1.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"effective_from": new Date('2024-12-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Includes solvent and cloths",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const WorkOrdersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "WO-2025-001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Pilot run for control unit assembly",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start": new Date('2025-01-20T07:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end": new Date('2025-01-22T19:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_start": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_end": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 150,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Cancelled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "High",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-10T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-10T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "WO-2025-002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Chassis batch production",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start": new Date('2025-01-25T06:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end": new Date('2025-02-01T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_start": new Date('2025-01-25T06:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_end": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "InProduction",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "Medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-11T08:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-25T06:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "WO-2024-190",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Maintenance run with replacement parts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start": new Date('2024-12-10T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end": new Date('2024-12-10T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_start": new Date('2024-12-10T08:05:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_end": new Date('2024-12-10T15:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 10,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "Medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2024-12-10T16:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "WO-2025-010",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Packaging trial for pilot units",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start": new Date('2025-01-18T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end": new Date('2025-01-19T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_start": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_end": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Cancelled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "Medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-09T07:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-09T07:45:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "WO-2025-011",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Cleaning kit production",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_start": new Date('2025-02-01T07:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"scheduled_end": new Date('2025-02-02T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_start": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"actual_end": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Released",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "Medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-12T08:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"modified_on": new Date('2025-01-12T08:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MachinesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "CNC Router A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "CNC-A01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Line 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"machine_type": "CNC",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Decommissioned",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_maintenance": new Date('2024-12-20T06:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_maintenance": new Date('2025-03-20T06:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 100,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uptime": 1240.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-10-10T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Hydraulic Press 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PRESS-02",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Line 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"machine_type": "Press",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Operational",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_maintenance": new Date('2025-01-05T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_maintenance": new Date('2025-02-05T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uptime": 860.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-09-12T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Assembly Robot 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "ARM-01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Line 3",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"machine_type": "Assembly",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Decommissioned",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_maintenance": new Date('2024-12-01T07:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_maintenance": new Date('2025-02-01T07:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uptime": 1900.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-08-15T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Lathe B",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "LATHE-B",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Line 1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"machine_type": "Press",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Maintenance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_maintenance": new Date('2024-11-10T06:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_maintenance": new Date('2025-02-10T06:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 80,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uptime": 540.25,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-07-20T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Conveyor East",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "CONV-E",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Line 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"machine_type": "Milling",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Idle",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_maintenance": new Date('2025-01-10T05:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"next_maintenance": new Date('2025-04-10T05:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 500,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uptime": 3000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-06-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const QaInspectionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"inspection_code": "QA-1001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"inspection_date": new Date('2025-01-26T10:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"result": "Pass",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "Minor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Visual inspection passed, no defects found",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-26T11:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"inspection_code": "QA-1002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"inspection_date": new Date('2025-01-21T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"result": "Rework",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "Minor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Connector torque out of spec, rework required",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-21T14:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"inspection_code": "QA-1003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"inspection_date": new Date('2024-12-10T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"result": "Fail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "Critical",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Maintenance verification completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-10T12:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"inspection_code": "QA-1004",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"inspection_date": new Date('2025-01-18T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"result": "Fail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "Minor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Packaging alignment issue, repack required",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-18T16:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"inspection_code": "QA-1005",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"inspection_date": new Date('2025-02-01T08:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"result": "Rework",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"severity": "Major",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Batch samples within spec",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-02-01T09:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const InventoryTransactionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "IT-0001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "Issue",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 500.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_cost": 3.75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance": 500.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_date": new Date('2025-01-06T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_by_user": "Olga Petrov",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-06T09:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "IT-0002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "Issue",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 50.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_cost": 45.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance": 450.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_date": new Date('2025-01-25T06:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_by_user": "Evelyn Carter",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-25T06:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "IT-0003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "Issue",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 200.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_cost": 0.02,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance": 200.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_date": new Date('2024-12-20T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_by_user": "Olga Petrov",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-20T10:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "IT-0004",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "Receipt",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": 120.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_cost": 8.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance": 120.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_date": new Date('2024-12-09T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_by_user": "Olga Petrov",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-12-09T09:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "IT-0005",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_type": "Adjustment",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"quantity": -5.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"unit_cost": 1.95,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"balance": 995.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"transaction_date": new Date('2025-01-08T14:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_by_user": "Inventory System",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-01-08T14:35:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const InventoryLocationsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Main Warehouse",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "WH-MAIN",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "1 Warehouse Way, Distribution Park",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 10000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-06-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Raw Materials Storage",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "ST-RAW",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Building B, Yard 2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 5000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-07-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Finished Goods Bay",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "FG-BAY",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Dock 3, Portside",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 3000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-08-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Quarantine Area",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "QUAR-01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "North Wing, Isolated Rack",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 200.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-09-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Maintenance Parts Locker",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "MP-LOCK",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"address": "Maintenance Floor, Locker 5",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"capacity": 500.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_active": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-10-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProductionLinesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Line 1 - Fabrication",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PL-01",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shift_schedule": "Mon-Fri 06:00-14:00",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-05-01T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Line 2 - Assembly",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PL-02",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shift_schedule": "Mon-Fri 14:00-22:00",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-05-02T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Line 3 - Final Test",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PL-03",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shift_schedule": "Mon-Sat 07:00-15:00",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-05-03T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Maintenance Line",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PL-MNT",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shift_schedule": "On demand",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-05-04T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Packing Line",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"code": "PL-PACK",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"shift_schedule": "Mon-Fri 08:00-16:00",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2024-05-05T08:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMaterialWithSupplier() {
|
|
|
|
const relatedSupplier0 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const Material0 = await Materials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Material0?.setSupplier)
|
|
{
|
|
await
|
|
Material0.
|
|
setSupplier(relatedSupplier0);
|
|
}
|
|
|
|
const relatedSupplier1 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const Material1 = await Materials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Material1?.setSupplier)
|
|
{
|
|
await
|
|
Material1.
|
|
setSupplier(relatedSupplier1);
|
|
}
|
|
|
|
const relatedSupplier2 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const Material2 = await Materials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Material2?.setSupplier)
|
|
{
|
|
await
|
|
Material2.
|
|
setSupplier(relatedSupplier2);
|
|
}
|
|
|
|
const relatedSupplier3 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const Material3 = await Materials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Material3?.setSupplier)
|
|
{
|
|
await
|
|
Material3.
|
|
setSupplier(relatedSupplier3);
|
|
}
|
|
|
|
const relatedSupplier4 = await Suppliers.findOne({
|
|
offset: Math.floor(Math.random() * (await Suppliers.count())),
|
|
});
|
|
const Material4 = await Materials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Material4?.setSupplier)
|
|
{
|
|
await
|
|
Material4.
|
|
setSupplier(relatedSupplier4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateBomWithProduct() {
|
|
|
|
const relatedProduct0 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const Bom0 = await Boms.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Bom0?.setProduct)
|
|
{
|
|
await
|
|
Bom0.
|
|
setProduct(relatedProduct0);
|
|
}
|
|
|
|
const relatedProduct1 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const Bom1 = await Boms.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Bom1?.setProduct)
|
|
{
|
|
await
|
|
Bom1.
|
|
setProduct(relatedProduct1);
|
|
}
|
|
|
|
const relatedProduct2 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const Bom2 = await Boms.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Bom2?.setProduct)
|
|
{
|
|
await
|
|
Bom2.
|
|
setProduct(relatedProduct2);
|
|
}
|
|
|
|
const relatedProduct3 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const Bom3 = await Boms.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Bom3?.setProduct)
|
|
{
|
|
await
|
|
Bom3.
|
|
setProduct(relatedProduct3);
|
|
}
|
|
|
|
const relatedProduct4 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const Bom4 = await Boms.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Bom4?.setProduct)
|
|
{
|
|
await
|
|
Bom4.
|
|
setProduct(relatedProduct4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateWorkOrderWithProduct() {
|
|
|
|
const relatedProduct0 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (WorkOrder0?.setProduct)
|
|
{
|
|
await
|
|
WorkOrder0.
|
|
setProduct(relatedProduct0);
|
|
}
|
|
|
|
const relatedProduct1 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (WorkOrder1?.setProduct)
|
|
{
|
|
await
|
|
WorkOrder1.
|
|
setProduct(relatedProduct1);
|
|
}
|
|
|
|
const relatedProduct2 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (WorkOrder2?.setProduct)
|
|
{
|
|
await
|
|
WorkOrder2.
|
|
setProduct(relatedProduct2);
|
|
}
|
|
|
|
const relatedProduct3 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const WorkOrder3 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (WorkOrder3?.setProduct)
|
|
{
|
|
await
|
|
WorkOrder3.
|
|
setProduct(relatedProduct3);
|
|
}
|
|
|
|
const relatedProduct4 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const WorkOrder4 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (WorkOrder4?.setProduct)
|
|
{
|
|
await
|
|
WorkOrder4.
|
|
setProduct(relatedProduct4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateWorkOrderWithBom() {
|
|
|
|
const relatedBom0 = await Boms.findOne({
|
|
offset: Math.floor(Math.random() * (await Boms.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (WorkOrder0?.setBom)
|
|
{
|
|
await
|
|
WorkOrder0.
|
|
setBom(relatedBom0);
|
|
}
|
|
|
|
const relatedBom1 = await Boms.findOne({
|
|
offset: Math.floor(Math.random() * (await Boms.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (WorkOrder1?.setBom)
|
|
{
|
|
await
|
|
WorkOrder1.
|
|
setBom(relatedBom1);
|
|
}
|
|
|
|
const relatedBom2 = await Boms.findOne({
|
|
offset: Math.floor(Math.random() * (await Boms.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (WorkOrder2?.setBom)
|
|
{
|
|
await
|
|
WorkOrder2.
|
|
setBom(relatedBom2);
|
|
}
|
|
|
|
const relatedBom3 = await Boms.findOne({
|
|
offset: Math.floor(Math.random() * (await Boms.count())),
|
|
});
|
|
const WorkOrder3 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (WorkOrder3?.setBom)
|
|
{
|
|
await
|
|
WorkOrder3.
|
|
setBom(relatedBom3);
|
|
}
|
|
|
|
const relatedBom4 = await Boms.findOne({
|
|
offset: Math.floor(Math.random() * (await Boms.count())),
|
|
});
|
|
const WorkOrder4 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (WorkOrder4?.setBom)
|
|
{
|
|
await
|
|
WorkOrder4.
|
|
setBom(relatedBom4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateWorkOrderWithAssigned_machine() {
|
|
|
|
const relatedAssigned_machine0 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (WorkOrder0?.setAssigned_machine)
|
|
{
|
|
await
|
|
WorkOrder0.
|
|
setAssigned_machine(relatedAssigned_machine0);
|
|
}
|
|
|
|
const relatedAssigned_machine1 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (WorkOrder1?.setAssigned_machine)
|
|
{
|
|
await
|
|
WorkOrder1.
|
|
setAssigned_machine(relatedAssigned_machine1);
|
|
}
|
|
|
|
const relatedAssigned_machine2 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (WorkOrder2?.setAssigned_machine)
|
|
{
|
|
await
|
|
WorkOrder2.
|
|
setAssigned_machine(relatedAssigned_machine2);
|
|
}
|
|
|
|
const relatedAssigned_machine3 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const WorkOrder3 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (WorkOrder3?.setAssigned_machine)
|
|
{
|
|
await
|
|
WorkOrder3.
|
|
setAssigned_machine(relatedAssigned_machine3);
|
|
}
|
|
|
|
const relatedAssigned_machine4 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const WorkOrder4 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (WorkOrder4?.setAssigned_machine)
|
|
{
|
|
await
|
|
WorkOrder4.
|
|
setAssigned_machine(relatedAssigned_machine4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateWorkOrderWithAssigned_to() {
|
|
|
|
const relatedAssigned_to0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder0 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (WorkOrder0?.setAssigned_to)
|
|
{
|
|
await
|
|
WorkOrder0.
|
|
setAssigned_to(relatedAssigned_to0);
|
|
}
|
|
|
|
const relatedAssigned_to1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder1 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (WorkOrder1?.setAssigned_to)
|
|
{
|
|
await
|
|
WorkOrder1.
|
|
setAssigned_to(relatedAssigned_to1);
|
|
}
|
|
|
|
const relatedAssigned_to2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder2 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (WorkOrder2?.setAssigned_to)
|
|
{
|
|
await
|
|
WorkOrder2.
|
|
setAssigned_to(relatedAssigned_to2);
|
|
}
|
|
|
|
const relatedAssigned_to3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder3 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (WorkOrder3?.setAssigned_to)
|
|
{
|
|
await
|
|
WorkOrder3.
|
|
setAssigned_to(relatedAssigned_to3);
|
|
}
|
|
|
|
const relatedAssigned_to4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const WorkOrder4 = await WorkOrders.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (WorkOrder4?.setAssigned_to)
|
|
{
|
|
await
|
|
WorkOrder4.
|
|
setAssigned_to(relatedAssigned_to4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMachineWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Machine0 = await Machines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Machine0?.setOwner)
|
|
{
|
|
await
|
|
Machine0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Machine1 = await Machines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Machine1?.setOwner)
|
|
{
|
|
await
|
|
Machine1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Machine2 = await Machines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Machine2?.setOwner)
|
|
{
|
|
await
|
|
Machine2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Machine3 = await Machines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Machine3?.setOwner)
|
|
{
|
|
await
|
|
Machine3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
const relatedOwner4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Machine4 = await Machines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Machine4?.setOwner)
|
|
{
|
|
await
|
|
Machine4.
|
|
setOwner(relatedOwner4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateQaInspectionWithWork_order() {
|
|
|
|
const relatedWork_order0 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QaInspection0 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (QaInspection0?.setWork_order)
|
|
{
|
|
await
|
|
QaInspection0.
|
|
setWork_order(relatedWork_order0);
|
|
}
|
|
|
|
const relatedWork_order1 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QaInspection1 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (QaInspection1?.setWork_order)
|
|
{
|
|
await
|
|
QaInspection1.
|
|
setWork_order(relatedWork_order1);
|
|
}
|
|
|
|
const relatedWork_order2 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QaInspection2 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (QaInspection2?.setWork_order)
|
|
{
|
|
await
|
|
QaInspection2.
|
|
setWork_order(relatedWork_order2);
|
|
}
|
|
|
|
const relatedWork_order3 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QaInspection3 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (QaInspection3?.setWork_order)
|
|
{
|
|
await
|
|
QaInspection3.
|
|
setWork_order(relatedWork_order3);
|
|
}
|
|
|
|
const relatedWork_order4 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const QaInspection4 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (QaInspection4?.setWork_order)
|
|
{
|
|
await
|
|
QaInspection4.
|
|
setWork_order(relatedWork_order4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateQaInspectionWithMachine() {
|
|
|
|
const relatedMachine0 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const QaInspection0 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (QaInspection0?.setMachine)
|
|
{
|
|
await
|
|
QaInspection0.
|
|
setMachine(relatedMachine0);
|
|
}
|
|
|
|
const relatedMachine1 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const QaInspection1 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (QaInspection1?.setMachine)
|
|
{
|
|
await
|
|
QaInspection1.
|
|
setMachine(relatedMachine1);
|
|
}
|
|
|
|
const relatedMachine2 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const QaInspection2 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (QaInspection2?.setMachine)
|
|
{
|
|
await
|
|
QaInspection2.
|
|
setMachine(relatedMachine2);
|
|
}
|
|
|
|
const relatedMachine3 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const QaInspection3 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (QaInspection3?.setMachine)
|
|
{
|
|
await
|
|
QaInspection3.
|
|
setMachine(relatedMachine3);
|
|
}
|
|
|
|
const relatedMachine4 = await Machines.findOne({
|
|
offset: Math.floor(Math.random() * (await Machines.count())),
|
|
});
|
|
const QaInspection4 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (QaInspection4?.setMachine)
|
|
{
|
|
await
|
|
QaInspection4.
|
|
setMachine(relatedMachine4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateQaInspectionWithInspector() {
|
|
|
|
const relatedInspector0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const QaInspection0 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (QaInspection0?.setInspector)
|
|
{
|
|
await
|
|
QaInspection0.
|
|
setInspector(relatedInspector0);
|
|
}
|
|
|
|
const relatedInspector1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const QaInspection1 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (QaInspection1?.setInspector)
|
|
{
|
|
await
|
|
QaInspection1.
|
|
setInspector(relatedInspector1);
|
|
}
|
|
|
|
const relatedInspector2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const QaInspection2 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (QaInspection2?.setInspector)
|
|
{
|
|
await
|
|
QaInspection2.
|
|
setInspector(relatedInspector2);
|
|
}
|
|
|
|
const relatedInspector3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const QaInspection3 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (QaInspection3?.setInspector)
|
|
{
|
|
await
|
|
QaInspection3.
|
|
setInspector(relatedInspector3);
|
|
}
|
|
|
|
const relatedInspector4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const QaInspection4 = await QaInspections.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (QaInspection4?.setInspector)
|
|
{
|
|
await
|
|
QaInspection4.
|
|
setInspector(relatedInspector4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateInventoryTransactionWithMaterial() {
|
|
|
|
const relatedMaterial0 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const InventoryTransaction0 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryTransaction0?.setMaterial)
|
|
{
|
|
await
|
|
InventoryTransaction0.
|
|
setMaterial(relatedMaterial0);
|
|
}
|
|
|
|
const relatedMaterial1 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const InventoryTransaction1 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryTransaction1?.setMaterial)
|
|
{
|
|
await
|
|
InventoryTransaction1.
|
|
setMaterial(relatedMaterial1);
|
|
}
|
|
|
|
const relatedMaterial2 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const InventoryTransaction2 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryTransaction2?.setMaterial)
|
|
{
|
|
await
|
|
InventoryTransaction2.
|
|
setMaterial(relatedMaterial2);
|
|
}
|
|
|
|
const relatedMaterial3 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const InventoryTransaction3 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (InventoryTransaction3?.setMaterial)
|
|
{
|
|
await
|
|
InventoryTransaction3.
|
|
setMaterial(relatedMaterial3);
|
|
}
|
|
|
|
const relatedMaterial4 = await Materials.findOne({
|
|
offset: Math.floor(Math.random() * (await Materials.count())),
|
|
});
|
|
const InventoryTransaction4 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (InventoryTransaction4?.setMaterial)
|
|
{
|
|
await
|
|
InventoryTransaction4.
|
|
setMaterial(relatedMaterial4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateInventoryTransactionWithLocation() {
|
|
|
|
const relatedLocation0 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryTransaction0 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryTransaction0?.setLocation)
|
|
{
|
|
await
|
|
InventoryTransaction0.
|
|
setLocation(relatedLocation0);
|
|
}
|
|
|
|
const relatedLocation1 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryTransaction1 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryTransaction1?.setLocation)
|
|
{
|
|
await
|
|
InventoryTransaction1.
|
|
setLocation(relatedLocation1);
|
|
}
|
|
|
|
const relatedLocation2 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryTransaction2 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryTransaction2?.setLocation)
|
|
{
|
|
await
|
|
InventoryTransaction2.
|
|
setLocation(relatedLocation2);
|
|
}
|
|
|
|
const relatedLocation3 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryTransaction3 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (InventoryTransaction3?.setLocation)
|
|
{
|
|
await
|
|
InventoryTransaction3.
|
|
setLocation(relatedLocation3);
|
|
}
|
|
|
|
const relatedLocation4 = await InventoryLocations.findOne({
|
|
offset: Math.floor(Math.random() * (await InventoryLocations.count())),
|
|
});
|
|
const InventoryTransaction4 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (InventoryTransaction4?.setLocation)
|
|
{
|
|
await
|
|
InventoryTransaction4.
|
|
setLocation(relatedLocation4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateInventoryTransactionWithRelated_work_order() {
|
|
|
|
const relatedRelated_work_order0 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const InventoryTransaction0 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryTransaction0?.setRelated_work_order)
|
|
{
|
|
await
|
|
InventoryTransaction0.
|
|
setRelated_work_order(relatedRelated_work_order0);
|
|
}
|
|
|
|
const relatedRelated_work_order1 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const InventoryTransaction1 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryTransaction1?.setRelated_work_order)
|
|
{
|
|
await
|
|
InventoryTransaction1.
|
|
setRelated_work_order(relatedRelated_work_order1);
|
|
}
|
|
|
|
const relatedRelated_work_order2 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const InventoryTransaction2 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryTransaction2?.setRelated_work_order)
|
|
{
|
|
await
|
|
InventoryTransaction2.
|
|
setRelated_work_order(relatedRelated_work_order2);
|
|
}
|
|
|
|
const relatedRelated_work_order3 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const InventoryTransaction3 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (InventoryTransaction3?.setRelated_work_order)
|
|
{
|
|
await
|
|
InventoryTransaction3.
|
|
setRelated_work_order(relatedRelated_work_order3);
|
|
}
|
|
|
|
const relatedRelated_work_order4 = await WorkOrders.findOne({
|
|
offset: Math.floor(Math.random() * (await WorkOrders.count())),
|
|
});
|
|
const InventoryTransaction4 = await InventoryTransactions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (InventoryTransaction4?.setRelated_work_order)
|
|
{
|
|
await
|
|
InventoryTransaction4.
|
|
setRelated_work_order(relatedRelated_work_order4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateInventoryLocationWithManager() {
|
|
|
|
const relatedManager0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const InventoryLocation0 = await InventoryLocations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (InventoryLocation0?.setManager)
|
|
{
|
|
await
|
|
InventoryLocation0.
|
|
setManager(relatedManager0);
|
|
}
|
|
|
|
const relatedManager1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const InventoryLocation1 = await InventoryLocations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (InventoryLocation1?.setManager)
|
|
{
|
|
await
|
|
InventoryLocation1.
|
|
setManager(relatedManager1);
|
|
}
|
|
|
|
const relatedManager2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const InventoryLocation2 = await InventoryLocations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (InventoryLocation2?.setManager)
|
|
{
|
|
await
|
|
InventoryLocation2.
|
|
setManager(relatedManager2);
|
|
}
|
|
|
|
const relatedManager3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const InventoryLocation3 = await InventoryLocations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (InventoryLocation3?.setManager)
|
|
{
|
|
await
|
|
InventoryLocation3.
|
|
setManager(relatedManager3);
|
|
}
|
|
|
|
const relatedManager4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const InventoryLocation4 = await InventoryLocations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (InventoryLocation4?.setManager)
|
|
{
|
|
await
|
|
InventoryLocation4.
|
|
setManager(relatedManager4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProductionLineWithSupervisor() {
|
|
|
|
const relatedSupervisor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProductionLine0 = await ProductionLines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProductionLine0?.setSupervisor)
|
|
{
|
|
await
|
|
ProductionLine0.
|
|
setSupervisor(relatedSupervisor0);
|
|
}
|
|
|
|
const relatedSupervisor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProductionLine1 = await ProductionLines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProductionLine1?.setSupervisor)
|
|
{
|
|
await
|
|
ProductionLine1.
|
|
setSupervisor(relatedSupervisor1);
|
|
}
|
|
|
|
const relatedSupervisor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProductionLine2 = await ProductionLines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProductionLine2?.setSupervisor)
|
|
{
|
|
await
|
|
ProductionLine2.
|
|
setSupervisor(relatedSupervisor2);
|
|
}
|
|
|
|
const relatedSupervisor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProductionLine3 = await ProductionLines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ProductionLine3?.setSupervisor)
|
|
{
|
|
await
|
|
ProductionLine3.
|
|
setSupervisor(relatedSupervisor3);
|
|
}
|
|
|
|
const relatedSupervisor4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProductionLine4 = await ProductionLines.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (ProductionLine4?.setSupervisor)
|
|
{
|
|
await
|
|
ProductionLine4.
|
|
setSupervisor(relatedSupervisor4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Materials.bulkCreate(MaterialsData);
|
|
|
|
|
|
|
|
|
|
await Suppliers.bulkCreate(SuppliersData);
|
|
|
|
|
|
|
|
|
|
await Boms.bulkCreate(BomsData);
|
|
|
|
|
|
|
|
|
|
await WorkOrders.bulkCreate(WorkOrdersData);
|
|
|
|
|
|
|
|
|
|
await Machines.bulkCreate(MachinesData);
|
|
|
|
|
|
|
|
|
|
await QaInspections.bulkCreate(QaInspectionsData);
|
|
|
|
|
|
|
|
|
|
await InventoryTransactions.bulkCreate(InventoryTransactionsData);
|
|
|
|
|
|
|
|
|
|
await InventoryLocations.bulkCreate(InventoryLocationsData);
|
|
|
|
|
|
|
|
|
|
await ProductionLines.bulkCreate(ProductionLinesData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMaterialWithSupplier(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateBomWithProduct(),
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateWorkOrderWithProduct(),
|
|
|
|
|
|
|
|
|
|
await associateWorkOrderWithBom(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateWorkOrderWithAssigned_machine(),
|
|
|
|
|
|
|
|
|
|
await associateWorkOrderWithAssigned_to(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMachineWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateQaInspectionWithWork_order(),
|
|
|
|
|
|
|
|
|
|
await associateQaInspectionWithMachine(),
|
|
|
|
|
|
|
|
|
|
await associateQaInspectionWithInspector(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateInventoryTransactionWithMaterial(),
|
|
|
|
|
|
|
|
|
|
await associateInventoryTransactionWithLocation(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateInventoryTransactionWithRelated_work_order(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateInventoryLocationWithManager(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProductionLineWithSupervisor(),
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('materials', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('suppliers', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('boms', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('work_orders', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('machines', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('qa_inspections', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('inventory_transactions', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('inventory_locations', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('production_lines', null, {});
|
|
|
|
|
|
},
|
|
}; |