/**
  * @Template()
  *
  */
 public function createAllPrevisionSpotAction($id = null)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $spot = $em->find('LaPoizWindBundle:Spot', $id);
     $allPrevWebSite = $em->getRepository('LaPoizWindBundle:WebSite')->findWithName(WebsiteGetData::allPrevName);
     AllPrevGetData::calculateWindAllPrev($allPrevWebSite, $spot, $em);
     $listSpot = $em->getRepository('LaPoizWindBundle:Spot')->findAllValid();
     $listRegion = $em->getRepository('LaPoizWindBundle:Region')->findAllOrderByNumDisplay();
     $listSpotNotValid = $em->getRepository('LaPoizWindBundle:Spot')->findAllNotValid();
     $listSpotsWithoutRegion = $em->getRepository('LaPoizWindBundle:Spot')->findAllWithoutRegion();
     $listWebsites = $em->getRepository('LaPoizWindBundle:WebSite')->findAll();
     return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Tools:calculAllPrevSpot.html.twig', array('spot' => $spot, 'listSpot' => $listSpot, 'listRegion' => $listRegion, 'listSpotNotValid' => $listSpotNotValid, 'listSpotsWithoutRegion' => $listSpotsWithoutRegion, 'listWebsites' => $listWebsites));
 }
 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();
     $allPrevWebSite = $em->getRepository('LaPoizWindBundle:WebSite')->findWithName(WebsiteGetData::allPrevName);
     foreach ($listSpot as $spot) {
         $output->writeln('<info>*** Spot ' . $spot->getNom() . ' ***</info>');
         // Find dataWindPrev with allPrevWebsite and spot
         $dataWindPrevAllPrev = $em->getRepository('LaPoizWindBundle:DataWindPrev')->getWithWebsiteAndSpot($allPrevWebSite, $spot);
         // Delete all old data
         AllPrevGetData::deleteOldData($dataWindPrevAllPrev, $em);
         // Construit un tableau avec toutes les heures pour les 7 prochains jours
         // Pour chaque site de prevision remplis le tableau avec ses prévisions (vent, vents max, orientation)
         // Pour chaque site remplis les cases vide en fonction des éléments remplis
         // Calcul la moyenne pour chaque heure (avec coef pour le spot)
     }
     $em->flush();
 }
Beispiel #3
0
 static function getPrevisionValue(&$arrayEveryDay, PrevisionDate $previsionDate, $webSiteName)
 {
     if (!array_key_exists($previsionDate->getDatePrev()->format('Y-m-d'), $arrayEveryDay)) {
         $arrayEveryDay[$previsionDate->getDatePrev()->format('Y-m-d')] = AllPrevGetData::createArrayEveryHoure();
         // tableau de toutes les heures
     }
     $listPrevision = $previsionDate->getListPrevision();
     $prevHour = 0;
     $prevOrient = 0;
     $prevWind = 0;
     foreach ($listPrevision as $prevision) {
         $wind = $prevision->getWind();
         $orientation = WebsiteGetData::transformeOrientationDeg($prevision->getOrientation());
         $hour = intval($prevision->getTime()->format('H'));
         $arrayEveryDay[$previsionDate->getDatePrev()->format('Y-m-d')][$hour]['wind'][$webSiteName] = $wind;
         $arrayEveryDay[$previsionDate->getDatePrev()->format('Y-m-d')][$hour]['orient'][$webSiteName] = $orientation;
         AllPrevGetData::completeArrayPrevision($arrayEveryDay[$previsionDate->getDatePrev()->format('Y-m-d')], $webSiteName, $wind, $orientation, $hour, $prevWind, $prevOrient, $prevHour);
         $prevHour = $hour;
         $prevOrient = $orientation;
         $prevWind = $wind;
     }
 }