Changed logic in process order #1452
@@ -87,13 +87,13 @@ class SendProcessOrderReport extends Command
|
|||||||
// ->get();
|
// ->get();
|
||||||
|
|
||||||
// Total coils grouped by process order
|
// Total coils grouped by process order
|
||||||
$processOrderTotals = DB::table('process_orders')
|
// $processOrderTotals = DB::table('process_orders')
|
||||||
->where('plant_id', $plant->id)
|
// ->where('plant_id', $plant->id)
|
||||||
->where('coil_number', '!=', 0)
|
// ->where('coil_number', '!=', 0)
|
||||||
->selectRaw('process_order, COUNT(*) AS total_count')
|
// ->selectRaw('process_order, COUNT(*) AS total_count')
|
||||||
->groupBy('process_order')
|
// ->groupBy('process_order')
|
||||||
->get()
|
// ->get()
|
||||||
->keyBy('process_order');
|
// ->keyBy('process_order');
|
||||||
|
|
||||||
// OK and Not OK counts grouped by process order
|
// OK and Not OK counts grouped by process order
|
||||||
$statusCounts = DB::table('characteristic_values')
|
$statusCounts = DB::table('characteristic_values')
|
||||||
@@ -126,12 +126,11 @@ class SendProcessOrderReport extends Command
|
|||||||
|
|
||||||
$processOrder = $order->process_order;
|
$processOrder = $order->process_order;
|
||||||
|
|
||||||
$total = $processOrderTotals[$processOrder]->total_count ?? 0;
|
$total = $statusCounts[$processOrder]->total_count ?? 0;
|
||||||
|
|
||||||
$notOk = $statusCounts[$processOrder]->notok_count ?? 0;
|
$notOk = $statusCounts[$processOrder]->notok_count ?? 0;
|
||||||
$ok = $statusCounts[$processOrder]->ok_count ?? 0;
|
$ok = $statusCounts[$processOrder]->ok_count ?? 0;
|
||||||
|
|
||||||
// Calculate percentages
|
|
||||||
$notOkPerc = $total > 0
|
$notOkPerc = $total > 0
|
||||||
? round(($notOk / $total) * 100, 2)
|
? round(($notOk / $total) * 100, 2)
|
||||||
: 0;
|
: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user