From 705d62d7ac69c1d51b04018260fb88b77e86b2dd Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 29 Sep 2026 10:36:39 +0530 Subject: [PATCH] Added day shift and night shift logic in production report --- app/Console/Commands/SendProductionReport.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index 7d29995..07aba92 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -249,6 +249,33 @@ class SendProductionReport extends Command $efficiency = 0; } + $dayShiftPlanQuan = ($totalTargetQuantity / 2); + + $nightShiftPlanQuan = ($totalTargetQuantity / 2); + + if (strtolower($line->type) == 'fg line') { + + $dayproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(8, 0, 0), + $endDate->copy()->setTime(19, 30, 0), + ]) + ->count(); + + $nightproductionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id) + ->where('line_id', $line->id) + ->whereBetween('created_at', [ + $startDate->copy()->setTime(19, 30, 0), + $endDate->copy()->addDay()->setTime(8, 0, 0), + ]) + ->count(); + } + + $dayShiftEfficiency = $dayShiftPlanQuan > 0 ? ($dayproductionQuantity / $dayShiftPlanQuan) * 100 : 0; + + $nightShiftEfficiency = $dayShiftPlanQuan > 0 ? ($nightproductionQuantity / $nightShiftPlanQuan) * 100 : 0; + $efficiency = round($efficiency, 2); $tableData[] = [ @@ -257,6 +284,12 @@ class SendProductionReport extends Command 'type' => $line->type, 'line' => $line->name, 'capacityQuantity' => floor($capacityQuan), + 'dayShiftPlanQuantity' => floor($dayShiftPlanQuan), + 'dayShiftActualQuantity' => floor($dayShiftPlanQuan), + 'dayShiftEfficiency' => floor($dayShiftEfficiency), + 'nightShiftPlanQuantity' => floor($nightShiftPlanQuan), + 'nightShiftActualQuantity' => floor($nightShiftPlanQuan), + 'nightShiftEfficiency' => floor($nightShiftEfficiency), 'targetQuantity' => floor($totalTargetQuantity), 'productionQuantity' => $productionQuantity, 'efficiency' => $efficiency . '%',