/**
  * Efetua a busca de Unidades Organizacional por Estado
  * @param EstadoValueObject $voEstado
  * @throws PersistException
  */
 public function findByUf(EstadoValueObject $voEstado)
 {
     try {
         $query = 'SELECT
                     uo.sq_pessoa,
                     uo.sq_unidade_superior,
                     uo.sq_unidade_adm_pai,
                     uo.sq_unidade_fin_pai,
                     uo.sq_tipo_unidade,
                     uo.co_uorg,
                     uo.co_unidade_gestora,
                     uo.sg_unidade_org,
                     uo.st_ativo,
                     uo.nu_latitude,
                     uo.nu_longitude,
                     uo.in_unidade_financeira
                 FROM corporativo.vw_unidade_org uo
                 JOIN corporativo.estado e 
                         ON st_intersects(
                                 ST_CollectionExtract(uo.the_geom, 3), ST_CollectionExtract(e.the_geom, 3)
                         )
                 WHERE e.sq_estado = :sqEstado';
         $params['sqEstado'] = new \stdClass();
         $params['sqEstado']->type = 'integer';
         $params['sqEstado']->value = $voEstado->getSqEstado();
         # executa query
         return $this->execute($query, $params);
     } catch (IllegalArgumentException $iae) {
         throw new PersistException('Um ou mais paramentros informados para na montagem da query foi avaliado como inválido', 0, $iae);
     } catch (\Exception $exp) {
         throw new PersistException('Um erro inesperado ocorreu ao tentar executar a recuperação dos dados', 0, $exp);
     }
 }
Exemple #2
0
 /**
  * Efetua pesquisa de bioma por Estado
  *
  * @param EstadoValueObject
  * @return ResultSet
  * */
 public function findByEstado(EstadoValueObject $estado)
 {
     try {
         $query = 'SELECT bio.sq_bioma,
                          bio.no_bioma
                   FROM corporativo.estado uf
                   INNER JOIN corporativo.bioma bio 
                         ON bio.the_geom && uf.the_geom AND st_intersects(bio.the_geom, uf.the_geom)
                   WHERE uf.sq_estado = :sqEstado';
         $params['sqEstado'] = new \stdClass();
         $params['sqEstado']->type = 'integer';
         $params['sqEstado']->value = (int) $estado->getSqEstado();
         # executa query
         return $this->execute($query, $params);
     } catch (IllegalArgumentException $iae) {
         throw new PersistException(self::EXP_ILLEGALARGUMENT);
     } catch (\exception $exp) {
         throw new PersistException(self::EXP_PERSIST);
     }
 }