Commit f55d89579e1fc8e36269d454c3a3b8b7ff8264d5
1 parent
f1cd004f
Exists in
master
and in
7 other branches
[Fixed #97] Correção de problema na reutilização de NRE em cancelamentos
Showing
6 changed files
with
209 additions
and
207 deletions
Show diff stats
dto/ComponenteDigitalDTO.php
| ... | ... | @@ -28,11 +28,14 @@ class ComponenteDigitalDTO extends InfraDTO { |
| 28 | 28 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'Ordem', 'ordem'); |
| 29 | 29 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'SinEnviar', 'sin_enviar'); |
| 30 | 30 | |
| 31 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'StaTipoTramite', 'sta_tipo_tramite', 'md_pen_tramite'); | |
| 31 | 32 | $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'TicketEnvioComponentes', 'ticket_envio_componentes', 'md_pen_tramite'); |
| 32 | 33 | $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'ConteudoAssinaturaDocumento', 'conteudo_assinatura', 'documento_conteudo'); |
| 33 | 34 | $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'ProtocoloDocumentoFormatado', 'protocolo_formatado', 'protocolo'); |
| 35 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'StaProtocolo', 'sta_protocolo', 'protocolo'); | |
| 34 | 36 | $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'StaEstadoProtocolo', 'sta_estado', 'protocolo'); |
| 35 | 37 | |
| 38 | + | |
| 36 | 39 | $this->configurarPK('NumeroRegistro', InfraDTO::$TIPO_PK_INFORMADO); |
| 37 | 40 | $this->configurarPK('IdDocumento', InfraDTO::$TIPO_PK_INFORMADO); |
| 38 | 41 | ... | ... |
rn/ExpedirProcedimentoRN.php
| ... | ... | @@ -365,31 +365,45 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 365 | 365 | |
| 366 | 366 | //Obtenção do número de registro eletrônico do processo |
| 367 | 367 | $strNumeroRegistro = null; |
| 368 | - $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | |
| 369 | - $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | |
| 370 | - $objProcessoEletronicoDTO->setDblIdProcedimento($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 371 | - //TODO: Tratar situao de quando localizado dois registros para o mesmo processo | |
| 372 | - $objProcessoEletronicoDTO->setNumMaxRegistrosRetorno(1); | |
| 373 | - $objProcessoEletronicoDTO->setOrd('IdProcedimento', InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 374 | - $objProcessoEletronicoDTO->retStrNumeroRegistro(); | |
| 375 | 368 | |
| 376 | - $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | |
| 377 | - if(isset($objProcessoEletronicoDTO)) { | |
| 378 | - $strNumeroRegistro = $objProcessoEletronicoDTO->getStrNumeroRegistro(); | |
| 369 | + $objTramiteBD = new TramiteBD($this->getObjInfraIBanco()); | |
| 370 | + $objTramiteDTOFiltro = new TramiteDTO(); | |
| 371 | + $objTramiteDTOFiltro->retStrNumeroRegistro(); | |
| 372 | + $objTramiteDTOFiltro->setNumIdProcedimento($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 373 | + $objTramiteDTOFiltro->setOrdNumIdTramite(InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 374 | + $objTramiteDTOFiltro->setNumMaxRegistrosRetorno(1); | |
| 375 | + | |
| 376 | + $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTOFiltro); | |
| 377 | + if(isset($objTramiteDTO)) { | |
| 378 | + $strNumeroRegistro = $objTramiteDTO->getStrNumeroRegistro(); | |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Consultar se processo eletrônico existe no PEN algum trâmite CANCELADO, caso |
| 382 | 382 | // sim deve ser gerada uma nova NRE, pois a atual ser recusada pelo PEN quando |
| 383 | 383 | // for enviado |
| 384 | - /* if(!InfraString::isBolVazia($strNumeroRegistro)) { | |
| 384 | + if(!InfraString::isBolVazia($strNumeroRegistro)) { | |
| 385 | 385 | $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites(null, $strNumeroRegistro); |
| 386 | - if(!empty($arrObjTramite) && is_array($arrObjTramite) && count($arrObjTramite) === 1) { | |
| 387 | - $objTramite = current($arrObjTramite); | |
| 388 | - if($objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_CANCELADO || $objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO){ | |
| 386 | + if(!empty($arrObjTramite) && is_array($arrObjTramite)) { | |
| 387 | + | |
| 388 | + $arrNumSituacoesTramiteEfetivado = array( | |
| 389 | + ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_RECIBO_ENVIADO_DESTINATARIO, | |
| 390 | + ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_RECIBO_RECEBIDO_REMETENTE, | |
| 391 | + ); | |
| 392 | + | |
| 393 | + $bolExisteTramiteConcluido = false; | |
| 394 | + foreach ($arrObjTramite as $objTramite) { | |
| 395 | + //Caso exista algum trâmite realizado com sucesso para outro destinatário, número do NRE precisa ser reutilizado | |
| 396 | + if(in_array($objTramite->situacaoAtual, $arrNumSituacoesTramiteEfetivado)){ | |
| 397 | + $bolExisteTramiteConcluido = true; | |
| 398 | + break; | |
| 399 | + } | |
| 400 | + } | |
| 401 | + | |
| 402 | + if(!$bolExisteTramiteConcluido){ | |
| 389 | 403 | $strNumeroRegistro = null; |
| 390 | 404 | } |
| 391 | 405 | } |
| 392 | - } */ | |
| 406 | + } | |
| 393 | 407 | |
| 394 | 408 | return $this->objProcessoEletronicoRN->construirCabecalho( |
| 395 | 409 | $strNumeroRegistro, |
| ... | ... | @@ -2241,7 +2255,7 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 2241 | 2255 | $tramite = $tramites ? $tramites[0] : null; |
| 2242 | 2256 | |
| 2243 | 2257 | if (!$tramite) { |
| 2244 | - throw new InfraException('Trâmite não encontrado para esse processo. '); | |
| 2258 | + throw new InfraException("Trâmite não encontrado para esse processo. ({$objDtoProtocolo->getDblIdProtocolo()})"); | |
| 2245 | 2259 | } |
| 2246 | 2260 | |
| 2247 | 2261 | //Verifica se o trâmite est com o status de iniciado | ... | ... |
rn/ProcessoEletronicoRN.php
| ... | ... | @@ -918,9 +918,7 @@ class ProcessoEletronicoRN extends InfraRN { |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | $objTramitesEncontrados = $this->getObjPenWs()->consultarTramites($parametro); |
| 921 | - | |
| 922 | 921 | if(isset($objTramitesEncontrados->tramitesEncontrados)) { |
| 923 | - | |
| 924 | 922 | $arrObjTramite = $objTramitesEncontrados->tramitesEncontrados->tramite; |
| 925 | 923 | if(!is_array($arrObjTramite)) { |
| 926 | 924 | $arrObjTramite = array($objTramitesEncontrados->tramitesEncontrados->tramite); |
| ... | ... | @@ -1455,10 +1453,10 @@ class ProcessoEletronicoRN extends InfraRN { |
| 1455 | 1453 | $arrObjAtividadeDTO = $objAtividadeRN->listarRN0036($objAtividadeDTO); |
| 1456 | 1454 | $numIdUnidade = SessaoSEI::getInstance()->getNumIdUnidadeAtual(); |
| 1457 | 1455 | |
| 1458 | - //if(!empty($arrObjAtividadeDTO)){ | |
| 1459 | - // $objAtividadeDTO = $arrObjAtividadeDTO[0]; | |
| 1460 | - // $numIdUnidade = $objAtividadeDTO->getNumIdUnidade(); | |
| 1461 | - //} | |
| 1456 | + if(!empty($arrObjAtividadeDTO)){ | |
| 1457 | + $objAtividadeDTO = $arrObjAtividadeDTO[0]; | |
| 1458 | + $numIdUnidade = $objAtividadeDTO->getNumIdUnidade(); | |
| 1459 | + } | |
| 1462 | 1460 | |
| 1463 | 1461 | return $numIdUnidade; |
| 1464 | 1462 | } | ... | ... |
rn/ReceberComponenteDigitalRN.php
| ... | ... | @@ -143,7 +143,6 @@ class ReceberComponenteDigitalRN extends InfraRN |
| 143 | 143 | $objDocumentoDTO->setObjProtocoloDTO($objProtocoloDTO); |
| 144 | 144 | $objProtocoloDTO->setArrObjAnexoDTO(array($parObjAnexoDTO)); |
| 145 | 145 | |
| 146 | - $objDocumentoDTO->setStrSinBloqueado('S'); | |
| 147 | 146 | $objDocumentoDTO = $objDocumentoRN->alterarRN0004($objDocumentoDTO); |
| 148 | 147 | } |
| 149 | 148 | } | ... | ... |
rn/ReceberProcedimentoRN.php
| ... | ... | @@ -94,7 +94,6 @@ class ReceberProcedimentoRN extends InfraRN |
| 94 | 94 | $this->gravarLogDebug("Obtendo metadados dos componentes digitais do processo", 4); |
| 95 | 95 | $arrAnexosComponentes = array(); |
| 96 | 96 | $arrayHash = array(); |
| 97 | - $arrayHashPendentes = array(); | |
| 98 | 97 | |
| 99 | 98 | // Lista todos os componentes digitais presente no protocolo |
| 100 | 99 | // Esta verificação é necessária pois existem situações em que a lista de componentes digitais |
| ... | ... | @@ -111,30 +110,21 @@ class ReceberProcedimentoRN extends InfraRN |
| 111 | 110 | |
| 112 | 111 | $numOrdemComponente = $key + 1; |
| 113 | 112 | if(!is_null($componentePendente)){ |
| 114 | - | |
| 115 | - //Verifica se o componente já foi recebido | |
| 116 | - $bolComponenteDigitalRegistrado = $this->documentoJaRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite, $componentePendente); | |
| 117 | - if(!$bolComponenteDigitalRegistrado){ | |
| 118 | - $arrayHashPendentes[] = $componentePendente; | |
| 119 | - } | |
| 120 | - | |
| 113 | + //TODO: Necessário otimizar trecho abaixo para evitar download desnecessário de documentos | |
| 121 | 114 | //TODO: Download do componente digital é realizado, mesmo já existindo na base de dados, devido a comportamento obrigatório do Barramento para mudança de status |
| 122 | 115 | //Ajuste deverá ser feito em versões futuas |
| 123 | 116 | $arrayHash[] = $componentePendente; |
| 124 | 117 | |
| 125 | - if(!$bolComponenteDigitalRegistrado || in_array($componentePendente, $arrHashPendentesDownload)) { | |
| 126 | - //Obter os dados do componente digital | |
| 127 | - $this->gravarLogDebug("Baixando componente digital $numOrdemComponente", 6); | |
| 128 | - $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo); | |
| 129 | - $arrAnexosComponentes[$key][$componentePendente] = $this->objReceberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); | |
| 130 | - $arrAnexosComponentes[$key]['recebido'] = false; | |
| 131 | - | |
| 132 | - //Valida a integridade do hash | |
| 133 | - $this->gravarLogDebug("Validando integridade de componente digital $numOrdemComponente", 6); | |
| 134 | - $this->objReceberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], $componentePendente, $parNumIdentificacaoTramite); | |
| 135 | - } else { | |
| 136 | - $this->gravarLogDebug("Componente digital $numOrdemComponente desconsiderado por já fazer parte do processo", 6); | |
| 137 | - } | |
| 118 | + //Obter os dados do componente digital | |
| 119 | + $this->gravarLogDebug("Baixando componente digital $numOrdemComponente", 6); | |
| 120 | + $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo); | |
| 121 | + $arrAnexosComponentes[$key][$componentePendente] = $this->objReceberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); | |
| 122 | + $arrAnexosComponentes[$key]['recebido'] = false; | |
| 123 | + | |
| 124 | + //Valida a integridade do hash | |
| 125 | + $this->gravarLogDebug("Validando integridade de componente digital $numOrdemComponente", 6); | |
| 126 | + $this->objReceberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], | |
| 127 | + $componentePendente, $parNumIdentificacaoTramite); | |
| 138 | 128 | } |
| 139 | 129 | } |
| 140 | 130 | |
| ... | ... | @@ -154,13 +144,11 @@ class ReceberProcedimentoRN extends InfraRN |
| 154 | 144 | } |
| 155 | 145 | |
| 156 | 146 | $this->gravarLogDebug("Persistindo/atualizando dados do processo com NRE " . $strNumeroRegistro, 4); |
| 157 | - $objProcedimentoDTO = $this->registrarProcesso( | |
| 147 | + list($objProcedimentoDTO, $bolProcedimentoExistente) = $this->registrarProcesso( | |
| 158 | 148 | $strNumeroRegistro, |
| 159 | 149 | $parNumIdentificacaoTramite, |
| 160 | 150 | $objProcesso, |
| 161 | - $objMetadadosProcedimento, | |
| 162 | - $arrayHash, | |
| 163 | - $arrayHashPendentes); | |
| 151 | + $objMetadadosProcedimento); | |
| 164 | 152 | |
| 165 | 153 | // @join_tec US008.08 (#23092) |
| 166 | 154 | $this->objProcedimentoAndamentoRN->setOpts($strNumeroRegistro, $parNumIdentificacaoTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO), $objProcedimentoDTO->getDblIdProcedimento()); |
| ... | ... | @@ -194,7 +182,9 @@ class ReceberProcedimentoRN extends InfraRN |
| 194 | 182 | $this->atribuirComponentesDigitaisAosDocumentos($objProcedimentoDTO, $strNumeroRegistro, $parNumIdentificacaoTramite, $arrayHash, $arrayHashPendentes); |
| 195 | 183 | |
| 196 | 184 | //Finalizar o envio do documento para a respectiva unidade |
| 197 | - $this->enviarProcedimentoUnidade($objProcedimentoDTO); | |
| 185 | + $this->enviarProcedimentoUnidade($objProcedimentoDTO, null, $bolProcedimentoExistente); | |
| 186 | + | |
| 187 | + $this->validarPosCondicoesTramite($objMetadadosProcedimento->metadados, $objProcedimentoDTO); | |
| 198 | 188 | |
| 199 | 189 | $this->gravarLogDebug("Enviando recibo de conclusão do trâmite $parNumIdentificacaoTramite", 6); |
| 200 | 190 | $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN(); |
| ... | ... | @@ -215,14 +205,12 @@ class ReceberProcedimentoRN extends InfraRN |
| 215 | 205 | /** |
| 216 | 206 | * Método responsável por atribuir a lista de componentes digitais baixados do PEN aos seus respectivos documentos no SEI |
| 217 | 207 | * |
| 218 | - * @param ProcedimentoDTO $parObjProcedimentoDTO Protocolo que está sendo recebido pelo SEI | |
| 219 | - * @param Array $parArrHashComponentesPendentes Lista de componentes pendentes para vinculação aos documentos | |
| 220 | 208 | * @return [type] [description] |
| 221 | 209 | */ |
| 222 | 210 | private function atribuirComponentesDigitaisAosDocumentos(ProcedimentoDTO $parObjProcedimentoDTO, $parStrNumeroRegistro, $parNumIdentificacaoTramite, |
| 223 | - $parArrHashComponentes, $parArrHashComponentesPendentes) | |
| 211 | + $parArrHashComponentes) | |
| 224 | 212 | { |
| 225 | - if(count($parArrHashComponentesPendentes) > 0){ | |
| 213 | + if(count($parArrHashComponentes) > 0){ | |
| 226 | 214 | //Obter dados dos componetes digitais |
| 227 | 215 | $this->gravarLogDebug("Iniciando o recebimento dos componentes digitais pendentes", 4); |
| 228 | 216 | $objComponenteDigitalDTO = new ComponenteDigitalDTO(); |
| ... | ... | @@ -230,6 +218,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 230 | 218 | $objComponenteDigitalDTO->setNumIdTramite($parNumIdentificacaoTramite); |
| 231 | 219 | $objComponenteDigitalDTO->setStrHashConteudo($parArrHashComponentes, InfraDTO::$OPER_IN); |
| 232 | 220 | $objComponenteDigitalDTO->setOrdNumOrdem(InfraDTO::$TIPO_ORDENACAO_ASC); |
| 221 | + $objComponenteDigitalDTO->retDblIdProcedimento(); | |
| 233 | 222 | $objComponenteDigitalDTO->retDblIdDocumento(); |
| 234 | 223 | $objComponenteDigitalDTO->retNumTicketEnvioComponentes(); |
| 235 | 224 | $objComponenteDigitalDTO->retStrProtocoloDocumentoFormatado(); |
| ... | ... | @@ -243,33 +232,27 @@ class ReceberProcedimentoRN extends InfraRN |
| 243 | 232 | $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); |
| 244 | 233 | $arrObjComponentesDigitaisDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO); |
| 245 | 234 | |
| 246 | - if ($objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0) { | |
| 247 | - //Esta unidade deverá ser considerada para posterior desbloqueio do processo e reabertura | |
| 248 | - $numIdUnidade = ProcessoEletronicoRN::obterUnidadeParaRegistroDocumento($parObjProcedimentoDTO->getDblIdProcedimento()); | |
| 249 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numIdUnidade); | |
| 235 | + if(!empty($arrObjComponentesDigitaisDTO)){ | |
| 250 | 236 | |
| 251 | - try{ | |
| 252 | - $arrStrNomeDocumento = $this->listarMetaDadosComponentesDigitais($objProcesso); | |
| 253 | - foreach($arrObjComponentesDigitaisDTO as $objComponenteDigitalDTOEnviado) { | |
| 254 | - if($objComponenteDigitalDTOEnviado->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | |
| 255 | - $strHash = $objComponenteDigitalDTOEnviado->getStrHashConteudo(); | |
| 256 | - $strNomeDocumento = array_key_exists($strHash, $arrStrNomeDocumento) ? $arrStrNomeDocumento[$strHash]['especieNome'] : '[Desconhecido]'; | |
| 237 | + $arrStrNomeDocumento = $this->listarMetaDadosComponentesDigitais($objProcesso); | |
| 238 | + foreach($arrObjComponentesDigitaisDTO as $objComponenteDigitalDTOEnviado) { | |
| 239 | + if($objComponenteDigitalDTOEnviado->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | |
| 257 | 240 | |
| 258 | - //Todo: Parei aqui: Verificar se documento já foi recebido anteriormente para poder registrar | |
| 259 | - //Alterar somente de documentos não bloqueados | |
| 241 | + $dblIdProcedimento = $objComponenteDigitalDTOEnviado->getDblIdProcedimento(); | |
| 242 | + $dblIdDocumento = $objComponenteDigitalDTOEnviado->getDblIdDocumento(); | |
| 243 | + $strHash = $objComponenteDigitalDTOEnviado->getStrHashConteudo(); | |
| 244 | + | |
| 245 | + //Verificar se documento já foi recebido anteriormente para poder registrar | |
| 246 | + if($this->documentosPendenteRegistro($dblIdProcedimento, $dblIdDocumento, $strHash)){ | |
| 247 | + $strNomeDocumento = array_key_exists($strHash, $arrStrNomeDocumento) ? $arrStrNomeDocumento[$strHash]['especieNome'] : '[Desconhecido]'; | |
| 260 | 248 | $this->objReceberComponenteDigitalRN->receberComponenteDigital($objComponenteDigitalDTOEnviado); |
| 261 | 249 | $strMensagemRecebimento = sprintf('Recebendo %s %s', $strNomeDocumento, $objComponenteDigitalDTOEnviado->getStrProtocoloDocumentoFormatado()); |
| 262 | 250 | $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento($strMensagemRecebimento, 'S')); |
| 263 | 251 | $this->gravarLogDebug($strMensagemRecebimento, 6); |
| 264 | 252 | } |
| 265 | 253 | } |
| 266 | - } finally { | |
| 267 | - $objPenParametroRN = new PenParametroRN(); | |
| 268 | - $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 269 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numUnidadeReceptora); | |
| 270 | 254 | } |
| 271 | 255 | |
| 272 | - // @join_tec US008.10 (#23092) | |
| 273 | 256 | $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Todos os componentes digitais foram recebidos', 'S')); |
| 274 | 257 | }else{ |
| 275 | 258 | $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Nenhum componente digital para receber', 'S')); |
| ... | ... | @@ -438,8 +421,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 438 | 421 | } |
| 439 | 422 | |
| 440 | 423 | |
| 441 | - private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento, | |
| 442 | - $parArrHashComponentes, $parArrHashComponentesPendentes) | |
| 424 | + private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento) | |
| 443 | 425 | { |
| 444 | 426 | // Validação dos dados do processo recebido |
| 445 | 427 | $objInfraException = new InfraException(); |
| ... | ... | @@ -453,17 +435,15 @@ class ReceberProcedimentoRN extends InfraRN |
| 453 | 435 | |
| 454 | 436 | //Verificar se procedimento já existia na base de dados do sistema |
| 455 | 437 | $dblIdProcedimento = $this->consultarProcedimentoExistente($parStrNumeroRegistro, $parObjProcesso->protocolo); |
| 438 | + $bolProcedimentoExistente = isset($dblIdProcedimento); | |
| 456 | 439 | |
| 457 | - if(isset($dblIdProcedimento)){ | |
| 458 | - $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso, $parNumIdentificacaoTramite, $parArrHashComponentes, $parArrHashComponentesPendentes); | |
| 440 | + if($bolProcedimentoExistente){ | |
| 441 | + $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso, $parNumIdentificacaoTramite); | |
| 459 | 442 | } |
| 460 | 443 | else { |
| 461 | - $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso, $parNumIdentificacaoTramite, $parArrHashComponentes, $parArrHashComponentesPendentes); | |
| 444 | + $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso, $parNumIdentificacaoTramite); | |
| 462 | 445 | } |
| 463 | 446 | |
| 464 | - //TODO: Fazer o envio de cada um dos procedimentos apensados (Processo principal e seus apensados, caso exista) | |
| 465 | - //... | |
| 466 | - | |
| 467 | 447 | //Chamada recursiva para registro dos processos apensados |
| 468 | 448 | if(isset($objProcesso->processoApensado)) { |
| 469 | 449 | if(!is_array($objProcesso->processoApensado)) { |
| ... | ... | @@ -475,7 +455,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 475 | 455 | } |
| 476 | 456 | } |
| 477 | 457 | |
| 478 | - return $objProcedimentoDTO; | |
| 458 | + return array($objProcedimentoDTO, $bolProcedimentoExistente); | |
| 479 | 459 | } |
| 480 | 460 | |
| 481 | 461 | private function tramiteRecebimentoRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite) |
| ... | ... | @@ -489,18 +469,6 @@ class ReceberProcedimentoRN extends InfraRN |
| 489 | 469 | } |
| 490 | 470 | |
| 491 | 471 | |
| 492 | - private function documentoJaRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parStrHashComponenteDigital) | |
| 493 | - { | |
| 494 | - //Verifica se componente digital já está registrado para o documento | |
| 495 | - $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | |
| 496 | - $objComponenteDigitalDTO->setStrNumeroRegistro($parStrNumeroRegistro); | |
| 497 | - $objComponenteDigitalDTO->setStrHashConteudo($parStrHashComponenteDigital); | |
| 498 | - $objComponenteDigitalDTO->setNumIdAnexo(null, InfraDTO::$OPER_DIFERENTE); | |
| 499 | - | |
| 500 | - $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | |
| 501 | - return $objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0; | |
| 502 | - } | |
| 503 | - | |
| 504 | 472 | |
| 505 | 473 | private function consultarProcedimentoExistente($parStrNumeroRegistro, $parStrProtocolo = null) |
| 506 | 474 | { |
| ... | ... | @@ -520,7 +488,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 520 | 488 | return $dblIdProcedimento; |
| 521 | 489 | } |
| 522 | 490 | |
| 523 | - private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso, $parNumIdTramite, $parArrHashComponentes, $parArrHashComponentesPendentes) | |
| 491 | + private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso, $parNumIdTramite) | |
| 524 | 492 | { |
| 525 | 493 | if(!isset($parDblIdProcedimento)){ |
| 526 | 494 | throw new InfraException('Parâmetro $parDblIdProcedimento não informado.'); |
| ... | ... | @@ -530,7 +498,6 @@ class ReceberProcedimentoRN extends InfraRN |
| 530 | 498 | throw new InfraException('Parâmetro $objMetadadosProcedimento não informado.'); |
| 531 | 499 | } |
| 532 | 500 | |
| 533 | - | |
| 534 | 501 | if ($this->destinatarioReal) { |
| 535 | 502 | $objDestinatario = $this->destinatarioReal; |
| 536 | 503 | } else { |
| ... | ... | @@ -542,6 +509,8 @@ class ReceberProcedimentoRN extends InfraRN |
| 542 | 509 | $numIdUnidade = ProcessoEletronicoRN::obterUnidadeParaRegistroDocumento($parDblIdProcedimento); |
| 543 | 510 | SessaoSEI::getInstance()->setNumIdUnidadeAtual($numIdUnidade); |
| 544 | 511 | |
| 512 | + $objPenParametroRN = new PenParametroRN(); | |
| 513 | + | |
| 545 | 514 | try { |
| 546 | 515 | $objSeiRN = new SeiRN(); |
| 547 | 516 | $objAtividadeDTO = new AtividadeDTO(); |
| ... | ... | @@ -567,49 +536,49 @@ class ReceberProcedimentoRN extends InfraRN |
| 567 | 536 | $objProcedimentoRN = new ProcedimentoRN(); |
| 568 | 537 | $objProcedimentoDTO = $objProcedimentoRN->consultarRN0201($objProcedimentoDTO); |
| 569 | 538 | |
| 570 | - $this->registrarAndamentoRecebimentoProcesso($objProcedimentoDTO, $objMetadadosProcedimento); | |
| 571 | - | |
| 572 | 539 | if($flgReabrir){ |
| 573 | 540 | $objEntradaReabrirProcessoAPI = new EntradaReabrirProcessoAPI(); |
| 574 | 541 | $objEntradaReabrirProcessoAPI->setIdProcedimento($parDblIdProcedimento); |
| 575 | 542 | $objSeiRN->reabrirProcesso($objEntradaReabrirProcessoAPI); |
| 576 | 543 | } |
| 577 | 544 | |
| 578 | - //Cadastro das atividades para quando o destinatário é desviado pelo receptor (!3!) | |
| 579 | - if ($this->destinatarioReal->numeroDeIdentificacaoDaEstrutura) { | |
| 580 | - $this->gerarAndamentoUnidadeReceptora($parDblIdProcedimento); | |
| 581 | - } | |
| 582 | - | |
| 583 | 545 | ProcessoEletronicoRN::desbloquearProcesso($parDblIdProcedimento); |
| 584 | 546 | |
| 585 | - //TODO: Obter código da unidade através de mapeamento entre SEI e Barramento | |
| 586 | - $objUnidadeDTO = $this->atribuirDadosUnidade($objProcedimentoDTO, $objDestinatario); | |
| 547 | + $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 548 | + $this->enviarProcedimentoUnidade($objProcedimentoDTO, $numUnidadeReceptora); | |
| 549 | + | |
| 550 | + } finally { | |
| 551 | + $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 552 | + SessaoSEI::getInstance()->setNumIdUnidadeAtual($numUnidadeReceptora); | |
| 553 | + } | |
| 587 | 554 | |
| 588 | - $this->atribuirDocumentos($objProcedimentoDTO, $objProcesso, $objUnidadeDTO, $objMetadadosProcedimento); | |
| 555 | + $this->registrarAndamentoRecebimentoProcesso($objProcedimentoDTO, $objMetadadosProcedimento); | |
| 589 | 556 | |
| 590 | - $this->registrarProcedimentoNaoVisualizado($objProcedimentoDTO); | |
| 557 | + //Cadastro das atividades para quando o destinatário é desviado pelo receptor (!3!) | |
| 558 | + if ($this->destinatarioReal->numeroDeIdentificacaoDaEstrutura) { | |
| 559 | + $this->gerarAndamentoUnidadeReceptora($parDblIdProcedimento); | |
| 560 | + } | |
| 591 | 561 | |
| 592 | - //TODO: Avaliar necessidade de restringir referência circular entre processos | |
| 593 | - //TODO: Registrar que o processo foi recebido com outros apensados. Necessário para posterior reenvio | |
| 594 | - $this->atribuirProcessosApensados($objProcedimentoDTO, $objProcesso->processoApensado); | |
| 562 | + //TODO: Obter código da unidade através de mapeamento entre SEI e Barramento | |
| 563 | + $objUnidadeDTO = $this->atribuirDadosUnidade($objProcedimentoDTO, $objDestinatario); | |
| 595 | 564 | |
| 596 | - //Realiza a alteração dos metadados do processo | |
| 597 | - //TODO: Implementar alteração de todos os metadados | |
| 598 | - $this->alterarMetadadosProcedimento($objProcedimentoDTO->getDblIdProcedimento(), $objProcesso); | |
| 565 | + $this->atribuirDocumentos($objProcedimentoDTO, $objProcesso, $objUnidadeDTO, $objMetadadosProcedimento); | |
| 599 | 566 | |
| 600 | - //Finaliza o envio do documento para a respectiva unidade | |
| 601 | - //$this->enviarProcedimentoUnidade($objProcedimentoDTO, true); | |
| 567 | + $this->registrarProcedimentoNaoVisualizado($objProcedimentoDTO); | |
| 602 | 568 | |
| 603 | - return $objProcedimentoDTO; | |
| 569 | + //TODO: Avaliar necessidade de restringir referência circular entre processos | |
| 570 | + //TODO: Registrar que o processo foi recebido com outros apensados. Necessário para posterior reenvio | |
| 571 | + $this->atribuirProcessosApensados($objProcedimentoDTO, $objProcesso->processoApensado); | |
| 604 | 572 | |
| 605 | - } finally { | |
| 606 | - $objPenParametroRN = new PenParametroRN(); | |
| 607 | - $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 608 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numUnidadeReceptora); | |
| 609 | - } | |
| 610 | - } | |
| 573 | + //Realiza a alteração dos metadados do processo | |
| 574 | + //TODO: Implementar alteração de todos os metadados | |
| 575 | + $this->alterarMetadadosProcedimento($objProcedimentoDTO->getDblIdProcedimento(), $objProcesso); | |
| 611 | 576 | |
| 577 | + //Finaliza o envio do documento para a respectiva unidade | |
| 578 | + //$this->enviarProcedimentoUnidade($objProcedimentoDTO, true); | |
| 612 | 579 | |
| 580 | + return $objProcedimentoDTO; | |
| 581 | + } | |
| 613 | 582 | |
| 614 | 583 | |
| 615 | 584 | private function gerarAndamentoUnidadeReceptora($parNumIdProcedimento) |
| ... | ... | @@ -643,7 +612,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 643 | 612 | $objAtividadeRN->gerarInternaRN0727($objAtividadeDTO); |
| 644 | 613 | } |
| 645 | 614 | |
| 646 | - private function gerarProcedimento($objMetadadosProcedimento, $objProcesso, $parNumIdTramite, $parArrHashComponentes, $parArrHashComponentesPendentes) | |
| 615 | + private function gerarProcedimento($objMetadadosProcedimento, $objProcesso, $parNumIdTramite) | |
| 647 | 616 | { |
| 648 | 617 | if(!isset($objMetadadosProcedimento)){ |
| 649 | 618 | throw new InfraException('Parâmetro $objMetadadosProcedimento não informado.'); |
| ... | ... | @@ -791,18 +760,8 @@ class ReceberProcedimentoRN extends InfraRN |
| 791 | 760 | $objProtocoloDTO->setNumIdHipoteseLegal($this->obterHipoteseLegalSEI($parObjMetadadoProcedimento->hipoteseLegal->identificacao)); |
| 792 | 761 | } |
| 793 | 762 | |
| 794 | - //Esta unidade deverá ser considerada para posterior desbloqueio do processo e reabertura | |
| 795 | - $numIdUnidade = ProcessoEletronicoRN::obterUnidadeParaRegistroDocumento($parNumIdProcedimento); | |
| 796 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numIdUnidade); | |
| 797 | - | |
| 798 | - try{ | |
| 799 | - $objProtocoloRN = new ProtocoloRN(); | |
| 800 | - $objProtocoloRN->alterarRN0203($objProtocoloDTO); | |
| 801 | - } finally { | |
| 802 | - $objPenParametroRN = new PenParametroRN(); | |
| 803 | - $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 804 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numUnidadeReceptora); | |
| 805 | - } | |
| 763 | + $objProtocoloRN = new ProtocoloRN(); | |
| 764 | + $objProtocoloRN->alterarRN0203($objProtocoloDTO); | |
| 806 | 765 | } |
| 807 | 766 | |
| 808 | 767 | private function alterarMetadadosDocumento($parNumIdProcedimento, $parNumIdDocumento, $parObjMetadadoDocumento) |
| ... | ... | @@ -816,18 +775,8 @@ class ReceberProcedimentoRN extends InfraRN |
| 816 | 775 | $objProtocoloDTO->setNumIdHipoteseLegal($this->obterHipoteseLegalSEI($parObjMetadadoDocumento->hipoteseLegal->identificacao)); |
| 817 | 776 | } |
| 818 | 777 | |
| 819 | - //Esta unidade deverá ser considerada para posterior desbloqueio do processo e reabertura | |
| 820 | - $numIdUnidade = ProcessoEletronicoRN::obterUnidadeParaRegistroDocumento($parNumIdProcedimento); | |
| 821 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numIdUnidade); | |
| 822 | - | |
| 823 | - try{ | |
| 824 | - $objProtocoloRN = new ProtocoloRN(); | |
| 825 | - $objProtocoloRN->alterarRN0203($objProtocoloDTO); | |
| 826 | - } finally { | |
| 827 | - $objPenParametroRN = new PenParametroRN(); | |
| 828 | - $numUnidadeReceptora = $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); | |
| 829 | - SessaoSEI::getInstance()->setNumIdUnidadeAtual($numUnidadeReceptora); | |
| 830 | - } | |
| 778 | + $objProtocoloRN = new ProtocoloRN(); | |
| 779 | + $objProtocoloRN->alterarRN0203($objProtocoloDTO); | |
| 831 | 780 | } |
| 832 | 781 | |
| 833 | 782 | |
| ... | ... | @@ -1203,16 +1152,17 @@ class ReceberProcedimentoRN extends InfraRN |
| 1203 | 1152 | $objAtividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); |
| 1204 | 1153 | |
| 1205 | 1154 | //TODO: Possivelmente, essa regra é desnecessária já que o processo pode ser enviado para outra unidade do órgão através da expedição |
| 1206 | - $objAtividadeRN = new AtividadeRN(); | |
| 1207 | - if ($objAtividadeRN->contarRN0035($objAtividadeDTO) == 0) { | |
| 1208 | - throw new InfraException('Unidade '.$objUnidadeDTO->getStrSigla().' não possui acesso ao Procedimento '.$objProcedimentoDTO->getStrProtocoloProcedimentoFormatado().'.'); | |
| 1209 | - } | |
| 1155 | + //$objAtividadeRN = new AtividadeRN(); | |
| 1156 | + //if ($objAtividadeRN->contarRN0035($objAtividadeDTO) == 0) { | |
| 1157 | + // throw new InfraException('Unidade '.$objUnidadeDTO->getStrSigla().' não possui acesso ao Procedimento '.$objProcedimentoDTO->getStrProtocoloProcedimentoFormatado().'.'); | |
| 1158 | + //} | |
| 1210 | 1159 | |
| 1211 | 1160 | $objAtividadeDTO = new AtividadeDTO(); |
| 1212 | 1161 | $objAtividadeDTO->setDblIdProtocolo($objDocumentoDTO->getDblIdProcedimento()); |
| 1213 | 1162 | $objAtividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); |
| 1214 | 1163 | $objAtividadeDTO->setDthConclusao(null); |
| 1215 | 1164 | |
| 1165 | + $objAtividadeRN = new AtividadeRN(); | |
| 1216 | 1166 | if ($objAtividadeRN->contarRN0035($objAtividadeDTO) == 0) { |
| 1217 | 1167 | $objReabrirProcessoDTO = new ReabrirProcessoDTO(); |
| 1218 | 1168 | $objReabrirProcessoDTO->setDblIdProcedimento($objDocumentoDTO->getDblIdProcedimento()); |
| ... | ... | @@ -1555,23 +1505,34 @@ class ReceberProcedimentoRN extends InfraRN |
| 1555 | 1505 | $objAtividadeRN->atualizarVisualizacao($objAtividadeDTOVisualizacao); |
| 1556 | 1506 | } |
| 1557 | 1507 | |
| 1558 | - private function enviarProcedimentoUnidade(ProcedimentoDTO $parObjProcedimentoDTO, $retransmissao = false) | |
| 1508 | + private function enviarProcedimentoUnidade(ProcedimentoDTO $parObjProcedimentoDTO, $parUnidadeDestino=null, $retransmissao=false) | |
| 1559 | 1509 | { |
| 1560 | 1510 | $objAtividadeRN = new PenAtividadeRN(); |
| 1511 | + $objPenParametroRN = new PenParametroRN(); | |
| 1561 | 1512 | $objInfraException = new InfraException(); |
| 1562 | 1513 | |
| 1563 | - if(!$parObjProcedimentoDTO->isSetArrObjUnidadeDTO() || count($parObjProcedimentoDTO->getArrObjUnidadeDTO()) == 0) { | |
| 1564 | - $objInfraException->lancarValidacao('Unidade de destino do processo não informada.'); | |
| 1565 | - } | |
| 1514 | + $strEnviaEmailNotificacao = 'N'; | |
| 1515 | + $numIdUnidade = $parUnidadeDestino; | |
| 1566 | 1516 | |
| 1567 | - $arrObjUnidadeDTO = $parObjProcedimentoDTO->getArrObjUnidadeDTO(); | |
| 1517 | + //Caso a unidade de destino não tenha sido informada, considerar as unidades atribuídas ao processo | |
| 1518 | + if(is_null($numIdUnidade)){ | |
| 1519 | + if(!$parObjProcedimentoDTO->isSetArrObjUnidadeDTO() || count($parObjProcedimentoDTO->getArrObjUnidadeDTO()) == 0) { | |
| 1520 | + $objInfraException->lancarValidacao('Unidade de destino do processo não informada.'); | |
| 1521 | + } | |
| 1568 | 1522 | |
| 1569 | - if(count($parObjProcedimentoDTO->getArrObjUnidadeDTO()) > 1) { | |
| 1570 | - $objInfraException->lancarValidacao('Não permitido a indicação de múltiplas unidades de destino para um processo recebido externamente.'); | |
| 1523 | + $arrObjUnidadeDTO = $parObjProcedimentoDTO->getArrObjUnidadeDTO(); | |
| 1524 | + if(count($parObjProcedimentoDTO->getArrObjUnidadeDTO()) > 1) { | |
| 1525 | + $objInfraException->lancarValidacao('Não permitido a indicação de múltiplas unidades de destino para um processo recebido externamente.'); | |
| 1526 | + } | |
| 1527 | + | |
| 1528 | + $arrObjUnidadeDTO = array_values($parObjProcedimentoDTO->getArrObjUnidadeDTO()); | |
| 1529 | + $objUnidadeDTO = $arrObjUnidadeDTO[0]; | |
| 1530 | + $numIdUnidade = $objUnidadeDTO->getNumIdUnidade(); | |
| 1531 | + | |
| 1532 | + //Somente considera regra de envio de e-mail para unidades vinculadas ao processo | |
| 1533 | + $strEnviaEmailNotificacao = $objPenParametroRN->getParametro('PEN_ENVIA_EMAIL_NOTIFICACAO_RECEBIMENTO'); | |
| 1571 | 1534 | } |
| 1572 | 1535 | |
| 1573 | - $arrObjUnidadeDTO = array_values($parObjProcedimentoDTO->getArrObjUnidadeDTO()); | |
| 1574 | - $objUnidadeDTO = $arrObjUnidadeDTO[0]; | |
| 1575 | 1536 | |
| 1576 | 1537 | $objProcedimentoDTO = new ProcedimentoDTO(); |
| 1577 | 1538 | $objProcedimentoDTO->retDblIdProcedimento(); |
| ... | ... | @@ -1580,7 +1541,8 @@ class ReceberProcedimentoRN extends InfraRN |
| 1580 | 1541 | $objProcedimentoDTO->retNumIdTipoProcedimento(); |
| 1581 | 1542 | $objProcedimentoDTO->retStrNomeTipoProcedimento(); |
| 1582 | 1543 | $objProcedimentoDTO->retStrStaNivelAcessoGlobalProtocolo(); |
| 1583 | - $objProcedimentoDTO->setStrProtocoloProcedimentoFormatado($parObjProcedimentoDTO->getStrProtocoloProcedimentoFormatado()); | |
| 1544 | + $objProcedimentoDTO->setDblIdProcedimento($parObjProcedimentoDTO->getDblIdProcedimento()); | |
| 1545 | + | |
| 1584 | 1546 | |
| 1585 | 1547 | $objProcedimentoRN = new ProcedimentoRN(); |
| 1586 | 1548 | $objProcedimentoDTO = $objProcedimentoRN->consultarRN0201($objProcedimentoDTO); |
| ... | ... | @@ -1592,7 +1554,7 @@ class ReceberProcedimentoRN extends InfraRN |
| 1592 | 1554 | if ($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo()==ProtocoloRN::$NA_RESTRITO) { |
| 1593 | 1555 | $objAcessoDTO = new AcessoDTO(); |
| 1594 | 1556 | $objAcessoDTO->setDblIdProtocolo($objProcedimentoDTO->getDblIdProcedimento()); |
| 1595 | - $objAcessoDTO->setNumIdUnidade($objUnidadeDTO->getNumIdUnidade()); | |
| 1557 | + $objAcessoDTO->setNumIdUnidade($numIdUnidade); | |
| 1596 | 1558 | |
| 1597 | 1559 | $objAcessoRN = new AcessoRN(); |
| 1598 | 1560 | if ($objAcessoRN->contar($objAcessoDTO)==0) { |
| ... | ... | @@ -1628,7 +1590,6 @@ class ReceberProcedimentoRN extends InfraRN |
| 1628 | 1590 | |
| 1629 | 1591 | $objInfraException->lancarValidacoes(); |
| 1630 | 1592 | |
| 1631 | - | |
| 1632 | 1593 | $objEnviarProcessoDTO = new EnviarProcessoDTO(); |
| 1633 | 1594 | $objEnviarProcessoDTO->setArrAtividadesOrigem($arrObjProcedimentoDTO[0]->getArrObjAtividadeDTO()); |
| 1634 | 1595 | |
| ... | ... | @@ -1636,14 +1597,11 @@ class ReceberProcedimentoRN extends InfraRN |
| 1636 | 1597 | $objAtividadeDTO->setDblIdProtocolo($objProcedimentoDTO->getDblIdProcedimento()); |
| 1637 | 1598 | $objAtividadeDTO->setNumIdUsuario(null); |
| 1638 | 1599 | $objAtividadeDTO->setNumIdUsuarioOrigem(SessaoSEI::getInstance()->getNumIdUsuario()); |
| 1639 | - $objAtividadeDTO->setNumIdUnidade($objUnidadeDTO->getNumIdUnidade()); | |
| 1600 | + $objAtividadeDTO->setNumIdUnidade($numIdUnidade); | |
| 1640 | 1601 | $objAtividadeDTO->setNumIdUnidadeOrigem(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); |
| 1641 | 1602 | $objEnviarProcessoDTO->setArrAtividades(array($objAtividadeDTO)); |
| 1642 | 1603 | |
| 1643 | - $objPenParametroRN = new PenParametroRN(); | |
| 1644 | - | |
| 1645 | 1604 | $objEnviarProcessoDTO->setStrSinManterAberto('N'); |
| 1646 | - $strEnviaEmailNotificacao = $objPenParametroRN->getParametro('PEN_ENVIA_EMAIL_NOTIFICACAO_RECEBIMENTO'); | |
| 1647 | 1605 | $objEnviarProcessoDTO->setStrSinEnviarEmailNotificacao($strEnviaEmailNotificacao); |
| 1648 | 1606 | $objEnviarProcessoDTO->setStrSinRemoverAnotacoes('S'); |
| 1649 | 1607 | $objEnviarProcessoDTO->setDtaPrazo(null); |
| ... | ... | @@ -1894,4 +1852,77 @@ class ReceberProcedimentoRN extends InfraRN |
| 1894 | 1852 | InfraDebug::getInstance()->gravar($strLog); |
| 1895 | 1853 | } |
| 1896 | 1854 | |
| 1855 | + | |
| 1856 | + /** | |
| 1857 | + * Verifica se existe documentos com pendência de download de seus componentes digitais | |
| 1858 | + * @param [type] $parNumIdProcedimento Identificador do processo | |
| 1859 | + * @param [type] $parNumIdDocumento Identificador do documento | |
| 1860 | + * @param [type] $parStrHashComponenteDigital Hash do componente digital | |
| 1861 | + * @return [type] Indicação se existe pendência ou não | |
| 1862 | + */ | |
| 1863 | + private function documentosPendenteRegistro($parNumIdProcedimento, $parNumIdDocumento=null, $parStrHashComponenteDigital=null) | |
| 1864 | + { | |
| 1865 | + //Valida se algum documento ficou sem seus respectivos componentes digitais | |
| 1866 | + $sql = "select doc.id_documento as id_documento, comp.hash_conteudo as hash_conteudo | |
| 1867 | + from procedimento proc join documento doc on (doc.id_procedimento = proc.id_procedimento) | |
| 1868 | + join protocolo prot_doc on (doc.id_documento = prot_doc.id_protocolo) | |
| 1869 | + left join md_pen_componente_digital comp on (comp.id_documento = doc.id_documento) | |
| 1870 | + where proc.id_procedimento = $parNumIdProcedimento and prot_doc.sta_protocolo = 'R' and | |
| 1871 | + not exists (select 1 from anexo where anexo.id_protocolo = prot_doc.id_protocolo) "; | |
| 1872 | + | |
| 1873 | + //Adiciona filtro adicional para verificar pelo identificador do documento, caso parâmetro tenha sido informado | |
| 1874 | + if(!is_null($parNumIdDocumento)){ | |
| 1875 | + $sql .= " and doc.id_documento = $parNumIdDocumento"; | |
| 1876 | + } | |
| 1877 | + | |
| 1878 | + $recordset = $this->getObjInfraIBanco()->consultarSql($sql); | |
| 1879 | + | |
| 1880 | + $bolDocumentoPendente = !empty($recordset); | |
| 1881 | + | |
| 1882 | + //Verifica especificamente um determinado hash através da verificação do hash do componente, caso parâmetro tenha sido informado | |
| 1883 | + if($bolDocumentoPendente && !is_null($parStrHashComponenteDigital)) { | |
| 1884 | + foreach ($recordset as $item) { | |
| 1885 | + if(!is_null($item['hash_conteudo']) && $item['hash_conteudo'] === $parStrHashComponenteDigital){ | |
| 1886 | + $bolDocumentoPendente = true; | |
| 1887 | + return $bolDocumentoPendente; | |
| 1888 | + } | |
| 1889 | + } | |
| 1890 | + | |
| 1891 | + $bolDocumentoPendente = false; | |
| 1892 | + } | |
| 1893 | + | |
| 1894 | + return $bolDocumentoPendente; | |
| 1895 | + } | |
| 1896 | + | |
| 1897 | + /** | |
| 1898 | + * Validação de pós condições para garantir que nenhuma inconsistência foi identificada no recebimento do processo | |
| 1899 | + * | |
| 1900 | + * @param [type] $parObjMetadadosProcedimento Metadados do Protocolo | |
| 1901 | + * @param [type] $parObjProcedimentoDTO Dados do Processo gerado no recebimento | |
| 1902 | + */ | |
| 1903 | + private function validarPosCondicoesTramite($parObjMetadadosProcedimento, $parObjProcedimentoDTO) | |
| 1904 | + { | |
| 1905 | + $strMensagemPadrao = "Inconsistência identificada no recebimento de processo: \n"; | |
| 1906 | + $strMensagemErro = ""; | |
| 1907 | + | |
| 1908 | + //Valida se metadados do trâmite e do protocolo foram identificado | |
| 1909 | + if(is_null($parObjMetadadosProcedimento)){ | |
| 1910 | + $strMensagemErro = "- Metadados do trâmite não identificado. \n"; | |
| 1911 | + } | |
| 1912 | + | |
| 1913 | + //Valida se metadados do trâmite e do protocolo foram identificado | |
| 1914 | + if(is_null($parObjProcedimentoDTO)){ | |
| 1915 | + $strMensagemErro = "- Dados do processo não identificados \n"; | |
| 1916 | + } | |
| 1917 | + | |
| 1918 | + //Valida se algum documento ficou sem seus respectivos componentes digitais | |
| 1919 | + if($this->documentosPendenteRegistro($parObjProcedimentoDTO->getDblIdProcedimento())){ | |
| 1920 | + $strProtocoloFormatado = $parObjProcedimentoDTO->getStrProtocoloProcedimentoFormatado(); | |
| 1921 | + $strMensagemErro = "- Componente digital de pelo menos um dos documentos do processo [$strProtocoloFormatado] não pode ser recebido. \n"; | |
| 1922 | + } | |
| 1923 | + | |
| 1924 | + if(!InfraString::isBolVazia($strMensagemErro)){ | |
| 1925 | + throw new InfraException($strMensagemPadrao . $strMensagemErro); | |
| 1926 | + } | |
| 1927 | + } | |
| 1897 | 1928 | } | ... | ... |
verificar-servicos.sh
| ... | ... | @@ -1,43 +0,0 @@ |
| 1 | -#!/bin/bash | |
| 2 | - | |
| 3 | -PATH=/usr/bin:/sbin:/bin:/usr/sbin | |
| 4 | -export PATH | |
| 5 | - | |
| 6 | -GEARMAN=$(ls /etc/init.d | grep -owih gearman.*) | |
| 7 | -if [[ -z $GEARMAN ]]; then | |
| 8 | - echo "ERROR: Instalação do Gearman não pode ser localizada." | |
| 9 | - exit 1 | |
| 10 | -else | |
| 11 | - ps cax | grep -ih gearman.* > /dev/null | |
| 12 | - if [ $? -ne 0 ]; then | |
| 13 | - echo "Gearman: Iniciando serviço de gerenciamento de fila de tarefas..." | |
| 14 | - /etc/init.d/$GEARMAN start; | |
| 15 | - fi | |
| 16 | -fi | |
| 17 | - | |
| 18 | -SUPERVISOR=$(ls /etc/init.d | grep -owih supervisor.*) | |
| 19 | -if [[ -z $SUPERVISOR ]]; then | |
| 20 | - echo "ERROR: Instalação do Supervisor não pode ser localizada." | |
| 21 | - exit 1 | |
| 22 | -else | |
| 23 | - ps cax | grep -ih supervisor.* > /dev/null | |
| 24 | - if [ $? -ne 0 ]; then | |
| 25 | - echo "Supervisor: Iniciando serviço de monitoramento dos processos de integração..." | |
| 26 | - /etc/init.d/$SUPERVISOR start; | |
| 27 | - else | |
| 28 | - | |
| 29 | - COMMAND=$(ps -C php -f | grep -o "PendenciasTramiteRN.php"); | |
| 30 | - if [ -z "$COMMAND" ]; then | |
| 31 | - echo "Supervisor: Reiniciando serviço de monitoramento dos processos de integração..." | |
| 32 | - /etc/init.d/$SUPERVISOR stop; | |
| 33 | - /etc/init.d/$SUPERVISOR start; | |
| 34 | - fi | |
| 35 | - | |
| 36 | - COMMAND=$(ps -C php -f | grep -o "ProcessarPendenciasRN.php"); | |
| 37 | - if [ -z "$COMMAND" ]; then | |
| 38 | - echo "Supervisor: Reiniciando serviço de monitoramento dos processos de integração..." | |
| 39 | - /etc/init.d/$SUPERVISOR stop; | |
| 40 | - /etc/init.d/$SUPERVISOR start; | |
| 41 | - fi | |
| 42 | - fi | |
| 43 | -fi |