diff --git a/app/Http/Controllers/CreateProjectController.php b/app/Http/Controllers/CreateProjectController.php index e99666c8..d01fcf17 100755 --- a/app/Http/Controllers/CreateProjectController.php +++ b/app/Http/Controllers/CreateProjectController.php @@ -521,7 +521,6 @@ public function createWorkStations(Request $request) public function createProjectForStep1() { $companies = User::where('type_users', 3)->get(); - // Apos terminar não vai ficar step 1 return view('projectsClients/createProject', ['step' => 1], ['companies' => $companies]); } diff --git a/app/Http/Controllers/WorkstationsJobsController.php b/app/Http/Controllers/WorkstationsJobsController.php index 08cb814f..ab95f143 100644 --- a/app/Http/Controllers/WorkstationsJobsController.php +++ b/app/Http/Controllers/WorkstationsJobsController.php @@ -13,187 +13,322 @@ public function index() { $userEmail = Auth::user()->email; - $equipmentsTodo = DB::table('ordered_equipment_tasks AS oet') - ->distinct() - ->select('oet.equipment_id', 'eq.equipment_tag') - ->join('equipments AS eq', 'oet.equipment_id', '=', 'eq.equipment_id') - ->join('workstations_association_tasks AS wat', 'oet.elemental_tasks_id', '=', 'wat.elemental_tasks_id') - ->whereIn('eq.company_projects_id', function ($query) use ($userEmail) { - $query->select('cw.company_projects_id') - ->from('construction_workstations AS cw') - ->join('users AS u', 'cw.name_workstations', '=', 'u.user_name') - ->where('u.email', $userEmail); - }) - ->whereIn('wat.id_workstations', function ($query) use ($userEmail) { - $query->select('cw.id_workstations') - ->from('construction_workstations AS cw') - ->join('users AS u', 'cw.name_workstations', '=', 'u.user_name') - ->where('u.email', $userEmail); - }) - ->where('oet.execution_order', '=', function ($query) { - $query->selectRaw('IFNULL(MIN(ot.execution_order), 1)') - ->from('ordered_equipment_tasks AS ot') - ->whereColumn('ot.equipment_id', 'oet.equipment_id') - ->whereNotIn('ot.elemental_tasks_id', function ($query) { - $query->select('cew.elemental_tasks_id') - ->from('control_equipment_workstation AS cew') - ->whereColumn('ot.equipment_id', 'cew.equipment_id'); - }); - }) - ->whereNotExists(function ($query) { - $query->select(DB::raw(1)) - ->from('control_equipment_workstation AS cew') - ->whereColumn('oet.equipment_id', 'cew.equipment_id'); - }) - ->get(); + // $equipmentsTodo= DB::select(" + // WITH equipments_multiple_rows AS ( + // SELECT + // e.equipment_id, + // e.equipment_tag, + // COALESCE(MAX(oet.elemental_tasks_id), MAX(oet.further_tasks_id)) AS equipment_all_tasks + // FROM + // users u + // JOIN + // construction_workstations cw ON u.user_name = cw.name_workstations + // JOIN + // workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + // JOIN + // equipments e ON wat.company_projects_id = e.company_projects_id + // JOIN + // ordered_equipment_tasks oet ON e.equipment_id = oet.equipment_id + // WHERE + // u.email = :email + // AND + // oet.execution_order = 1 + // GROUP BY + // e.equipment_id, + // e.equipment_tag + // ), + + // workstations_multiple_rows AS ( + // SELECT + // cw.id_workstations, + // cw.name_workstations, + // COALESCE(wat.elemental_tasks_id, wat.further_tasks_id) AS all_tasks + // FROM + // users u + // JOIN + // construction_workstations cw ON u.user_name = cw.name_workstations + // JOIN + // workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + // WHERE + // u.email = :email + // ), + + // workstations_control_all_tasks AS ( + // SELECT + // cew.control_equipment_workstation_id, + // cew.equipment_id, + // CASE + // WHEN cew.id_workstations IS NULL THEN NULL + // WHEN cew.id_workstations IN ( + // SELECT wat.id_workstations + // FROM workstations_association_tasks wat + // JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + // JOIN users u ON u.user_name = cw.name_workstations + // WHERE u.email = :email + // ) THEN cew.id_workstations + // ELSE NULL + // END AS control_id_workstations, + // COALESCE(cew.elemental_tasks_id, cew.further_tasks_id) AS control_workstation_all_tasks, + // cew.equipment_comments_id, + // cew.entry_date, + // cew.departure_date + // FROM + // control_equipment_workstation cew + // WHERE + // cew.id_workstations IS NULL + // OR cew.id_workstations IN ( + // SELECT wat.id_workstations + // FROM workstations_association_tasks wat + // JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + // JOIN users u ON u.user_name = cw.name_workstations + // WHERE u.email = :email + // ) + // ) + + // SELECT + // emr.equipment_id, + // emr.equipment_tag + // FROM + // equipments_multiple_rows emr + // WHERE + // ( + // emr.equipment_all_tasks IN (SELECT all_tasks FROM workstations_multiple_rows) + // AND NOT EXISTS ( + // SELECT 1 + // FROM workstations_control_all_tasks wc + // WHERE wc.equipment_id = emr.equipment_id + // AND wc.control_id_workstations IN (SELECT id_workstations FROM workstations_multiple_rows) + // ) + // ) + // OR + // ( + // emr.equipment_id IN ( + // SELECT equipment_id + // FROM workstations_control_all_tasks + // WHERE control_id_workstations IS NULL + // AND entry_date IS NULL + // AND departure_date IS NULL + // AND control_workstation_all_tasks IN (SELECT all_tasks FROM workstations_multiple_rows) + // ) + // AND NOT EXISTS ( + // SELECT 1 + // FROM workstations_control_all_tasks wc + // WHERE wc.equipment_id = emr.equipment_id + // AND wc.control_id_workstations IS NOT NULL + // GROUP BY wc.equipment_id + // HAVING COUNT(DISTINCT wc.control_id_workstations) > 1 + // ) + // ) + // GROUP BY + // emr.equipment_id, + // emr.equipment_tag + // ORDER BY + // emr.equipment_id ASC; + // ", ['email' => $userEmail]); $equipmentsDone = DB::select(" - WITH username AS ( - SELECT - user_name - FROM - users - WHERE - email = :email - ), - workstations AS ( - SELECT - id_workstations, - company_projects_id - FROM - construction_workstations - WHERE - name_workstations = (SELECT user_name FROM username) - ), - watet AS ( - SELECT - elemental_tasks_id - FROM - workstations_association_tasks - WHERE - id_workstations = (SELECT id_workstations FROM workstations) - ), - jobs AS ( - SELECT - ordered_equipment_tasks.equipment_id, - equipments.equipment_tag, - ordered_equipment_tasks.execution_order, - ordered_equipment_tasks.elemental_tasks_id, - workstations.id_workstations - FROM - ordered_equipment_tasks - INNER JOIN - equipments - ON - ordered_equipment_tasks.equipment_id = equipments.equipment_id - INNER JOIN - workstations - ON - equipments.company_projects_id = workstations.company_projects_id - WHERE - ordered_equipment_tasks.elemental_tasks_id IN (SELECT elemental_tasks_id FROM watet) - ), - valid_jobs AS ( - SELECT - jobs.equipment_id, - jobs.equipment_tag - FROM - jobs - WHERE - NOT EXISTS ( - SELECT - 1 - FROM - jobs AS j2 - WHERE - j2.equipment_id = jobs.equipment_id - AND NOT EXISTS ( - SELECT - 1 - FROM - control_equipment_workstation - WHERE - control_equipment_workstation.equipment_id = j2.equipment_id - AND control_equipment_workstation.elemental_tasks_id = j2.elemental_tasks_id - AND control_equipment_workstation.elemental_tasks_id IS NOT NULL - ) - ) - AND EXISTS ( - SELECT - 1 - FROM - control_equipment_workstation - WHERE - control_equipment_workstation.equipment_id = jobs.equipment_id - AND jobs.id_workstations = control_equipment_workstation.id_workstations - AND control_equipment_workstation.id_workstations IS NOT NULL - AND control_equipment_workstation.entry_date IS NOT NULL - AND control_equipment_workstation.departure_date IS NOT NULL - ) + WITH equipments_multiple_rows AS ( + SELECT + e.equipment_id, + e.equipment_tag, + COALESCE(MAX(oet.elemental_tasks_id), MAX(oet.further_tasks_id)) AS equipment_all_tasks + FROM + users u + JOIN + construction_workstations cw ON u.user_name = cw.name_workstations + JOIN + workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + JOIN + equipments e ON wat.company_projects_id = e.company_projects_id + JOIN + ordered_equipment_tasks oet ON e.equipment_id = oet.equipment_id + WHERE + u.email = :email + AND + oet.execution_order = 1 + GROUP BY + e.equipment_id, + e.equipment_tag + ), + + workstations_multiple_rows AS ( + SELECT + cw.id_workstations, + cw.name_workstations, + COALESCE(wat.elemental_tasks_id, wat.further_tasks_id) AS all_tasks + FROM + users u + JOIN + construction_workstations cw ON u.user_name = cw.name_workstations + JOIN + workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + WHERE + u.email = :email + ), + + workstations_control_all_tasks AS ( + SELECT + cew.control_equipment_workstation_id, + cew.equipment_id, + CASE + WHEN cew.id_workstations IS NULL THEN NULL + WHEN cew.id_workstations IN ( + SELECT wat.id_workstations + FROM workstations_association_tasks wat + JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + JOIN users u ON u.user_name = cw.name_workstations + WHERE u.email = :email + ) THEN cew.id_workstations + ELSE NULL + END AS control_id_workstations, + COALESCE(cew.elemental_tasks_id, cew.further_tasks_id) AS control_workstation_all_tasks, + cew.equipment_comments_id, + cew.entry_date, + cew.departure_date + FROM + control_equipment_workstation cew + WHERE + cew.id_workstations IS NULL + OR cew.id_workstations IN ( + SELECT wat.id_workstations + FROM workstations_association_tasks wat + JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + JOIN users u ON u.user_name = cw.name_workstations + WHERE u.email = :email ) - SELECT DISTINCT - valid_jobs.equipment_id, - valid_jobs.equipment_tag - FROM - valid_jobs; + ) + + SELECT + emr.equipment_id, + emr.equipment_tag + FROM + equipments_multiple_rows emr + WHERE + EXISTS ( + SELECT 1 + FROM workstations_control_all_tasks wc + JOIN workstations_multiple_rows wmr ON wc.control_id_workstations = wmr.id_workstations + WHERE wc.equipment_id = emr.equipment_id + AND wc.control_workstation_all_tasks = wmr.all_tasks + AND wc.entry_date IS NOT NULL + AND wc.departure_date IS NOT NULL + AND wc.control_id_workstations IS NOT NULL + ) + AND NOT EXISTS ( + SELECT 1 + FROM workstations_control_all_tasks wc + WHERE wc.equipment_id = emr.equipment_id + AND wc.control_workstation_all_tasks IN (SELECT all_tasks FROM workstations_multiple_rows) + AND wc.control_id_workstations IS NULL + ) + GROUP BY + emr.equipment_id, + emr.equipment_tag + ORDER BY + emr.equipment_id ASC; ", ['email' => $userEmail]); - + $equipmentsReturned = DB::select(" - SELECT DISTINCT - jobs.equipment_id, - jobs.equipment_tag - FROM ( + WITH equipments_multiple_rows AS ( SELECT - oet.equipment_id, + e.equipment_id, e.equipment_tag, - oet.execution_order, - oet.elemental_tasks_id, - cw.id_workstations + COALESCE(MAX(oet.elemental_tasks_id), MAX(oet.further_tasks_id)) AS equipment_all_tasks FROM - ordered_equipment_tasks AS oet + users u JOIN - equipments AS e ON oet.equipment_id = e.equipment_id + construction_workstations cw ON u.user_name = cw.name_workstations JOIN - ( - SELECT - cw.id_workstations, - cw.company_projects_id, - wat.elemental_tasks_id - FROM - construction_workstations AS cw - JOIN - users AS u ON cw.name_workstations = u.user_name - JOIN - ( - SELECT - wat.id_workstations, - wat.elemental_tasks_id - FROM - workstations_association_tasks AS wat - ) AS wat ON wat.id_workstations = cw.id_workstations - WHERE - u.email = :email - ) AS cw ON e.company_projects_id = cw.company_projects_id + workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + JOIN + equipments e ON wat.company_projects_id = e.company_projects_id + JOIN + ordered_equipment_tasks oet ON e.equipment_id = oet.equipment_id WHERE - oet.elemental_tasks_id = cw.elemental_tasks_id - ) AS jobs - INNER JOIN ( - SELECT cew.* - FROM control_equipment_workstation cew - INNER JOIN ( - SELECT equipment_id, elemental_tasks_id - FROM control_equipment_workstation - GROUP BY equipment_id, elemental_tasks_id - HAVING COUNT(*) > 1 - ) AS subquery - ON cew.equipment_id = subquery.equipment_id - AND cew.elemental_tasks_id = subquery.elemental_tasks_id - WHERE cew.id_workstations IS NULL - AND cew.entry_date IS NULL - ) AS repeated ON jobs.equipment_id = repeated.equipment_id - AND jobs.elemental_tasks_id = repeated.elemental_tasks_id + u.email = :email + AND + oet.execution_order = 1 + GROUP BY + e.equipment_id, + e.equipment_tag + ), + + workstations_multiple_rows AS ( + SELECT + cw.id_workstations, + cw.name_workstations, + COALESCE(wat.elemental_tasks_id, wat.further_tasks_id) AS all_tasks + FROM + users u + JOIN + construction_workstations cw ON u.user_name = cw.name_workstations + JOIN + workstations_association_tasks wat ON cw.id_workstations = wat.id_workstations + WHERE + u.email = :email + ), + + workstations_control_all_tasks AS ( + SELECT + cew.control_equipment_workstation_id, + cew.equipment_id, + CASE + WHEN cew.id_workstations IS NULL THEN NULL + WHEN cew.id_workstations IN ( + SELECT wat.id_workstations + FROM workstations_association_tasks wat + JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + JOIN users u ON u.user_name = cw.name_workstations + WHERE u.email = :email + ) THEN cew.id_workstations + ELSE NULL + END AS control_id_workstations, + COALESCE(cew.elemental_tasks_id, cew.further_tasks_id) AS control_workstation_all_tasks, + cew.equipment_comments_id, + cew.entry_date, + cew.departure_date + FROM + control_equipment_workstation cew + WHERE + cew.id_workstations IS NULL + OR cew.id_workstations IN ( + SELECT wat.id_workstations + FROM workstations_association_tasks wat + JOIN construction_workstations cw ON wat.company_projects_id = cw.company_projects_id + JOIN users u ON u.user_name = cw.name_workstations + WHERE u.email = :email + ) + ) + + SELECT + emr.equipment_id, + emr.equipment_tag + FROM + equipments_multiple_rows emr + WHERE + emr.equipment_id IN ( + SELECT equipment_id + FROM workstations_control_all_tasks + WHERE control_id_workstations IS NULL + AND entry_date IS NULL + AND departure_date IS NULL + AND control_workstation_all_tasks IN (SELECT all_tasks FROM workstations_multiple_rows) + AND EXISTS ( + SELECT 1 + FROM workstations_control_all_tasks wc + WHERE wc.equipment_id = emr.equipment_id + AND wc.control_id_workstations IS NOT NULL + GROUP BY wc.equipment_id + HAVING COUNT(DISTINCT wc.control_id_workstations) >= 2 + ) + ) + GROUP BY + emr.equipment_id, + emr.equipment_tag + ORDER BY + emr.equipment_id ASC; ", ['email' => $userEmail]); $workstationNameQuery = DB::select(" @@ -207,16 +342,16 @@ public function index() $workstationName = $workstationNameQuery[0]->nomenclature_workstation; //Counting of equipments - $equipmentsTodoCount = count($equipmentsTodo); + // $equipmentsTodoCount = count($equipmentsTodo); $equipmentsDoneCount = count($equipmentsDone); $equipmentsReturnedCount = count($equipmentsReturned); - + //Returning values of the queries to workstations layout return view('workstations.index', [ - 'equipmentsTodo' => $equipmentsTodo, 'equipmentsTodoCount' => $equipmentsTodoCount, + // 'equipmentsTodo' => $equipmentsTodo, 'equipmentsTodoCount' => $equipmentsTodoCount, 'equipmentsDone' => $equipmentsDone, 'equipmentsDoneCount' => $equipmentsDoneCount, 'equipmentsReturned' => $equipmentsReturned, 'equipmentsReturnedCount' => $equipmentsReturnedCount, - 'workstationName' =>$workstationName + 'workstationName' => $workstationName ]); } } diff --git a/app/Http/Controllers/WorkstationsJobsController1.php b/app/Http/Controllers/WorkstationsJobsController1.php new file mode 100644 index 00000000..0b1c2cda --- /dev/null +++ b/app/Http/Controllers/WorkstationsJobsController1.php @@ -0,0 +1,224 @@ +email; + + dd($userEmail); + + $equipmentsTodo = DB::table('ordered_equipment_tasks AS oet') + ->distinct() + ->select('oet.equipment_id', 'eq.equipment_tag') + ->join('equipments AS eq', 'oet.equipment_id', '=', 'eq.equipment_id') + ->join('workstations_association_tasks AS wat', 'oet.elemental_tasks_id', '=', 'wat.elemental_tasks_id') + ->whereIn('eq.company_projects_id', function ($query) use ($userEmail) { + $query->select('cw.company_projects_id') + ->from('construction_workstations AS cw') + ->join('users AS u', 'cw.name_workstations', '=', 'u.user_name') + ->where('u.email', $userEmail); + }) + ->whereIn('wat.id_workstations', function ($query) use ($userEmail) { + $query->select('cw.id_workstations') + ->from('construction_workstations AS cw') + ->join('users AS u', 'cw.name_workstations', '=', 'u.user_name') + ->where('u.email', $userEmail); + }) + ->where('oet.execution_order', '=', function ($query) { + $query->selectRaw('IFNULL(MIN(ot.execution_order), 1)') + ->from('ordered_equipment_tasks AS ot') + ->whereColumn('ot.equipment_id', 'oet.equipment_id') + ->whereNotIn('ot.elemental_tasks_id', function ($query) { + $query->select('cew.elemental_tasks_id') + ->from('control_equipment_workstation AS cew') + ->whereColumn('ot.equipment_id', 'cew.equipment_id'); + }); + }) + ->whereNotExists(function ($query) { + $query->select(DB::raw(1)) + ->from('control_equipment_workstation AS cew') + ->whereColumn('oet.equipment_id', 'cew.equipment_id'); + }) + ->get(); + + + $equipmentsDone = DB::select(" + WITH username AS ( + SELECT + user_name + FROM + users + WHERE + email = :email + ), + workstations AS ( + SELECT + id_workstations, + company_projects_id + FROM + construction_workstations + WHERE + name_workstations = (SELECT user_name FROM username) + ), + watet AS ( + SELECT + elemental_tasks_id + FROM + workstations_association_tasks + WHERE + id_workstations = (SELECT id_workstations FROM workstations) + ), + jobs AS ( + SELECT + ordered_equipment_tasks.equipment_id, + equipments.equipment_tag, + ordered_equipment_tasks.execution_order, + ordered_equipment_tasks.elemental_tasks_id, + workstations.id_workstations + FROM + ordered_equipment_tasks + INNER JOIN + equipments + ON + ordered_equipment_tasks.equipment_id = equipments.equipment_id + INNER JOIN + workstations + ON + equipments.company_projects_id = workstations.company_projects_id + WHERE + ordered_equipment_tasks.elemental_tasks_id IN (SELECT elemental_tasks_id FROM watet) + ), + valid_jobs AS ( + SELECT + jobs.equipment_id, + jobs.equipment_tag + FROM + jobs + WHERE + NOT EXISTS ( + SELECT + 1 + FROM + jobs AS j2 + WHERE + j2.equipment_id = jobs.equipment_id + AND NOT EXISTS ( + SELECT + 1 + FROM + control_equipment_workstation + WHERE + control_equipment_workstation.equipment_id = j2.equipment_id + AND control_equipment_workstation.elemental_tasks_id = j2.elemental_tasks_id + AND control_equipment_workstation.elemental_tasks_id IS NOT NULL + ) + ) + AND EXISTS ( + SELECT + 1 + FROM + control_equipment_workstation + WHERE + control_equipment_workstation.equipment_id = jobs.equipment_id + AND jobs.id_workstations = control_equipment_workstation.id_workstations + AND control_equipment_workstation.id_workstations IS NOT NULL + AND control_equipment_workstation.entry_date IS NOT NULL + AND control_equipment_workstation.departure_date IS NOT NULL + ) + ) + SELECT DISTINCT + valid_jobs.equipment_id, + valid_jobs.equipment_tag + FROM + valid_jobs; + ", ['email' => $userEmail]); + + + $equipmentsReturned = DB::select(" + SELECT DISTINCT + jobs.equipment_id, + jobs.equipment_tag + FROM ( + SELECT + oet.equipment_id, + e.equipment_tag, + oet.execution_order, + oet.elemental_tasks_id, + cw.id_workstations + FROM + ordered_equipment_tasks AS oet + JOIN + equipments AS e ON oet.equipment_id = e.equipment_id + JOIN + ( + SELECT + cw.id_workstations, + cw.company_projects_id, + wat.elemental_tasks_id + FROM + construction_workstations AS cw + JOIN + users AS u ON cw.name_workstations = u.user_name + JOIN + ( + SELECT + wat.id_workstations, + wat.elemental_tasks_id + FROM + workstations_association_tasks AS wat + ) AS wat ON wat.id_workstations = cw.id_workstations + WHERE + u.email = :email + ) AS cw ON e.company_projects_id = cw.company_projects_id + WHERE + oet.elemental_tasks_id = cw.elemental_tasks_id + ) AS jobs + INNER JOIN ( + SELECT cew.* + FROM control_equipment_workstation cew + INNER JOIN ( + SELECT equipment_id, elemental_tasks_id + FROM control_equipment_workstation + GROUP BY equipment_id, elemental_tasks_id + HAVING COUNT(*) > 1 + ) AS subquery + ON cew.equipment_id = subquery.equipment_id + AND cew.elemental_tasks_id = subquery.elemental_tasks_id + WHERE cew.id_workstations IS NULL + AND cew.entry_date IS NULL + ) AS repeated ON jobs.equipment_id = repeated.equipment_id + AND jobs.elemental_tasks_id = repeated.elemental_tasks_id + ", ['email' => $userEmail]); + + $workstationNameQuery = DB::select(" + SELECT construction_workstations.nomenclature_workstation + FROM construction_workstations + JOIN users + WHERE construction_workstations.name_workstations = users.user_name + AND users.email = :email; + ", ['email' => $userEmail]); + + $workstationName = $workstationNameQuery[0]->nomenclature_workstation; + + //Counting of equipments + $equipmentsTodoCount = count($equipmentsTodo); + $equipmentsDoneCount = count($equipmentsDone); + $equipmentsReturnedCount = count($equipmentsReturned); + + //Returning values of the queries to workstations layout + return view('workstations.index', [ + 'equipmentsTodo' => $equipmentsTodo, 'equipmentsTodoCount' => $equipmentsTodoCount, + 'equipmentsDone' => $equipmentsDone, 'equipmentsDoneCount' => $equipmentsDoneCount, + 'equipmentsReturned' => $equipmentsReturned, 'equipmentsReturnedCount' => $equipmentsReturnedCount, + 'workstationName' => $workstationName + ]); + } +} diff --git a/app/Livewire/Execução/EquipmentsDashboard.php b/app/Livewire/Execução/EquipmentsDashboard.php index fffcdb40..f186c797 100644 --- a/app/Livewire/Execução/EquipmentsDashboard.php +++ b/app/Livewire/Execução/EquipmentsDashboard.php @@ -17,7 +17,7 @@ class EquipmentsDashboard extends Component public $unstarted; public $inProgress; public $completed; - + public $completed1; public $totalEquivalentEquipment; public $equivalentUnstarted; public $equivalentInProgress; @@ -112,16 +112,28 @@ public function refreshDataEquipments($datasProject) // Verifica inicialmente se a quantido de vezes que tal equipamento apacere na ControlEquipmentWorkstation e o mesmo numero de vezes que aparece na tabela : OrderEquipmentTasks // Isto para ver se o ciclo foi correto sem retornos se os 2 valores forem iguais significa que o equipamento foi concluido. - if ( - $controlCount >= $tasksCount && ControlEquipmentWorkstation::where('equipment_id', $equipment->equipment_id) + // if ( + // $controlCount >= $tasksCount && ControlEquipmentWorkstation::where('equipment_id', $equipment->equipment_id) + // // apos receber ambos os numeros se as colunas 'entry_date' e 'departure_date' forem diferente de Null significa que o equipamento foi concluido + // ->whereNotNull('entry_date') + // ->whereNotNull('departure_date') + // ->count() >= $tasksCount + // ) { + + if (ControlEquipmentWorkstation::where('equipment_id', $equipment->equipment_id) + // apos receber ambos os numeros se as colunas 'entry_date' e 'departure_date' forem diferente de Null significa que o equipamento foi concluido + + ->whereNotNull('id_workstations') + ->whereNotNull('entry_date') + ->whereNotNull('departure_date') + ->count() >= $tasksCount + ) { - // apos receber ambos os numeros se as colunas 'entry_date' e 'departure_date' forem diferente de Null significa que o equipamento foi concluido - ->whereNotNull('entry_date') - ->whereNotNull('departure_date') - ->count() >= $tasksCount - ) { // se o equipamento foi considerado concluido, conta +1 para o completed e o equivalentCompleted busca no array equipmentCounts, quando a key for igual ao equipment_id atual e conta com + os valores da key encontrada $this->completed++; + + $this->completed1[] = $equipment->equipment_id; // Adiciona o equipment_id ao array + $this->equivalentCompleted += $equipmentCounts[$equipment->equipment_id]; } elseif (ControlEquipmentWorkstation::where('equipment_id', $equipment->equipment_id)->exists()) { $this->inProgress++; @@ -133,6 +145,9 @@ public function refreshDataEquipments($datasProject) } // Busca o valor total de todas as ocorrências criadas na variavel equipmentCounts $this->totalEquivalentEquipment = array_sum($equipmentCounts); + + $this->completed1 = collect($this->completed1); + dump($this->completed1); } diff --git a/resources/views/Admin/index.blade.php b/resources/views/Admin/index.blade.php index baa6655b..350fb493 100755 --- a/resources/views/Admin/index.blade.php +++ b/resources/views/Admin/index.blade.php @@ -8,7 +8,7 @@