protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); // récupere tous les spots $listSpot = $em->getRepository('LaPoizWindBundle:Spot')->findAll(); foreach ($listSpot as $spot) { $output->writeln('<info>Note du Spot ' . $spot->getNom() . ' - </info>'); // On efface les vielles notes (avant aujourd'hui) ManageNote::deleteOldData($spot, $em); $tabNotes = array(); $tabListePrevisionDate = array(); // tableau des liste des PrevisionDate, chaque cellule correspondant à une dateprev // Pour les 7 prochains jours $day = new \DateTime("now"); for ($nbPrevision = 0; $nbPrevision < 7; $nbPrevision++) { $tabNotes[$day->format('Y-m-d')] = -1; $tabListePrevisionDate[$day->format('Y-m-d')] = array(); $day->modify('+1 day'); } $output->writeln('<info> Note la maree </info>'); //********** Marée ********** // récupére la marée du jour // Note la marée en fonction des restrictions $listeMareeFuture = $em->getRepository('LaPoizWindBundle:MareeDate')->getFuturMaree($spot); foreach ($listeMareeFuture as $mareeDate) { $noteDate = ManageNote::getNotesDate($spot, $mareeDate->getDatePrev(), $em); $tabNotes = NoteMaree::calculNoteMaree($spot, $tabNotes, $mareeDate); $keyDate = $mareeDate->getDatePrev()->format('Y-m-d'); $noteMaree = $tabNotes[$keyDate]["marée"]; $noteDate->setNoteMaree($noteMaree); $output->writeln('<info>' . $keyDate . ': ' . $noteMaree . '</info> '); $em->persist($noteDate); } $output->writeln('<info> Note la Météo</info>'); //********** Meteo ********** //list des PrevisionDate pour les prochain jour, pour le spot pour tous les websites $listALlPrevisionDate = $em->getRepository('LaPoizWindBundle:PrevisionDate')->getPrevDateAllWebSiteNextDays($spot); foreach ($listALlPrevisionDate as $previsionDate) { // ajouter au tableau de la cellule du jour de $tabListePrevisionDate $tabListePrevisionDate[$previsionDate->getDatePrev()->format('Y-m-d')][] = $previsionDate; } // Save Note on spot foreach ($tabNotes as $keyDate => $note) { if ($tabListePrevisionDate[$keyDate] != null && count($tabListePrevisionDate[$keyDate]) > 0) { $noteDate = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $output->write('<info>' . $keyDate . ': '); $noteDate->setNoteWind(NoteWind::calculNoteWind($tabListePrevisionDate[$keyDate])); $output->write(' wind:' . $noteDate->getNoteWind() . ' - '); $noteDate->setNoteMeteo(NoteMeteo::calculNoteMeteo($tabListePrevisionDate[$keyDate])); $output->write(' meteo:' . $noteDate->getNoteMeteo() . ' - '); $noteDate->setNoteTemp(NoteTemp::calculNoteTemp($tabListePrevisionDate[$keyDate])); $output->write(' temp:' . $noteDate->getNoteTemp()); $output->writeln('</info>'); $em->persist($noteDate); } } //********** Température de l'eau ********** // rien n'existe actuellement // récupére la temperature de l'eau dans la journée (elle ne varie quasi pas // calcul de la note en fonction de la T°C $output->writeln('<info>******************************</info>'); } $em->flush(); }
/** * @Template() * * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/spot/save/nbHoureNav/1 */ public function saveNbHoureNavAction($id = null) { $em = $this->container->get('doctrine.orm.entity_manager'); $spot = $em->find('LaPoizWindBundle:Spot', $id); if (!$spot) { return $this->render('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "Spot not find !")); } list($tabDataNbHoureNav, $tabDataMeteo) = NbHoureNav::createTabNbHoureNav($spot, $em); $tabNbHoureNav = NbHoureNav::calculateNbHourNav($tabDataNbHoureNav); $tabMeteo = NbHoureMeteo::calculateMeteoNav($tabDataMeteo); // Save nbHoure on spot foreach ($tabNbHoureNav as $keyDate => $tabWebSite) { foreach ($tabWebSite as $keyWebSite => $nbHoureNav) { $noteDates = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $nbHoureNavObj = ManageNote::getNbHoureNav($noteDates, $keyWebSite, $em); $nbHoureNavObj->setNbHoure($nbHoureNav); $em->persist($nbHoureNavObj); $em->persist($noteDates); } } // Save meteo foreach ($tabMeteo as $keyDate => $tabMeteoDay) { $noteDates = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $noteDates->setTempMax($tabMeteoDay["tempMax"]); $noteDates->setTempMin($tabMeteoDay["tempMin"]); $noteDates->setMeteoBest($tabMeteoDay["meteoBest"]); $noteDates->setMeteoWorst($tabMeteoDay["meteoWorst"]); $em->persist($noteDates); } $em->flush(); return $this->render('LaPoizWindBundle:BackOffice/Test:nbHoureNav.html.twig', array('spot' => $spot, 'tabNbHoure' => $tabNbHoureNav, 'tabMeteo' => $tabMeteo, 'message' => "", 'saveSuccess' => true)); }
/** * @Template() * Note les marées * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/spot/maree/note/save/1 */ public function mareeSaveNoteAction($id) { $em = $this->container->get('doctrine.orm.entity_manager'); $spot = $em->find('LaPoizWindBundle:Spot', $id); if (!$spot) { return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "Spot not find !")); } // On efface les vielles notes (avant aujourd'hui) ManageNote::deleteOldData($spot, $em); $tabNotes = array(); // Pour les 7 prochains jours $day = new \DateTime("now"); for ($nbPrevision = 0; $nbPrevision < 7; $nbPrevision++) { $tabNotes[$day->format('Y-m-d')] = array(); $day->modify('+1 day'); } //********** Marée ********** // récupére la marée du jour // Note la marée en fonction des restrictions $listeMareeFuture = $em->getRepository('LaPoizWindBundle:MareeDate')->getFuturMaree($spot); foreach ($listeMareeFuture as $mareeDate) { $noteDate = ManageNote::getNotesDate($spot, $mareeDate->getDatePrev(), $em); $tabNotes = NoteMaree::calculNoteMaree($spot, $tabNotes, $mareeDate); $noteDate->setNoteMaree($tabNotes[$mareeDate->getDatePrev()->format('Y-m-d')]["marée"]); $em->persist($noteDate); } $em->flush(); return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Spot/Ajax:displayNote.html.twig', array('spot' => $spot, 'message' => "", 'saveSuccess' => true)); }
/** * @Template() * Note la meteo: pluie + soleil * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/spot/meteo/note/save/1 */ public function spotSaveMeteoNoteAction($id) { $em = $this->container->get('doctrine.orm.entity_manager'); $spot = $em->find('LaPoizWindBundle:Spot', $id); if (!$spot) { return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "Spot not find !")); } $tabNotes = array(); $tabListePrevisionDate = array(); // tableau des liste des PrevisionDate, cahque cellule correspondant à une dateprev // Pour les 7 prochains jours $day = new \DateTime("now"); for ($nbPrevision = 0; $nbPrevision < 7; $nbPrevision++) { $tabNotes[$day->format('Y-m-d')] = -1; $tabListePrevisionDate[$day->format('Y-m-d')] = array(); $day->modify('+1 day'); } //********** Meteo ********** // On efface les vielle données ManageNote::deleteOldData($spot, $em); //list des PrevisionDate pour les prochain jour, pour le spot pour tous les websites $listALlPrevisionDate = $this->getDoctrine()->getRepository('LaPoizWindBundle:PrevisionDate')->getPrevDateAllWebSiteNextDays($spot); foreach ($listALlPrevisionDate as $previsionDate) { // ajouter au tableau de la cellule du jour de $tabListePrevisionDate $tabListePrevisionDate[$previsionDate->getDatePrev()->format('Y-m-d')][] = $previsionDate; } foreach ($tabNotes as $keyDate => $note) { if ($tabListePrevisionDate[$keyDate] != null && count($tabListePrevisionDate[$keyDate]) > 0) { $noteDate = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $noteDate->setNoteMeteo(NoteMeteo::calculNoteMeteo($tabListePrevisionDate[$keyDate])); $noteDate->setNoteWind(NoteWind::calculNoteWind($tabListePrevisionDate[$keyDate])); $noteDate->setNoteTemp(NoteTemp::calculNoteTemp($tabListePrevisionDate[$keyDate])); $em->persist($noteDate); } } $em->flush(); return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Spot/Ajax:displayNote.html.twig', array('spot' => $spot, 'message' => "", 'saveSuccess' => true)); }
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); // récupere tous les spots $listSpot = $em->getRepository('LaPoizWindBundle:Spot')->findAll(); foreach ($listSpot as $spot) { $output->writeln('<info>Note du Spot ' . $spot->getNom() . ' - </info>'); // On efface les vielles notes (avant aujourd'hui) ManageNote::deleteOldData($spot, $em); list($tabDataNbHoureNav, $tabDataMeteo) = NbHoureNav::createTabNbHoureNav($spot, $em); $tabNbHoureNav = NbHoureNav::calculateNbHourNav($tabDataNbHoureNav); $output->writeln('<info> *** Nb Heure nav ***</info>'); // Save nbHoure on spot foreach ($tabNbHoureNav as $keyDate => $tabWebSite) { $output->writeln('<info>' . $keyDate . ': '); $nbHoureNavCalc = 0; $nbSiteCalc = 0; foreach ($tabWebSite as $keyWebSite => $nbHoureNav) { $output->writeln('<info> ' . $keyWebSite . ' : ' . $nbHoureNav . '</info> '); $noteDates = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $nbHoureNavObj = ManageNote::getNbHoureNav($noteDates, $keyWebSite, $em); $nbHoureNavObj->setNbHoure($nbHoureNav); $em->persist($nbHoureNavObj); $em->persist($noteDates); if ($nbHoureNav > 0) { $nbSiteCalc++; $nbHoureNavCalc += $nbHoureNav; } } if ($nbSiteCalc > 0) { $output->writeln('<info> ' . $keyDate . ' : ' . $nbHoureNavCalc . ' / ' . $nbSiteCalc . ' = ' . $nbHoureNavCalc / $nbSiteCalc . '</info> '); $noteDates->setNbHoureNavCalc($nbHoureNavCalc / $nbSiteCalc); $em->persist($noteDates); } } $output->writeln('<info> *** Meteo ***</info>'); // Save meteo $tabMeteo = NbHoureMeteo::calculateMeteoNav($tabDataMeteo); foreach ($tabMeteo as $keyDate => $tabMeteoDay) { $output->writeln('<info> Calcule Meteo of ' . $keyDate . '</info> '); $noteDates = ManageNote::getNotesDate($spot, \DateTime::createFromFormat('Y-m-d', $keyDate), $em); $noteDates->setTempMax($tabMeteoDay["tempMax"]); $noteDates->setTempMin($tabMeteoDay["tempMin"]); $noteDates->setMeteoBest($tabMeteoDay["meteoBest"]); $noteDates->setMeteoWorst($tabMeteoDay["meteoWorst"]); $em->persist($noteDates); } $output->writeln('<info> *** T C de l eau ***</info>'); //********** Température de l'eau ********** try { $tabTempWater = null; $tabTempWater = TempWaterGetData::getTempWaterFromSpot($spot, $output); } catch (\Exception $e) { $output->writeln('<warn>' . $e->getMessage() . '</warn>'); $output->writeln('<warn> * End Warn * </warn>'); } if ($tabTempWater != null) { $currentDay = new \DateTime("now"); foreach ($tabTempWater as $numJourFromToday => $tempWater) { $noteDates = ManageNote::getNotesDate($spot, clone $currentDay, $em); $noteDates->setTempWater($tempWater); $em->persist($noteDates); $currentDay = date_add($currentDay, new \DateInterval('P1D')); // Jour suivant } } $output->writeln('<info>******************************</info>'); } $em->flush(); }