示例#1
0
 /**
  * @Route("/parser45", name="all_export")
  */
 public function parser45Action()
 {
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Гема');
     //        $company->setTitle('Гема');
     //        $em->persist($company);
     //        $em->flush($company);
     //        $em->refresh($company);
     $filePath = '/var/www/navigator/current/web/Gema.xls';
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($filePath);
     $num = 9;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         //            $banner = $this->getDoctrine()->getRepository('AppBundle:Banner')->findOneById($phpExcelObject->setActiveSheetIndex(0)->getCell('J'.$num)->getValue());
         //            if (!$banner){
         //                $isNew = true;
         $banner = new Banner();
         //            }else{
         //                $isNew = false;
         //            }
         $banner->setCompany($company);
         $banner->setArea($this->getArea($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue()));
         $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getValue()));
         $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('H' . $num)->getValue() == 'Да' ? 1 : 0);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue());
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat($this->getFormat($phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue()));
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('O' . $num)->getValue());
         $banner->setImg($phpExcelObject->setActiveSheetIndex(0)->getCell('Q' . $num)->getValue());
         $pos = $this->getPosition($phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue());
         $banner->setLongitude($pos[0]);
         $banner->setLatitude($pos[1]);
         $banner->setBody(' ');
         //            if ($isNew == true){
         $em->persist($banner);
         //            }
         $em->flush($banner);
         $num++;
     }
     return new Response('открылось');
 }
示例#2
0
文件: VeraParser.php 项目: Quiss/Oon
 /**
  * @Route("/parserVera/6")
  */
 public function parserVera6Action($hot = false)
 {
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Вера Олимп');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Вера Олимп');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     $city = $em->getRepository('AppBundle:City')->findOneById(2);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(5)->getCell('A' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(5)->getCell('B' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(5)->getCell('R' . $num)->getValue());
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(5)->getCell('E' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(5)->getCell('F' . $num)->getValue());
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(5)->getCell('M' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('G' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('G' . $num)->getValue() * 1.18));
         $banner->setTaxType('НДС (18%)');
         $banner->setPriceDeploy(str_replace(array(',', ' '), array('.', ''), $phpExcelObject->setActiveSheetIndex(5)->getCell('Q' . $num)->getValue()));
         $banner->setFormat('3x6');
         $banner->setType($phpExcelObject->setActiveSheetIndex(5)->getCell('O' . $num)->getValue());
         $banner->setArea(null);
         $banner->setLight($phpExcelObject->setActiveSheetIndex(5)->getCell('N' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(5)->getCell('N' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg(null);
         $banner->setLink($phpExcelObject->setActiveSheetIndex(5)->getCell('J' . $num)->getHyperlink()->getUrl());
         //            $pos = $this->getPosition($phpExcelObject->setActiveSheetIndex(5)->getCell('R'.$num)->getValue());
         //            $banner->setLongitude($pos[1]);
         //            $banner->setLatitude($pos[0]);
         //            if ($hot){
         //                $banner->setHot(true);
         //            }else{
         $banner->setHot(true);
         //            }
         $banner2 = $em->getRepository('AppBundle:Banner2')->findOneByTitle($banner->getTitle());
         if ($banner2) {
             $banner->setLatitude($banner2->getLatitude());
             $banner->setLongitude($banner2->getLongitude());
         } else {
             $banner->setLatitude(0);
             $banner->setLongitude(0);
         }
         $em->persist($banner);
         $em->flush($banner);
         $num++;
     }
     return true;
 }
示例#3
0
 public function parserGellary3Action($hot = false)
 {
     //        $this->filePath = $this->filePath.'G2.XLSX';
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Gallery  roller');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Gallery roller');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 2;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue()));
         $city = $this->em->getRepository('AppBundle:City')->findOneByTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue());
         if ($city == null) {
             $city = new City();
             $city->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue());
             $em->persist($city);
             $em->flush($city);
             $em->refresh($city);
         }
         $banner->setCity($city);
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue());
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setPriceDeploy(0);
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue());
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('W' . $num)->getValue());
         $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg($this->getImage($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl()));
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl());
         if ($hot) {
             $banner->setHot(true);
         } else {
             $banner->setHot(false);
         }
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $banner = $this->setBanner($banner);
         $month = array('2015-06-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('O' . $num)->getFill()->getStartColor()->getRGB()), '2015-07-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('P' . $num)->getFill()->getStartColor()->getRGB()), '2015-08-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('Q' . $num)->getFill()->getStartColor()->getRGB()), '2015-09-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('R' . $num)->getFill()->getStartColor()->getRGB()), '2015-10-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('S' . $num)->getFill()->getStartColor()->getRGB()), '2015-11-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('T' . $num)->getFill()->getStartColor()->getRGB()), '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('U' . $num)->getFill()->getStartColor()->getRGB()));
         $this->refreshStatus($banner, $month, array('date' => '2015-06-01', 'sale' => $hot));
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return true;
 }
