Added plant and line in non production plan grid
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 21s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 3m50s
Laravel Larastan / larastan (pull_request) Failing after 4m18s

This commit is contained in:
dhanabalan
2026-10-12 14:13:02 +05:30
parent ee44ac832c
commit 94fbcb1af8
2 changed files with 55 additions and 9 deletions

View File

@@ -2,11 +2,13 @@
namespace App\Livewire;
use App\Exports\ProductionNonPlanExport;
use App\Models\ProductionPlan;
use App\Models\QualityValidation;
use Carbon\Carbon;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Livewire\Component;
use Maatwebsite\Excel\Facades\Excel;
class ProductionNonPlanned extends Component
{
@@ -20,8 +22,6 @@ class ProductionNonPlanned extends Component
public int $nonPlannedQuantity = 0;
// public $dates = [];
public $monthlyRecords = [];
public $efficiency = [];
@@ -37,7 +37,8 @@ class ProductionNonPlanned extends Component
protected $listeners = [
'loadData' => 'loadProductionData',
'loadDataCategory' => 'loadProductionCategoryData'
'loadDataCategory' => 'loadProductionCategoryData',
'loadDataExport' => 'exportNonPlannedData'
];
public function loadProductionData($date, $plantId, $lineId)
@@ -116,6 +117,18 @@ class ProductionNonPlanned extends Component
'=',
'sticker_masters.item_id'
)
->join(
'plants',
'plants.id',
'=',
'quality_validations.plant_id'
)
->join(
'lines',
'lines.id',
'=',
'quality_validations.line_id'
)
->where('quality_validations.plant_id', $plantId)
->where('quality_validations.line_id', $lineId)
->where('quality_validations.created_at', '>=', $startDate)
@@ -130,6 +143,8 @@ class ProductionNonPlanned extends Component
$nonPlannedData = $nonPlannedQuery
->selectRaw("
plants.name as plant_name,
lines.name as line_name,
sticker_masters.item_id,
items.code as item_code,
items.description as item_description,
@@ -137,6 +152,8 @@ class ProductionNonPlanned extends Component
COUNT(*) as total_qty
")
->groupBy(
'plants.name',
'lines.name',
'sticker_masters.item_id',
'items.code',
'items.description',
@@ -228,6 +245,18 @@ class ProductionNonPlanned extends Component
'=',
'sticker_masters.item_id'
)
->join(
'plants',
'plants.id',
'=',
'quality_validations.plant_id'
)
->join(
'lines',
'lines.id',
'=',
'quality_validations.line_id'
)
->where('quality_validations.plant_id', $plantId)
->where('quality_validations.line_id', $lineId)
->where('items.category', $category)
@@ -243,6 +272,8 @@ class ProductionNonPlanned extends Component
$nonPlannedData = $nonPlannedQuery
->selectRaw("
plants.name as plant_name,
lines.name as line_name,
sticker_masters.item_id,
items.code as item_code,
items.description as item_description,
@@ -250,6 +281,8 @@ class ProductionNonPlanned extends Component
COUNT(*) as total_qty
")
->groupBy(
'plants.name',
'lines.name',
'sticker_masters.item_id',
'items.code',
'items.description',
@@ -264,15 +297,24 @@ class ProductionNonPlanned extends Component
$this->nonPlannedQuantity = (int) $nonPlannedData->sum('total_qty');
}
public function exportNonPlannedData()
{
$selectedDate = Carbon::parse($this->date)->toDateString();
$startDate = Carbon::parse($selectedDate)->setTime(8, 0, 0);
$endDate = $startDate->copy()->addDay();
return Excel::download(
new ProductionNonPlanExport($this->nonPlannedRecords, $startDate->toDateTimeString(),
$endDate->toDateTimeString()),
'production_non_plan_data.xlsx'
);
}
public function render()
{
// return view('livewire.production-non-planned');
return view('livewire.production-non-planned', [
'records' => $this->records,
'monthlyRecords' => $this->monthlyRecords,
'monthlyActualRecords' => $this->monthlyActualQuantity,
'monthlyEfficiency' => $this->efficiency,
'dates' => $this->dates,
'records' => $this->nonPlannedRecords,
]);
}
}