public function ImportarRegistro($Row) { $resultado = new ResultadoLote(); //$resultado->Registros[] = $Row; $Seccion = strtoupper(trim($Row['SECCION'], ' .')); $MacizoNum = trim($Row['MACIZO_NUM'], ' .'); $MacizoAlfa = trim($Row['MACIZO_ALFA'], ' .'); $ParcelaNum = trim($Row['PARCELA_NUM'], ' .'); $ParcelaAlfa = trim($Row['PARCELA_ALFA'], ' .'); $SubparcelaNum = trim($Row['SUBPARC_NUM'], ' .'); $SubparcelaAlfa = trim($Row['SUBPARC_ALFA'], ' .'); $UnidadFuncional = (int) $Row['UNID_FUNC']; $entity = $this->em->getRepository('YacareCatastroBundle:Partida')->findOneBy(array('ImportSrc' => 'dbmunirg.TR3A100', 'ImportId' => $Row['TR3A100_ID'])); if (!$entity) { $entity = $this->em->getRepository('YacareCatastroBundle:Partida')->findOneBy(array('Seccion' => $Seccion, 'MacizoNum' => $MacizoNum, 'MacizoAlfa' => $MacizoAlfa, 'ParcelaNum' => $ParcelaNum, 'ParcelaAlfa' => $ParcelaAlfa, 'SubparcelaNum' => $SubparcelaNum, 'SubparcelaAlfa' => $SubparcelaAlfa, 'UnidadFuncional' => $UnidadFuncional)); } if (!$entity) { $entity = $this->em->getRepository('YacareCatastroBundle:Partida')->findOneBy(array('Numero' => (int) $Row['PARTIDA'])); } if (!$entity) { $entity = new \Yacare\CatastroBundle\Entity\Partida(); $entity->setSeccion($Seccion); $entity->setMacizoAlfa($MacizoAlfa); $entity->setMacizoNum($MacizoNum); $entity->setParcelaAlfa($ParcelaAlfa); $entity->setParcelaNum($ParcelaNum); $entity->setSubparcelaAlfa($SubparcelaAlfa); $entity->setSubparcelaNum($SubparcelaNum); $entity->setUnidadFuncional($UnidadFuncional); $resultado->RegistrosNuevos++; } else { $resultado->RegistrosActualizados++; } $CodigoCalle = $this->ArreglarCodigoCalle($Row['CODIGO_CALLE']); if ($CodigoCalle) { $entity->setDomicilioCalle($this->em->getReference('YacareCatastroBundle:Calle', $CodigoCalle)); } else { $entity->setDomicilioCalle(null); } if ($Row['ZONA_CODIGO']) { $ZonaId = @$this->Zonas[$Row['ZONA_CODIGO']]; if ($ZonaId) { $entity->setZona($this->em->getReference('YacareCatastroBundle:Zona', $ZonaId)); } else { $entity->setZona(null); } } else { $entity->setZona(null); } $Titulares = $this->ObtenerTitularesPorId($Row['TR3A100_ID']); if (count($Titulares) >= 1) { $entity->setTitular($Titulares[0]); //} else { // $entity->setTitular(null); } $entity->setUnidadFuncional($UnidadFuncional); $entity->setDomicilioNumero((int) $Row['NUMERO']); $entity->setDomicilioPiso(trim($Row['PISO'])); $entity->setDomicilioPuerta(trim($Row['DEPTO'])); $entity->setNumero((int) $Row['PARTIDA']); // Guardo los TG06100_ID de los titulares de las partidas, para debug $Tg06100Id = trim($Row['TG06100_TG06100_ID']); $Tg06100IdActual = $entity->getTg06100Id(); if ($Tg06100IdActual) { if (strpos($Tg06100IdActual, $Tg06100Id) === false) { $entity->setTg06100Id($Tg06100IdActual . ',' . $Tg06100Id); } } else { $entity->setTg06100Id($Tg06100Id); } $entity->setImportSrc('dbmunirg.TR3A100'); $entity->setImportId($Row['TR3A100_ID']); $entity->setSuprimido(0); $this->em->persist($entity); $this->em->flush(); return $resultado; }