Commit ce667e82f4ccc920632a50c63606563d81463f55
1 parent
81d62914
Exists in
master
and in
19 other branches
[Fixed #38] Padronização do formato de envio de documento sem link do Número SEI
Showing
1 changed file
with
249 additions
and
212 deletions
Show diff stats
rn/ExpedirProcedimentoRN.php
| ... | ... | @@ -117,150 +117,147 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 117 | 117 | return $this->objProcessoEletronicoRN->consultarMotivosUrgencia(); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public function expedirProcedimentoControlado(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) | |
| 121 | - { | |
| 120 | + public function expedirProcedimentoControlado(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) | |
| 121 | + { | |
| 122 | + $numIdTramite = 0; | |
| 123 | + try { | |
| 124 | + //Valida Permissão | |
| 125 | + SessaoSEI::getInstance()->validarAuditarPermissao('pen_procedimento_expedir',__METHOD__, $objExpedirProcedimentoDTO); | |
| 126 | + $dblIdProcedimento = $objExpedirProcedimentoDTO->getDblIdProcedimento(); | |
| 122 | 127 | |
| 123 | - $numIdTramite = 0; | |
| 128 | + $this->barraProgresso->exibir(); | |
| 129 | + //Valida regras de negócio | |
| 130 | + $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_VALIDACAO); | |
| 131 | + $this->barraProgresso->setStrRotulo(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_VALIDACAO); | |
| 124 | 132 | |
| 125 | - try { | |
| 126 | - //Valida Permissão | |
| 127 | - SessaoSEI::getInstance()->validarAuditarPermissao('pen_procedimento_expedir',__METHOD__, $objExpedirProcedimentoDTO); | |
| 128 | - $dblIdProcedimento = $objExpedirProcedimentoDTO->getDblIdProcedimento(); | |
| 133 | + $objInfraException = new InfraException(); | |
| 134 | + //Carregamento dos dados de processo e documento para validação e envio externo | |
| 135 | + $objProcedimentoDTO = $this->consultarProcedimento($dblIdProcedimento); | |
| 136 | + $objProcedimentoDTO->setArrObjDocumentoDTO($this->listarDocumentos($dblIdProcedimento)); | |
| 137 | + $objProcedimentoDTO->setArrObjParticipanteDTO($this->listarInteressados($dblIdProcedimento)); | |
| 138 | + $this->validarPreCondicoesExpedirProcedimento($objInfraException, $objProcedimentoDTO); | |
| 139 | + $this->validarParametrosExpedicao($objInfraException, $objExpedirProcedimentoDTO); | |
| 129 | 140 | |
| 130 | - $this->barraProgresso->exibir(); | |
| 131 | - //Valida regras de negócio | |
| 132 | - $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_VALIDACAO); | |
| 133 | - $this->barraProgresso->setStrRotulo(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_VALIDACAO); | |
| 134 | - | |
| 135 | - $objInfraException = new InfraException(); | |
| 136 | - //Carregamento dos dados de processo e documento para validação e envio externo | |
| 137 | - $objProcedimentoDTO = $this->consultarProcedimento($dblIdProcedimento); | |
| 138 | - $objProcedimentoDTO->setArrObjDocumentoDTO($this->listarDocumentos($dblIdProcedimento)); | |
| 139 | - $objProcedimentoDTO->setArrObjParticipanteDTO($this->listarInteressados($dblIdProcedimento)); | |
| 140 | - $this->validarPreCondicoesExpedirProcedimento($objInfraException, $objProcedimentoDTO); | |
| 141 | - $this->validarParametrosExpedicao($objInfraException, $objExpedirProcedimentoDTO); | |
| 142 | 141 | //Apresentao da mensagens de validao na janela da barra de progresso |
| 143 | - if($objInfraException->contemValidacoes()){ | |
| 144 | - $this->barraProgresso->mover(0); | |
| 145 | - $this->barraProgresso->setStrRotulo('Erro durante validação dos dados do processo.'); | |
| 146 | - $objInfraException->lancarValidacoes(); | |
| 147 | - } | |
| 142 | + if($objInfraException->contemValidacoes()){ | |
| 143 | + $this->barraProgresso->mover(0); | |
| 144 | + $this->barraProgresso->setStrRotulo('Erro durante validação dos dados do processo.'); | |
| 145 | + $objInfraException->lancarValidacoes(); | |
| 146 | + } | |
| 148 | 147 | |
| 149 | - $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_PROCEDIMENTO); | |
| 150 | - $this->barraProgresso->setStrRotulo(sprintf(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_PROCEDIMENTO, $objProcedimentoDTO->getStrProtocoloProcedimentoFormatado())); | |
| 151 | - //Construo dos cabecalho para envio do processo | |
| 152 | - $objCabecalho = $this->construirCabecalho($objExpedirProcedimentoDTO); | |
| 148 | + $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_PROCEDIMENTO); | |
| 149 | + $this->barraProgresso->setStrRotulo(sprintf(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_PROCEDIMENTO, $objProcedimentoDTO->getStrProtocoloProcedimentoFormatado())); | |
| 153 | 150 | |
| 154 | - //Construo do processo para envio | |
| 155 | - $objProcesso = $this->construirProcesso($dblIdProcedimento, $objExpedirProcedimentoDTO->getArrIdProcessoApensado()); | |
| 151 | + //Construo dos cabecalho para envio do processo | |
| 152 | + $objCabecalho = $this->construirCabecalho($objExpedirProcedimentoDTO); | |
| 156 | 153 | |
| 157 | - try { | |
| 154 | + //Construo do processo para envio | |
| 155 | + $objProcesso = $this->construirProcesso($dblIdProcedimento, $objExpedirProcedimentoDTO->getArrIdProcessoApensado()); | |
| 158 | 156 | |
| 157 | + try { | |
| 158 | + $param = new stdClass(); | |
| 159 | + $param->novoTramiteDeProcesso = new stdClass(); | |
| 160 | + $param->novoTramiteDeProcesso->cabecalho = $objCabecalho; | |
| 161 | + $param->novoTramiteDeProcesso->processo = $objProcesso; | |
| 162 | + $novoTramite = $this->objProcessoEletronicoRN->enviarProcesso($param); | |
| 163 | + $numIdTramite = $novoTramite->dadosTramiteDeProcessoCriado->IDT; | |
| 159 | 164 | |
| 160 | - $param = new stdClass(); | |
| 161 | - $param->novoTramiteDeProcesso = new stdClass(); | |
| 162 | - $param->novoTramiteDeProcesso->cabecalho = $objCabecalho; | |
| 163 | - $param->novoTramiteDeProcesso->processo = $objProcesso; | |
| 164 | - $novoTramite = $this->objProcessoEletronicoRN->enviarProcesso($param); | |
| 165 | - $numIdTramite = $novoTramite->dadosTramiteDeProcessoCriado->IDT; | |
| 165 | + } catch (\Exception $e) { | |
| 166 | + throw new InfraException("Error Processing Request", $e); | |
| 167 | + } | |
| 166 | 168 | |
| 167 | - } catch (\Exception $e) { | |
| 168 | - throw new InfraException("Error Processing Request", $e); | |
| 169 | - } | |
| 169 | + $this->atualizarPenProtocolo($dblIdProcedimento); | |
| 170 | 170 | |
| 171 | - $this->atualizarPenProtocolo($dblIdProcedimento); | |
| 172 | - if (isset($novoTramite->dadosTramiteDeProcessoCriado)) { | |
| 173 | - $objTramite = $novoTramite->dadosTramiteDeProcessoCriado; | |
| 174 | - $this->objProcedimentoAndamentoRN->setOpts($objTramite->NRE, $objTramite->IDT, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO), $dblIdProcedimento); | |
| 175 | - try { | |
| 171 | + if (isset($novoTramite->dadosTramiteDeProcessoCriado)) { | |
| 172 | + $objTramite = $novoTramite->dadosTramiteDeProcessoCriado; | |
| 173 | + $this->objProcedimentoAndamentoRN->setOpts($objTramite->NRE, $objTramite->IDT, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO), $dblIdProcedimento); | |
| 176 | 174 | |
| 177 | - $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Envio do metadados do processo', 'S')); | |
| 178 | - $idAtividadeExpedicao = $this->bloquearProcedimentoExpedicao($objExpedirProcedimentoDTO, $objProcesso->idProcedimentoSEI); | |
| 175 | + try { | |
| 176 | + $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Envio do metadados do processo', 'S')); | |
| 177 | + $idAtividadeExpedicao = $this->bloquearProcedimentoExpedicao($objExpedirProcedimentoDTO, $objProcesso->idProcedimentoSEI); | |
| 179 | 178 | |
| 179 | + $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso( | |
| 180 | + $objProcesso->idProcedimentoSEI, | |
| 181 | + $objTramite->NRE, | |
| 182 | + $objTramite->IDT, | |
| 183 | + ProcessoEletronicoRN::$STA_TIPO_TRAMITE_ENVIO, | |
| 184 | + $objTramite->dataHoraDeRegistroDoTramite, | |
| 185 | + $objExpedirProcedimentoDTO->getNumIdRepositorioOrigem(), | |
| 186 | + $objExpedirProcedimentoDTO->getNumIdUnidadeOrigem(), | |
| 187 | + $objExpedirProcedimentoDTO->getNumIdRepositorioDestino(), | |
| 188 | + $objExpedirProcedimentoDTO->getNumIdUnidadeDestino(), | |
| 189 | + $objProcesso, | |
| 190 | + $objTramite->ticketParaEnvioDeComponentesDigitais, | |
| 191 | + $objTramite->componentesDigitaisSolicitados); | |
| 180 | 192 | |
| 181 | - $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso( | |
| 182 | - $objProcesso->idProcedimentoSEI, | |
| 183 | - $objTramite->NRE, | |
| 184 | - $objTramite->IDT, | |
| 185 | - ProcessoEletronicoRN::$STA_TIPO_TRAMITE_ENVIO, | |
| 186 | - $objTramite->dataHoraDeRegistroDoTramite, | |
| 187 | - $objExpedirProcedimentoDTO->getNumIdRepositorioOrigem(), | |
| 188 | - $objExpedirProcedimentoDTO->getNumIdUnidadeOrigem(), | |
| 189 | - $objExpedirProcedimentoDTO->getNumIdRepositorioDestino(), | |
| 190 | - $objExpedirProcedimentoDTO->getNumIdUnidadeDestino(), | |
| 191 | - $objProcesso, | |
| 192 | - $objTramite->ticketParaEnvioDeComponentesDigitais, | |
| 193 | - $objTramite->componentesDigitaisSolicitados); | |
| 194 | 193 | |
| 194 | + $this->objProcessoEletronicoRN->cadastrarTramitePendente($objTramite->IDT, $idAtividadeExpedicao); | |
| 195 | + //error_log('TRAMITE: ' . print_r($objTramite, true)); | |
| 196 | + //error_log('before enviarComponentesDigitais'); | |
| 195 | 197 | |
| 196 | - $this->objProcessoEletronicoRN->cadastrarTramitePendente($objTramite->IDT, $idAtividadeExpedicao); | |
| 197 | - //error_log('TRAMITE: ' . print_r($objTramite, true)); | |
| 198 | - //error_log('before enviarComponentesDigitais'); | |
| 198 | + //TODO: Erro no BARRAMENTO: Processo no pode ser enviado se possuir 2 documentos iguais(mesmo hash) | |
| 199 | + //TODO: Melhoria no barramento de servios. O mtodo solicitar metadados no deixa claro quais os componentes digitais que | |
| 200 | + //precisam ser baixados. No cenrio de retorno de um processo existente, a nica forma consultar o status do trâmite para | |
| 201 | + //saber quais precisam ser baixados. O processo poderia ser mais otimizado se o retorno nos metadados j informasse quais os | |
| 202 | + //componentes precisam ser baixados, semelhante ao que ocorre no enviarProcesso onde o barramento informa quais os componentes | |
| 203 | + //que precisam ser enviados | |
| 199 | 204 | |
| 200 | - //TODO: Erro no BARRAMENTO: Processo no pode ser enviado se possuir 2 documentos iguais(mesmo hash) | |
| 201 | - //TODO: Melhoria no barramento de servios. O mtodo solicitar metadados no deixa claro quais os componentes digitais que | |
| 202 | - //precisam ser baixados. No cenrio de retorno de um processo existente, a nica forma consultar o status do trâmite para | |
| 203 | - //saber quais precisam ser baixados. O processo poderia ser mais otimizado se o retorno nos metadados j informasse quais os | |
| 204 | - //componentes precisam ser baixados, semelhante ao que ocorre no enviarProcesso onde o barramento informa quais os componentes | |
| 205 | - //que precisam ser enviados | |
| 205 | + $this->enviarComponentesDigitais($objTramite->NRE, $objTramite->IDT, $objProcesso->protocolo); | |
| 206 | + //error_log('after enviarComponentesDigitais'); | |
| 207 | + //$strNumeroRegistro, $numIdTramite, $strProtocolo | |
| 208 | + //error_log('==========================>>>>' . print_r($objTramite, true)); | |
| 206 | 209 | |
| 207 | - $this->enviarComponentesDigitais($objTramite->NRE, $objTramite->IDT, $objProcesso->protocolo); | |
| 208 | - //error_log('after enviarComponentesDigitais'); | |
| 209 | - //$strNumeroRegistro, $numIdTramite, $strProtocolo | |
| 210 | - //error_log('==========================>>>>' . print_r($objTramite, true)); | |
| 210 | + //TODO: Ao enviar o processo e seus documentos, necessrio bloquear os documentos para alterao | |
| 211 | + //pois eles j foram visualizados | |
| 212 | + //$objDocumentoRN = new DocumentoRN(); | |
| 213 | + //$objDocumentoRN->bloquearConsultado($objDocumentoRN->consultarRN0005($objDocumentoDTO)); | |
| 211 | 214 | |
| 212 | - //TODO: Ao enviar o processo e seus documentos, necessrio bloquear os documentos para alterao | |
| 213 | - //pois eles j foram visualizados | |
| 214 | - //$objDocumentoRN = new DocumentoRN(); | |
| 215 | - //$objDocumentoRN->bloquearConsultado($objDocumentoRN->consultarRN0005($objDocumentoDTO)); | |
| 216 | 215 | |
| 216 | + //TODO: Implementar o registro de auditoria, armazenando os metadados xml enviados para o PEN | |
| 217 | 217 | |
| 218 | - //TODO: Implementar o registro de auditoria, armazenando os metadados xml enviados para o PEN | |
| 219 | 218 | |
| 220 | - //return ; | |
| 219 | + # $this->enviarDocProdimentoTramite(); | |
| 220 | + // $this->gravarAuditoria(__METHOD__ , $objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 221 | + //$this->bloquearProcesso($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 222 | + #$this->enviarDocProdimentoTramite(); | |
| 223 | + //return array('mensagem' => 'Processo em expedio!', 'retorno' => 1); | |
| 221 | 224 | |
| 222 | - # $this->enviarDocProdimentoTramite(); | |
| 223 | - // $this->gravarAuditoria(__METHOD__ , $objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 224 | - //$this->bloquearProcesso($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 225 | - #$this->enviarDocProdimentoTramite(); | |
| 226 | - //return array('mensagem' => 'Processo em expedio!', 'retorno' => 1); | |
| 225 | + //TODO: Alterar atualizao para somente apresentar ao final de todo o trâmite | |
| 226 | + $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_CONCLUSAO); | |
| 227 | + $this->barraProgresso->setStrRotulo(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_CONCLUSAO); | |
| 227 | 228 | |
| 228 | - //TODO: Alterar atualizao para somente apresentar ao final de todo o trâmite | |
| 229 | - $this->barraProgresso->mover(ProcessoEletronicoINT::NEE_EXPEDICAO_ETAPA_CONCLUSAO); | |
| 230 | - $this->barraProgresso->setStrRotulo(ProcessoEletronicoINT::TEE_EXPEDICAO_ETAPA_CONCLUSAO); | |
| 229 | + // @join_tec US008.06 (#23092) | |
| 230 | + $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Concluído envio dos componentes do processo', 'S')); | |
| 231 | 231 | |
| 232 | - // @join_tec US008.06 (#23092) | |
| 233 | - $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Concluído envio dos componentes do processo', 'S')); | |
| 232 | + $this->receberReciboDeEnvio($objTramite->IDT); | |
| 233 | + } | |
| 234 | + catch (\Exception $e) { | |
| 235 | + //@TODO: Melhorar essa estrutura | |
| 236 | + //Realiza o desbloqueio do processo | |
| 237 | + try{ $this->desbloquearProcessoExpedicao($objProcesso->idProcedimentoSEI); } catch (InfraException $ex) { } | |
| 238 | + | |
| 239 | + //@TODO: Melhorar essa estrutura | |
| 240 | + //Realiza o cancelamento do tramite | |
| 241 | + try{ | |
| 242 | + if($numIdTramite != 0){ | |
| 243 | + $this->objProcessoEletronicoRN->cancelarTramite($numIdTramite); | |
| 244 | + } | |
| 245 | + } catch (InfraException $ex) { } | |
| 246 | + | |
| 247 | + $this->registrarAndamentoExpedicaoAbortada($objProcesso->idProcedimentoSEI); | |
| 248 | + | |
| 249 | + // @join_tec US008.06 (#23092) | |
| 250 | + $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Concluído envio dos componentes do processo', 'N')); | |
| 251 | + throw $e; | |
| 252 | + } | |
| 253 | + } | |
| 234 | 254 | |
| 235 | - $this->receberReciboDeEnvio($objTramite->IDT); | |
| 255 | + } catch (\Exception $e) { | |
| 256 | + throw new InfraException('Falha de comunicação com o serviços de integração. Por favor, tente novamente mais tarde.', $e); | |
| 236 | 257 | } |
| 237 | - catch (\Exception $e) { | |
| 238 | - //@TODO: Melhorar essa estrutura | |
| 239 | - //Realiza o desbloqueio do processo | |
| 240 | - try{ | |
| 241 | - $this->desbloquearProcessoExpedicao($objProcesso->idProcedimentoSEI); | |
| 242 | - } catch (InfraException $ex) { } | |
| 243 | - | |
| 244 | - //@TODO: Melhorar essa estrutura | |
| 245 | - //Realiza o cancelamento do tramite | |
| 246 | - try{ | |
| 247 | - if($numIdTramite != 0){ | |
| 248 | - $this->objProcessoEletronicoRN->cancelarTramite($numIdTramite); | |
| 249 | - } | |
| 250 | - } catch (InfraException $ex) { } | |
| 258 | + } | |
| 251 | 259 | |
| 252 | - $this->registrarAndamentoExpedicaoAbortada($objProcesso->idProcedimentoSEI); | |
| 253 | 260 | |
| 254 | - // @join_tec US008.06 (#23092) | |
| 255 | - $this->objProcedimentoAndamentoRN->cadastrar(ProcedimentoAndamentoDTO::criarAndamento('Concluído envio dos componentes do processo', 'N')); | |
| 256 | - throw $e; | |
| 257 | - } | |
| 258 | - } | |
| 259 | - | |
| 260 | - } catch (\Exception $e) { | |
| 261 | - throw new InfraException('Falha de comunicação com o serviços de integração. Por favor, tente novamente mais tarde.', $e); | |
| 262 | - } | |
| 263 | - } | |
| 264 | 261 | |
| 265 | 262 | private function registrarAndamentoExpedicaoProcesso($objExpedirProcedimentoDTO, $objProcesso) |
| 266 | 263 | { |
| ... | ... | @@ -322,90 +319,85 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 322 | 319 | $this->registrarAndamentoExpedicaoProcesso($objExpedirProcedimentoDTO, $objProcessoApensado); |
| 323 | 320 | } |
| 324 | 321 | } |
| 325 | - | |
| 326 | - | |
| 327 | 322 | } |
| 328 | 323 | |
| 329 | - private function construirCabecalho(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) | |
| 330 | - { | |
| 331 | - if(!isset($objExpedirProcedimentoDTO)){ | |
| 332 | - throw new InfraException('Parâmetro $objExpedirProcedimentoDTO não informado.'); | |
| 333 | - } | |
| 324 | + private function construirCabecalho(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) | |
| 325 | + { | |
| 326 | + if(!isset($objExpedirProcedimentoDTO)){ | |
| 327 | + throw new InfraException('Parâmetro $objExpedirProcedimentoDTO não informado.'); | |
| 328 | + } | |
| 334 | 329 | |
| 335 | - //Obtenção do nmero de registro eletrônico do processo | |
| 336 | - $strNumeroRegistro = null; | |
| 337 | - $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | |
| 338 | - $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | |
| 339 | - $objProcessoEletronicoDTO->setDblIdProcedimento($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 330 | + //Obtenção do número de registro eletrônico do processo | |
| 331 | + $strNumeroRegistro = null; | |
| 332 | + $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | |
| 333 | + $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | |
| 334 | + $objProcessoEletronicoDTO->setDblIdProcedimento($objExpedirProcedimentoDTO->getDblIdProcedimento()); | |
| 340 | 335 | //TODO: Tratar situao de quando localizado dois registros para o mesmo processo |
| 341 | - $objProcessoEletronicoDTO->setNumMaxRegistrosRetorno(1); | |
| 342 | - $objProcessoEletronicoDTO->setOrd('IdProcedimento', InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 343 | - $objProcessoEletronicoDTO->retStrNumeroRegistro(); | |
| 344 | - | |
| 345 | - $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | |
| 346 | - if(isset($objProcessoEletronicoDTO)) { | |
| 347 | - $strNumeroRegistro = $objProcessoEletronicoDTO->getStrNumeroRegistro(); | |
| 348 | - } | |
| 349 | - | |
| 350 | - // Consultar se processo eletrônico existe no PEN algum trâmite CANCELADO, caso | |
| 351 | - // sim deve ser gerada uma nova NRE, pois a atual ser recusada pelo PEN quando | |
| 352 | - // for enviado | |
| 353 | - /* if(!InfraString::isBolVazia($strNumeroRegistro)) { | |
| 354 | - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites(null, $strNumeroRegistro); | |
| 355 | - if(!empty($arrObjTramite) && is_array($arrObjTramite) && count($arrObjTramite) === 1) { | |
| 356 | - $objTramite = current($arrObjTramite); | |
| 357 | - if($objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_CANCELADO || $objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO){ | |
| 358 | - $strNumeroRegistro = null; | |
| 359 | - } | |
| 336 | + $objProcessoEletronicoDTO->setNumMaxRegistrosRetorno(1); | |
| 337 | + $objProcessoEletronicoDTO->setOrd('IdProcedimento', InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 338 | + $objProcessoEletronicoDTO->retStrNumeroRegistro(); | |
| 339 | + | |
| 340 | + $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | |
| 341 | + if(isset($objProcessoEletronicoDTO)) { | |
| 342 | + $strNumeroRegistro = $objProcessoEletronicoDTO->getStrNumeroRegistro(); | |
| 360 | 343 | } |
| 361 | - } */ | |
| 362 | 344 | |
| 345 | + // Consultar se processo eletrônico existe no PEN algum trâmite CANCELADO, caso | |
| 346 | + // sim deve ser gerada uma nova NRE, pois a atual ser recusada pelo PEN quando | |
| 347 | + // for enviado | |
| 348 | + /* if(!InfraString::isBolVazia($strNumeroRegistro)) { | |
| 349 | + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites(null, $strNumeroRegistro); | |
| 350 | + if(!empty($arrObjTramite) && is_array($arrObjTramite) && count($arrObjTramite) === 1) { | |
| 351 | + $objTramite = current($arrObjTramite); | |
| 352 | + if($objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_CANCELADO || $objTramite->situacaoAtual == ProcessoeletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO){ | |
| 353 | + $strNumeroRegistro = null; | |
| 354 | + } | |
| 355 | + } | |
| 356 | + } */ | |
| 357 | + | |
| 358 | + return $this->objProcessoEletronicoRN->construirCabecalho( | |
| 359 | + $strNumeroRegistro, | |
| 360 | + $objExpedirProcedimentoDTO->getNumIdRepositorioOrigem(), | |
| 361 | + $objExpedirProcedimentoDTO->getNumIdUnidadeOrigem(), | |
| 362 | + $objExpedirProcedimentoDTO->getNumIdRepositorioDestino(), | |
| 363 | + $objExpedirProcedimentoDTO->getNumIdUnidadeDestino(), | |
| 364 | + $objExpedirProcedimentoDTO->getBolSinUrgente(), | |
| 365 | + $objExpedirProcedimentoDTO->getNumIdMotivoUrgencia(), | |
| 366 | + false /*obrigarEnvioDeTodosOsComponentesDigitais*/ | |
| 367 | + ); | |
| 368 | + } | |
| 363 | 369 | |
| 364 | - return $this->objProcessoEletronicoRN->construirCabecalho( | |
| 365 | - //TODO: Desabilitado consulta do NRE para questes de teste | |
| 366 | - $strNumeroRegistro, | |
| 367 | - $objExpedirProcedimentoDTO->getNumIdRepositorioOrigem(), | |
| 368 | - $objExpedirProcedimentoDTO->getNumIdUnidadeOrigem(), | |
| 369 | - $objExpedirProcedimentoDTO->getNumIdRepositorioDestino(), | |
| 370 | - $objExpedirProcedimentoDTO->getNumIdUnidadeDestino(), | |
| 371 | - $objExpedirProcedimentoDTO->getBolSinUrgente(), | |
| 372 | - $objExpedirProcedimentoDTO->getNumIdMotivoUrgencia(), | |
| 373 | - false /*obrigarEnvioDeTodosOsComponentesDigitais*/); | |
| 370 | + private function construirProcesso($dblIdProcedimento, $arrIdProcessoApensado = null) | |
| 371 | + { | |
| 372 | + if(!isset($dblIdProcedimento)){ | |
| 373 | + throw new InfraException('Parâmetro $dblIdProcedimento não informado.'); | |
| 374 | + } | |
| 374 | 375 | |
| 375 | - } | |
| 376 | + //TODO: Passar dados do ProcedimentoDTO via parâmetro j carregado anteriormente | |
| 377 | + $objProcedimentoDTO = $this->consultarProcedimento($dblIdProcedimento); | |
| 378 | + $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN(); | |
| 379 | + | |
| 380 | + $objProcesso = new stdClass(); | |
| 381 | + $objProcesso->protocolo = utf8_encode($objProcedimentoDTO->getStrProtocoloProcedimentoFormatado()); | |
| 382 | + $objProcesso->nivelDeSigilo = $this->obterNivelSigiloPEN($objProcedimentoDTO->getStrStaNivelAcessoLocalProtocolo()); | |
| 383 | + $objProcesso->processoDeNegocio = utf8_encode($objProcedimentoDTO->getStrNomeTipoProcedimento()); | |
| 384 | + $objProcesso->descricao = utf8_encode($objProcedimentoDTO->getStrDescricaoProtocolo()); | |
| 385 | + $objProcesso->dataHoraDeProducao = $this->objProcessoEletronicoRN->converterDataWebService($objProcedimentoDTO->getDtaGeracaoProtocolo()); | |
| 386 | + if($objProcedimentoDTO->getStrStaNivelAcessoLocalProtocolo() == ProtocoloRN::$NA_RESTRITO){ | |
| 387 | + $objProcesso->hipoteseLegal = new stdClass(); | |
| 388 | + $objProcesso->hipoteseLegal->identificacao = $objPenRelHipoteseLegalRN->getIdHipoteseLegalPEN($objProcedimentoDTO->getNumIdHipoteseLegalProtocolo()); | |
| 389 | + } | |
| 376 | 390 | |
| 377 | - private function construirProcesso($dblIdProcedimento, $arrIdProcessoApensado = null) | |
| 378 | - { | |
| 391 | + $this->atribuirProdutorProcesso($objProcesso, $objProcedimentoDTO->getNumIdUsuarioGeradorProtocolo(), $objProcedimentoDTO->getNumIdUnidadeGeradoraProtocolo()); | |
| 392 | + $this->atribuirDataHoraDeRegistro($objProcesso, $objProcedimentoDTO->getDblIdProcedimento()); | |
| 393 | + $this->atribuirDocumentos($objProcesso, $dblIdProcedimento); | |
| 394 | + $this->atribuirDadosInteressados($objProcesso, $dblIdProcedimento); | |
| 395 | + $this->adicionarProcessosApensados($objProcesso, $arrIdProcessoApensado); | |
| 379 | 396 | |
| 380 | - if(!isset($dblIdProcedimento)){ | |
| 381 | - throw new InfraException('Parâmetro $dblIdProcedimento não informado.'); | |
| 397 | + $objProcesso->idProcedimentoSEI = $dblIdProcedimento; | |
| 398 | + return $objProcesso; | |
| 382 | 399 | } |
| 383 | 400 | |
| 384 | - //TODO: Passar dados do ProcedimentoDTO via parâmetro j carregado anteriormente | |
| 385 | - $objProcedimentoDTO = $this->consultarProcedimento($dblIdProcedimento); | |
| 386 | - $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN(); | |
| 387 | - $objProcesso = new stdClass(); | |
| 388 | - $objProcesso->protocolo = utf8_encode($objProcedimentoDTO->getStrProtocoloProcedimentoFormatado()); | |
| 389 | - $objProcesso->nivelDeSigilo = $this->obterNivelSigiloPEN($objProcedimentoDTO->getStrStaNivelAcessoLocalProtocolo()); | |
| 390 | - $objProcesso->processoDeNegocio = utf8_encode($objProcedimentoDTO->getStrNomeTipoProcedimento()); | |
| 391 | - $objProcesso->descricao = utf8_encode($objProcedimentoDTO->getStrDescricaoProtocolo()); | |
| 392 | - $objProcesso->dataHoraDeProducao = $this->objProcessoEletronicoRN->converterDataWebService($objProcedimentoDTO->getDtaGeracaoProtocolo()); | |
| 393 | - if($objProcedimentoDTO->getStrStaNivelAcessoLocalProtocolo() == ProtocoloRN::$NA_RESTRITO){ | |
| 394 | - $objProcesso->hipoteseLegal = new stdClass(); | |
| 395 | - $objProcesso->hipoteseLegal->identificacao = $objPenRelHipoteseLegalRN->getIdHipoteseLegalPEN($objProcedimentoDTO->getNumIdHipoteseLegalProtocolo()); | |
| 396 | - } | |
| 397 | - $this->atribuirProdutorProcesso($objProcesso, | |
| 398 | - $objProcedimentoDTO->getNumIdUsuarioGeradorProtocolo(), | |
| 399 | - $objProcedimentoDTO->getNumIdUnidadeGeradoraProtocolo()); | |
| 400 | - $this->atribuirDataHoraDeRegistro($objProcesso, $objProcedimentoDTO->getDblIdProcedimento()); | |
| 401 | - | |
| 402 | - $this->atribuirDocumentos($objProcesso, $dblIdProcedimento); | |
| 403 | - $this->atribuirDadosInteressados($objProcesso, $dblIdProcedimento); | |
| 404 | - $this->adicionarProcessosApensados($objProcesso, $arrIdProcessoApensado); | |
| 405 | - $objProcesso->idProcedimentoSEI = $dblIdProcedimento; | |
| 406 | - return $objProcesso; | |
| 407 | - } | |
| 408 | - | |
| 409 | 401 | //TODO: Implementar mapeamento de atividades que sero enviadas para barramento (semelhante Protocolo Integrado) |
| 410 | 402 | private function atribuirDadosHistorico($objProcesso, $dblIdProcedimento) |
| 411 | 403 | { |
| ... | ... | @@ -828,6 +820,7 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 828 | 820 | if($documentoDTO->getStrStaNivelAcessoLocalProtocolo() == ProtocoloRN::$NA_RESTRITO){ |
| 829 | 821 | $documento->hipoteseLegal = new stdClass(); |
| 830 | 822 | $documento->hipoteseLegal->identificacao = $objPenRelHipoteseLegalRN->getIdHipoteseLegalPEN($documentoDTO->getNumIdHipoteseLegalProtocolo()); |
| 823 | + //TODO: Adicionar nome da hipótese legal atribuida ao documento | |
| 831 | 824 | } |
| 832 | 825 | $documento->dataHoraDeProducao = $this->objProcessoEletronicoRN->converterDataWebService($documentoDTO->getDtaGeracaoProtocolo()); |
| 833 | 826 | $documento->produtor = new stdClass(); |
| ... | ... | @@ -846,7 +839,7 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 846 | 839 | $documento->produtor->unidade->tipo = self::STA_TIPO_PESSOA_ORGAOPUBLICO; |
| 847 | 840 | //TODO: Informar dados da estrutura organizacional (estruturaOrganizacional) |
| 848 | 841 | } |
| 849 | - $documento->produtor->numeroDeIdentificacao = $documentoDTO->getStrProtocoloDocumentoFormatado(); | |
| 842 | + $documento->produtor->numeroDeIdentificacao = $documentoDTO->getStrProtocoloDocumentoFormatado(); //TODO: Avaliar se informação está correta | |
| 850 | 843 | |
| 851 | 844 | $this->atribuirDataHoraDeRegistro($documento, $documentoDTO->getDblIdProcedimento(), $documentoDTO->getDblIdDocumento()); |
| 852 | 845 | //TODO: Implementar mapeamento de espécies documentais |
| ... | ... | @@ -958,8 +951,6 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 958 | 951 | |
| 959 | 952 | private function atribuirComponentesDigitais($objDocumento, DocumentoDTO $objDocumentoDTO) |
| 960 | 953 | { |
| 961 | - | |
| 962 | - | |
| 963 | 954 | if(!isset($objDocumento)){ |
| 964 | 955 | throw new InfraException('Parâmetro $objDocumento não informado.'); |
| 965 | 956 | } |
| ... | ... | @@ -973,11 +964,22 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 973 | 964 | if(!isset($arrInformacaoArquivo) || count($arrInformacaoArquivo) == 0){ |
| 974 | 965 | throw new InfraException('Erro durante obtenção de informações sobre o componente digital do documento {$objDocumentoDTO->getStrProtocoloDocumentoFormatado()}.'); |
| 975 | 966 | } |
| 976 | - //TODO: Revisar tal implementao para atender a gerao de hash de arquivos grandes | |
| 967 | + | |
| 977 | 968 | $strAlgoritmoHash = self::ALGORITMO_HASH_DOCUMENTO; |
| 978 | 969 | $strConteudoAssinatura = $arrInformacaoArquivo['CONTEUDO']; |
| 979 | 970 | $hashDoComponenteDigital = hash($strAlgoritmoHash, $strConteudoAssinatura, true); |
| 980 | 971 | $hashDoComponenteDigital = base64_encode($hashDoComponenteDigital); |
| 972 | + | |
| 973 | + //Busca registro de tramitações anteriores para este componente digital para identificar se o Barramento do PEN já havia registrado o hash do documento gerado da | |
| 974 | + //forma antiga, ou seja, considerando o link do Número SEI. Este link foi removido para manter o padrão de conteúdo de documentos utilizado pelo SEI para assinatura | |
| 975 | + //Para não bloquear os documentos gerados anteriormente, aqueles já registrados pelo Barramento com o hash antigo deverão manter a geração de conteúdo anteriormente utilizada. | |
| 976 | + $objComponenteDigital = $this->consultarComponenteDigital($objDocumentoDTO->getDblIdDocumento()); | |
| 977 | + $hashDoComponenteDigitalAnterior = (isset($objComponenteDigital)) ? $objComponenteDigital->getStrHashConteudo() : null; | |
| 978 | + if(isset($hashDoComponenteDigitalAnterior) && ($hashDoComponenteDigitalAnterior <> $hashDoComponenteDigital)){ | |
| 979 | + $hashDoComponenteDigital = $arrInformacaoArquivo['CONTEUDO_LEGADO']; | |
| 980 | + } | |
| 981 | + | |
| 982 | + //TODO: Revisar tal implementao para atender a gerao de hash de arquivos grandes | |
| 981 | 983 | $objDocumento->componenteDigital = new stdClass(); |
| 982 | 984 | $objDocumento->componenteDigital->ordem = 1; |
| 983 | 985 | $objDocumento->componenteDigital->nome = utf8_encode($arrInformacaoArquivo["NOME"]); |
| ... | ... | @@ -1081,10 +1083,22 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 1081 | 1083 | $objDocumento->componenteDigital->assinaturaDigital[] = $objAssinaturaDigital; |
| 1082 | 1084 | } |
| 1083 | 1085 | |
| 1084 | - | |
| 1085 | 1086 | return $objDocumento; |
| 1086 | 1087 | } |
| 1087 | 1088 | |
| 1089 | + | |
| 1090 | + private function consultarComponenteDigital($parDblIdDocumento) | |
| 1091 | + { | |
| 1092 | + $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | |
| 1093 | + $objComponenteDigitalDTO->setDblIdDocumento($parDblIdDocumento); | |
| 1094 | + $objComponenteDigitalDTO->setNumMaxRegistrosRetorno(1); | |
| 1095 | + $objComponenteDigitalDTO->setOrd('IdTramite', InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 1096 | + $objComponenteDigitalDTO->retTodos(); | |
| 1097 | + | |
| 1098 | + $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | |
| 1099 | + return $objComponenteDigitalBD->consultar($objComponenteDigitalDTO); | |
| 1100 | + } | |
| 1101 | + | |
| 1088 | 1102 | private function obterDadosArquivo(DocumentoDTO $objDocumentoDTO) |
| 1089 | 1103 | { |
| 1090 | 1104 | |
| ... | ... | @@ -1100,27 +1114,12 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 1100 | 1114 | $docEmailEnviado = $objDocumentoDTO->getNumIdSerie() == $idSerieEmail && $objDocumentoDTO->getStrStaDocumento() == DocumentoRN::$TD_FORMULARIO_AUTOMATICO ? true : false; |
| 1101 | 1115 | |
| 1102 | 1116 | if($objDocumentoDTO->getStrStaDocumento() == DocumentoRN::$TD_EDITOR_INTERNO) { |
| 1117 | + $strConteudoAssinatura = $this->obterConteudoInternoAssinatura($objDocumentoDTO->getDblIdDocumento()); | |
| 1118 | + $strConteudoAssinaturaLegado = $this->obterConteudoInternoAssinatura($objDocumentoDTO->getDblIdDocumento(), true); | |
| 1103 | 1119 | |
| 1104 | - $objEditorDTO = new EditorDTO(); | |
| 1105 | - $objEditorDTO->setDblIdDocumento($objDocumentoDTO->getDblIdDocumento()); | |
| 1106 | - $objEditorDTO->setNumIdBaseConhecimento(null); | |
| 1107 | - $objEditorDTO->setStrSinCabecalho('S'); | |
| 1108 | - $objEditorDTO->setStrSinRodape('S'); | |
| 1109 | - $objEditorDTO->setStrSinIdentificacaoVersao('S'); | |
| 1110 | - $objEditorDTO->setStrSinProcessarLinks('S'); | |
| 1111 | - | |
| 1112 | - $numVersaoAtual = intval(str_replace('.', '', SEI_VERSAO)); | |
| 1113 | - $numVersaoCarimboObrigatorio = intval(str_replace('.', '', self::VERSAO_CARIMBO_PUBLICACAO_OBRIGATORIO)); | |
| 1114 | - if ($numVersaoAtual >= $numVersaoCarimboObrigatorio) { | |
| 1115 | - $objEditorDTO->setStrSinCarimboPublicacao('N'); | |
| 1116 | - } | |
| 1117 | - | |
| 1118 | - $objEditorRN = new EditorRN(); | |
| 1119 | - $strConteudoAssinatura = $objEditorRN->consultarHtmlVersao($objEditorDTO); | |
| 1120 | - | |
| 1121 | - //$strConteudoAssinatura = $objDocumentoDTO->getStrConteudoAssinatura(); | |
| 1122 | 1120 | $arrInformacaoArquivo['NOME'] = $strProtocoloDocumentoFormatado . ".html"; |
| 1123 | 1121 | $arrInformacaoArquivo['CONTEUDO'] = $strConteudoAssinatura; |
| 1122 | + $arrInformacaoArquivo['CONTEUDO_LEGADO'] = $strConteudoAssinaturaLegado; | |
| 1124 | 1123 | $arrInformacaoArquivo['TAMANHO'] = strlen($strConteudoAssinatura); |
| 1125 | 1124 | $arrInformacaoArquivo['MIME_TYPE'] = 'text/html'; |
| 1126 | 1125 | $arrInformacaoArquivo['ID_ANEXO'] = null; |
| ... | ... | @@ -1199,6 +1198,46 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 1199 | 1198 | return $arrInformacaoArquivo; |
| 1200 | 1199 | } |
| 1201 | 1200 | |
| 1201 | + | |
| 1202 | + /** | |
| 1203 | + * Método de obtenção do conteúdo do documento interno para envio e cálculo de hash | |
| 1204 | + * | |
| 1205 | + * Anteriormente, os documentos enviados para o Barramento de Serviços do PEN continham o link para o número SEI do documento. | |
| 1206 | + * Este link passou a não ser mais considerado pois é uma informação dinâmica e pertinente apenas quando o documento é visualizado | |
| 1207 | + * dentro do sistema SEI. Quando o documento é tramitado externamente, este link não possui mais sentido. | |
| 1208 | + * | |
| 1209 | + * Para tratar esta transição entre os formatos de documentos, existe o parâmetro $bolFormatoLegado para indicar qual formato deverá | |
| 1210 | + * ser utilizado na montagem dos metadados para envio. * | |
| 1211 | + * | |
| 1212 | + * @param Double $parDblIdDocumento Identificador do documento | |
| 1213 | + * @param boolean $bolFormatoLegado Flag indicando se a forma antiga de recuperação de conteúdo para envio deverá ser utilizada | |
| 1214 | + * @return String Conteúdo completo do documento para envio | |
| 1215 | + */ | |
| 1216 | + private function obterConteudoInternoAssinatura($parDblIdDocumento, $bolFormatoLegado=false) | |
| 1217 | + { | |
| 1218 | + $objEditorDTO = new EditorDTO(); | |
| 1219 | + $objEditorDTO->setDblIdDocumento($parDblIdDocumento); | |
| 1220 | + $objEditorDTO->setNumIdBaseConhecimento(null); | |
| 1221 | + $objEditorDTO->setStrSinCabecalho('S'); | |
| 1222 | + $objEditorDTO->setStrSinRodape('S'); | |
| 1223 | + $objEditorDTO->setStrSinIdentificacaoVersao('N'); | |
| 1224 | + | |
| 1225 | + if($bolFormatoLegado) { | |
| 1226 | + $objEditorDTO->setStrSinIdentificacaoVersao('S'); | |
| 1227 | + $objEditorDTO->setStrSinProcessarLinks('S'); | |
| 1228 | + } | |
| 1229 | + | |
| 1230 | + $numVersaoAtual = intval(str_replace('.', '', SEI_VERSAO)); | |
| 1231 | + $numVersaoCarimboObrigatorio = intval(str_replace('.', '', self::VERSAO_CARIMBO_PUBLICACAO_OBRIGATORIO)); | |
| 1232 | + if ($numVersaoAtual >= $numVersaoCarimboObrigatorio) { | |
| 1233 | + $objEditorDTO->setStrSinCarimboPublicacao('N'); | |
| 1234 | + } | |
| 1235 | + | |
| 1236 | + $objEditorRN = new EditorRN(); | |
| 1237 | + return $objEditorRN->consultarHtmlVersao($objEditorDTO); | |
| 1238 | + } | |
| 1239 | + | |
| 1240 | + | |
| 1202 | 1241 | private function obterTipoDeConteudo($strMimeType) |
| 1203 | 1242 | { |
| 1204 | 1243 | if(!isset($strMimeType)){ |
| ... | ... | @@ -1532,8 +1571,6 @@ class ExpedirProcedimentoRN extends InfraRN { |
| 1532 | 1571 | $arrInformacaoArquivo = $this->obterDadosArquivo($objDocumentoDTO); |
| 1533 | 1572 | $dadosDoComponenteDigital->conteudoDoComponenteDigital = new SoapVar($arrInformacaoArquivo['CONTEUDO'], XSD_BASE64BINARY); |
| 1534 | 1573 | |
| 1535 | - | |
| 1536 | - | |
| 1537 | 1574 | try { |
| 1538 | 1575 | //Enviar componentes digitais |
| 1539 | 1576 | $parametros = new stdClass(); | ... | ... |