示例#4
0
 /**
  * Checks if given banner is allowed to modify for the current user
  *
  * @param User $user
  * @param Banner $banner
  * @return boolean
  */
 public function isAllowedToModify(User $user, Banner $banner)
 {
     return $user === $banner->getUser();
 }
示例#5
0
 /**
  * @Route("/parserRus/{type}", name="parserRus")
  */
 public function parserRusAction($type)
 {
     set_time_limit(0);
     ini_set("memory_limit", "-1");
     //        if ($type == 1){
     //            $filename = '3x6/'.$filename.'.json';
     //        }elseif($type == 2){
     //            $filename = 'big/'.$filename;
     //        }
     if ($type == 1) {
         $folder = '3x6';
     } elseif ($type == 2) {
         $folder = 'big';
     }
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Russoutdoor');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Russoutdoor');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $files = scandir($this->get('kernel')->getRootDir() . '/../web/' . $folder);
     unset($files[1]);
     unset($files[0]);
     foreach ($files as $f) {
         $filename = $this->get('kernel')->getRootDir() . '/../web/' . $folder . '/' . $f;
         $file = file_get_contents($filename);
         $array = json_decode($file, true);
         $i = 0;
         foreach ($array['billboards'] as $val) {
             if (isset($val['longtitude']) && isset($val['latitude']) && isset($val['address'])) {
                 $i++;
                 $banner = new Banner();
                 $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneByTitle($val['cityName']);
                 if ($city == null) {
                     $city = new City();
                     $city->setTitle($val['cityName']);
                     $em->persist($city);
                     $em->flush($city);
                     $em->refresh($city);
                 }
                 $banner->setCity($city);
                 $banner->setCompany($company);
                 $banner->setAdrs($val['address']);
                 $banner->setTitle($val['address']);
                 $banner->setGid($val['gid']);
                 $banner->setGrp($val['grp']);
                 $banner->setOts($val['ots']);
                 $banner->setPrice((isset($val['price']) ? $val['price'] : 0) * 0.82);
                 $banner->setPrice2(isset($val['price']) ? $val['price'] : 0);
                 $banner->setLight($val['light']);
                 $banner->setSide($val['side']);
                 $desc = (isset($val['top']) ? $val['top'] : '') . '<br />' . (isset($val['distance']) ? $val['distance'] : '');
                 $banner->setBody($desc);
                 if ($type == 1) {
                     $banner->setFormat('3x6');
                 } elseif ($type == 2) {
                     $banner->setFormat('big');
                 }
                 $banner->setLongitude($val['longtitude']);
                 $banner->setLatitude($val['latitude']);
                 $banner->setImg(str_replace('//', 'http://', $val['imageURL']));
                 $em->persist($banner);
                 $em->flush();
             } else {
                 echo $val['address'] . '<br />';
                 echo '<br />';
                 print_r($val);
                 echo '<br />';
                 echo '<br />';
             }
         }
     }
     exit;
 }
示例#6
0
 /**
  * @Route("/parserVera/6")
  */
 public function parserVera6Action()
 {
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Вера Олимп');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Вера Олимп');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(4)->getCell('A' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(4)->getCell('B' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(4)->getCell('C' . $num)->getValue());
         $banner->setCity('Московская область');
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(4)->getCell('E' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(4)->getCell('F' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(4)->getCell('G' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(4)->getCell('G' . $num)->getValue()) * 1.18);
         $banner->setTaxType('НДС (18%)');
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(4)->getCell('M' . $num)->getValue()));
         $banner->setFormat('3x6');
         $banner->setType($phpExcelObject->setActiveSheetIndex(4)->getCell('N' . $num)->getValue());
         $banner->setArea(null);
         $banner->setLight($phpExcelObject->setActiveSheetIndex(4)->getCell('Q' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(4)->getCell('Q' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg(null);
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getHyperlink()->getUrl());
         $pos = $this->getPosition($phpExcelObject->setActiveSheetIndex(4)->getCell('R' . $num)->getValue());
         $banner->setLongitude($pos[1]);
         $banner->setLatitude($pos[0]);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
     }
     return new Response('открылось');
 }
示例#7
0
 /**
  * @Route("/parserGellary/2")
  */
 public function parserGellary2Action()
 {
     $this->filePath = $this->filePath . 'G2.XLSX';
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Gallery');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Gallery');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 11;
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue()));
         $banner->setCity($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue() == 'Москва' ? 'Москва' : 'Московская область');
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('F' . $num)->getValue());
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setPriceDeploy(0);
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue());
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('X' . $num)->getValue());
         $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'да' ? 1 : 0);
         $banner->setImg($this->getImage($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl()));
         $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl());
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return new Response('открылось');
 }
