From a9f0cf7819e86fc262129f8d1da87994c9478e65 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 17 Nov 2026 09:43:43 +0530 Subject: [PATCH] Added logic for day and night production quantity in send production report --- app/Console/Commands/SendProductionReport.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index fe7585ee..a4ecfe4c 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -326,7 +326,7 @@ class SendProductionReport extends Command ->whereBetween('created_at', [$startDate, $endDate]) ->count(); } - else { + else if(strtolower($line->type) == 'base fg line'){ $productionQuantity = ProductionQuantity::where('plant_id', $plant->id) ->where('line_id', $line->id) @@ -470,10 +470,28 @@ class SendProductionReport extends Command if (strtolower($line->type) == 'base fg line') { - $productionQuantity = ProductionQuantity::where('plant_id', $plant->id) + $dayproductionQuantity = ProductionQuantity::where('plant_id', $plant->id) ->where('line_id', $line->id) - ->whereBetween('created_at', [$startDate, $endDate]) + ->whereIn('item_id', $itemIds) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(8, 0, 0), + $startDate->copy()->setTime(19, 30, 0), + ]) ->count(); + + $nightproductionQuantity = ProductionQuantity::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereIn('item_id', $itemIds) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(19, 30, 0), + $endDate->copy()->setTime(8, 0, 0), + ]) + ->count(); + + // $productionQuantity = ProductionQuantity::where('plant_id', $plant->id) + // ->where('line_id', $line->id) + // ->whereBetween('created_at', [$startDate, $endDate]) + // ->count(); } $dayShiftEfficiency = $dayShiftPlanQuan > 0 ? ($dayproductionQuantity / $dayShiftPlanQuan) * 100 : 0; -- 2.49.1