1
0
forked from poc/pds

Added hourly data in production quantity in modules

This commit is contained in:
dhanabalan
2025-07-11 17:18:01 +05:30
parent 484bc6d070
commit b4ca4a9fcd

View File

@@ -227,10 +227,43 @@ class ModuleFilterDataController extends Controller
->whereBetween('created_at', [$startDate, $endDate])
->count();
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => $rowCount
], 200);
// return response()->json([
// 'status_code' => 'SUCCESS',
// 'status_description' => $rowCount
// ], 200);
$chartName = $request->header('chart-name');
if ($chartName == 'Production Hourly Count') {
$hourlyCounts = [];
$hourStart = $startDate->copy();
while ($hourStart < $endDate) {
$hourEnd = $hourStart->copy()->addHour();
$label = $hourStart->format('g:i A') . ' to ' . $hourEnd->format('g:i A');
$count = ProductionQuantity::where('plant_id', $plant->id)
->where('line_id', $line->id)
->whereBetween('created_at', [$hourStart, $hourEnd])
->count();
$hourlyCounts[$label] = $count;
$hourStart = $hourEnd;
}
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => $hourlyCounts
], 200);
}
if ($chartName == 'Production Line Count')
{
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => $rowCount
], 200);
}
}