From beddc17f5facf966ea0ce6aee7f921ade7672baf Mon Sep 17 00:00:00 2001 From: eduardo.praxedes Date: Fri, 3 Feb 2017 17:02:58 -0200 Subject: [PATCH] Correção no recebimento dos componentes digitais iguais para o mesmo processo e dos hashs nos recibos --- rn/ExpedirProcedimentoRN.php | 1 + rn/ReceberComponenteDigitalRN.php | 14 +++++++++++++- rn/ReceberProcedimentoRN.php | 12 +++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/rn/ExpedirProcedimentoRN.php b/rn/ExpedirProcedimentoRN.php index 67c3108..58d66c7 100644 --- a/rn/ExpedirProcedimentoRN.php +++ b/rn/ExpedirProcedimentoRN.php @@ -1837,6 +1837,7 @@ class ExpedirProcedimentoRN extends InfraRN { $objGenericoBD->cadastrar($objReciboTramiteDTO); + $objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital = !is_array($objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital) ? array($objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital) : $objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital; if($objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital && is_array($objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital)){ foreach($objReciboEnvio->reciboDeEnvio->hashDoComponenteDigital as $strHashComponenteDigital){ diff --git a/rn/ReceberComponenteDigitalRN.php b/rn/ReceberComponenteDigitalRN.php index d2943e2..76bf596 100644 --- a/rn/ReceberComponenteDigitalRN.php +++ b/rn/ReceberComponenteDigitalRN.php @@ -50,7 +50,19 @@ class ReceberComponenteDigitalRN extends InfraRN - $objAnexoDTO = $this->arrAnexos[$parObjComponenteDigitalDTO->getStrHashConteudo()]; + $objAnexoDTO = null; + + foreach($this->arrAnexos as $key => $objAnexo){ + if(array_key_exists($parObjComponenteDigitalDTO->getStrHashConteudo(), $objAnexo) && $objAnexo['recebido'] == false){ + $objAnexoDTO = $objAnexo[$parObjComponenteDigitalDTO->getStrHashConteudo()]; + $this->arrAnexos[$key]['recebido'] = true; + break; + } + } + + if(is_null($objAnexoDTO)){ + throw new InfraException('Anexo '.$parObjComponenteDigitalDTO->getStrHashConteudo().' não encontrado'.var_export($this->arrAnexos, true)); + } //Validar o hash do documento recebido com os dados informados pelo remetente //$this->validarIntegridadeDoComponenteDigital($objAnexoDTO, $parObjComponenteDigitalDTO); diff --git a/rn/ReceberProcedimentoRN.php b/rn/ReceberProcedimentoRN.php index 0b7d99c..6fd3737 100644 --- a/rn/ReceberProcedimentoRN.php +++ b/rn/ReceberProcedimentoRN.php @@ -136,9 +136,10 @@ class ReceberProcedimentoRN extends InfraRN //Cria o array com a lista de hash $arrayHash = array(); - + + //Percorre os componentes que precisam ser recebidos - foreach($objTramite->componenteDigitalPendenteDeRecebimento as $componentePendente){ + foreach($objTramite->componenteDigitalPendenteDeRecebimento as $key => $componentePendente){ if(!is_null($componentePendente)){ @@ -148,13 +149,14 @@ class ReceberProcedimentoRN extends InfraRN //Obter os dados do componente digital $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo); //Copia o componente para a pasta temporária - $arrAnexosComponentes[$componentePendente] = $receberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); + $arrAnexosComponentes[$key][$componentePendente] = $receberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); + $arrAnexosComponentes[$key]['recebido'] = false; //Valida a integridade do hash - $receberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$componentePendente], $componentePendente, $parNumIdentificacaoTramite); + $receberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], $componentePendente, $parNumIdentificacaoTramite); } } - + if(count($arrAnexosComponentes) > 0){ $receberComponenteDigitalRN->setArrAnexos($arrAnexosComponentes); -- libgit2 0.21.2