test receive correctly

This commit is contained in:
ygbanzato 2023-08-01 15:20:39 +01:00
parent 3d64ba9bc6
commit a5b90015a3
4277 changed files with 428 additions and 154 deletions

0
.editorconfig Normal file → Executable file
View File

0
.env.example Normal file → Executable file
View File

0
.gitattributes vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
app/Actions/Fortify/CreateNewUser.php Normal file → Executable file
View File

0
app/Actions/Fortify/PasswordValidationRules.php Normal file → Executable file
View File

0
app/Actions/Fortify/ResetUserPassword.php Normal file → Executable file
View File

0
app/Actions/Fortify/UpdateUserPassword.php Normal file → Executable file
View File

0
app/Actions/Fortify/UpdateUserProfileInformation.php Normal file → Executable file
View File

0
app/Console/Kernel.php Normal file → Executable file
View File

0
app/Exceptions/Handler.php Normal file → Executable file
View File

View File

0
app/Http/Controllers/Auth/ResetPasswordController.php Normal file → Executable file
View File

0
app/Http/Controllers/Controller.php Normal file → Executable file
View File

110
app/Http/Controllers/CreateProjectController.php Normal file → Executable file
View File

@ -33,16 +33,20 @@
class CreateProjectController extends Controller
{
// public function receiveUnitsForExcelTemplate($numberProject)
// {
// $receveCompanyProject = CompanyProject::where('company_projects_id',$numberProject)->first();
// $recevePlant = Plant::where('plant_id', $receveCompanyProject->plant_id)->first();
// $receveUnits = Unit::where('plant_id',$recevePlant->plant_id)->get();
// // dd($receveUnits);
// $filePath = public_path('templateExcel/TestTemplate.xlsx');
// $fileName = 'Valves_Template.xlsx';
// return response()->download($filePath, $fileName);
// }
public function receiveEquipmentToAssociateTasks(Request $request)
{
// dd($request);
foreach ($request->equipment as $equipment) {
$equipmentModel = Equipment::where('equipment_id', $equipment['equipment_id'])->first();
if ($equipmentModel) {
$equipmentModel->company_projects_id = $request->receiveNumberProject;
$equipmentModel->save();
}
}
return redirect()->back()->with('success', 'Equipametos associados a Obra com Sucesso !');
}
public function receiveUnitsForExcelTemplate($numberProject)
{
@ -85,6 +89,36 @@ function () use ($writer) {
public function finishCreatingProject($numberProject)
{
$receiveWorkstaions = ConstructionWorkstation::where('company_projects_id', $numberProject)->get();
$receiveEquipments = Equipment::where('company_projects_id', $numberProject)->get();
$equipmentCounts = $receiveEquipments->countBy('equipment_type_id');
$countType1 = $equipmentCounts[1] ?? 0;
$countType2 = $equipmentCounts[2] ?? 0;
$countType3 = $equipmentCounts[3] ?? 0;
$valuesTypeCV = [];
$valuesTypeISV = [];
$valuesTypePSV = [];
$GeneralValues = [1,2,8,14,17];
if ($countType1 > 0) {
$valuesTypeCV = [18, 4, 6, 11, 19, 16];
}
if ($countType2 > 0) {
$valuesTypeISV = [7, 12, 20, 15, 21];
}
if ($countType3 > 0) {
$valuesTypePSV = [3, 9, 10, 13, 15];
}
$project = CompanyProject::find($numberProject);
$project->order_project = 2;
$project->save();
@ -531,15 +565,14 @@ public function showStep2($company_projects_id)
->with('typeEquipments', $typeEquipments)
->with('checkEquipments', $checkEquipments)
->with('checkUnits', $checkUnits)
->with('receiveNumberProject',$project);
->with('receiveNumberProject', $project);
}
return view('projectsClients/articulated_2', ['step' => 2, 'numberProject' => $numberProject])
->with('listEquipmentsProjects', $listEquipmentsProjects)
->with('typeEquipments', $typeEquipments)
->with('checkEquipments', $checkEquipments)
->with('checkUnits', $checkUnits)
->with('receiveNumberProject',$project);
->with('receiveNumberProject', $project);
}
public function createEquipmentManual(Request $request)
@ -771,13 +804,29 @@ public function processStep2(Request $request)
$ambit_id = $ambit->ambits_id;
}
//Criar associacao do equipamento ao Ambito
$AssociationEquipmentAmbit = new EquipmentAssociationAmbit;
$AssociationEquipmentAmbit->equipment_type_id = $receveEquipament_type_ID;
$AssociationEquipmentAmbit->ambits_id = $ambit_id;
$AssociationEquipmentAmbit->equipment_id = $receveEquipment_ID;
$AssociationEquipmentAmbit->save();
$execution_order = 1;
//Recebe a tabela com as associoacoes entre Ambitos e tarefas Elementares
$TasksAssociationAmbits = TasksAssociationAmbits::all()->where('ambits_equipment_id', $AssociationEquipmentAmbit->ambits_id);
foreach ($TasksAssociationAmbits as $TasksAssociationAmbit) {
$JoinsEquipmentsWithTasks = new OrderEquipmentTasks;
$JoinsEquipmentsWithTasks->equipment_id = $receveEquipment_ID;
$JoinsEquipmentsWithTasks->execution_order = $execution_order++;
$JoinsEquipmentsWithTasks->elemental_tasks_id = $TasksAssociationAmbit->elemental_tasks_id;
$JoinsEquipmentsWithTasks->further_tasks_id = null;
$JoinsEquipmentsWithTasks->inspection = 'Nao';
$JoinsEquipmentsWithTasks->save();
}
$generalAttributes = GeneralAttributesEquipment::all();
foreach ($generalAttributes as $generalAttribute) {
@ -847,38 +896,12 @@ public function workstationsAssociationTasks(Request $request)
}
// então, iteramos sobre as três listas de tarefas e as associamos à estação de trabalho
$taskTypes = ['generalTasks', 'PsvTasks', 'CvTasks'];
// dd($taskTypes);
// foreach ($taskTypes as $taskType) {
// if (isset($request->$taskType)) {
// foreach ($request->$taskType as $taskId) {
// dd($taskId);
// $taskAssociation = new WorkstationsAssociationTasks;
// $taskAssociation->id_workstations = $workStation->id_workstations;
// $taskAssociation->elemental_tasks_id = $taskId; // assumindo que $taskId é o id da tarefa
// $taskAssociation->company_projects_id = $workStation->company_projects_id;
// $taskAssociation->save();
// }
// }
// }
// foreach($taskTypes as $groupTasks){
// if (isset($request[$groupTasks])) { // Checar se esse grupo de tarefas existe no request
// foreach ($request[$groupTasks] as $taskID => $check) {
// if ($check == 'on') {
// $taskAssociation = new WorkstationsAssociationTasks;
// $taskAssociation->id_workstations = $workStation->id_workstations;
// $taskAssociation->elemental_tasks_id = $taskID; // Usando $taskID, que é a key
// $taskAssociation->company_projects_id = $workStation->company_projects_id;
// $taskAssociation->save();
// }
// }
// }
// }
$taskTypes = ['generalTasks', 'PsvTasks', 'CvTasks', 'IsvTasks'];
foreach ($taskTypes as $groupTasks) {
if (isset($request[$groupTasks])) { // Checar se esse grupo de tarefas existe no request
foreach ($request[$groupTasks] as $taskID => $check) {
// Encontra a tarefa existente, se houver
$taskAssociation = WorkstationsAssociationTasks::where('id_workstations', $workStation->id_workstations)
->where('elemental_tasks_id', $taskID)
@ -900,9 +923,6 @@ public function workstationsAssociationTasks(Request $request)
}
}
// Redirecionar de volta com uma mensagem de sucesso
return back()->with('success', 'Posto de trabalho : ' . $workStation->name_workstations . ' atualizado com sucesso!');
}

0
app/Http/Controllers/CustomRegistrationController.php Normal file → Executable file
View File

0
app/Http/Controllers/ExecutionProjectController.php Normal file → Executable file
View File

0
app/Http/Controllers/FormController.php Normal file → Executable file
View File

0
app/Http/Controllers/Pending_UserController.php Normal file → Executable file
View File

0
app/Http/Controllers/PreparedProjectController.php Normal file → Executable file
View File

29
app/Http/Controllers/ProjectoDatacontroller.php Normal file → Executable file
View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Models\AmbitsEquipment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -21,6 +21,26 @@
class ProjectoDatacontroller extends Controller
{
public function getEquipmentDetails($receiveListEquipmentId)
{
$ids = explode(',', $receiveListEquipmentId);
$equipments = Equipment::whereIn('equipment_id', $ids)->get();
// Pegar os unique "equipment_type_id"s
$equipmentTypeIds = $equipments->pluck('equipment_type_id')->unique();
// Obter todos os "AmbitsEquipment" para esses "equipment_type_id"s
$ambitsEquipments = AmbitsEquipment::whereIn('equipment_type_id', $equipmentTypeIds)->get();
// Mapear os "AmbitsEquipment" de volta aos equipamentos correspondentes
foreach ($equipments as $equipment) {
$equipment->ambits = $ambitsEquipments->where('equipment_type_id', $equipment->equipment_type_id);
}
return response()->json($equipments);
}
public function receiveAllInstallationEquipment($receiveNumberProject)
{
@ -28,8 +48,10 @@ public function receiveAllInstallationEquipment($receiveNumberProject)
$receveEquipments = Equipment::whereHas('unit.plant', function ($query) use ($receveProject) {
$query->where('plants.plant_id', '=', $receveProject->plant_id);
})
->with(['equipmentType', 'unit', 'equipmentAssociationAmbit.ambitsEquipment'])
->get();
->where('company_projects_id', null) // Adiciona a condição aqui
->with(['equipmentType', 'unit', 'equipmentAssociationAmbit.ambitsEquipment'])
->get();
return DataTables::of($receveEquipments)
->addColumn('equipment_type', function ($row) {
@ -93,7 +115,6 @@ public function receiveEquipmentsProject($receiveNumberProject)
$model = Equipment::query()
->where('company_projects_id', $receiveNumberProject)
->with(['equipmentType', 'unit', 'equipmentAssociationAmbit.ambitsEquipment']);
}
// Caso 'equipment_type_id' não seja '#', filtra os equipamentos por tipo e ambito (caso 'ambits_id' não seja '#')
else {

0
app/Http/Controllers/userController.php Normal file → Executable file
View File

0
app/Http/Kernel.php Normal file → Executable file
View File

0
app/Http/Middleware/Authenticate.php Normal file → Executable file
View File

0
app/Http/Middleware/CheckSuperAdmin.php Normal file → Executable file
View File

0
app/Http/Middleware/CheckUserType.php Normal file → Executable file
View File

0
app/Http/Middleware/EncryptCookies.php Normal file → Executable file
View File

View File

0
app/Http/Middleware/RedirectIfAuthenticated.php Normal file → Executable file
View File

0
app/Http/Middleware/TrimStrings.php Normal file → Executable file
View File

0
app/Http/Middleware/TrustHosts.php Normal file → Executable file
View File

0
app/Http/Middleware/TrustProxies.php Normal file → Executable file
View File

0
app/Http/Middleware/ValidateSignature.php Normal file → Executable file
View File

0
app/Http/Middleware/VerifyCsrfToken.php Normal file → Executable file
View File

0
app/Mail/NewUserNotification.php Normal file → Executable file
View File

0
app/Models/AmbitsEquipment.php Normal file → Executable file
View File

0
app/Models/CompanyProject.php Normal file → Executable file
View File

0
app/Models/ConstructionWorkstation.php Normal file → Executable file
View File

0
app/Models/ControlEquipmentWorkstation.php Normal file → Executable file
View File

0
app/Models/ElementalTasks.php Normal file → Executable file
View File

0
app/Models/Equipment.php Normal file → Executable file
View File

0
app/Models/EquipmentAssociationAmbit.php Normal file → Executable file
View File

0
app/Models/EquipmentComments.php Normal file → Executable file
View File

0
app/Models/EquipmentType.php Normal file → Executable file
View File

0
app/Models/FurtherTasks.php Normal file → Executable file
View File

0
app/Models/GeneralAttributesEquipment.php Normal file → Executable file
View File

0
app/Models/OrderEquipmentTasks.php Normal file → Executable file
View File

0
app/Models/PendingEquipment.php Normal file → Executable file
View File

0
app/Models/PendingUser.php Normal file → Executable file
View File

0
app/Models/Plant.php Normal file → Executable file
View File

0
app/Models/SpecificAttributesEquipmentType.php Normal file → Executable file
View File

0
app/Models/TasksAssociationAmbits.php Normal file → Executable file
View File

0
app/Models/TypeUser.php Normal file → Executable file
View File

0
app/Models/Unit.php Normal file → Executable file
View File

0
app/Models/User.php Normal file → Executable file
View File

0
app/Models/WorkstationsAssociationTasks.php Normal file → Executable file
View File

0
app/Providers/AppServiceProvider.php Normal file → Executable file
View File

0
app/Providers/AuthServiceProvider.php Normal file → Executable file
View File

0
app/Providers/BroadcastServiceProvider.php Normal file → Executable file
View File

0
app/Providers/EventServiceProvider.php Normal file → Executable file
View File

0
app/Providers/FortifyServiceProvider.php Normal file → Executable file
View File

0
app/Providers/RouteServiceProvider.php Normal file → Executable file
View File

0
bootstrap/app.php Normal file → Executable file
View File

0
bootstrap/cache/.gitignore vendored Normal file → Executable file
View File

0
composer.json Normal file → Executable file
View File

0
composer.lock generated Normal file → Executable file
View File

0
config/app.php Normal file → Executable file
View File

0
config/auth.php Normal file → Executable file
View File

0
config/broadcasting.php Normal file → Executable file
View File

0
config/cache.php Normal file → Executable file
View File

0
config/cors.php Normal file → Executable file
View File

0
config/database.php Normal file → Executable file
View File

0
config/filesystems.php Normal file → Executable file
View File

0
config/fortify.php Normal file → Executable file
View File

0
config/hashing.php Normal file → Executable file
View File

0
config/logging.php Normal file → Executable file
View File

0
config/mail.php Normal file → Executable file
View File

0
config/queue.php Normal file → Executable file
View File

0
config/sanctum.php Normal file → Executable file
View File

0
config/services.php Normal file → Executable file
View File

0
config/session.php Normal file → Executable file
View File

0
config/view.php Normal file → Executable file
View File

0
database/.gitignore vendored Normal file → Executable file
View File

0
database/factories/UserFactory.php Normal file → Executable file
View File

View File

View File

0
database/seeders/DatabaseSeeder.php Normal file → Executable file
View File

0
package.json Normal file → Executable file
View File

0
phpunit.xml Normal file → Executable file
View File

0
public/.htaccess Normal file → Executable file
View File

0
public/StyleAdmin/css/adminlte.css Normal file → Executable file
View File

0
public/StyleAdmin/css/adminlte.css.map Normal file → Executable file
View File

0
public/StyleAdmin/css/adminlte.min.css vendored Normal file → Executable file
View File

0
public/StyleAdmin/css/adminlte.min.css.map Normal file → Executable file
View File

0
public/StyleAdmin/css/stepprogressbar.css Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More