示例#1
0
 public function ImportarRegistro($Row)
 {
     $resultado = new ResultadoLote();
     //$resultado->Registros[] = $Row;
     $nombreBueno = StringHelper::Desoraclizar($Row['detalle']);
     $entity = $this->em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.sectores', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion'] . '.' . $Row['sector']));
     if (!$entity) {
         $nuevoId = $this->em->createQuery('SELECT MAX(r.id) FROM YacareOrganizacionBundle:Departamento r')->getSingleScalarResult();
         $entity = new \Yacare\OrganizacionBundle\Entity\Departamento();
         $entity->setId(++$nuevoId);
         $entity->setRango(70);
         $entity->setImportSrc('rr_hh.sectores');
         $entity->setImportId($Row['secretaria'] . '.' . $Row['direccion'] . '.' . $Row['sector']);
         $resultado->RegistrosNuevos++;
     } else {
         $resultado->RegistrosActualizados++;
     }
     if ($entity->getNombreOriginal() != $Row['detalle']) {
         $entity->setNombre($nombreBueno);
         $entity->setNombreOriginal($Row['detalle']);
     }
     if ($Row['fecha_baja']) {
         $entity->setSuprimido(true);
     } else {
         $entity->setSuprimido(false);
     }
     if ($Row['parte']) {
         $entity->setHaceParteDiario(true);
     } else {
         $entity->setHaceParteDiario(false);
     }
     $Dire = $this->em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.direcciones', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion']));
     $entity->setParentNode($Dire);
     $this->em->persist($entity);
     $this->em->flush();
     return $resultado;
 }
示例#2
0
 /**
  * @Route("departamentos/")
  * @Template("YacareMunirgBundle:Importar:importar.html.twig")
  */
 public function importarDepartamentosAction()
 {
     mb_internal_encoding('UTF-8');
     ini_set('display_errors', 1);
     $em = $this->getDoctrine()->getManager();
     $DbRecursos = $this->ConectarRrhh();
     $importar_importados = 0;
     $importar_actualizados = 0;
     $importar_procesados = 0;
     $log = array();
     $Ejecutivo = $em->getRepository('YacareOrganizacionBundle:Departamento')->find(1);
     foreach ($DbRecursos->query('SELECT * FROM secretarias WHERE codigo<>999') as $Row) {
         $nombreBueno = StringHelper::Desoraclizar($Row['detalle']);
         $entity = $em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.secretarias', 'ImportId' => $Row['codigo']));
         if (!$entity) {
             $nuevoId = $this->getDoctrine()->getManager()->createQuery('SELECT MAX(r.id) FROM YacareOrganizacionBundle:Departamento r')->getSingleScalarResult();
             $entity = new \Yacare\OrganizacionBundle\Entity\Departamento();
             $entity->setId(++$nuevoId);
             $entity->setRango(30);
             $entity->setImportSrc('rr_hh.secretarias');
             $entity->setImportId($Row['codigo']);
             $importar_importados++;
         } else {
             $importar_actualizados++;
         }
         $entity->setNombre($nombreBueno);
         $entity->setParentNode($Ejecutivo);
         if ($Row['fecha_baja']) {
             $entity->setSuprimido(true);
         }
         $em->persist($entity);
         $em->flush();
         $importar_procesados++;
         $log[] = 'Secretaría ' . $Row['codigo'] . " \t" . $nombreBueno;
     }
     foreach ($DbRecursos->query('SELECT * FROM direcciones WHERE secretaria<>999') as $Row) {
         $nombreBueno = StringHelper::Desoraclizar($Row['detalle']);
         $entity = $em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.direcciones', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion']));
         if (!$entity) {
             $nuevoId = $this->getDoctrine()->getManager()->createQuery('SELECT MAX(r.id) FROM YacareOrganizacionBundle:Departamento r')->getSingleScalarResult();
             $entity = new \Yacare\OrganizacionBundle\Entity\Departamento();
             $entity->setId(++$nuevoId);
             $entity->setRango(50);
             $entity->setImportSrc('rr_hh.direcciones');
             $entity->setImportId($Row['secretaria'] . '.' . $Row['direccion']);
             $importar_importados++;
         } else {
             $importar_actualizados++;
         }
         $entity->setNombre($nombreBueno);
         if ($Row['fecha_baja']) {
             $entity->setSuprimido(true);
         }
         $Secre = $em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.secretarias', 'ImportId' => $Row['secretaria']));
         $entity->setParentNode($Secre);
         $em->persist($entity);
         $em->flush();
         $importar_procesados++;
         $log[] = 'Dirección ' . $Row['secretaria'] . '.' . $Row['direccion'] . " \t" . $nombreBueno;
     }
     foreach ($DbRecursos->query('SELECT * FROM sectores') as $Row) {
         $nombreBueno = StringHelper::Desoraclizar($Row['detalle']);
         $entity = $em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.sectores', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion'] . '.' . $Row['sector']));
         if (!$entity) {
             $nuevoId = $this->getDoctrine()->getManager()->createQuery('SELECT MAX(r.id) FROM YacareOrganizacionBundle:Departamento r')->getSingleScalarResult();
             $entity = new \Yacare\OrganizacionBundle\Entity\Departamento();
             $entity->setId(++$nuevoId);
             $entity->setRango(70);
             $entity->setImportSrc('rr_hh.sectores');
             $entity->setImportId($Row['secretaria'] . '.' . $Row['direccion'] . '.' . $Row['sector']);
             $importar_importados++;
         } else {
             $importar_actualizados++;
         }
         $entity->setNombre($nombreBueno);
         if ($Row['fecha_baja']) {
             $entity->setSuprimido(true);
         } else {
             $entity->setSuprimido(false);
         }
         if ($Row['parte']) {
             $entity->setHaceParteDiario(true);
         } else {
             $entity->setHaceParteDiario(false);
         }
         $Dire = $em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.direcciones', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion']));
         $entity->setParentNode($Dire);
         $em->persist($entity);
         $em->flush();
         $importar_procesados++;
         $log[] = 'Sector ' . $Row['secretaria'] . '.' . $Row['direccion'] . '.' . $Row['sector'] . " \t" . $nombreBueno;
     }
     return array('importar_importados' => $importar_importados, 'importar_actualizados' => $importar_actualizados, 'importar_procesados' => $importar_procesados, 'log' => $log);
 }