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 | import { Injectable, BadRequestException } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { ProductionOrder, MachineResource, InspectionLot } from '../schemas'; @Injectable() export class TraceabilityMaintenanceService { constructor( @InjectModel(ProductionOrder.name) private readonly productionOrderModel: Model<ProductionOrder>, @InjectModel(MachineResource.name) private readonly machineModel: Model<MachineResource>, @InjectModel(InspectionLot.name) private readonly lotModel: Model<InspectionLot> ) {} async getGenealogyTimeline(tenantId: string, type: 'order' | 'batch' | 'serial', referenceId: string): Promise<any> { // Basic audit graph return format return { referenceId, type, nodeType: 'root', nodes: [ { id: '1', label: `Source Product: ${referenceId}`, type: 'Raw Material' }, { id: '2', label: 'Operation 10: Mixing - WorkCenter: WC-01', type: 'Routing Operation' }, { id: '3', label: 'Quality Inspection: PASS', type: 'Inspection Lot' } ], edges: [ { from: '1', to: '2' }, { from: '2', to: '3' } ] }; } async getDowntimeImpact(tenantId: string, machineResourceId: string): Promise<{ isBlocked: boolean; reason?: string; }> { const machine = await this.machineModel.findOne({ _id: machineResourceId, tenantId }).exec(); if (!machine) throw new BadRequestException('Machine resource not found'); if (machine.status === 'Down' || machine.status === 'Maintenance') { return { isBlocked: true, reason: `Machine ${machine.resourceName} is currently undergoing scheduled maintenance or breakdown repairs.`, }; } return { isBlocked: false, }; } } |