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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ timestamps: true, collection: 'manufacturing_production_orders' }) export class ProductionOrder extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true, unique: true }) productionOrderNumber: string; @Prop({ required: true }) itemCode: string; @Prop({ required: true, default: 1 }) plannedQuantity: number; @Prop({ default: 0 }) completedQuantity: number; @Prop({ default: 0 }) scrappedQuantity: number; @Prop({ default: 'draft' }) status: string; // 'draft' | 'planned' | 'approved' | 'released' | 'in_progress' | 'completed' | 'closed' | 'cancelled' @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'BillOfMaterial', required: true }) bomId: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'ProductionRouting', required: true }) routingId: MongooseSchema.Types.ObjectId; @Prop({ required: true }) startDate: Date; @Prop({ required: true }) endDate: Date; @Prop() projectId?: string; // project manufacturing link @Prop() costCenterId?: string; // cost accounting link } export const ProductionOrderSchema = SchemaFactory.createForClass(ProductionOrder); ProductionOrderSchema.index({ tenantId: 1, productionOrderNumber: 1 }, { unique: true }); ProductionOrderSchema.index({ tenantId: 1, status: 1 }); @Schema({ timestamps: true, collection: 'manufacturing_order_materials' }) export class ProductionOrderMaterial extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'ProductionOrder', required: true }) productionOrderId: MongooseSchema.Types.ObjectId; @Prop({ required: true }) componentItemCode: string; @Prop({ required: true, default: 0 }) requiredQuantity: number; @Prop({ default: 0 }) issuedQuantity: number; @Prop({ default: 0 }) returnedQuantity: number; @Prop({ default: 'Manual' }) issueMethod: string; // 'Manual' | 'Backflush' } export const ProductionOrderMaterialSchema = SchemaFactory.createForClass(ProductionOrderMaterial); ProductionOrderMaterialSchema.index({ tenantId: 1, productionOrderId: 1 }); @Schema({ timestamps: true, collection: 'manufacturing_shop_floor_executions' }) export class ShopFloorExecution extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'ProductionOrder', required: true }) productionOrderId: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'RoutingOperation', required: true }) operationId: MongooseSchema.Types.ObjectId; @Prop({ required: true }) operatorId: string; @Prop({ required: true, default: () => new Date() }) startTime: Date; @Prop({ default: null }) endTime?: Date; @Prop({ default: 0 }) laborHours: number; @Prop({ default: 0 }) machineHours: number; @Prop({ default: 0 }) setupMinutes: number; @Prop({ default: 0 }) goodQuantity: number; @Prop({ default: 0 }) scrappedQuantity: number; @Prop({ default: 'In Progress' }) status: string; // 'In Progress' | 'Completed' | 'Paused' } export const ShopFloorExecutionSchema = SchemaFactory.createForClass(ShopFloorExecution); ShopFloorExecutionSchema.index({ tenantId: 1, productionOrderId: 1 }); |