From 44c70f473d83a2fd4aeb826762176de72823db24 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 14 Nov 2026 14:26:03 +0530 Subject: [PATCH] Added sfg part validation line type in production report --- app/Console/Commands/SendProductionReport.php | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index aa1c489d..f53a7fa4 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -154,6 +154,7 @@ class SendProductionReport extends Command ->whereIn('type', [ 'Base FG Line', 'Base FG Leak Test Line', + 'SFG Part Validation Line', 'FG Line', 'Process FG Line', 'SFG Line', @@ -162,9 +163,10 @@ class SendProductionReport extends Command CASE WHEN LOWER(type) = 'fg line' THEN 0 WHEN LOWER(type) = 'base fg leak test line' THEN 1 - WHEN LOWER(type) = 'base fg line' THEN 2 - WHEN LOWER(type) = 'process fg line' THEN 3 - WHEN LOWER(type) = 'sfg line' THEN 4 + WHEN LOWER(type) = 'sfg part validation line' THEN 2 + WHEN LOWER(type) = 'base fg line' THEN 3 + WHEN LOWER(type) = 'process fg line' THEN 4 + WHEN LOWER(type) = 'sfg line' THEN 5 ELSE 4 END ") @@ -292,6 +294,25 @@ class SendProductionReport extends Command ->whereBetween('created_at', [$startDate, $endDate]) ->count(); + } + else if (strtolower($line->type) == 'sfg part validation line') { + + $productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) + ->whereBetween('created_at', [$startDate, $endDate]) + ->count(); + + $nonPlannedproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereNotIn('item_id', $itemIds); + }) + ->whereBetween('created_at', [$startDate, $endDate]) + ->count(); + } else if(strtolower($line->type) == 'process fg line'){ $productionQuantity = \App\Models\ProcessOrder::where('plant_id', $plant->id) @@ -393,6 +414,32 @@ class SendProductionReport extends Command ->count(); } + if (strtolower($line->type) == 'sfg part validation line') { + + $dayproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(8, 0, 0), + $startDate->copy()->setTime(19, 30, 0), + ]) + ->count(); + + $nightproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereHas('stickerMaster', function ($query) use ($itemIds) { + $query->whereIn('item_id', $itemIds); + }) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(19, 30, 0), + $endDate->copy()->setTime(8, 0, 0), + ]) + ->count(); + + } + $dayShiftEfficiency = $dayShiftPlanQuan > 0 ? ($dayproductionQuantity / $dayShiftPlanQuan) * 100 : 0; $nightShiftEfficiency = $nightShiftPlanQuan > 0 ? ($nightproductionQuantity / $nightShiftPlanQuan) * 100 : 0;