Commit 49e40dd395ff74926cf331fabb526033966553cd

Authored by Eduardo Heinske
1 parent 8eafc82e

Cancelamento do trâmite de um processo em caso de falha na expedição

rn/ExpedirProcedimentoRN.php
@@ -70,7 +70,7 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -70,7 +70,7 @@ class ExpedirProcedimentoRN extends InfraRN {
70 "video/ogg", 70 "video/ogg",
71 "video/webm" 71 "video/webm"
72 ); 72 );
73 - 73 +
74 public function __construct() { 74 public function __construct() {
75 parent::__construct(); 75 parent::__construct();
76 76
@@ -116,6 +116,8 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -116,6 +116,8 @@ class ExpedirProcedimentoRN extends InfraRN {
116 116
117 public function expedirProcedimentoControlado(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) { 117 public function expedirProcedimentoControlado(ExpedirProcedimentoDTO $objExpedirProcedimentoDTO) {
118 118
  119 + $numIdTramite = 0;
  120 +
119 try { 121 try {
120 //Valida Permissao 122 //Valida Permissao
121 SessaoSEI::getInstance()->validarAuditarPermissao('pen_procedimento_expedir',__METHOD__, $objExpedirProcedimentoDTO); 123 SessaoSEI::getInstance()->validarAuditarPermissao('pen_procedimento_expedir',__METHOD__, $objExpedirProcedimentoDTO);
@@ -160,7 +162,8 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -160,7 +162,8 @@ class ExpedirProcedimentoRN extends InfraRN {
160 $param->novoTramiteDeProcesso->cabecalho = $objCabecalho; 162 $param->novoTramiteDeProcesso->cabecalho = $objCabecalho;
161 $param->novoTramiteDeProcesso->processo = $objProcesso; 163 $param->novoTramiteDeProcesso->processo = $objProcesso;
162 $novoTramite = $this->objProcessoEletronicoRN->enviarProcesso($param); 164 $novoTramite = $this->objProcessoEletronicoRN->enviarProcesso($param);
163 - 165 + $numIdTramite = $novoTramite->dadosTramiteDeProcessoCriado->IDT;
  166 +
164 } catch (\Exception $e) { 167 } catch (\Exception $e) {
165 throw new InfraException("Error Processing Request", $e); 168 throw new InfraException("Error Processing Request", $e);
166 } 169 }
@@ -175,7 +178,7 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -175,7 +178,7 @@ class ExpedirProcedimentoRN extends InfraRN {
175 178
176 $this->objProcedimentoAndamentoRN->setOpts($dblIdProcedimento, $objTramite->IDT, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO)); 179 $this->objProcedimentoAndamentoRN->setOpts($dblIdProcedimento, $objTramite->IDT, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO));
177 try { 180 try {
178 - 181 +
179 $this->objProcedimentoAndamentoRN->cadastrar('Envio do metadados do processo', 'S'); 182 $this->objProcedimentoAndamentoRN->cadastrar('Envio do metadados do processo', 'S');
180 183
181 $idAtividadeExpedicao = $this->bloquearProcedimentoExpedicao($objExpedirProcedimentoDTO, $objProcesso->idProcedimentoSEI); 184 $idAtividadeExpedicao = $this->bloquearProcedimentoExpedicao($objExpedirProcedimentoDTO, $objProcesso->idProcedimentoSEI);
@@ -192,7 +195,7 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -192,7 +195,7 @@ class ExpedirProcedimentoRN extends InfraRN {
192 195
193 196
194 $this->objProcessoEletronicoRN->cadastrarTramitePendente($objTramite->IDT, $idAtividadeExpedicao); 197 $this->objProcessoEletronicoRN->cadastrarTramitePendente($objTramite->IDT, $idAtividadeExpedicao);
195 - 198 +
196 //error_log('TRAMITE: ' . print_r($objTramite, true)); 199 //error_log('TRAMITE: ' . print_r($objTramite, true));
197 //error_log('before enviarComponentesDigitais'); 200 //error_log('before enviarComponentesDigitais');
198 201
@@ -203,7 +206,6 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -203,7 +206,6 @@ class ExpedirProcedimentoRN extends InfraRN {
203 //componentes precisam ser baixados, semelhante ao que ocorre no enviarProcesso onde o barramento informa quais os componentes 206 //componentes precisam ser baixados, semelhante ao que ocorre no enviarProcesso onde o barramento informa quais os componentes
204 //que precisam ser enviados 207 //que precisam ser enviados
205 $this->enviarComponentesDigitais($objTramite->NRE, $objTramite->IDT, $objProcesso->protocolo); 208 $this->enviarComponentesDigitais($objTramite->NRE, $objTramite->IDT, $objProcesso->protocolo);
206 -  
207 //error_log('after enviarComponentesDigitais'); 209 //error_log('after enviarComponentesDigitais');
208 //$strNumeroRegistro, $numIdTramite, $strProtocolo 210 //$strNumeroRegistro, $numIdTramite, $strProtocolo
209 //error_log('==========================>>>>' . print_r($objTramite, true)); 211 //error_log('==========================>>>>' . print_r($objTramite, true));
@@ -235,7 +237,20 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -235,7 +237,20 @@ class ExpedirProcedimentoRN extends InfraRN {
235 $this->receberReciboDeEnvio($objTramite->IDT); 237 $this->receberReciboDeEnvio($objTramite->IDT);
236 } 238 }
237 catch (\Exception $e) { 239 catch (\Exception $e) {
238 - $this->desbloquearProcessoExpedicao($objProcesso->idProcedimentoSEI); 240 + //@TODO: Melhorar essa estrutura
  241 + //Realiza o desbloqueio do processo
  242 + try{
  243 + $this->desbloquearProcessoExpedicao($objProcesso->idProcedimentoSEI);
  244 + } catch (InfraException $ex) { }
  245 +
  246 + //@TODO: Melhorar essa estrutura
  247 + //Realiza o cancelamento do tramite
  248 + try{
  249 + if($numIdTramite != 0){
  250 + $this->objProcessoEletronicoRN->cancelarTramite($numIdTramite);
  251 + }
  252 + } catch (InfraException $ex) { }
  253 +
239 $this->registrarAndamentoExpedicaoAbortada($objProcesso->idProcedimentoSEI); 254 $this->registrarAndamentoExpedicaoAbortada($objProcesso->idProcedimentoSEI);
240 255
241 // @join_tec US008.06 (#23092) 256 // @join_tec US008.06 (#23092)
@@ -1004,6 +1019,8 @@ class ExpedirProcedimentoRN extends InfraRN { @@ -1004,6 +1019,8 @@ class ExpedirProcedimentoRN extends InfraRN {
1004 1019
1005 private function obterDadosArquivo(DocumentoDTO $objDocumentoDTO) 1020 private function obterDadosArquivo(DocumentoDTO $objDocumentoDTO)
1006 { 1021 {
  1022 +
  1023 +
1007 1024
1008 if(!isset($objDocumentoDTO)){ 1025 if(!isset($objDocumentoDTO)){
1009 throw new InfraException('Parâmetro $objDocumentoDTO não informado.'); 1026 throw new InfraException('Parâmetro $objDocumentoDTO não informado.');
rn/ProcessoEletronicoRN.php
@@ -1333,7 +1333,7 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1333,7 +1333,7 @@ class ProcessoEletronicoRN extends InfraRN {
1333 $tramitePendenteBD->cadastrar($tramitePendenteDTO); 1333 $tramitePendenteBD->cadastrar($tramitePendenteDTO);
1334 1334
1335 } catch (\InfraException $ex) { 1335 } catch (\InfraException $ex) {
1336 - throw new InfraException($ex->getDescricao()); 1336 + throw new InfraException($ex->getStrDescricao());
1337 } catch (\Exception $ex) { 1337 } catch (\Exception $ex) {
1338 throw new InfraException($ex->getMessage()); 1338 throw new InfraException($ex->getMessage());
1339 } 1339 }