From ca17d5741e60eca40845b1f1ea61fa60bc3e6c56 Mon Sep 17 00:00:00 2001 From: Thiago Farias Date: Mon, 13 Nov 2017 15:33:26 -0200 Subject: [PATCH] AJustes: US042 refs #8517 --- dto/PenRelHipoteseLegalDTO.php | 5 ++++- dto/PenRelTipoDocMapEnviadoDTO.php | 2 +- pen_parametros_configuracao.php | 47 +++++++++++++++++++++++++++++++++++------------ rn/ExpedirProcedimentoRN.php | 50 +++++++++++++++++++++++++++++++++++++++++++------- rn/PenRelHipoteseLegalEnvioRN.php | 27 +++++++++++++++++++++++++++ rn/PenRelHipoteseLegalRecebidoRN.php | 46 ++++++++++++++++++++++++++++++++++++++++++---- rn/ReceberProcedimentoRN.php | 27 ++++++++++++++++++++++++++- 7 files changed, 178 insertions(+), 26 deletions(-) diff --git a/dto/PenRelHipoteseLegalDTO.php b/dto/PenRelHipoteseLegalDTO.php index 97e00b5..58981f1 100644 --- a/dto/PenRelHipoteseLegalDTO.php +++ b/dto/PenRelHipoteseLegalDTO.php @@ -14,11 +14,14 @@ class PenRelHipoteseLegalDTO extends InfraDTO { public function montar() { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdMap', 'id_mapeamento'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal', 'id_hipotese_legal'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdBarramento', 'id_hipotese_legal_pen'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Tipo', 'tipo'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Ativo', 'sin_ativo'); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdBarramento', 'id_hipotese_legal_pen'); + + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'Identificacao', 'identificacao', 'md_pen_hipotese_legal'); $this->configurarPK('IdMap',InfraDTO::$TIPO_PK_SEQUENCIAL); + $this->configurarFK('IdBarramento', 'md_pen_hipotese_legal', 'id_hipotese_legal'); //$this->configurarExclusaoLogica('Ativo', 'N'); } diff --git a/dto/PenRelTipoDocMapEnviadoDTO.php b/dto/PenRelTipoDocMapEnviadoDTO.php index 8e9d5ed..2ad2e33 100644 --- a/dto/PenRelTipoDocMapEnviadoDTO.php +++ b/dto/PenRelTipoDocMapEnviadoDTO.php @@ -17,7 +17,7 @@ class PenRelTipoDocMapEnviadoDTO extends InfraDTO { $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeSerie', 'nome', 'serie'); $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeEspecie','nome_especie', 'md_pen_especie_documental'); - + $this->configurarPK('IdMap', InfraDTO::$TIPO_PK_SEQUENCIAL); $this->configurarFK('IdSerie', 'serie', 'id_serie'); $this->configurarFK('CodigoEspecie', 'md_pen_especie_documental', 'id_especie'); diff --git a/pen_parametros_configuracao.php b/pen_parametros_configuracao.php index 7f53c49..628db1e 100644 --- a/pen_parametros_configuracao.php +++ b/pen_parametros_configuracao.php @@ -14,14 +14,33 @@ try { $objBanco = BancoSEI::getInstance(); $objSessao = SessaoSEI::getInstance(); + + $o = new PenRelHipoteseLegalEnvioRN(); + $os = new PenRelHipoteseLegalRecebidoRN(); + $objSessao->validarPermissao('pen_parametros_configuracao'); $objPENParametroDTO = new PenParametroDTO(); $objPENParametroDTO->retTodos(); - $objPENParametroRN = new PENParametroRN(); $retParametros = $objPENParametroRN->listar($objPENParametroDTO); + /* Busca os dados para montar dropdown ( TIPO DE PROCESSO EXTERNO ) */ + $objTipoProcedimentoDTO = new TipoProcedimentoDTO(); + $objTipoProcedimentoDTO->retNumIdTipoProcedimento(); + $objTipoProcedimentoDTO->retStrNome(); + $objTipoProcedimentoDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC); + $objTipoProcedimentoRN = new TipoProcedimentoRN(); + $arrObjTipoProcedimentoDTO = $objTipoProcedimentoRN->listarRN0244($objTipoProcedimentoDTO); + + /* Busca os dados para montar dropdown ( UNIDADE GERADORA DOCUMENTO RECEBIDO ) */ + $objUnidadeDTO = new UnidadeDTO(); + $objUnidadeDTO->retNumIdUnidade(); + $objUnidadeDTO->retStrSigla(); + $objUnidadeDTO->setOrdStrSigla(InfraDTO::$TIPO_ORDENACAO_ASC); + $objUnidadeRN = new UnidadeRN(); + $arrObjUnidade = $objUnidadeRN->listarRN0127($objUnidadeDTO); + if ($objPENParametroDTO===null){ throw new PENException("Registros não encontrados."); } @@ -131,17 +150,21 @@ $objPagina->abrirBody($strTitulo, 'onload="inicializar();"'); echo ''; -// -// echo ''; -// -// echo ''; + foreach ($arrObjTipoProcedimentoDTO as $procedimento) { + echo ''; + } + echo ''; + foreach ($arrObjUnidade as $unidade) { + echo ''; + } + echo '
'; diff --git a/rn/ExpedirProcedimentoRN.php b/rn/ExpedirProcedimentoRN.php index 3f5b1fe..ea74e15 100644 --- a/rn/ExpedirProcedimentoRN.php +++ b/rn/ExpedirProcedimentoRN.php @@ -386,7 +386,8 @@ class ExpedirProcedimentoRN extends InfraRN { //TODO: Passar dados do ProcedimentoDTO via parâmetro já carregado anteriormente $objProcedimentoDTO = $this->consultarProcedimento($dblIdProcedimento); - + $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN(); + $objProcesso = new stdClass(); $objProcesso->protocolo = utf8_encode($objProcedimentoDTO->getStrProtocoloProcedimentoFormatado()); $objProcesso->nivelDeSigilo = $this->obterNivelSigiloPEN($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo()); @@ -394,6 +395,10 @@ class ExpedirProcedimentoRN extends InfraRN { $objProcesso->descricao = utf8_encode($objProcedimentoDTO->getStrDescricaoProtocolo()); $objProcesso->dataHoraDeProducao = $this->objProcessoEletronicoRN->converterDataWebService($objProcedimentoDTO->getDtaGeracaoProtocolo()); + if($this->obterNivelSigiloPEN($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo()) == ProtocoloRN::$NA_RESTRITO){ + $objProcesso->hipoteseLegal = $objPenRelHipoteseLegalRN->getIdHipoteseLegalPEN($objProcedimentoDTO->getNumIdHipoteseLegalProtocolo()); + } + $this->atribuirProdutorProcesso($objProcesso, $objProcedimentoDTO->getNumIdUsuarioGeradorProtocolo(), $objProcedimentoDTO->getNumIdUnidadeGeradoraProtocolo()); @@ -808,7 +813,7 @@ class ExpedirProcedimentoRN extends InfraRN { //$protocoloDocumentoDTO = $this->consultarProtocoloDocumento($documeto->getDblIdProcedimento()); $documento = new stdClass(); - + $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN(); //TODO: Atribuir das informações abaixo ao documento //123 //456 @@ -843,7 +848,11 @@ class ExpedirProcedimentoRN extends InfraRN { $documento->descricao = utf8_encode($strDescricaoDocumento); $documento->nivelDeSigilo = $this->obterNivelSigiloPEN($documentoDTO->getStrStaNivelAcessoLocalProtocolo()); $documento->dataHoraDeProducao = $this->objProcessoEletronicoRN->converterDataWebService($documentoDTO->getDtaGeracaoProtocolo()); - + + if($this->obterNivelSigiloPEN($documentoDTO->getStrStaNivelAcessoLocalProtocolo()) == ProtocoloRN::$NA_RESTRITO){ + $documento->hipoteseLegal = $objPenRelHipoteseLegalRN->getIdHipoteseLegalPEN($documentoDTO->getNumIdHipoteseLegalProtocolo()); + } + $usuarioDTO = $this->consultarUsuario($documentoDTO->getNumIdUsuarioGeradorProtocolo()); if(isset($usuarioDTO)) { $documento->produtor = new stdClass(); @@ -1250,6 +1259,7 @@ class ExpedirProcedimentoRN extends InfraRN { $objProcedimentoDTO->retDtaGeracaoProtocolo(); $objProcedimentoDTO->retStrStaEstadoProtocolo(); $objProcedimentoDTO->retDblIdProcedimento(); + $objProcedimentoDTO->retNumIdHipoteseLegalProtocolo(); return $this->objProcedimentoRN->consultarRN0201($objProcedimentoDTO); } @@ -1341,6 +1351,7 @@ class ExpedirProcedimentoRN extends InfraRN { $documentoDTO->retStrNumero(); $documentoDTO->retNumIdTipoConferencia(); $documentoDTO->retStrStaDocumento(); + $documentoDTO->retNumIdHipoteseLegalProtocolo(); $documentoDTO->setOrdStrProtocoloDocumentoFormatado(InfraDTO::$TIPO_ORDENACAO_ASC); return $this->objDocumentoRN->listarRN0008($documentoDTO); @@ -1398,6 +1409,7 @@ class ExpedirProcedimentoRN extends InfraRN { $documentoDTO->retStrConteudoAssinatura(); $documentoDTO->retStrStaDocumento(); $documentoDTO->retStrStaEstadoProtocolo(); + $documentoDTO->retNumIdHipoteseLegalProtocolo(); //$documentoDTO->retStrNumero(); return $this->objDocumentoRN->consultarRN0005($documentoDTO); @@ -1536,11 +1548,12 @@ class ExpedirProcedimentoRN extends InfraRN { } private function validarDadosDocumentos(InfraException $objInfraException, $arrDocumentoDTO, $strAtributoValidacao = null) { - + if(!empty($arrDocumentoDTO)) { $objDocMapDTO = new PenRelTipoDocMapEnviadoDTO(); $objGenericoBD = new GenericoBD($this->inicializarObjInfraIBanco()); + $objPenRelHipoteseLegalEnvioRN = new PenRelHipoteseLegalEnvioRN(); foreach($arrDocumentoDTO as $objDocumentoDTO) { @@ -1557,6 +1570,12 @@ class ExpedirProcedimentoRN extends InfraRN { $objInfraException->adicionarValidacao($strDescricao, $strAtributoValidacao); } + + if (!empty($objDocumentoDTO->getNumIdHipoteseLegalProtocolo()) + && empty($objPenRelHipoteseLegalEnvioRN->getIdHipoteseLegalPEN($objDocumentoDTO->getNumIdHipoteseLegalProtocolo()))) { + + $objInfraException->adicionarValidacao('Hipótese Legal do Documento Não Mapeada', $strAtributoValidacao); + } } } } @@ -1586,11 +1605,27 @@ class ExpedirProcedimentoRN extends InfraRN { // $objProcedimentoDTO->retStrStaNivelAcessoGlobalProtocolo(); // $objProcedimentoDTO = $this->objProcedimentoRN->consultarRN0201($objProcedimentoDTO); - - if ($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() != ProtocoloRN::$NA_PUBLICO) { - $objInfraException->adicionarValidacao('Não é possível expedir processo com informações restritas ou sigilosas.', $strAtributoValidacao); + + if ($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() == ProtocoloRN::$NA_SIGILOSO) { + $objInfraException->adicionarValidacao('Não é possível expedir processo com informações sigilosas.', $strAtributoValidacao); } } + + /** + * Valida existência da Hipótese legal de Envio + * @param InfraException $objInfraException + * @param ProcedimentoDTO $objProcedimentoDTO + * @param string $strAtributoValidacao + */ + private function validarHipoteseLegalEnvio(InfraException $objInfraException, ProcedimentoDTO $objProcedimentoDTO, $strAtributoValidacao = null) { + if ($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() != ProtocoloRN::$NA_RESTRITO) { + + if (empty($objProcedimentoDTO->getNumIdHipoteseLegalProtocolo())) { + $objInfraException->adicionarValidacao('Não é possível expedir processo de nível restrito sem a hipótese legal mapeada.', $strAtributoValidacao); + } + + } + } private function validarAssinaturas(InfraException $objInfraException, $objProcedimentoDTO, $strAtributoValidacao = null) { @@ -1647,6 +1682,7 @@ class ExpedirProcedimentoRN extends InfraRN { $this->validarDocumentacaoExistende($objInfraException, $objProcedimentoDTO, $strAtributoValidacao); $this->validarProcessoAbertoUnidade($objInfraException, $objProcedimentoDTO, $strAtributoValidacao); $this->validarNivelAcessoProcesso($objInfraException, $objProcedimentoDTO, $strAtributoValidacao); + $this->validarHipoteseLegalEnvio($objInfraException, $objProcedimentoDTO, $strAtributoValidacao); $this->validarAssinaturas($objInfraException, $objProcedimentoDTO, $strAtributoValidacao); } diff --git a/rn/PenRelHipoteseLegalEnvioRN.php b/rn/PenRelHipoteseLegalEnvioRN.php index 49431bb..5371f63 100644 --- a/rn/PenRelHipoteseLegalEnvioRN.php +++ b/rn/PenRelHipoteseLegalEnvioRN.php @@ -25,4 +25,31 @@ class PenRelHipoteseLegalEnvioRN extends PenRelHipoteseLegalRN { SessaoSEI::getInstance()->validarAuditarPermissao('pen_map_hipotese_legal_envio_excluir', __METHOD__, $objDTO); return parent::excluirConectado($objDTO); } + public function consultar(PenRelHipoteseLegalDTO $objDTO){ + return parent::consultarConectado($objDTO); + } + + /** + * Pega o ID hipotese sei para buscar o ID do barramento + * @param integer $numIdHipoteseSEI + * @return integer + */ + public function getIdHipoteseLegalPEN($numIdHipoteseSEI) { + $objBanco = BancoSEI::getInstance(); + $objGenericoBD = new GenericoBD($objBanco); + + // Mapeamento da hipotese legal remota + $objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO(); + $objPenRelHipoteseLegalDTO->setStrTipo('E'); + $objPenRelHipoteseLegalDTO->retNumIdentificacao(); + $objPenRelHipoteseLegalDTO->setNumIdHipoteseLegal($numIdHipoteseSEI); + + $objPenRelHipoteseLegal = $objGenericoBD->consultar($objPenRelHipoteseLegalDTO); + + if ($objPenRelHipoteseLegal) { + return $objPenRelHipoteseLegal->getNumIdentificacao(); + } else { + return null; + } + } } diff --git a/rn/PenRelHipoteseLegalRecebidoRN.php b/rn/PenRelHipoteseLegalRecebidoRN.php index fc13a27..ff600d4 100644 --- a/rn/PenRelHipoteseLegalRecebidoRN.php +++ b/rn/PenRelHipoteseLegalRecebidoRN.php @@ -9,20 +9,58 @@ require_once dirname(__FILE__) . '/../../../SEI.php'; */ class PenRelHipoteseLegalRecebidoRN extends PenRelHipoteseLegalRN { - public function listar(PenRelHipoteseLegalDTO $objDTO){ + public function listar(PenRelHipoteseLegalDTO $objDTO) { SessaoSEI::getInstance()->validarAuditarPermissao('pen_map_hipotese_legal_recebimento_listar', __METHOD__, $objDTO); return parent::listarConectado($objDTO); } - public function alterar(PenRelHipoteseLegalDTO $objDTO){ + + public function alterar(PenRelHipoteseLegalDTO $objDTO) { SessaoSEI::getInstance()->validarAuditarPermissao('pen_map_hipotese_legal_recebimento_alterar', __METHOD__, $objDTO); return parent::alterarConectado($objDTO); } - public function cadastrar(PenRelHipoteseLegalDTO $objDTO){ + + public function cadastrar(PenRelHipoteseLegalDTO $objDTO) { SessaoSEI::getInstance()->validarAuditarPermissao('pen_map_hipotese_legal_recebimento_cadastrar', __METHOD__, $objDTO); return parent::cadastrarConectado($objDTO); } - public function excluir(PenRelHipoteseLegalDTO $objDTO){ + + public function excluir(PenRelHipoteseLegalDTO $objDTO) { SessaoSEI::getInstance()->validarAuditarPermissao('pen_map_hipotese_legal_recebimento_excluir', __METHOD__, $objDTO); return parent::excluirConectado($objDTO); } + + /** + * Pega o ID hipotese PEN para buscar o ID do SEI + * @param integer $numIdentificacao + * @return integer + */ + public function getIdHipoteseLegalSEI($numIdentificacao) { + $objBanco = BancoSEI::getInstance(); + $objGenericoBD = new GenericoBD($objBanco); + + $objPenHipoteseLegalDTO = new PenHipoteseLegalDTO(); + $objPenHipoteseLegalDTO->setNumIdentificacao($numIdentificacao); + $objPenHipoteseLegalDTO->retNumIdHipoteseLegal(); + $objPenHipoteseLegalDTO = $objGenericoBD->consultar($objPenHipoteseLegalDTO); + + if ($objPenHipoteseLegalDTO) { + + // Mapeamento da hipotese legal remota + $objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO(); + $objPenRelHipoteseLegalDTO->setStrTipo('R'); + $objPenRelHipoteseLegalDTO->retNumIdHipoteseLegal(); + $objPenRelHipoteseLegalDTO->setNumIdBarramento($objPenHipoteseLegalDTO->getNumIdHipoteseLegal()); + + $objPenRelHipoteseLegal = $objGenericoBD->consultar($objPenRelHipoteseLegalDTO); + + if ($objPenRelHipoteseLegal) { + return $objPenRelHipoteseLegal->getNumIdHipoteseLegal(); + } else { + return null; + } + } else { + return null; + } + } + } diff --git a/rn/ReceberProcedimentoRN.php b/rn/ReceberProcedimentoRN.php index 9c22dd2..2a32738 100644 --- a/rn/ReceberProcedimentoRN.php +++ b/rn/ReceberProcedimentoRN.php @@ -578,6 +578,18 @@ class ReceberProcedimentoRN extends InfraRN $objProtocoloDTO->setDblIdProtocolo(null); $objProtocoloDTO->setStrDescricao(utf8_decode($objProcesso->descricao)); $objProtocoloDTO->setStrStaNivelAcessoLocal($this->obterNivelSigiloSEI($objProcesso->nivelDeSigilo)); + + if($this->obterNivelSigiloSEI($objProcesso->nivelDeSigilo) == ProtocoloRN::$NA_RESTRITO){ + $objHipoteseLegalRecebido = new PenRelHipoteseLegalRecebidoRN(); + $numIdHipoteseLegal = $objHipoteseLegalRecebido->getIdHipoteseLegalSEI($objProcesso->hipoteseLegal); + if (empty($numIdHipoteseLegal)) { + $objPENParametroRN = new PENParametroRN(); + $objProtocoloDTO->setNumIdHipoteseLegal($objPENParametroRN->getParametro('HIPOTESE_LEGAL_PADRAO')); + } else { + $objProtocoloDTO->setNumIdHipoteseLegal($numIdHipoteseLegal); + } + } + $objProtocoloDTO->setStrProtocoloFormatado(utf8_decode($objProcesso->protocolo)); $objProtocoloDTO->setDtaGeracao($this->objProcessoEletronicoRN->converterDataSEI($objProcesso->dataHoraDeProducao)); $objProtocoloDTO->setArrObjAnexoDTO(array()); @@ -587,6 +599,8 @@ class ReceberProcedimentoRN extends InfraRN $this->atribuirRemetente($objProtocoloDTO, $objRemetente); $this->atribuirParticipantes($objProtocoloDTO, $objProcesso->interessado); + + $strDescricao = sprintf('Tipo de processo no órgão de origem: %s', utf8_decode($objProcesso->processoDeNegocio)).PHP_EOL; $strDescricao .= $objProcesso->observacao; @@ -1100,7 +1114,18 @@ class ReceberProcedimentoRN extends InfraRN $objDocumentoDTO->getObjProtocoloDTO()->setStrStaGrauSigilo($objTipoProcedimentoDTO->getStrStaGrauSigiloSugestao()); $objDocumentoDTO->getObjProtocoloDTO()->setNumIdHipoteseLegal($objTipoProcedimentoDTO->getNumIdHipoteseLegalSugestao()); } - + + if ($this->obterNivelSigiloSEI($objDocumento->nivelDeSigilo) == ProtocoloRN::$NA_RESTRITO) { + $objHipoteseLegalRecebido = new PenRelHipoteseLegalRecebidoRN(); + $numIdHipoteseLegal = $objHipoteseLegalRecebido->getIdHipoteseLegalSEI($objDocumento->hipoteseLegal); + if (empty($numIdHipoteseLegal)) { + $objPENParametroRN = new PENParametroRN(); + $objDocumentoDTO->getObjProtocoloDTO()->setNumIdHipoteseLegal($objPENParametroRN->getParametro('HIPOTESE_LEGAL_PADRAO')); + } else { + $objDocumentoDTO->getObjProtocoloDTO()->setNumIdHipoteseLegal($numIdHipoteseLegal); + } + } + $objDocumentoDTO->getObjProtocoloDTO()->setArrObjParticipanteDTO($this->prepararParticipantes($objDocumentoDTO->getObjProtocoloDTO()->getArrObjParticipanteDTO())); $objDocumentoRN = new DocumentoRN(); -- libgit2 0.21.2