示例#8
0
 /**
  * @Route("/parserRasvero/1")
  */
 public function parserRasvero1Action($hot = false)
 {
     $em = $this->em;
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Расверо');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Расверо');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 7;
     $city = $em->getRepository('AppBundle:City')->findOneById(1);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($phpExcelObject->setActiveSheetIndex(0)->getCell('H' . $num)->getValue());
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue() * 0.82));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue()));
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue() . ' ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue() . ' ' . ' ( ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getValue() . ' ) ');
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('F' . $num)->getValue());
         $banner->setLight(0);
         $banner->setImg($this->getPhoto($phpExcelObject->setActiveSheetIndex(0)->getCell('O' . $num)->getValue()));
         $banner->setLink(0);
         $url = $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue();
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($url);
         $content = file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         //            $banner = $this->setBanner($banner);
         //            $month = array(
         //                '2015-08-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('S'.$num)->getValue()),
         //                '2015-09-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('T'.$num)->getValue()),
         //                '2015-10-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('U'.$num)->getValue()),
         //                '2015-11-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('V'.$num)->getValue()),
         //                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('W'.$num)->getValue()),
         ////                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('X'.$num)->getValue()),
         ////                '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getCell('Y'.$num)->getValue()),
         //            );
         //            $this->refreshStatus($banner,$month, array('date' => '2015-06-01' , 'sale' => $hot));
         //            if ($hot){
         //                $banner->setHot(true);
         //            }else{
         $banner->setHot(false);
         //            }
         //            if (strripos($phpExcelObject->setActiveSheetIndex(0)->getCell('S' . $num)->getValue(),'Свободно') !== false){
         //                $banner->setHot(true);
         //            }
         $this->em->persist($banner);
         $this->em->flush($banner);
         $num++;
         if ($num % 50 == 0) {
             sleep(rand(1, 5));
         }
     }
     return true;
 }
示例#9
0
 /**
  * Finds an appropriate contentunit for the given banner
  *
  * @param Banner $banner
  * @return AppBundle\Entity\Contentunit
  */
 protected function findContentunit(Banner $banner)
 {
     $em = $this->getDoctrine()->getManager();
     return $em->getRepository('AppBundle:Contentunit')->findByImage($banner->getImageFile());
 }
示例#10
0
 /**
  * @Route("/parserRasvero/1")
  */
 public function parserVera1Action()
 {
     $em = $this->getDoctrine()->getManager();
     $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Расверо');
     if ($company == null) {
         $company = new Company();
         $company->setTitle('Расверо');
         $em->persist($company);
         $em->flush($company);
         $em->refresh($company);
     }
     $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($this->filePath);
     $num = 7;
     $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneById(1);
     while (true) {
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') {
             break;
         }
         $banner = new Banner();
         $banner->setCompany($company);
         $banner->setAdrs(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setTitle(explode("\n", $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue())[0]);
         $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue());
         $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue()));
         $banner->setCity($city);
         $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue()));
         $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue()));
         $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue());
         $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('R' . $num)->getValue()));
         $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('T' . $num)->getValue()));
         $banner->setTaxType('НДС (18%)');
         $banner->setFormat('small');
         $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue() . ' ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('K' . $num)->getValue() . ' ' . ' ( ' . $phpExcelObject->setActiveSheetIndex(0)->getCell('H' . $num)->getValue() . ' ) ');
         $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getValue());
         $banner->setLight(0);
         $banner->setImg($this->getPhoto($phpExcelObject->setActiveSheetIndex(0)->getCell('P' . $num)->getValue()));
         $banner->setLink(0);
         if ($phpExcelObject->setActiveSheetIndex(0)->getCell('S' . $num)->getValue() == 'Свободно') {
             $banner->setHot(true);
         }
         //            $url = substr ($phpExcelObject->setActiveSheetIndex(0)->getCell('E'.$num)->getValue(), 0, strrpos($phpExcelObject->setActiveSheetIndex(0)->getCell('E'.$num)->getValue(), '.'));
         $url = $phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue();
         //            if ($url == ''){
         //                echo '<br /><br />'.$num;
         //                break;
         //            }
         $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($url);
         $content = @file_get_contents($url);
         $XmlObj = simplexml_load_string($content);
         if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) {
             $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1];
             $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0];
         } else {
             $pos['x'] = 0;
             $pos['y'] = 0;
         }
         $banner->setLongitude($pos['y']);
         $banner->setLatitude($pos['x']);
         $em->persist($banner);
         $em->flush($banner);
         $num++;
         if ($num % 30 == 0) {
             sleep(rand(1, 5));
         }
     }
     return new Response('открылось');
 }
示例#11
0
文件: MainParser.php 项目: Quiss/Oon
 public function refreshStatus(Banner $banner, $status, $hot = null)
 {
     return true;
     $months = $banner->getMonths();
     foreach ($months as $m) {
         $this->em->remove($m);
     }
     foreach ($status as $m => $s) {
         $date = new \DateTime($m . ' 00:00:00');
         $month = new Month();
         $month->setBanner($banner);
         $month->setDate($date);
         $month->setStatus($s);
         if ($hot) {
             if ($m == $hot['date']) {
                 $month->setSale($hot['sale']);
             }
         }
         $this->em->persist($month);
         $this->em->flush($month);
     }
 }