Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | import { Controller, Get, Post, Body, Param, Req, Patch, Query } from '@nestjs/common'; import { ApiTags, ApiOperation } from '@nestjs/swagger'; import { BomRoutingService, MpsCapacityService, MrpEngineService, ProductionExecutionService, CostingSubcontractService, TraceabilityMaintenanceService } from '../services'; @ApiTags('Manufacturing') @Controller('api/v1/manufacturing') export class ManufacturingController { constructor( private readonly bomRoutingSvc: BomRoutingService, private readonly mpsCapacitySvc: MpsCapacityService, private readonly mrpEngineSvc: MrpEngineService, private readonly executionSvc: ProductionExecutionService, private readonly costingSubcontractSvc: CostingSubcontractService, private readonly traceabilitySvc: TraceabilityMaintenanceService ) {} @Post('boms') @ApiOperation({ summary: 'Create a new Bill of Materials' }) async createBom(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.bomRoutingSvc.createBom(tenantId, body); } @Post('boms/:id/lines') @ApiOperation({ summary: 'Add a line component to BOM' }) async addBomLine(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.bomRoutingSvc.addBomLine(tenantId, id, body); } @Post('boms/:id/activate') @ApiOperation({ summary: 'Approve and activate BOM version to immutable status' }) async activateBom(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.bomRoutingSvc.activateBom(tenantId, id); } @Post('routings') @ApiOperation({ summary: 'Create production routing template' }) async createRouting(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.bomRoutingSvc.createRouting(tenantId, body); } @Post('routings/:id/operations') @ApiOperation({ summary: 'Add routing operation sequence' }) async addRoutingOperation(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.bomRoutingSvc.addRoutingOperation(tenantId, id, body); } @Post('forecasts') @ApiOperation({ summary: 'Add demand forecast records' }) async createForecast(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.mrpEngineSvc.createForecast(tenantId, body); } @Post('mps') @ApiOperation({ summary: 'Add Master Production Schedule entry' }) async createMpsLine(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.mpsCapacitySvc.createMpsLine(tenantId, body); } @Post('mrp/run') @ApiOperation({ summary: 'Execute MRP planner calculations' }) async executeMrp(@Req() req: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; const userId = req.headers['x-user-id'] || '60c72b2f9b1d8b23c4d5e6f2'; return this.mrpEngineSvc.runMrp(tenantId, userId); } @Get('planned-orders') @ApiOperation({ summary: 'Get suggested planned orders' }) async getPlannedOrders(@Req() req: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.mrpEngineSvc.getPlannedOrders(tenantId); } @Post('production-orders') @ApiOperation({ summary: 'Create new production shop floor order' }) async createProductionOrder(@Req() req: any, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.executionSvc.createProductionOrder(tenantId, body); } @Post('production-orders/:id/release') @ApiOperation({ summary: 'Release planned production order' }) async releaseOrder(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.executionSvc.releaseOrder(tenantId, id); } @Post('production-orders/:id/issues') @ApiOperation({ summary: 'Issue raw materials to production staging location' }) async issueMaterials(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.executionSvc.issueMaterials(tenantId, id, body); } @Post('production-orders/:id/receipt') @ApiOperation({ summary: 'Request finished goods receipt post verification' }) async requestReceipt(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.executionSvc.requestReceipt(tenantId, id, body.fgWarehouseId); } @Get('costing/orders/:id/variance') @ApiOperation({ summary: 'Get production variance report standard vs actual' }) async getVariance(@Req() req: any, @Param('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.costingSubcontractSvc.calculateProductionVariance(tenantId, id); } @Post('costing/orders/:id/post') @ApiOperation({ summary: 'Publish variance cost posting transactions to Finance event outbox' }) async postCosts(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.costingSubcontractSvc.publishCostPosting(tenantId, id, body.type, body.amountMinor); } @Get('traceability/timeline') @ApiOperation({ summary: 'Get item genealogy traceability graph' }) async getTraceability(@Req() req: any, @Query('type') type: 'order' | 'batch' | 'serial', @Query('id') id: string) { const tenantId = req.headers['x-tenant-id'] || '60c72b2f9b1d8b23c4d5e6f1'; return this.traceabilitySvc.getGenealogyTimeline(tenantId, type, id); } } |