Commit f4c68f7ed46966ad9860031e4bd03974072b8d8d
1 parent
62add16d
Exists in
master
and in
3 other branches
Correção de recebimento de processos por 2 unidades do mesmo sistema
Showing
11 changed files
with
430 additions
and
426 deletions
Show diff stats
PENIntegracao.php
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | class PENIntegracao extends SeiIntegracao { | 3 | class PENIntegracao extends SeiIntegracao { |
| 4 | 4 | ||
| 5 | - const COMPATIBILIDADE_MODULO_SEI = array('3.0.5', '3.0.6', '3.0.7', '3.0.8', '3.0.9', '3.0.11', '3.0.12', '3.0.13'); | 5 | + const COMPATIBILIDADE_MODULO_SEI = array('3.0.5', '3.0.6', '3.0.7', '3.0.8', '3.0.9', '3.0.11', '3.0.12', '3.0.13', '3.0.14', '3.0.15'); |
| 6 | 6 | ||
| 7 | private static $strDiretorio; | 7 | private static $strDiretorio; |
| 8 | 8 | ||
| @@ -11,7 +11,7 @@ class PENIntegracao extends SeiIntegracao { | @@ -11,7 +11,7 @@ class PENIntegracao extends SeiIntegracao { | ||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | public function getVersao() { | 13 | public function getVersao() { |
| 14 | - return '1.1.5'; | 14 | + return '1.1.7'; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | 17 |
bd/PenMetaBD.php
| @@ -19,7 +19,6 @@ class PenMetaBD extends InfraMetaBD { | @@ -19,7 +19,6 @@ class PenMetaBD extends InfraMetaBD { | ||
| 19 | public function adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, $bolRetornarQuery = false){ | 19 | public function adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, $bolRetornarQuery = false){ |
| 20 | 20 | ||
| 21 | $objInfraBanco = $this->getObjInfraIBanco(); | 21 | $objInfraBanco = $this->getObjInfraIBanco(); |
| 22 | - | ||
| 23 | $strTableDrive = get_parent_class($objInfraBanco); | 22 | $strTableDrive = get_parent_class($objInfraBanco); |
| 24 | $strQuery = ''; | 23 | $strQuery = ''; |
| 25 | 24 | ||
| @@ -30,18 +29,18 @@ class PenMetaBD extends InfraMetaBD { | @@ -30,18 +29,18 @@ class PenMetaBD extends InfraMetaBD { | ||
| 30 | break; | 29 | break; |
| 31 | 30 | ||
| 32 | case 'InfraSqlServer': | 31 | case 'InfraSqlServer': |
| 33 | - $strQuery = sprintf("ALTER TABLE [%s] ADD DEFAULT('%s') FOR [%s]", $strNomeTabela, $strValorPadrao, $strNomeColuna); | 32 | + $strQuery = sprintf("ALTER TABLE [%s] ADD DEFAULT('%s') FOR [%s]", $strNomeTabela, $strValorPadrao, $strNomeColuna); |
| 33 | + break; | ||
| 34 | 34 | ||
| 35 | case 'InfraOracle': | 35 | case 'InfraOracle': |
| 36 | + $strQuery = sprintf("ALTER TABLE %s MODIFY %s DEFAULT '%s'", $strNomeTabela, $strNomeColuna, $strValorPadrao); | ||
| 36 | break; | 37 | break; |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | if($bolRetornarQuery === false) { | 40 | if($bolRetornarQuery === false) { |
| 40 | - | ||
| 41 | $objInfraBanco->executarSql($strQuery); | 41 | $objInfraBanco->executarSql($strQuery); |
| 42 | } | 42 | } |
| 43 | else { | 43 | else { |
| 44 | - | ||
| 45 | return $strQuery; | 44 | return $strQuery; |
| 46 | } | 45 | } |
| 47 | } | 46 | } |
| @@ -139,6 +138,7 @@ class PenMetaBD extends InfraMetaBD { | @@ -139,6 +138,7 @@ class PenMetaBD extends InfraMetaBD { | ||
| 139 | break; | 138 | break; |
| 140 | 139 | ||
| 141 | case 'InfraOracle': | 140 | case 'InfraOracle': |
| 141 | + $this->getObjInfraIBanco()->executarSql('ALTER TABLE '.$strNomeTabela.' DROP CONSTRAINT '.$strNomeChave); | ||
| 142 | break; | 142 | break; |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| @@ -156,12 +156,10 @@ class PenMetaBD extends InfraMetaBD { | @@ -156,12 +156,10 @@ class PenMetaBD extends InfraMetaBD { | ||
| 156 | if($this->isTabelaExiste($strNomeTabelaAtual)) { | 156 | if($this->isTabelaExiste($strNomeTabelaAtual)) { |
| 157 | 157 | ||
| 158 | $objInfraBanco = $this->getObjInfraIBanco(); | 158 | $objInfraBanco = $this->getObjInfraIBanco(); |
| 159 | - | ||
| 160 | $strTableDrive = get_parent_class($objInfraBanco); | 159 | $strTableDrive = get_parent_class($objInfraBanco); |
| 161 | $strQuery = ''; | 160 | $strQuery = ''; |
| 162 | 161 | ||
| 163 | switch ($strTableDrive) { | 162 | switch ($strTableDrive) { |
| 164 | - | ||
| 165 | case 'InfraMySqli': | 163 | case 'InfraMySqli': |
| 166 | $strQuery = sprintf("ALTER TABLE `%s` RENAME TO `%s`", $strNomeTabelaAtual, $strNomeTabelaNovo); | 164 | $strQuery = sprintf("ALTER TABLE `%s` RENAME TO `%s`", $strNomeTabelaAtual, $strNomeTabelaNovo); |
| 167 | break; | 165 | break; |
dto/PenTramiteProcessadoDTO.php
| @@ -3,23 +3,24 @@ | @@ -3,23 +3,24 @@ | ||
| 3 | require_once dirname(__FILE__) . '/../../../SEI.php'; | 3 | require_once dirname(__FILE__) . '/../../../SEI.php'; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * | 6 | + * |
| 7 | * @author Join Tecnologia | 7 | * @author Join Tecnologia |
| 8 | */ | 8 | */ |
| 9 | class PenTramiteProcessadoDTO extends InfraDTO { | 9 | class PenTramiteProcessadoDTO extends InfraDTO { |
| 10 | - | 10 | + |
| 11 | public function getStrNomeTabela() { | 11 | public function getStrNomeTabela() { |
| 12 | - return 'md_pen_tramite_processado'; | 12 | + return 'md_pen_tramite_processado'; |
| 13 | } | 13 | } |
| 14 | - | 14 | + |
| 15 | public function montar() { | 15 | public function montar() { |
| 16 | - | 16 | + |
| 17 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdTramite', 'id_tramite'); | 17 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdTramite', 'id_tramite'); |
| 18 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DTH, 'Ultimo', 'dth_ultimo_processamento'); | 18 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DTH, 'Ultimo', 'dth_ultimo_processamento'); |
| 19 | - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'Tentativas', 'numero_tentativas'); | 19 | + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'Tentativas', 'numero_tentativas'); |
| 20 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Recebido', 'sin_recebimento_concluido'); | 20 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Recebido', 'sin_recebimento_concluido'); |
| 21 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Tipo', 'tipo_tramite_processo'); | 21 | $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Tipo', 'tipo_tramite_processo'); |
| 22 | 22 | ||
| 23 | $this->configurarPK('IdTramite', InfraDTO::$TIPO_PK_INFORMADO); | 23 | $this->configurarPK('IdTramite', InfraDTO::$TIPO_PK_INFORMADO); |
| 24 | + $this->configurarPK('Tipo', InfraDTO::$TIPO_PK_INFORMADO); | ||
| 24 | } | 25 | } |
| 25 | } | 26 | } |
rn/EnviarReciboTramiteRN.php
| 1 | -<?php | 1 | +<?php |
| 2 | + | ||
| 2 | require_once dirname(__FILE__) . '/../../../SEI.php'; | 3 | require_once dirname(__FILE__) . '/../../../SEI.php'; |
| 3 | 4 | ||
| 4 | class EnviarReciboTramiteRN extends InfraRN | 5 | class EnviarReciboTramiteRN extends InfraRN |
| @@ -18,60 +19,60 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -18,60 +19,60 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 18 | { | 19 | { |
| 19 | return BancoSEI::getInstance(); | 20 | return BancoSEI::getInstance(); |
| 20 | } | 21 | } |
| 21 | - | 22 | + |
| 22 | /** | 23 | /** |
| 23 | - * Gera o recibo do tramite para o destinário informando o recebimento | 24 | + * Gera o recibo do tramite para o destinário informando o recebimento |
| 24 | * do procedimento. | 25 | * do procedimento. |
| 25 | - * | 26 | + * |
| 26 | * @param int $numIdTramite | 27 | * @param int $numIdTramite |
| 27 | * @return array | 28 | * @return array |
| 28 | */ | 29 | */ |
| 29 | protected function gerarReciboTramite($numIdTramite){ | 30 | protected function gerarReciboTramite($numIdTramite){ |
| 30 | - | 31 | + |
| 31 | $arrStrHashConteudo = array(); | 32 | $arrStrHashConteudo = array(); |
| 32 | - | 33 | + |
| 33 | $objMetaRetorno = $this->objProcessoEletronicoRN->solicitarMetadados($numIdTramite); | 34 | $objMetaRetorno = $this->objProcessoEletronicoRN->solicitarMetadados($numIdTramite); |
| 34 | - | 35 | + |
| 35 | $objMetaProcesso = $objMetaRetorno->metadados->processo; | 36 | $objMetaProcesso = $objMetaRetorno->metadados->processo; |
| 36 | 37 | ||
| 37 | $arrObjMetaDocumento = is_array($objMetaProcesso->documento) ? $objMetaProcesso->documento : array($objMetaProcesso->documento); | 38 | $arrObjMetaDocumento = is_array($objMetaProcesso->documento) ? $objMetaProcesso->documento : array($objMetaProcesso->documento); |
| 38 | - | 39 | + |
| 39 | $objDTO = new ComponenteDigitalDTO(); | 40 | $objDTO = new ComponenteDigitalDTO(); |
| 40 | $objBD = new ComponenteDigitalBD($this->inicializarObjInfraIBanco()); | 41 | $objBD = new ComponenteDigitalBD($this->inicializarObjInfraIBanco()); |
| 41 | - | 42 | + |
| 42 | foreach($arrObjMetaDocumento as $objMetaDocumento) { | 43 | foreach($arrObjMetaDocumento as $objMetaDocumento) { |
| 43 | - | 44 | + |
| 44 | $strHashConteudo = ProcessoEletronicoRN::getHashFromMetaDados($objMetaDocumento->componenteDigital->hash); | 45 | $strHashConteudo = ProcessoEletronicoRN::getHashFromMetaDados($objMetaDocumento->componenteDigital->hash); |
| 45 | - | 46 | + |
| 46 | $objDTO->setStrHashConteudo($strHashConteudo); | 47 | $objDTO->setStrHashConteudo($strHashConteudo); |
| 47 | - | 48 | + |
| 48 | if($objBD->contar($objDTO) > 0) { | 49 | if($objBD->contar($objDTO) > 0) { |
| 49 | - | 50 | + |
| 50 | $arrStrHashConteudo[] = $strHashConteudo; | 51 | $arrStrHashConteudo[] = $strHashConteudo; |
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| 53 | - | 54 | + |
| 54 | return $arrStrHashConteudo; | 55 | return $arrStrHashConteudo; |
| 55 | } | 56 | } |
| 56 | - | 57 | + |
| 57 | protected function cadastrarReciboTramiteRecebimento($strNumeroRegistro = '', $parNumIdTramite = 0, $strHashConteudo = '', $parArrayHash = array()){ | 58 | protected function cadastrarReciboTramiteRecebimento($strNumeroRegistro = '', $parNumIdTramite = 0, $strHashConteudo = '', $parArrayHash = array()){ |
| 58 | - | 59 | + |
| 59 | $objBD = new ReciboTramiteRecebidoBD($this->inicializarObjInfraIBanco()); | 60 | $objBD = new ReciboTramiteRecebidoBD($this->inicializarObjInfraIBanco()); |
| 60 | - | 61 | + |
| 61 | $objDTO = new ReciboTramiteRecebidoDTO(); | 62 | $objDTO = new ReciboTramiteRecebidoDTO(); |
| 62 | $objDTO->setStrNumeroRegistro($strNumeroRegistro); | 63 | $objDTO->setStrNumeroRegistro($strNumeroRegistro); |
| 63 | $objDTO->setNumIdTramite($parNumIdTramite); | 64 | $objDTO->setNumIdTramite($parNumIdTramite); |
| 64 | - | ||
| 65 | - if(!empty($strHashConteudo)) $objDTO->setStrHashAssinatura($strHashConteudo); | 65 | + |
| 66 | + if(!empty($strHashConteudo)) $objDTO->setStrHashAssinatura($strHashConteudo); | ||
| 66 | 67 | ||
| 67 | if(intval($objBD->contar($objDTO)) == 0) { | 68 | if(intval($objBD->contar($objDTO)) == 0) { |
| 68 | - | 69 | + |
| 69 | $objDTO->setDthRecebimento(date('d/m/Y H:i:s')); | 70 | $objDTO->setDthRecebimento(date('d/m/Y H:i:s')); |
| 70 | $objBD->cadastrar($objDTO); | 71 | $objBD->cadastrar($objDTO); |
| 71 | } | 72 | } |
| 72 | - | 73 | + |
| 73 | foreach($parArrayHash as $strHashComponenteDigital){ | 74 | foreach($parArrayHash as $strHashComponenteDigital){ |
| 74 | - | 75 | + |
| 75 | $objReciboTramiteHashDTO = new ReciboTramiteHashDTO(); | 76 | $objReciboTramiteHashDTO = new ReciboTramiteHashDTO(); |
| 76 | $objReciboTramiteHashDTO->setStrNumeroRegistro($strNumeroRegistro); | 77 | $objReciboTramiteHashDTO->setStrNumeroRegistro($strNumeroRegistro); |
| 77 | $objReciboTramiteHashDTO->setNumIdTramite($parNumIdTramite); | 78 | $objReciboTramiteHashDTO->setNumIdTramite($parNumIdTramite); |
| @@ -80,33 +81,33 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -80,33 +81,33 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 80 | 81 | ||
| 81 | $objBD->cadastrar($objReciboTramiteHashDTO); | 82 | $objBD->cadastrar($objReciboTramiteHashDTO); |
| 82 | } | 83 | } |
| 83 | - | ||
| 84 | - | 84 | + |
| 85 | + | ||
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | public function enviarReciboTramiteProcesso($parNumIdTramite, $parArrayHash = null, $parDthRecebimento = null) | 88 | public function enviarReciboTramiteProcesso($parNumIdTramite, $parArrayHash = null, $parDthRecebimento = null) |
| 88 | - { | 89 | + { |
| 89 | 90 | ||
| 90 | date_default_timezone_set('America/Sao_Paulo'); | 91 | date_default_timezone_set('America/Sao_Paulo'); |
| 91 | 92 | ||
| 92 | if(!isset($parNumIdTramite) || $parNumIdTramite == 0) { | 93 | if(!isset($parNumIdTramite) || $parNumIdTramite == 0) { |
| 93 | - throw new InfraException('Parâmetro $parNumIdTramite não informado.'); | ||
| 94 | - } | 94 | + throw new InfraException('Parâmetro $parNumIdTramite não informado.'); |
| 95 | + } | ||
| 95 | 96 | ||
| 96 | - //Verifica se todos os componentes digitais já foram devidamente recebido | 97 | + //Verifica se todos os componentes digitais já foram devidamente recebido |
| 97 | $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdTramite); | 98 | $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdTramite); |
| 98 | if(!isset($arrObjTramite) || count($arrObjTramite) != 1) { | 99 | if(!isset($arrObjTramite) || count($arrObjTramite) != 1) { |
| 99 | - throw new InfraException("Trâmite não pode ser localizado pelo identificador $parNumIdTramite."); | 100 | + throw new InfraException("Trâmite não pode ser localizado pelo identificador $parNumIdTramite."); |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | $objTramite = $arrObjTramite[0]; | 103 | $objTramite = $arrObjTramite[0]; |
| 103 | $strNumeroRegistro = $objTramite->NRE; | 104 | $strNumeroRegistro = $objTramite->NRE; |
| 104 | 105 | ||
| 105 | if($objTramite->situacaoAtual != ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { | 106 | if($objTramite->situacaoAtual != ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { |
| 106 | - throw new InfraException('Situação do Trâmite diferente da permitida para o envio do recibo de conclusão de trâmite.'); | 107 | + throw new InfraException('Situação do Trâmite diferente da permitida para o envio do recibo de conclusão de trâmite.'); |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | - $dthRecebimentoComponentesDigitais = $this->obterDataRecebimentoComponentesDigitais($objTramite); | 110 | + $dthRecebimentoComponentesDigitais = $this->obterDataRecebimentoComponentesDigitais($objTramite); |
| 110 | $dthRecebimentoComponentesDigitais = $dthRecebimentoComponentesDigitais ?: date(); | 111 | $dthRecebimentoComponentesDigitais = $dthRecebimentoComponentesDigitais ?: date(); |
| 111 | $dthRecebimento = gmdate("Y-m-d\TH:i:s.000\Z", InfraData::getTimestamp($dthRecebimentoComponentesDigitais)); | 112 | $dthRecebimento = gmdate("Y-m-d\TH:i:s.000\Z", InfraData::getTimestamp($dthRecebimentoComponentesDigitais)); |
| 112 | 113 | ||
| @@ -115,23 +116,23 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -115,23 +116,23 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 115 | $strReciboTramite .= "<NRE>$strNumeroRegistro</NRE>"; | 116 | $strReciboTramite .= "<NRE>$strNumeroRegistro</NRE>"; |
| 116 | $strReciboTramite .= "<dataDeRecebimento>$dthRecebimento</dataDeRecebimento>"; | 117 | $strReciboTramite .= "<dataDeRecebimento>$dthRecebimento</dataDeRecebimento>"; |
| 117 | sort($parArrayHash); | 118 | sort($parArrayHash); |
| 118 | - | 119 | + |
| 119 | foreach ($parArrayHash as $strHashConteudo) { | 120 | foreach ($parArrayHash as $strHashConteudo) { |
| 120 | if(!empty($strHashConteudo)){ | 121 | if(!empty($strHashConteudo)){ |
| 121 | $strReciboTramite .= "<hashDoComponenteDigital>$strHashConteudo</hashDoComponenteDigital>"; | 122 | $strReciboTramite .= "<hashDoComponenteDigital>$strHashConteudo</hashDoComponenteDigital>"; |
| 122 | } | 123 | } |
| 123 | - } | 124 | + } |
| 124 | $strReciboTramite .= "</recibo>"; | 125 | $strReciboTramite .= "</recibo>"; |
| 125 | - | 126 | + |
| 126 | //Envia o Recibo de salva no banco | 127 | //Envia o Recibo de salva no banco |
| 127 | $hashAssinatura = $this->objProcessoEletronicoRN->enviarReciboDeTramite($parNumIdTramite, $dthRecebimento, $strReciboTramite); | 128 | $hashAssinatura = $this->objProcessoEletronicoRN->enviarReciboDeTramite($parNumIdTramite, $dthRecebimento, $strReciboTramite); |
| 128 | $this->cadastrarReciboTramiteRecebimento($strNumeroRegistro, $parNumIdTramite, $hashAssinatura, $parArrayHash); | 129 | $this->cadastrarReciboTramiteRecebimento($strNumeroRegistro, $parNumIdTramite, $hashAssinatura, $parArrayHash); |
| 129 | - } | 130 | + } |
| 130 | 131 | ||
| 131 | private function obterDataRecebimentoComponentesDigitais($parObjTramite){ | 132 | private function obterDataRecebimentoComponentesDigitais($parObjTramite){ |
| 132 | - | 133 | + |
| 133 | if(!isset($parObjTramite)) { | 134 | if(!isset($parObjTramite)) { |
| 134 | - throw new InfraException('Parâmetro $parObjTramite não informado.'); | 135 | + throw new InfraException('Parâmetro $parObjTramite não informado.'); |
| 135 | } | 136 | } |
| 136 | 137 | ||
| 137 | if(!is_array($parObjTramite->historico->operacao)) { | 138 | if(!is_array($parObjTramite->historico->operacao)) { |
| @@ -140,7 +141,7 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -140,7 +141,7 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 140 | 141 | ||
| 141 | foreach ($parObjTramite->historico->operacao as $operacao) { | 142 | foreach ($parObjTramite->historico->operacao as $operacao) { |
| 142 | if($operacao->situacao == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { | 143 | if($operacao->situacao == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { |
| 143 | - return ProcessoEletronicoRN::converterDataSEI($operacao->dataHora); | 144 | + return ProcessoEletronicoRN::converterDataSEI($operacao->dataHora); |
| 144 | } | 145 | } |
| 145 | } | 146 | } |
| 146 | 147 | ||
| @@ -148,17 +149,17 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -148,17 +149,17 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | /** | 151 | /** |
| 151 | - * Consulta o componente digital no barramento. Utilizado para casos de retrasmissão, | ||
| 152 | - * onde esta unidade esta recebendo um componente digital que pertence à ela | ||
| 153 | - * própria, então o id_tramite de envio, que foi gravado, é diferente do de recebimento | ||
| 154 | - * | 152 | + * Consulta o componente digital no barramento. Utilizado para casos de retrasmissão, |
| 153 | + * onde esta unidade esta recebendo um componente digital que pertence à ela | ||
| 154 | + * própria, então o id_tramite de envio, que foi gravado, é diferente do de recebimento | ||
| 155 | + * | ||
| 155 | * @param int $numIdTramite | 156 | * @param int $numIdTramite |
| 156 | * @return array[ComponenteDigitalDTO] | 157 | * @return array[ComponenteDigitalDTO] |
| 157 | */ | 158 | */ |
| 158 | private function recarregarComponenteDigitalDTO($numIdTramite){ | 159 | private function recarregarComponenteDigitalDTO($numIdTramite){ |
| 159 | - | 160 | + |
| 160 | $arrObjComponenteDigitalDTO = array(); | 161 | $arrObjComponenteDigitalDTO = array(); |
| 161 | - | 162 | + |
| 162 | $objMetaRetorno = $this->objProcessoEletronicoRN->solicitarMetadados($numIdTramite); | 163 | $objMetaRetorno = $this->objProcessoEletronicoRN->solicitarMetadados($numIdTramite); |
| 163 | 164 | ||
| 164 | if(!empty($objMetaRetorno)) { | 165 | if(!empty($objMetaRetorno)) { |
| @@ -166,43 +167,44 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -166,43 +167,44 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 166 | $objMetaProcesso = $objMetaRetorno->metadados->processo; | 167 | $objMetaProcesso = $objMetaRetorno->metadados->processo; |
| 167 | 168 | ||
| 168 | $arrObjMetaDocumento = is_array($objMetaProcesso->documento) ? $objMetaProcesso->documento : array($objMetaProcesso->documento); | 169 | $arrObjMetaDocumento = is_array($objMetaProcesso->documento) ? $objMetaProcesso->documento : array($objMetaProcesso->documento); |
| 169 | - | 170 | + |
| 170 | foreach($arrObjMetaDocumento as $objMetaDocumento) { | 171 | foreach($arrObjMetaDocumento as $objMetaDocumento) { |
| 171 | 172 | ||
| 172 | $dblIdProcedimento = null; | 173 | $dblIdProcedimento = null; |
| 173 | $dblIdDocumento = null; | 174 | $dblIdDocumento = null; |
| 174 | - | 175 | + |
| 175 | $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | 176 | $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); |
| 176 | $objProcessoEletronicoDTO->setStrNumeroRegistro($objMetaRetorno->metadados->NRE); | 177 | $objProcessoEletronicoDTO->setStrNumeroRegistro($objMetaRetorno->metadados->NRE); |
| 177 | $objProcessoEletronicoDTO->retDblIdProcedimento(); | 178 | $objProcessoEletronicoDTO->retDblIdProcedimento(); |
| 178 | - | 179 | + |
| 179 | $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | 180 | $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); |
| 180 | $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | 181 | $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); |
| 181 | - | 182 | + |
| 182 | if(empty($objProcessoEletronicoDTO)) { | 183 | if(empty($objProcessoEletronicoDTO)) { |
| 183 | - | 184 | + |
| 184 | $dblIdProcedimento = $objProcessoEletronicoDTO->getDblIdProcedimento(); | 185 | $dblIdProcedimento = $objProcessoEletronicoDTO->getDblIdProcedimento(); |
| 185 | - | 186 | + |
| 186 | $objDocumentoDTO = new DocumentoDTO(); | 187 | $objDocumentoDTO = new DocumentoDTO(); |
| 187 | $objDocumentoDTO->setDblIdProcedimento($dblIdProcedimento); | 188 | $objDocumentoDTO->setDblIdProcedimento($dblIdProcedimento); |
| 188 | $objDocumentoDTO->retDblIdDocumento(); | 189 | $objDocumentoDTO->retDblIdDocumento(); |
| 189 | - | 190 | + |
| 190 | $objDocumentoBD = new DocumentoBD(); | 191 | $objDocumentoBD = new DocumentoBD(); |
| 191 | $objDocumentoDTO = $objDocumentoBD->consultar($objDocumentoDTO); | 192 | $objDocumentoDTO = $objDocumentoBD->consultar($objDocumentoDTO); |
| 192 | - | 193 | + |
| 193 | if(empty($objDocumentoDTO)) { | 194 | if(empty($objDocumentoDTO)) { |
| 194 | - | 195 | + |
| 195 | $dblIdDocumento = $objDocumentoDTO->getDblIdDocumento(); | 196 | $dblIdDocumento = $objDocumentoDTO->getDblIdDocumento(); |
| 196 | - } | 197 | + } |
| 197 | } | 198 | } |
| 198 | 199 | ||
| 199 | $objMetaComponenteDigital = $objMetaDocumento->componenteDigital; | 200 | $objMetaComponenteDigital = $objMetaDocumento->componenteDigital; |
| 200 | - | 201 | + |
| 201 | $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | 202 | $objComponenteDigitalDTO = new ComponenteDigitalDTO(); |
| 202 | $objComponenteDigitalDTO->setStrNumeroRegistro($objMetaRetorno->metadados->NRE); | 203 | $objComponenteDigitalDTO->setStrNumeroRegistro($objMetaRetorno->metadados->NRE); |
| 203 | $objComponenteDigitalDTO->setDblIdProcedimento($dblIdProcedimento); | 204 | $objComponenteDigitalDTO->setDblIdProcedimento($dblIdProcedimento); |
| 204 | $objComponenteDigitalDTO->setDblIdDocumento($dblIdDocumento); | 205 | $objComponenteDigitalDTO->setDblIdDocumento($dblIdDocumento); |
| 205 | $objComponenteDigitalDTO->setNumIdTramite($numIdTramite); | 206 | $objComponenteDigitalDTO->setNumIdTramite($numIdTramite); |
| 207 | + | ||
| 206 | $objComponenteDigitalDTO->setNumIdAnexo($objMetaComponenteDigital->idAnexo); | 208 | $objComponenteDigitalDTO->setNumIdAnexo($objMetaComponenteDigital->idAnexo); |
| 207 | $objComponenteDigitalDTO->setStrNome($objMetaComponenteDigital->nome); | 209 | $objComponenteDigitalDTO->setStrNome($objMetaComponenteDigital->nome); |
| 208 | $objComponenteDigitalDTO->setStrHashConteudo(ProcessoEletronicoRN::getHashFromMetaDados($objMetaComponenteDigital->hash)); | 210 | $objComponenteDigitalDTO->setStrHashConteudo(ProcessoEletronicoRN::getHashFromMetaDados($objMetaComponenteDigital->hash)); |
| @@ -214,30 +216,30 @@ class EnviarReciboTramiteRN extends InfraRN | @@ -214,30 +216,30 @@ class EnviarReciboTramiteRN extends InfraRN | ||
| 214 | $objComponenteDigitalDTO->setNumTamanho($objMetaComponenteDigital->tamanhoEmBytes); | 216 | $objComponenteDigitalDTO->setNumTamanho($objMetaComponenteDigital->tamanhoEmBytes); |
| 215 | $objComponenteDigitalDTO->setNumOrdem($objMetaDocumento->ordem); | 217 | $objComponenteDigitalDTO->setNumOrdem($objMetaDocumento->ordem); |
| 216 | $objComponenteDigitalDTO->setStrSinEnviar('S'); | 218 | $objComponenteDigitalDTO->setStrSinEnviar('S'); |
| 217 | - | 219 | + |
| 218 | $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO; | 220 | $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO; |
| 219 | - } | ||
| 220 | - } | ||
| 221 | - | 221 | + } |
| 222 | + } | ||
| 223 | + | ||
| 222 | return $arrObjComponenteDigitalDTO; | 224 | return $arrObjComponenteDigitalDTO; |
| 223 | } | 225 | } |
| 224 | - | 226 | + |
| 225 | /** | 227 | /** |
| 226 | */ | 228 | */ |
| 227 | private function listarComponenteDigitalDTO($parNumIdTramite) { | 229 | private function listarComponenteDigitalDTO($parNumIdTramite) { |
| 228 | - | 230 | + |
| 229 | $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | 231 | $objComponenteDigitalDTO = new ComponenteDigitalDTO(); |
| 230 | $objComponenteDigitalDTO->retTodos(); | 232 | $objComponenteDigitalDTO->retTodos(); |
| 231 | $objComponenteDigitalDTO->setNumIdTramite($parNumIdTramite); | 233 | $objComponenteDigitalDTO->setNumIdTramite($parNumIdTramite); |
| 232 | - | 234 | + |
| 233 | $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | 235 | $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); |
| 234 | $arrObjComponenteDigitalDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO); | 236 | $arrObjComponenteDigitalDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO); |
| 235 | 237 | ||
| 236 | if (empty($arrObjComponenteDigitalDTO)) { | 238 | if (empty($arrObjComponenteDigitalDTO)) { |
| 237 | - | ||
| 238 | - //$arrObjComponenteDigitalDTO = $this->recarregarComponenteDigitalDTO($parNumIdTramite); | 239 | + |
| 240 | + //$arrObjComponenteDigitalDTO = $this->recarregarComponenteDigitalDTO($parNumIdTramite); | ||
| 239 | } | 241 | } |
| 240 | 242 | ||
| 241 | return $arrObjComponenteDigitalDTO; | 243 | return $arrObjComponenteDigitalDTO; |
| 242 | } | 244 | } |
| 243 | -} | ||
| 244 | \ No newline at end of file | 245 | \ No newline at end of file |
| 246 | +} |
rn/PenTramiteProcessadoRN.php
| @@ -4,12 +4,12 @@ | @@ -4,12 +4,12 @@ | ||
| 4 | * @author Join Tecnologia | 4 | * @author Join Tecnologia |
| 5 | */ | 5 | */ |
| 6 | class PenTramiteProcessadoRN extends InfraRN { | 6 | class PenTramiteProcessadoRN extends InfraRN { |
| 7 | - | 7 | + |
| 8 | const STR_TIPO_PROCESSO = 'RP'; | 8 | const STR_TIPO_PROCESSO = 'RP'; |
| 9 | const STR_TIPO_RECIBO = 'RR'; | 9 | const STR_TIPO_RECIBO = 'RR'; |
| 10 | - | 10 | + |
| 11 | const PARAM_NUMERO_TENTATIVAS = 'PEN_NUMERO_TENTATIVAS_TRAMITE_RECEBIMENTO'; | 11 | const PARAM_NUMERO_TENTATIVAS = 'PEN_NUMERO_TENTATIVAS_TRAMITE_RECEBIMENTO'; |
| 12 | - | 12 | + |
| 13 | protected $objInfraBanco; | 13 | protected $objInfraBanco; |
| 14 | private $strTipo; | 14 | private $strTipo; |
| 15 | 15 | ||
| @@ -17,64 +17,63 @@ class PenTramiteProcessadoRN extends InfraRN { | @@ -17,64 +17,63 @@ class PenTramiteProcessadoRN extends InfraRN { | ||
| 17 | parent::__construct(); | 17 | parent::__construct(); |
| 18 | $this->strTipo = $strTipo; | 18 | $this->strTipo = $strTipo; |
| 19 | } | 19 | } |
| 20 | - | 20 | + |
| 21 | /** | 21 | /** |
| 22 | - * | 22 | + * |
| 23 | * @return BancoSEI | 23 | * @return BancoSEI |
| 24 | */ | 24 | */ |
| 25 | protected function inicializarObjInfraIBanco() { | 25 | protected function inicializarObjInfraIBanco() { |
| 26 | - | 26 | + |
| 27 | if(empty($this->objInfraBanco)) { | 27 | if(empty($this->objInfraBanco)) { |
| 28 | - | 28 | + |
| 29 | $this->objInfraBanco = BancoSEI::getInstance(); | 29 | $this->objInfraBanco = BancoSEI::getInstance(); |
| 30 | } | 30 | } |
| 31 | - | 31 | + |
| 32 | return $this->objInfraBanco; | 32 | return $this->objInfraBanco; |
| 33 | } | 33 | } |
| 34 | - | 34 | + |
| 35 | /** | 35 | /** |
| 36 | - * | 36 | + * |
| 37 | * @return bool | 37 | * @return bool |
| 38 | */ | 38 | */ |
| 39 | protected function isProcedimentoRecebidoControlado($dblIdTramite = 0){ | 39 | protected function isProcedimentoRecebidoControlado($dblIdTramite = 0){ |
| 40 | - | 40 | + |
| 41 | //Verifica se o trâmite não foi cancelado ou recusado | 41 | //Verifica se o trâmite não foi cancelado ou recusado |
| 42 | if($this->isTramiteRecusadoCancelado($dblIdTramite)){ | 42 | if($this->isTramiteRecusadoCancelado($dblIdTramite)){ |
| 43 | return true; | 43 | return true; |
| 44 | } | 44 | } |
| 45 | - | 45 | + |
| 46 | $objFilDTO = new PenTramiteProcessadoDTO(); | 46 | $objFilDTO = new PenTramiteProcessadoDTO(); |
| 47 | $objFilDTO->setDblIdTramite($dblIdTramite); | 47 | $objFilDTO->setDblIdTramite($dblIdTramite); |
| 48 | $objFilDTO->setStrTipo($this->strTipo); | 48 | $objFilDTO->setStrTipo($this->strTipo); |
| 49 | $objFilDTO->setNumMaxRegistrosRetorno(1); | 49 | $objFilDTO->setNumMaxRegistrosRetorno(1); |
| 50 | $objFilDTO->retTodos(); | 50 | $objFilDTO->retTodos(); |
| 51 | - | ||
| 52 | - $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); | 51 | + |
| 52 | + $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); | ||
| 53 | $objDTO = $objBD->consultar($objFilDTO); | 53 | $objDTO = $objBD->consultar($objFilDTO); |
| 54 | 54 | ||
| 55 | if(empty($objDTO)) { | 55 | if(empty($objDTO)) { |
| 56 | - | ||
| 57 | $objFilDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); | 56 | $objFilDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); |
| 58 | $objFilDTO->setNumTentativas(0); | 57 | $objFilDTO->setNumTentativas(0); |
| 59 | $objFilDTO->setStrRecebido('N'); | 58 | $objFilDTO->setStrRecebido('N'); |
| 60 | $objFilDTO->setStrTipo($this->strTipo); | 59 | $objFilDTO->setStrTipo($this->strTipo); |
| 61 | - | ||
| 62 | $objDTO = $objBD->cadastrar($objFilDTO); | 60 | $objDTO = $objBD->cadastrar($objFilDTO); |
| 61 | + return false; | ||
| 63 | } | 62 | } |
| 64 | - | ||
| 65 | - if($objDTO->getStrRecebido() == 'S') { | ||
| 66 | 63 | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + if($objDTO->getStrRecebido() == 'S') { | ||
| 67 | return true; | 67 | return true; |
| 68 | + | ||
| 68 | } | 69 | } |
| 69 | else { | 70 | else { |
| 70 | - | ||
| 71 | $objPenParametroRN = new PenParametroRN(); | 71 | $objPenParametroRN = new PenParametroRN(); |
| 72 | $numTentativas = $objPenParametroRN->getParametro(self::PARAM_NUMERO_TENTATIVAS); | 72 | $numTentativas = $objPenParametroRN->getParametro(self::PARAM_NUMERO_TENTATIVAS); |
| 73 | - | 73 | + |
| 74 | // Verifica o número de tentativas já realizadas é igual ao configurado | 74 | // Verifica o número de tentativas já realizadas é igual ao configurado |
| 75 | // no parâmetro | 75 | // no parâmetro |
| 76 | if($objDTO->getNumTentativas() >= $numTentativas) { | 76 | if($objDTO->getNumTentativas() >= $numTentativas) { |
| 77 | - | ||
| 78 | // Somente faz a recusa se estiver recebendo o procedimento, pois | 77 | // Somente faz a recusa se estiver recebendo o procedimento, pois |
| 79 | // ao receber o recibo não pode mais recursar | 78 | // ao receber o recibo não pode mais recursar |
| 80 | if($objDTO->getStrTipo() == self::STR_TIPO_PROCESSO) { | 79 | if($objDTO->getStrTipo() == self::STR_TIPO_PROCESSO) { |
| @@ -85,59 +84,55 @@ class PenTramiteProcessadoRN extends InfraRN { | @@ -85,59 +84,55 @@ class PenTramiteProcessadoRN extends InfraRN { | ||
| 85 | return true;// Mente que já foi recebido para não executar novamente | 84 | return true;// Mente que já foi recebido para não executar novamente |
| 86 | } | 85 | } |
| 87 | else { | 86 | else { |
| 88 | - | ||
| 89 | // Incrementa o contador pois após sair desse método com false | 87 | // Incrementa o contador pois após sair desse método com false |
| 90 | // ira executar o recebimento novamente | 88 | // ira executar o recebimento novamente |
| 91 | $objDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); | 89 | $objDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); |
| 92 | $objDTO->setNumTentativas($objDTO->getNumTentativas() + 1); | 90 | $objDTO->setNumTentativas($objDTO->getNumTentativas() + 1); |
| 91 | + $objDTO->setStrTipo($this->strTipo); | ||
| 93 | $objBD->alterar($objDTO); | 92 | $objBD->alterar($objDTO); |
| 94 | return false; | 93 | return false; |
| 95 | - } | 94 | + } |
| 96 | } | 95 | } |
| 97 | } | 96 | } |
| 98 | - | 97 | + |
| 99 | public function setRecebido($dblIdTramite = 0){ | 98 | public function setRecebido($dblIdTramite = 0){ |
| 100 | - | 99 | + |
| 101 | $objDTO = new PenTramiteProcessadoDTO(); | 100 | $objDTO = new PenTramiteProcessadoDTO(); |
| 102 | $objDTO->setDblIdTramite($dblIdTramite); | 101 | $objDTO->setDblIdTramite($dblIdTramite); |
| 103 | $objDTO->setStrTipo($this->strTipo); | 102 | $objDTO->setStrTipo($this->strTipo); |
| 104 | $objDTO->setNumMaxRegistrosRetorno(1); | 103 | $objDTO->setNumMaxRegistrosRetorno(1); |
| 105 | $objDTO->retTodos(); | 104 | $objDTO->retTodos(); |
| 106 | - | ||
| 107 | $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); | 105 | $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); |
| 108 | $objDTO = $objBD->consultar($objDTO); | 106 | $objDTO = $objBD->consultar($objDTO); |
| 109 | - | ||
| 110 | if(empty($objDTO)) { | 107 | if(empty($objDTO)) { |
| 111 | throw new InfraException(sprintf('ID do tramite %s não foi localizado', $dblIdTramite)); | 108 | throw new InfraException(sprintf('ID do tramite %s não foi localizado', $dblIdTramite)); |
| 112 | } | 109 | } |
| 113 | - | ||
| 114 | $objDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); | 110 | $objDTO->setDthUltimo(InfraData::getStrDataHoraAtual()); |
| 115 | $objDTO->setStrRecebido('S'); | 111 | $objDTO->setStrRecebido('S'); |
| 116 | - | ||
| 117 | - $objBD->alterar($objDTO); | 112 | + $objBD->alterar($objDTO); |
| 118 | } | 113 | } |
| 119 | - | 114 | + |
| 120 | /** | 115 | /** |
| 121 | * Método que verifica se o trâmite em questão foi cancelado ou recusado | 116 | * Método que verifica se o trâmite em questão foi cancelado ou recusado |
| 122 | - * | 117 | + * |
| 123 | * @param integer $parNumIdTramite | 118 | * @param integer $parNumIdTramite |
| 124 | * @return boolean | 119 | * @return boolean |
| 125 | */ | 120 | */ |
| 126 | public function isTramiteRecusadoCancelado($parNumIdTramite){ | 121 | public function isTramiteRecusadoCancelado($parNumIdTramite){ |
| 127 | - | 122 | + |
| 128 | //Instancia a classe processo eletrônico | 123 | //Instancia a classe processo eletrônico |
| 129 | $processoEletronicoRN = new ProcessoEletronicoRN(); | 124 | $processoEletronicoRN = new ProcessoEletronicoRN(); |
| 130 | - | 125 | + |
| 131 | //Busca os dados do trâmite | 126 | //Busca os dados do trâmite |
| 132 | $arrObjTramite = $processoEletronicoRN->consultarTramites($parNumIdTramite); | 127 | $arrObjTramite = $processoEletronicoRN->consultarTramites($parNumIdTramite); |
| 133 | $objTramite = $arrObjTramite[0]; | 128 | $objTramite = $arrObjTramite[0]; |
| 134 | - | 129 | + |
| 135 | //Verifica se o trâmite em questão. foi recusado o cancelado | 130 | //Verifica se o trâmite em questão. foi recusado o cancelado |
| 136 | if($objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_CANCELADO || $objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO){ | 131 | if($objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_CANCELADO || $objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO){ |
| 137 | return true; | 132 | return true; |
| 138 | }else{ | 133 | }else{ |
| 139 | return false; | 134 | return false; |
| 140 | } | 135 | } |
| 141 | - | 136 | + |
| 142 | } | 137 | } |
| 143 | } | 138 | } |
rn/ProcessarPendenciasRN.php
| @@ -86,8 +86,10 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | @@ -86,8 +86,10 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | ||
| 86 | $objReceberReciboTramiteRN = new ReceberReciboTramiteRN(); | 86 | $objReceberReciboTramiteRN = new ReceberReciboTramiteRN(); |
| 87 | $objReceberReciboTramiteRN->receberReciboDeTramite($numIdentificacaoTramite); | 87 | $objReceberReciboTramiteRN->receberReciboDeTramite($numIdentificacaoTramite); |
| 88 | } | 88 | } |
| 89 | + | ||
| 89 | } | 90 | } |
| 90 | catch(Exception $e){ | 91 | catch(Exception $e){ |
| 92 | + $this->gravarLogDebug(InfraException::inspecionar($e), 0, true); | ||
| 91 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); | 93 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); |
| 92 | } | 94 | } |
| 93 | }); | 95 | }); |
| @@ -105,6 +107,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | @@ -105,6 +107,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | ||
| 105 | } | 107 | } |
| 106 | } | 108 | } |
| 107 | catch(Exception $e){ | 109 | catch(Exception $e){ |
| 110 | + $this->gravarLogDebug(InfraException::inspecionar($e), 0, true); | ||
| 108 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); | 111 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); |
| 109 | $objProcessoEletronicoRN = new ProcessoEletronicoRN(); | 112 | $objProcessoEletronicoRN = new ProcessoEletronicoRN(); |
| 110 | $strMensagem = ($e instanceof InfraException) ? $e->__toString() : $e->getMessage(); | 113 | $strMensagem = ($e instanceof InfraException) ? $e->__toString() : $e->getMessage(); |
| @@ -120,9 +123,9 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | @@ -120,9 +123,9 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | ||
| 120 | $objReceberProcedimentoRN = new ReceberProcedimentoRN(); | 123 | $objReceberProcedimentoRN = new ReceberProcedimentoRN(); |
| 121 | $objReceberProcedimentoRN->receberTramitesRecusados($numIdentificacaoTramite); | 124 | $objReceberProcedimentoRN->receberTramitesRecusados($numIdentificacaoTramite); |
| 122 | } catch (Exception $e) { | 125 | } catch (Exception $e) { |
| 126 | + $this->gravarLogDebug(InfraException::inspecionar($e), 0, true); | ||
| 123 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); | 127 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); |
| 124 | } | 128 | } |
| 125 | - | ||
| 126 | }); | 129 | }); |
| 127 | 130 | ||
| 128 | //Processamento de pendências de recebimento dos componentes digitais do processo | 131 | //Processamento de pendências de recebimento dos componentes digitais do processo |
| @@ -139,6 +142,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | @@ -139,6 +142,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | ||
| 139 | $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN(); | 142 | $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN(); |
| 140 | $objEnviarReciboTramiteRN->enviarReciboTramiteProcesso($numIdentificacaoTramite); | 143 | $objEnviarReciboTramiteRN->enviarReciboTramiteProcesso($numIdentificacaoTramite); |
| 141 | } catch (Exception $e) { | 144 | } catch (Exception $e) { |
| 145 | + $this->gravarLogDebug(InfraException::inspecionar($e), 0, true); | ||
| 142 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); | 146 | LogSEI::getInstance()->gravar(InfraException::inspecionar($e)); |
| 143 | } | 147 | } |
| 144 | }); | 148 | }); |
| @@ -147,7 +151,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | @@ -147,7 +151,7 @@ class ProcessarPendenciasRN extends InfraAgendamentoTarefa | ||
| 147 | private function gravarLogDebug($strMensagem, $numIdentacao=0, $bolEcho=false) | 151 | private function gravarLogDebug($strMensagem, $numIdentacao=0, $bolEcho=false) |
| 148 | { | 152 | { |
| 149 | $strDataLog = date("d/m/Y H:i:s"); | 153 | $strDataLog = date("d/m/Y H:i:s"); |
| 150 | - $strLog = sprintf("[%s] [PROCESSAMENTO] %s %s", $strDataLog, str_repeat("\t", $numIdentacao), $strMensagem); | 154 | + $strLog = sprintf("[%s] [PROCESSAMENTO] %s %s", $strDataLog, str_repeat(" ", $numIdentacao * 4), $strMensagem); |
| 151 | InfraDebug::getInstance()->gravar($strLog); | 155 | InfraDebug::getInstance()->gravar($strLog); |
| 152 | if(!InfraDebug::getInstance()->isBolEcho() && $bolEcho) echo sprintf("\n[%s] [PROCESSAMENTO] %s", $strDataLog, $strMensagem); | 156 | if(!InfraDebug::getInstance()->isBolEcho() && $bolEcho) echo sprintf("\n[%s] [PROCESSAMENTO] %s", $strDataLog, $strMensagem); |
| 153 | } | 157 | } |
rn/ProcessoEletronicoRN.php
| @@ -818,8 +818,8 @@ class ProcessoEletronicoRN extends InfraRN { | @@ -818,8 +818,8 @@ class ProcessoEletronicoRN extends InfraRN { | ||
| 818 | 818 | ||
| 819 | //TODO: Avaliar dados do tamanho do documento em bytes salvo na base de dados | 819 | //TODO: Avaliar dados do tamanho do documento em bytes salvo na base de dados |
| 820 | $objComponenteDigitalDTO->setNumTamanho($objComponenteDigital->tamanhoEmBytes); | 820 | $objComponenteDigitalDTO->setNumTamanho($objComponenteDigital->tamanhoEmBytes); |
| 821 | - $objComponenteDigitalDTO->setNumIdAnexo($objComponenteDigital->idAnexo); | ||
| 822 | 821 | ||
| 822 | + $objComponenteDigitalDTO->setNumIdAnexo($objComponenteDigital->idAnexo); | ||
| 823 | $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO; | 823 | $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO; |
| 824 | } | 824 | } |
| 825 | 825 |
rn/ProcessoExpedidoRN.php
| @@ -77,7 +77,7 @@ class ProcessoExpedidoRN extends InfraRN { | @@ -77,7 +77,7 @@ class ProcessoExpedidoRN extends InfraRN { | ||
| 77 | AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ." | 77 | AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ." |
| 78 | AND at2.dth_abertura > a.dth_abertura ) "; | 78 | AND at2.dth_abertura > a.dth_abertura ) "; |
| 79 | 79 | ||
| 80 | -//die($sql); | 80 | + //die($sql); |
| 81 | $pag = $this->getObjInfraIBanco()->consultarSql($sql); | 81 | $pag = $this->getObjInfraIBanco()->consultarSql($sql); |
| 82 | $count = $this->getObjInfraIBanco()->consultarSql($sqlCount); | 82 | $count = $this->getObjInfraIBanco()->consultarSql($sqlCount); |
| 83 | $total = $count ? $count[0]['total'] : 0; | 83 | $total = $count ? $count[0]['total'] : 0; |
| @@ -88,12 +88,12 @@ class ProcessoExpedidoRN extends InfraRN { | @@ -88,12 +88,12 @@ class ProcessoExpedidoRN extends InfraRN { | ||
| 88 | $objProtocoloDTO->setNumRegistrosPaginaAtual(count($pag)); | 88 | $objProtocoloDTO->setNumRegistrosPaginaAtual(count($pag)); |
| 89 | 89 | ||
| 90 | foreach ($pag as $res) { | 90 | foreach ($pag as $res) { |
| 91 | - $data = new \DateTime($res['dth_abertura']); | 91 | + $data = BancoSEI::getInstance()->formatarLeituraDth($res['dth_abertura']); |
| 92 | $objProcessoExpedidoDTO = new ProcessoExpedidoDTO(); | 92 | $objProcessoExpedidoDTO = new ProcessoExpedidoDTO(); |
| 93 | $objProcessoExpedidoDTO->setDblIdProtocolo($res['id_protocolo']); | 93 | $objProcessoExpedidoDTO->setDblIdProtocolo($res['id_protocolo']); |
| 94 | $objProcessoExpedidoDTO->setStrProtocoloFormatado($res['protocolo_formatado']); | 94 | $objProcessoExpedidoDTO->setStrProtocoloFormatado($res['protocolo_formatado']); |
| 95 | $objProcessoExpedidoDTO->setStrNomeUsuario($res['nome_usuario']); | 95 | $objProcessoExpedidoDTO->setStrNomeUsuario($res['nome_usuario']); |
| 96 | - $objProcessoExpedidoDTO->setDthExpedido($data->format('d/m/Y H:i:s')); | 96 | + $objProcessoExpedidoDTO->setDthExpedido($data); |
| 97 | $objProcessoExpedidoDTO->setStrDestino($res['unidade_destino']); | 97 | $objProcessoExpedidoDTO->setStrDestino($res['unidade_destino']); |
| 98 | 98 | ||
| 99 | $arrProcessosExpedidos[] = $objProcessoExpedidoDTO; | 99 | $arrProcessosExpedidos[] = $objProcessoExpedidoDTO; |
rn/ReceberComponenteDigitalRN.php
| @@ -6,7 +6,7 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -6,7 +6,7 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 6 | private $objProcessoEletronicoRN; | 6 | private $objProcessoEletronicoRN; |
| 7 | private $objInfraParametro; | 7 | private $objInfraParametro; |
| 8 | private $arrAnexos = array(); | 8 | private $arrAnexos = array(); |
| 9 | - | 9 | + |
| 10 | public function __construct() | 10 | public function __construct() |
| 11 | { | 11 | { |
| 12 | parent::__construct(); | 12 | parent::__construct(); |
| @@ -18,40 +18,24 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -18,40 +18,24 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 18 | public function setArrAnexos($arrAnexos){ | 18 | public function setArrAnexos($arrAnexos){ |
| 19 | $this->arrAnexos = $arrAnexos; | 19 | $this->arrAnexos = $arrAnexos; |
| 20 | } | 20 | } |
| 21 | - | 21 | + |
| 22 | public function getArrAnexos(){ | 22 | public function getArrAnexos(){ |
| 23 | return $this->arrAnexos; | 23 | return $this->arrAnexos; |
| 24 | } | 24 | } |
| 25 | - | 25 | + |
| 26 | protected function inicializarObjInfraIBanco() | 26 | protected function inicializarObjInfraIBanco() |
| 27 | { | 27 | { |
| 28 | return BancoSEI::getInstance(); | 28 | return BancoSEI::getInstance(); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - //TODO: Implementar o recebimento fracionado dos componentes digitais | ||
| 32 | protected function receberComponenteDigitalConectado(ComponenteDigitalDTO $parObjComponenteDigitalDTO) | 31 | protected function receberComponenteDigitalConectado(ComponenteDigitalDTO $parObjComponenteDigitalDTO) |
| 33 | { | 32 | { |
| 33 | + | ||
| 34 | if(!isset($parObjComponenteDigitalDTO) || !isset($parObjComponenteDigitalDTO)) { | 34 | if(!isset($parObjComponenteDigitalDTO) || !isset($parObjComponenteDigitalDTO)) { |
| 35 | throw new InfraException('Parâmetro $parObjComponenteDigitalDTO não informado.'); | 35 | throw new InfraException('Parâmetro $parObjComponenteDigitalDTO não informado.'); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | - //Obter os dados do componente digital | ||
| 39 | -// $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital( | ||
| 40 | -// $parObjComponenteDigitalDTO->getNumIdTramite(), | ||
| 41 | -// $parObjComponenteDigitalDTO->getStrHashConteudo(), | ||
| 42 | -// $parObjComponenteDigitalDTO->getStrProtocolo()); | ||
| 43 | - | ||
| 44 | -// if(!isset($objComponenteDigital) || InfraString::isBolVazia($objComponenteDigital->conteudoDoComponenteDigital)) { | ||
| 45 | -// throw new InfraException("Não foi possível obter informações do componente digital identificado (".$parObjComponenteDigitalDTO->getStrHashConteudo().")"); | ||
| 46 | -// } | ||
| 47 | - | ||
| 48 | - //Copiar dados dos componentes digitais para o diretório de upload | ||
| 49 | -// $objAnexoDTO = $this->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | $objAnexoDTO = null; | 38 | $objAnexoDTO = null; |
| 54 | - | ||
| 55 | foreach($this->arrAnexos as $key => $objAnexo){ | 39 | foreach($this->arrAnexos as $key => $objAnexo){ |
| 56 | if(array_key_exists($parObjComponenteDigitalDTO->getStrHashConteudo(), $objAnexo) && $objAnexo['recebido'] == false){ | 40 | if(array_key_exists($parObjComponenteDigitalDTO->getStrHashConteudo(), $objAnexo) && $objAnexo['recebido'] == false){ |
| 57 | $objAnexoDTO = $objAnexo[$parObjComponenteDigitalDTO->getStrHashConteudo()]; | 41 | $objAnexoDTO = $objAnexo[$parObjComponenteDigitalDTO->getStrHashConteudo()]; |
| @@ -59,15 +43,15 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -59,15 +43,15 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 59 | break; | 43 | break; |
| 60 | } | 44 | } |
| 61 | } | 45 | } |
| 62 | - | 46 | + |
| 63 | if(is_null($objAnexoDTO)){ | 47 | if(is_null($objAnexoDTO)){ |
| 64 | - throw new InfraException('Anexo '.$parObjComponenteDigitalDTO->getStrHashConteudo().' não encontrado'.var_export($this->arrAnexos, true)); | 48 | + throw new InfraException('Anexo '.$parObjComponenteDigitalDTO->getStrHashConteudo().' não encontrado '.var_export($this->arrAnexos, true)); |
| 65 | } | 49 | } |
| 66 | - | 50 | + |
| 67 | //Validar o hash do documento recebido com os dados informados pelo remetente | 51 | //Validar o hash do documento recebido com os dados informados pelo remetente |
| 68 | //$this->validarIntegridadeDoComponenteDigital($objAnexoDTO, $parObjComponenteDigitalDTO); | 52 | //$this->validarIntegridadeDoComponenteDigital($objAnexoDTO, $parObjComponenteDigitalDTO); |
| 69 | 53 | ||
| 70 | - //Transaferir documentos validados para o repositório final de arquivos | 54 | + //Transferir documentos validados para o repositório final de arquivos |
| 71 | $this->cadastrarComponenteDigital($parObjComponenteDigitalDTO, $objAnexoDTO); | 55 | $this->cadastrarComponenteDigital($parObjComponenteDigitalDTO, $objAnexoDTO); |
| 72 | 56 | ||
| 73 | //Registrar anexo relacionado com o componente digital | 57 | //Registrar anexo relacionado com o componente digital |
| @@ -80,9 +64,7 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -80,9 +64,7 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 80 | $objComponenteDigitalDTO->setNumIdTramite($parObjComponenteDigitalDTO->getNumIdTramite()); | 64 | $objComponenteDigitalDTO->setNumIdTramite($parObjComponenteDigitalDTO->getNumIdTramite()); |
| 81 | $objComponenteDigitalDTO->setStrNumeroRegistro($parObjComponenteDigitalDTO->getStrNumeroRegistro()); | 65 | $objComponenteDigitalDTO->setStrNumeroRegistro($parObjComponenteDigitalDTO->getStrNumeroRegistro()); |
| 82 | $objComponenteDigitalDTO->setDblIdDocumento($parObjComponenteDigitalDTO->getDblIdDocumento()); | 66 | $objComponenteDigitalDTO->setDblIdDocumento($parObjComponenteDigitalDTO->getDblIdDocumento()); |
| 83 | - | ||
| 84 | $objComponenteDigitalDTO->setNumIdAnexo($parObjAnexoDTO->getNumIdAnexo()); | 67 | $objComponenteDigitalDTO->setNumIdAnexo($parObjAnexoDTO->getNumIdAnexo()); |
| 85 | - | ||
| 86 | $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | 68 | $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); |
| 87 | $objComponenteDigitalDTO = $objComponenteDigitalBD->alterar($objComponenteDigitalDTO); | 69 | $objComponenteDigitalDTO = $objComponenteDigitalBD->alterar($objComponenteDigitalDTO); |
| 88 | } | 70 | } |
| @@ -93,12 +75,11 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -93,12 +75,11 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 93 | $strNomeArquivoUpload = $objAnexoRN->gerarNomeArquivoTemporario(); | 75 | $strNomeArquivoUpload = $objAnexoRN->gerarNomeArquivoTemporario(); |
| 94 | $strConteudoCodificado = $objComponenteDigital->conteudoDoComponenteDigital; | 76 | $strConteudoCodificado = $objComponenteDigital->conteudoDoComponenteDigital; |
| 95 | $strNome = $objComponenteDigital->nome; | 77 | $strNome = $objComponenteDigital->nome; |
| 96 | - | ||
| 97 | - | 78 | + |
| 98 | $fp = fopen(DIR_SEI_TEMP.'/'.$strNomeArquivoUpload,'w'); | 79 | $fp = fopen(DIR_SEI_TEMP.'/'.$strNomeArquivoUpload,'w'); |
| 99 | fwrite($fp,$strConteudoCodificado); | 80 | fwrite($fp,$strConteudoCodificado); |
| 100 | fclose($fp); | 81 | fclose($fp); |
| 101 | - | 82 | + |
| 102 | //Atribui informações do arquivo anexo | 83 | //Atribui informações do arquivo anexo |
| 103 | $objAnexoDTO = new AnexoDTO(); | 84 | $objAnexoDTO = new AnexoDTO(); |
| 104 | $objAnexoDTO->setNumIdAnexo($strNomeArquivoUpload); | 85 | $objAnexoDTO->setNumIdAnexo($strNomeArquivoUpload); |
| @@ -119,11 +100,11 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -119,11 +100,11 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 119 | $strHashDoArquivo = hash_file("sha256", $strCaminhoAnexo, true); | 100 | $strHashDoArquivo = hash_file("sha256", $strCaminhoAnexo, true); |
| 120 | 101 | ||
| 121 | if(strcmp($strHashInformado, $strHashDoArquivo) != 0) { | 102 | if(strcmp($strHashInformado, $strHashDoArquivo) != 0) { |
| 122 | - | 103 | + |
| 123 | $this->objProcessoEletronicoRN->recusarTramite($parNumIdentificacaoTramite, "Hash do componente digital não confere com o valor informado pelo remetente.", ProcessoEletronicoRN::MTV_RCSR_TRAM_CD_CORROMPIDO); | 104 | $this->objProcessoEletronicoRN->recusarTramite($parNumIdentificacaoTramite, "Hash do componente digital não confere com o valor informado pelo remetente.", ProcessoEletronicoRN::MTV_RCSR_TRAM_CD_CORROMPIDO); |
| 124 | 105 | ||
| 125 | // Adiciono nos detalhes o nome do método para poder manipular o cache | 106 | // Adiciono nos detalhes o nome do método para poder manipular o cache |
| 126 | - throw new InfraException("Hash do componente digital não confere com o valor informado pelo remetente.", null, __METHOD__); | 107 | + throw new InfraException("Hash do componente digital não confere com o valor informado pelo remetente.", null, __METHOD__); |
| 127 | } | 108 | } |
| 128 | } | 109 | } |
| 129 | 110 | ||
| @@ -134,10 +115,10 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -134,10 +115,10 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 134 | $objDocumentoDTO->retDblIdDocumento(); | 115 | $objDocumentoDTO->retDblIdDocumento(); |
| 135 | $objDocumentoDTO->retDblIdProcedimento(); | 116 | $objDocumentoDTO->retDblIdProcedimento(); |
| 136 | $objDocumentoDTO->setDblIdDocumento($parObjComponenteDigitalDTO->getDblIdDocumento()); | 117 | $objDocumentoDTO->setDblIdDocumento($parObjComponenteDigitalDTO->getDblIdDocumento()); |
| 137 | - | 118 | + |
| 138 | $objDocumentoRN = new DocumentoRN(); | 119 | $objDocumentoRN = new DocumentoRN(); |
| 139 | $objDocumentoDTO = $objDocumentoRN->consultarRN0005($objDocumentoDTO); | 120 | $objDocumentoDTO = $objDocumentoRN->consultarRN0005($objDocumentoDTO); |
| 140 | - | 121 | + |
| 141 | if ($objDocumentoDTO==null){ | 122 | if ($objDocumentoDTO==null){ |
| 142 | throw new InfraException("Registro não encontrado."); | 123 | throw new InfraException("Registro não encontrado."); |
| 143 | } | 124 | } |
| @@ -149,24 +130,24 @@ class ReceberComponenteDigitalRN extends InfraRN | @@ -149,24 +130,24 @@ class ReceberComponenteDigitalRN extends InfraRN | ||
| 149 | 130 | ||
| 150 | $objProtocoloRN = new ProtocoloRN(); | 131 | $objProtocoloRN = new ProtocoloRN(); |
| 151 | $objProtocoloDTO = $objProtocoloRN->consultarRN0186($objProtocoloDTO); | 132 | $objProtocoloDTO = $objProtocoloRN->consultarRN0186($objProtocoloDTO); |
| 152 | - | 133 | + |
| 153 | //Complementa informações do componente digital | 134 | //Complementa informações do componente digital |
| 154 | $parObjAnexoDTO->setStrNome($parObjComponenteDigitalDTO->getStrNome()); | 135 | $parObjAnexoDTO->setStrNome($parObjComponenteDigitalDTO->getStrNome()); |
| 155 | - | 136 | + |
| 156 | $arrStrNome = explode('.',$parObjComponenteDigitalDTO->getStrNome()); | 137 | $arrStrNome = explode('.',$parObjComponenteDigitalDTO->getStrNome()); |
| 157 | $strProtocoloFormatado = current($arrStrNome); | 138 | $strProtocoloFormatado = current($arrStrNome); |
| 158 | - | 139 | + |
| 159 | $objDocumentoDTO->setObjProtocoloDTO($objProtocoloDTO); | 140 | $objDocumentoDTO->setObjProtocoloDTO($objProtocoloDTO); |
| 160 | $objProtocoloDTO->setArrObjAnexoDTO(array($parObjAnexoDTO)); | 141 | $objProtocoloDTO->setArrObjAnexoDTO(array($parObjAnexoDTO)); |
| 161 | $objDocumentoDTO = $objDocumentoRN->alterarRN0004($objDocumentoDTO); | 142 | $objDocumentoDTO = $objDocumentoRN->alterarRN0004($objDocumentoDTO); |
| 162 | - | 143 | + |
| 163 | // @join_tec US029 (#3790) | 144 | // @join_tec US029 (#3790) |
| 164 | /*$objObservacaoDTO = new ObservacaoDTO(); | 145 | /*$objObservacaoDTO = new ObservacaoDTO(); |
| 165 | $objObservacaoDTO->setDblIdProtocolo($objProtocoloDTO->getDblIdProtocolo()); | 146 | $objObservacaoDTO->setDblIdProtocolo($objProtocoloDTO->getDblIdProtocolo()); |
| 166 | $objObservacaoDTO->setStrDescricao(sprintf('Número SEI do Documento na Origem: %s', $strProtocoloFormatado)); | 147 | $objObservacaoDTO->setStrDescricao(sprintf('Número SEI do Documento na Origem: %s', $strProtocoloFormatado)); |
| 167 | $objObservacaoDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); | 148 | $objObservacaoDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); |
| 168 | - | 149 | + |
| 169 | $objObservacaoBD = new ObservacaoRN(); | 150 | $objObservacaoBD = new ObservacaoRN(); |
| 170 | $objObservacaoBD->cadastrarRN0222($objObservacaoDTO);*/ | 151 | $objObservacaoBD->cadastrarRN0222($objObservacaoDTO);*/ |
| 171 | } | 152 | } |
| 172 | -} | ||
| 173 | \ No newline at end of file | 153 | \ No newline at end of file |
| 154 | +} |
rn/ReceberProcedimentoRN.php
| @@ -80,209 +80,193 @@ class ReceberProcedimentoRN extends InfraRN | @@ -80,209 +80,193 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 80 | $objInfraSessao->trocarUnidadeAtual(); | 80 | $objInfraSessao->trocarUnidadeAtual(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | - // TODO: Adicionar comandos de debug. Vide SeiWs.php gerarProcedimento | ||
| 84 | - protected function receberProcedimentoControlado($parNumIdentificacaoTramite) | ||
| 85 | - { | ||
| 86 | - | ||
| 87 | - $objPenParametroRN = new PenParametroRN(); | ||
| 88 | - SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO')); | ||
| 89 | - | ||
| 90 | - $objSeiRN = new SeiRN(); | ||
| 91 | - | ||
| 92 | - if (!isset($parNumIdentificacaoTramite)) { | ||
| 93 | - throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.'); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - //TODO: Urgente: Verificar o status do trâmite e verificar se ele já foi salvo na base de dados | ||
| 97 | - $objMetadadosProcedimento = $this->objProcessoEletronicoRN->solicitarMetadados($parNumIdentificacaoTramite); | ||
| 98 | - | ||
| 99 | - //!Substituir a unidade destinatária para a receptora (!1!) | ||
| 100 | - if (isset($objMetadadosProcedimento->metadados->unidadeReceptora)) { | ||
| 101 | - $this->destinatarioReal = $objMetadadosProcedimento->metadados->destinatario; | ||
| 102 | - $objMetadadosProcedimento->metadados->destinatario = $objMetadadosProcedimento->metadados->unidadeReceptora; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - if (isset($objMetadadosProcedimento)) { | ||
| 106 | - | ||
| 107 | - $strNumeroRegistro = $objMetadadosProcedimento->metadados->NRE; | ||
| 108 | - $objProcesso = $objMetadadosProcedimento->metadados->processo; | ||
| 109 | - | ||
| 110 | - //Verifica se processo já foi registrado para esse trâmite | ||
| 111 | - //TODO: Ajuste para receber corretamente processo em outra unidade do mesmo sistema passando pelo Barramento | ||
| 112 | - //Comentando o trecho abaixo funciona, mas o processo fica aberto na unidade de destino | ||
| 113 | - if($this->tramiteRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite)) { | ||
| 114 | - InfraDebug::getInstance()->gravar("Trâmite $parNumIdentificacaoTramite desconsiderado por já ter sido processado para o processo" . $objProcesso->protocolo); | ||
| 115 | - // return ; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - // Validação dos dados do processo recebido | ||
| 119 | - $objInfraException = new InfraException(); | ||
| 120 | - $this->validarDadosDestinatario($objInfraException, $objMetadadosProcedimento); | ||
| 121 | - $objInfraException->lancarValidacoes(); | ||
| 122 | - | ||
| 123 | - #############################INICIA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################ | ||
| 124 | - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 125 | - $objTramite = $arrObjTramite[0]; | ||
| 126 | - | ||
| 127 | - //Obtém lista de componentes digitais que precisam ser obtidos | ||
| 128 | - if(!is_array($objTramite->componenteDigitalPendenteDeRecebimento)){ | ||
| 129 | - $objTramite->componenteDigitalPendenteDeRecebimento = array($objTramite->componenteDigitalPendenteDeRecebimento); | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - //Faz a validação do tamanho e espécie dos componentes digitais | ||
| 133 | - $this->validarComponentesDigitais($objProcesso, $parNumIdentificacaoTramite); | ||
| 134 | - | ||
| 135 | - //Faz a validação da extensão dos componentes digitais a serem recebidos | ||
| 136 | - $this->validarExtensaoComponentesDigitais($parNumIdentificacaoTramite, $objProcesso); | ||
| 137 | - //Faz a validação das permissões de leitura e escrita | ||
| 138 | - $this->verificarPermissoesDiretorios($parNumIdentificacaoTramite); | ||
| 139 | - | ||
| 140 | - $arrStrNomeDocumento = $this->listarMetaDadosComponentesDigitais($objProcesso); | ||
| 141 | - | ||
| 142 | - //Instancia a RN que faz o recebimento dos componentes digitais | ||
| 143 | - $receberComponenteDigitalRN = new ReceberComponenteDigitalRN(); | ||
| 144 | - | ||
| 145 | - //Cria o array que receberá os anexos após os arquivos físicos serem salvos | ||
| 146 | - $arrAnexosComponentes = array(); | ||
| 147 | - | ||
| 148 | - //Cria o array com a lista de hash | ||
| 149 | - $arrayHash = array(); | ||
| 150 | - | ||
| 151 | - //Percorre os componentes que precisam ser recebidos | ||
| 152 | - foreach($objTramite->componenteDigitalPendenteDeRecebimento as $key => $componentePendente){ | ||
| 153 | - | ||
| 154 | - if(!is_null($componentePendente)){ | ||
| 155 | - | ||
| 156 | - //Adiciona o hash do componente digital ao array | ||
| 157 | - $arrayHash[] = $componentePendente; | ||
| 158 | - | ||
| 159 | - //Obter os dados do componente digital | ||
| 160 | - $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo); | ||
| 161 | - //Copia o componente para a pasta temporária | ||
| 162 | - $arrAnexosComponentes[$key][$componentePendente] = $receberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); | ||
| 163 | - $arrAnexosComponentes[$key]['recebido'] = false; | ||
| 164 | 83 | ||
| 165 | - //Valida a integridade do hash | ||
| 166 | - $receberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], $componentePendente, $parNumIdentificacaoTramite); | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - if(count($arrAnexosComponentes) > 0){ | ||
| 170 | - | ||
| 171 | - $receberComponenteDigitalRN->setArrAnexos($arrAnexosComponentes); | ||
| 172 | - } | ||
| 173 | - #############################TERMINA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################ | 84 | + protected function receberProcedimentoControlado($parNumIdentificacaoTramite) |
| 85 | + { | ||
| 86 | + try { | ||
| 87 | + $objPenParametroRN = new PenParametroRN(); | ||
| 88 | + SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objPenParametroRN->getParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO')); | ||
| 174 | 89 | ||
| 175 | - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 176 | - $objTramite = $arrObjTramite[0]; | 90 | + $objSeiRN = new SeiRN(); |
| 177 | 91 | ||
| 178 | - //Verifica se o trâmite está recusado | ||
| 179 | - if($objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO) { | ||
| 180 | - return; | ||
| 181 | - } | 92 | + if (!isset($parNumIdentificacaoTramite)) { |
| 93 | + throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.'); | ||
| 94 | + } | ||
| 182 | 95 | ||
| 183 | - $objProcedimentoDTO = $this->registrarProcesso($strNumeroRegistro, $parNumIdentificacaoTramite, $objProcesso, $objMetadadosProcedimento); | 96 | + //TODO: Urgente: Verificar o status do trâmite e verificar se ele já foi salvo na base de dados |
| 97 | + $this->gravarLogDebug("Solicitando metadados do trâmite " . $parNumIdentificacaoTramite, 4); | ||
| 98 | + $objMetadadosProcedimento = $this->objProcessoEletronicoRN->solicitarMetadados($parNumIdentificacaoTramite); | ||
| 184 | 99 | ||
| 100 | + //Substituir a unidade destinatária para a receptora (!1!) | ||
| 101 | + if (isset($objMetadadosProcedimento->metadados->unidadeReceptora)) { | ||
| 102 | + $numUnidadeReceptora = $objMetadadosProcedimento->metadados->unidadeReceptora; | ||
| 103 | + $this->destinatarioReal = $objMetadadosProcedimento->metadados->destinatario; | ||
| 104 | + $objMetadadosProcedimento->metadados->destinatario = $numUnidadeReceptora; | ||
| 105 | + $this->gravarLogDebug("Atribuindo unidade receptora $numUnidadeReceptora para o trâmite $parNumIdentificacaoTramite", 4); | ||
| 106 | + } | ||
| 185 | 107 | ||
| 108 | + if (isset($objMetadadosProcedimento)) { | ||
| 109 | + $strNumeroRegistro = $objMetadadosProcedimento->metadados->NRE; | ||
| 110 | + $objProcesso = $objMetadadosProcedimento->metadados->processo; | ||
| 186 | 111 | ||
| 112 | + //Verifica se processo já foi registrado para esse trâmite | ||
| 113 | + //TODO: Ajuste para receber corretamente processo em outra unidade do mesmo sistema passando pelo Barramento | ||
| 114 | + //Comentando o trecho abaixo funciona, mas o processo fica aberto na unidade de destino | ||
| 115 | + if($this->tramiteRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite)) { | ||
| 116 | + $this->gravarLogDebug("Trâmite $parNumIdentificacaoTramite já para o processo " . $objProcesso->protocolo, 4); | ||
| 117 | + // return ; | ||
| 118 | + } | ||
| 187 | 119 | ||
| 188 | - // @join_tec US008.08 (#23092) | ||
| 189 | - $this->objProcedimentoAndamentoRN->setOpts($objProcedimentoDTO->getDblIdProcedimento(), $parNumIdentificacaoTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO)); | ||
| 190 | - $this->objProcedimentoAndamentoRN->cadastrar('Obtendo metadados do processo', 'S'); | 120 | + // Validação dos dados do processo recebido |
| 121 | + $objInfraException = new InfraException(); | ||
| 122 | + $this->validarDadosDestinatario($objInfraException, $objMetadadosProcedimento); | ||
| 123 | + $objInfraException->lancarValidacoes(); | ||
| 191 | 124 | ||
| 192 | - //Verificar se procedimento já existia na base de dados do sistema | ||
| 193 | - //$dblIdProcedimento = $this->consultarProcedimentoExistente($strNumeroRegistro, $strProtocolo); | 125 | + #############################INICIA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################ |
| 126 | + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 127 | + $objTramite = $arrObjTramite[0]; | ||
| 194 | 128 | ||
| 195 | - //if(isset($dblIdProcedimento)){ | ||
| 196 | - //TODO: Tratar situação em que o processo (NUP) já existia na base do sistema mas não havia nenhum NRE registrado para ele | ||
| 197 | - // $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $objMetadadosProcedimento, $objProcesso); | ||
| 198 | - //} | ||
| 199 | - //else { | ||
| 200 | - //TODO: Gerar Procedimento com status BLOQUEADO, aguardando o recebimento dos componentes digitais | ||
| 201 | - // $objProcedimentoDTO = $this->gerarProcedimento($objMetadadosProcedimento, $objProcesso); | ||
| 202 | - //} | 129 | + //Obtém lista de componentes digitais que precisam ser obtidos |
| 130 | + $this->gravarLogDebug("Obtém lista de componentes digitais que precisam ser obtidos", 4); | ||
| 131 | + if(!is_array($objTramite->componenteDigitalPendenteDeRecebimento)){ | ||
| 132 | + $objTramite->componenteDigitalPendenteDeRecebimento = array($objTramite->componenteDigitalPendenteDeRecebimento); | ||
| 133 | + } | ||
| 203 | 134 | ||
| 204 | - //TODO: Fazer o envio de cada um dos procedimentos apensados (Processo principal e seus apensados, caso exista) | ||
| 205 | - //... | ||
| 206 | - //TODO: Parei aqui!!! Recebimento de processos apensados | 135 | + $this->validarComponentesDigitais($objProcesso, $parNumIdentificacaoTramite); |
| 136 | + $this->validarExtensaoComponentesDigitais($parNumIdentificacaoTramite, $objProcesso); | ||
| 137 | + $this->verificarPermissoesDiretorios($parNumIdentificacaoTramite); | ||
| 207 | 138 | ||
| 208 | - $objProcessoEletronicoDTO = $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso($objProcedimentoDTO->getDblIdProcedimento(), | ||
| 209 | - $strNumeroRegistro, $parNumIdentificacaoTramite, null, $objProcesso); | 139 | + $this->gravarLogDebug("Obtendo metadados dos componentes digitais do processo", 4); |
| 140 | + $arrStrNomeDocumento = $this->listarMetaDadosComponentesDigitais($objProcesso); | ||
| 141 | + $receberComponenteDigitalRN = new ReceberComponenteDigitalRN(); | ||
| 142 | + $arrAnexosComponentes = array(); | ||
| 143 | + $arrayHash = array(); | ||
| 144 | + $arrayHashPendentes = array(); | ||
| 210 | 145 | ||
| 146 | + //Percorre os componentes que precisam ser recebidos | ||
| 147 | + foreach($objTramite->componenteDigitalPendenteDeRecebimento as $key => $componentePendente){ | ||
| 211 | 148 | ||
| 149 | + if(!is_null($componentePendente)){ | ||
| 212 | 150 | ||
| 213 | - //TODO: Passar implementação para outra classe de negócio | ||
| 214 | - //Verifica se o tramite se encontra na situação correta | ||
| 215 | - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 216 | - if(!isset($arrObjTramite) || count($arrObjTramite) != 1) { | ||
| 217 | - throw new InfraException("Trâmite não pode ser localizado pelo identificado $parNumIdentificacaoTramite."); | ||
| 218 | - } | 151 | + if(!$this->documentoJaRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite, $componentePendente)){ |
| 152 | + $arrayHashPendentes[] = $componentePendente; | ||
| 153 | + } | ||
| 219 | 154 | ||
| 155 | + //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 | ||
| 156 | + //Ajuste deverá ser feito em versões futuas | ||
| 157 | + $arrayHash[] = $componentePendente; | ||
| 220 | 158 | ||
| 221 | - $objTramite = $arrObjTramite[0]; | 159 | + //Obter os dados do componente digital |
| 160 | + $this->gravarLogDebug("Baixando componente digital $key", 6); | ||
| 161 | + $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo); | ||
| 162 | + $arrAnexosComponentes[$key][$componentePendente] = $receberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital); | ||
| 163 | + $arrAnexosComponentes[$key]['recebido'] = false; | ||
| 222 | 164 | ||
| 165 | + //Valida a integridade do hash | ||
| 166 | + $this->gravarLogDebug("Validando integridade de componente digital $key", 6); | ||
| 167 | + $receberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], $componentePendente, $parNumIdentificacaoTramite); | ||
| 168 | + } | ||
| 169 | + } | ||
| 223 | 170 | ||
| 224 | - if($objTramite->situacaoAtual != ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { | ||
| 225 | - return; | ||
| 226 | - } | 171 | + if(count($arrAnexosComponentes) > 0){ |
| 172 | + $receberComponenteDigitalRN->setArrAnexos($arrAnexosComponentes); | ||
| 173 | + } | ||
| 174 | + #############################TERMINA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################ | ||
| 227 | 175 | ||
| 176 | + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 177 | + $objTramite = $arrObjTramite[0]; | ||
| 228 | 178 | ||
| 229 | - // throw new InfraException("COMPONENTES DIGITAIS A SEREM ANEXADOS: ".var_export($arrayHash, true)); | ||
| 230 | - if(count($arrayHash) > 0){ | 179 | + //Verifica se o trâmite está recusado |
| 180 | + if($objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO) { | ||
| 181 | + $this->gravarLogDebug("Trâmite $parNumIdentificacaoTramite já se encontra recusado. Cancelando o recebimento do processo", 4); | ||
| 182 | + return; | ||
| 183 | + } | ||
| 231 | 184 | ||
| 232 | - //Obter dados dos componetes digitais | ||
| 233 | - $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | ||
| 234 | - $objComponenteDigitalDTO->setStrNumeroRegistro($strNumeroRegistro); | ||
| 235 | - $objComponenteDigitalDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 236 | - $objComponenteDigitalDTO->setStrHashConteudo($arrayHash, InfraDTO::$OPER_IN); | ||
| 237 | - $objComponenteDigitalDTO->setOrdNumOrdem(InfraDTO::$TIPO_ORDENACAO_ASC); | ||
| 238 | - $objComponenteDigitalDTO->retDblIdDocumento(); | ||
| 239 | - $objComponenteDigitalDTO->retNumTicketEnvioComponentes(); | ||
| 240 | - // $objComponenteDigitalDTO->retStrConteudoAssinaturaDocumento(); | ||
| 241 | - $objComponenteDigitalDTO->retStrProtocoloDocumentoFormatado(); | ||
| 242 | - $objComponenteDigitalDTO->retStrHashConteudo(); | ||
| 243 | - $objComponenteDigitalDTO->retStrProtocolo(); | ||
| 244 | - $objComponenteDigitalDTO->retStrNumeroRegistro(); | ||
| 245 | - $objComponenteDigitalDTO->retNumIdTramite(); | ||
| 246 | - $objComponenteDigitalDTO->retStrNome(); | ||
| 247 | - $objComponenteDigitalDTO->retStrStaEstadoProtocolo(); | 185 | + $this->gravarLogDebug("Persistindo/atualizando dados do processo com NRE " . $strNumeroRegistro, 4); |
| 186 | + $objProcedimentoDTO = $this->registrarProcesso($strNumeroRegistro, $parNumIdentificacaoTramite, $objProcesso, $objMetadadosProcedimento); | ||
| 248 | 187 | ||
| 249 | - $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | ||
| 250 | - $arrObjComponentesDigitaisDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO); | ||
| 251 | 188 | ||
| 252 | - // throw new InfraException('Componentes encontrados: '.var_export($arrObjComponentesDigitaisDTO, true)); | 189 | + // @join_tec US008.08 (#23092) |
| 190 | + $this->objProcedimentoAndamentoRN->setOpts($objProcedimentoDTO->getDblIdProcedimento(), $parNumIdentificacaoTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO)); | ||
| 191 | + $this->objProcedimentoAndamentoRN->cadastrar('Obtendo metadados do processo', 'S'); | ||
| 253 | 192 | ||
| 254 | - if ($objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0) { | ||
| 255 | 193 | ||
| 256 | - $objReceberComponenteDigitalRN = $receberComponenteDigitalRN; | 194 | + $this->gravarLogDebug("Registrando trâmite externo do processo", 4); |
| 195 | + $objProcessoEletronicoDTO = $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso($objProcedimentoDTO->getDblIdProcedimento(), | ||
| 196 | + $strNumeroRegistro, $parNumIdentificacaoTramite, null, $objProcesso); | ||
| 257 | 197 | ||
| 258 | - foreach($arrObjComponentesDigitaisDTO as $objComponenteDigitalDTOEnviado) { | ||
| 259 | - if($objComponenteDigitalDTOEnviado->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | ||
| 260 | - $strHash = $objComponenteDigitalDTOEnviado->getStrHashConteudo(); | ||
| 261 | - $strNomeDocumento = (array_key_exists($strHash, $arrStrNomeDocumento)) ? $arrStrNomeDocumento[$strHash]['especieNome'] : '[Desconhecido]'; | 198 | + //Verifica se o tramite se encontra na situação correta |
| 199 | + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 200 | + if(!isset($arrObjTramite) || count($arrObjTramite) != 1) { | ||
| 201 | + throw new InfraException("Trâmite não pode ser localizado pelo identificado $parNumIdentificacaoTramite."); | ||
| 202 | + } | ||
| 262 | 203 | ||
| 263 | - $objReceberComponenteDigitalRN->receberComponenteDigital($objComponenteDigitalDTOEnviado); | ||
| 264 | 204 | ||
| 265 | - // @join_tec US008.09 (#23092) | ||
| 266 | - $this->objProcedimentoAndamentoRN->cadastrar(sprintf('Recebendo %s %s', $strNomeDocumento, $objComponenteDigitalDTOEnviado->getStrProtocoloDocumentoFormatado()), 'S'); | ||
| 267 | - } | 205 | + $objTramite = $arrObjTramite[0]; |
| 206 | + if($objTramite->situacaoAtual != ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) { | ||
| 207 | + $this->gravarLogDebug("Desconsiderando recebimento do processo devido a situação de trâmite inconsistente: " . $objTramite->situacaoAtual, 4); | ||
| 208 | + return; | ||
| 209 | + } | ||
| 268 | 210 | ||
| 211 | + if(count($arrayHashPendentes) > 0){ | ||
| 212 | + //Obter dados dos componetes digitais | ||
| 213 | + $this->gravarLogDebug("Iniciando o recebimento dos componentes digitais pendentes", 4); | ||
| 214 | + $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | ||
| 215 | + $objComponenteDigitalDTO->setStrNumeroRegistro($strNumeroRegistro); | ||
| 216 | + $objComponenteDigitalDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 217 | + $objComponenteDigitalDTO->setStrHashConteudo($arrayHash, InfraDTO::$OPER_IN); | ||
| 218 | + $objComponenteDigitalDTO->setOrdNumOrdem(InfraDTO::$TIPO_ORDENACAO_ASC); | ||
| 219 | + $objComponenteDigitalDTO->retDblIdDocumento(); | ||
| 220 | + $objComponenteDigitalDTO->retNumTicketEnvioComponentes(); | ||
| 221 | + $objComponenteDigitalDTO->retStrProtocoloDocumentoFormatado(); | ||
| 222 | + $objComponenteDigitalDTO->retStrHashConteudo(); | ||
| 223 | + $objComponenteDigitalDTO->retStrProtocolo(); | ||
| 224 | + $objComponenteDigitalDTO->retStrNumeroRegistro(); | ||
| 225 | + $objComponenteDigitalDTO->retNumIdTramite(); | ||
| 226 | + $objComponenteDigitalDTO->retStrNome(); | ||
| 227 | + $objComponenteDigitalDTO->retStrStaEstadoProtocolo(); | ||
| 228 | + | ||
| 229 | + $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | ||
| 230 | + $arrObjComponentesDigitaisDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO); | ||
| 231 | + | ||
| 232 | + if ($objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0) { | ||
| 233 | + $objReceberComponenteDigitalRN = $receberComponenteDigitalRN; | ||
| 234 | + foreach($arrObjComponentesDigitaisDTO as $objComponenteDigitalDTOEnviado) { | ||
| 235 | + if($objComponenteDigitalDTOEnviado->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | ||
| 236 | + $strHash = $objComponenteDigitalDTOEnviado->getStrHashConteudo(); | ||
| 237 | + $strNomeDocumento = (array_key_exists($strHash, $arrStrNomeDocumento)) ? $arrStrNomeDocumento[$strHash]['especieNome'] : '[Desconhecido]'; | ||
| 238 | + $objReceberComponenteDigitalRN->receberComponenteDigital($objComponenteDigitalDTOEnviado); | ||
| 239 | + | ||
| 240 | + // @join_tec US008.09 (#23092) | ||
| 241 | + $strMensagemRecebimento = sprintf('Recebendo %s %s', $strNomeDocumento, $objComponenteDigitalDTOEnviado->getStrProtocoloDocumentoFormatado()); | ||
| 242 | + $this->objProcedimentoAndamentoRN->cadastrar($strMensagemRecebimento, 'S'); | ||
| 243 | + $this->gravarLogDebug($strMensagemRecebimento, 6); | ||
| 244 | + } | ||
| 245 | + } | ||
| 246 | + // @join_tec US008.10 (#23092) | ||
| 247 | + $this->objProcedimentoAndamentoRN->cadastrar('Todos os componentes digitais foram recebidos', 'S'); | ||
| 248 | + | ||
| 249 | + }else{ | ||
| 250 | + $this->objProcedimentoAndamentoRN->cadastrar('Nenhum componente digital para receber', 'S'); | ||
| 251 | + } | ||
| 269 | } | 252 | } |
| 270 | - // @join_tec US008.10 (#23092) | ||
| 271 | - $this->objProcedimentoAndamentoRN->cadastrar('Todos os componentes digitais foram recebidos', 'S'); | ||
| 272 | - | ||
| 273 | - }else{ | ||
| 274 | - $this->objProcedimentoAndamentoRN->cadastrar('Nenhum componente digital para receber', 'S'); | ||
| 275 | } | 253 | } |
| 276 | - } | 254 | + //$this->fecharProcedimentoEmOutraUnidades($objProcedimentoDTO, $objMetadadosProcedimento); |
| 255 | + $this->gravarLogDebug("Enviando recibo de conclusão do trâmite $parNumIdentificacaoTramite", 6); | ||
| 256 | + $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN(); | ||
| 257 | + $objEnviarReciboTramiteRN->enviarReciboTramiteProcesso($parNumIdentificacaoTramite, $arrayHash); | ||
| 258 | + | ||
| 259 | + $this->gravarLogDebug("Registrando a conclusão do recebimento do trâmite $parNumIdentificacaoTramite", 6); | ||
| 260 | + $objPenTramiteProcessadoRN = new PenTramiteProcessadoRN(PenTramiteProcessadoRN::STR_TIPO_PROCESSO); | ||
| 261 | + $objPenTramiteProcessadoRN->setRecebido($parNumIdentificacaoTramite); | ||
| 262 | + | ||
| 263 | + } catch (Exception $e) { | ||
| 264 | + $mensagemErro = InfraException::inspecionar($e); | ||
| 265 | + $this->gravarLogDebug($mensagemErro); | ||
| 266 | + LogSEI::getInstance()->gravar($mensagemErro); | ||
| 267 | + throw $e; | ||
| 268 | + } | ||
| 277 | } | 269 | } |
| 278 | - //$this->fecharProcedimentoEmOutraUnidades($objProcedimentoDTO, $objMetadadosProcedimento); | ||
| 279 | - | ||
| 280 | - $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN(); | ||
| 281 | - $objEnviarReciboTramiteRN->enviarReciboTramiteProcesso($parNumIdentificacaoTramite, $arrayHash); | ||
| 282 | - | ||
| 283 | - $objPenTramiteProcessadoRN = new PenTramiteProcessadoRN(PenTramiteProcessadoRN::STR_TIPO_PROCESSO); | ||
| 284 | - $objPenTramiteProcessadoRN->setRecebido($parNumIdentificacaoTramite); | ||
| 285 | - } | ||
| 286 | 270 | ||
| 287 | /** | 271 | /** |
| 288 | * Retorna um array com alguns metadados, onde o indice de é o hash do arquivo | 272 | * Retorna um array com alguns metadados, onde o indice de é o hash do arquivo |
| @@ -376,8 +360,6 @@ class ReceberProcedimentoRN extends InfraRN | @@ -376,8 +360,6 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 376 | 360 | ||
| 377 | private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento) | 361 | private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento) |
| 378 | { | 362 | { |
| 379 | - | ||
| 380 | - | ||
| 381 | // Validação dos dados do processo recebido | 363 | // Validação dos dados do processo recebido |
| 382 | $objInfraException = new InfraException(); | 364 | $objInfraException = new InfraException(); |
| 383 | $this->validarDadosProcesso($objInfraException, $parObjProcesso); | 365 | $this->validarDadosProcesso($objInfraException, $parObjProcesso); |
| @@ -392,13 +374,9 @@ class ReceberProcedimentoRN extends InfraRN | @@ -392,13 +374,9 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 392 | $dblIdProcedimento = $this->consultarProcedimentoExistente($parStrNumeroRegistro, $parObjProcesso->protocolo); | 374 | $dblIdProcedimento = $this->consultarProcedimentoExistente($parStrNumeroRegistro, $parObjProcesso->protocolo); |
| 393 | 375 | ||
| 394 | if(isset($dblIdProcedimento)){ | 376 | if(isset($dblIdProcedimento)){ |
| 395 | - | ||
| 396 | - //TODO: Tratar situação em que o processo (NUP) já existia na base do sistema mas não havia nenhum NRE registrado para ele | ||
| 397 | $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso); | 377 | $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso); |
| 398 | } | 378 | } |
| 399 | else { | 379 | else { |
| 400 | - | ||
| 401 | - //TODO: Gerar Procedimento com status BLOQUEADO, aguardando o recebimento dos componentes digitais | ||
| 402 | $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso); | 380 | $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso); |
| 403 | } | 381 | } |
| 404 | 382 | ||
| @@ -419,7 +397,8 @@ class ReceberProcedimentoRN extends InfraRN | @@ -419,7 +397,8 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 419 | return $objProcedimentoDTO; | 397 | return $objProcedimentoDTO; |
| 420 | } | 398 | } |
| 421 | 399 | ||
| 422 | - private function tramiteRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite) { | 400 | + private function tramiteRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite) |
| 401 | + { | ||
| 423 | 402 | ||
| 424 | $objTramiteDTO = new TramiteDTO(); | 403 | $objTramiteDTO = new TramiteDTO(); |
| 425 | $objTramiteDTO->setStrNumeroRegistro($parStrNumeroRegistro); | 404 | $objTramiteDTO->setStrNumeroRegistro($parStrNumeroRegistro); |
| @@ -429,6 +408,29 @@ class ReceberProcedimentoRN extends InfraRN | @@ -429,6 +408,29 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 429 | return $objTramiteBD->contar($objTramiteDTO) > 0; | 408 | return $objTramiteBD->contar($objTramiteDTO) > 0; |
| 430 | } | 409 | } |
| 431 | 410 | ||
| 411 | + | ||
| 412 | + private function documentoJaRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parStrHashComponenteDigital) | ||
| 413 | + { | ||
| 414 | + //Verifica se componente digital já está registrado para o documento | ||
| 415 | + $objComponenteDigitalDTO = new ComponenteDigitalDTO(); | ||
| 416 | + $objComponenteDigitalDTO->setStrNumeroRegistro($parStrNumeroRegistro); | ||
| 417 | + $objComponenteDigitalDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 418 | + $objComponenteDigitalDTO->setStrHashConteudo($parStrHashComponenteDigital); | ||
| 419 | + // $objComponenteDigitalDTO->retDblIdDocumento(); | ||
| 420 | + // $objComponenteDigitalDTO->retNumTicketEnvioComponentes(); | ||
| 421 | + // $objComponenteDigitalDTO->retStrProtocoloDocumentoFormatado(); | ||
| 422 | + // $objComponenteDigitalDTO->retStrHashConteudo(); | ||
| 423 | + // $objComponenteDigitalDTO->retStrProtocolo(); | ||
| 424 | + // $objComponenteDigitalDTO->retStrNumeroRegistro(); | ||
| 425 | + // $objComponenteDigitalDTO->retNumIdTramite(); | ||
| 426 | + // $objComponenteDigitalDTO->retStrNome(); | ||
| 427 | + // $objComponenteDigitalDTO->retStrStaEstadoProtocolo(); | ||
| 428 | + | ||
| 429 | + $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco()); | ||
| 430 | + return $objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0; | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + | ||
| 432 | private function consultarProcedimentoExistente($parStrNumeroRegistro, $parStrProtocolo = null) { | 434 | private function consultarProcedimentoExistente($parStrNumeroRegistro, $parStrProtocolo = null) { |
| 433 | 435 | ||
| 434 | $dblIdProcedimento = null; | 436 | $dblIdProcedimento = null; |
| @@ -448,8 +450,8 @@ class ReceberProcedimentoRN extends InfraRN | @@ -448,8 +450,8 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 448 | return $dblIdProcedimento; | 450 | return $dblIdProcedimento; |
| 449 | } | 451 | } |
| 450 | 452 | ||
| 451 | - private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso){ | ||
| 452 | - | 453 | + private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso) |
| 454 | + { | ||
| 453 | 455 | ||
| 454 | if(!isset($parDblIdProcedimento)){ | 456 | if(!isset($parDblIdProcedimento)){ |
| 455 | throw new InfraException('Parâmetro $parDblIdProcedimento não informado.'); | 457 | throw new InfraException('Parâmetro $parDblIdProcedimento não informado.'); |
| @@ -1683,102 +1685,117 @@ class ReceberProcedimentoRN extends InfraRN | @@ -1683,102 +1685,117 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 1683 | } | 1685 | } |
| 1684 | 1686 | ||
| 1685 | 1687 | ||
| 1686 | - public function receberTramitesRecusados($parNumIdentificacaoTramite) { | ||
| 1687 | - | ||
| 1688 | - if (empty($parNumIdentificacaoTramite)) { | ||
| 1689 | - throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.'); | ||
| 1690 | - } | ||
| 1691 | - | ||
| 1692 | - //Busca os dados do trâmite no barramento | ||
| 1693 | - $tramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 1694 | - | ||
| 1695 | - if(!isset($tramite[0])){ | ||
| 1696 | - throw new InfraException("Não foi encontrado no PEN o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa"); | ||
| 1697 | - } | 1688 | + public function receberTramitesRecusados($parNumIdentificacaoTramite) |
| 1689 | + { | ||
| 1690 | + try { | ||
| 1691 | + if (empty($parNumIdentificacaoTramite)) { | ||
| 1692 | + throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.'); | ||
| 1693 | + } | ||
| 1698 | 1694 | ||
| 1699 | - $tramite = $tramite[0]; | 1695 | + //Busca os dados do trâmite no barramento |
| 1696 | + $tramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite); | ||
| 1700 | 1697 | ||
| 1701 | - $objTramiteDTO = new TramiteDTO(); | ||
| 1702 | - $objTramiteDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 1703 | - $objTramiteDTO->retNumIdUnidade(); | 1698 | + if(!isset($tramite[0])){ |
| 1699 | + throw new InfraException("Não foi encontrado no PEN o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa"); | ||
| 1700 | + } | ||
| 1704 | 1701 | ||
| 1705 | - $objTramiteBD = new TramiteBD(BancoSEI::getInstance()); | ||
| 1706 | - $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO); | 1702 | + $tramite = $tramite[0]; |
| 1707 | 1703 | ||
| 1708 | - if(!isset($objTramiteDTO)){ | ||
| 1709 | - throw new InfraException("Não foi encontrado no sistema o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa"); | ||
| 1710 | - } | 1704 | + $objTramiteDTO = new TramiteDTO(); |
| 1705 | + $objTramiteDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 1706 | + $objTramiteDTO->retNumIdUnidade(); | ||
| 1711 | 1707 | ||
| 1712 | - SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade()); | 1708 | + $objTramiteBD = new TramiteBD(BancoSEI::getInstance()); |
| 1709 | + $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO); | ||
| 1713 | 1710 | ||
| 1714 | - //Busca os dados do procedimento | ||
| 1715 | - $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | ||
| 1716 | - $objProcessoEletronicoDTO->setStrNumeroRegistro($tramite->NRE); | ||
| 1717 | - $objProcessoEletronicoDTO->retDblIdProcedimento(); | 1711 | + if(!isset($objTramiteDTO)){ |
| 1712 | + throw new InfraException("Não foi encontrado no sistema o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa"); | ||
| 1713 | + } | ||
| 1718 | 1714 | ||
| 1719 | - $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | ||
| 1720 | - $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | 1715 | + SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade()); |
| 1721 | 1716 | ||
| 1722 | - //Busca a última atividade de trâmite externo | ||
| 1723 | - $objAtividadeDTO = new AtividadeDTO(); | ||
| 1724 | - $objAtividadeDTO->setDblIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento()); | ||
| 1725 | - $objAtividadeDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO)); | ||
| 1726 | - $objAtividadeDTO->setNumMaxRegistrosRetorno(1); | ||
| 1727 | - $objAtividadeDTO->setOrdDthAbertura(InfraDTO::$TIPO_ORDENACAO_DESC); | ||
| 1728 | - $objAtividadeDTO->retNumIdAtividade(); | 1717 | + //Busca os dados do procedimento |
| 1718 | + $this->gravarLogDebug("Buscando os dados de procedimento com NRE " . $tramite->NRE, 2); | ||
| 1719 | + $objProcessoEletronicoDTO = new ProcessoEletronicoDTO(); | ||
| 1720 | + $objProcessoEletronicoDTO->setStrNumeroRegistro($tramite->NRE); | ||
| 1721 | + $objProcessoEletronicoDTO->retDblIdProcedimento(); | ||
| 1722 | + $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); | ||
| 1723 | + $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); | ||
| 1729 | 1724 | ||
| 1730 | - //TODO: Necessário refatoração para chamada da casse AtividadeRN, e não a classe AtividadeBD com risco de quebra de regas internas do sistema | ||
| 1731 | - $objAtividadeBD = new AtividadeBD($this->getObjInfraIBanco()); | ||
| 1732 | - $objAtividadeDTO = $objAtividadeBD->consultar($objAtividadeDTO); | ||
| 1733 | - | ||
| 1734 | - //Busca a unidade de destino | ||
| 1735 | - $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); | ||
| 1736 | - $objAtributoAndamentoDTO->setNumIdAtividade($objAtividadeDTO->getNumIdAtividade()); | ||
| 1737 | - $objAtributoAndamentoDTO->setStrNome('UNIDADE_DESTINO'); | ||
| 1738 | - $objAtributoAndamentoDTO->retStrValor(); | ||
| 1739 | - | ||
| 1740 | - $objAtributoAndamentoBD = new AtributoAndamentoBD($this->getObjInfraIBanco()); | ||
| 1741 | - $objAtributoAndamentoDTO = $objAtributoAndamentoBD->consultar($objAtributoAndamentoDTO); | ||
| 1742 | - | ||
| 1743 | - //Monta o DTO de receber tramite recusado | ||
| 1744 | - $objReceberTramiteRecusadoDTO = new ReceberTramiteRecusadoDTO(); | ||
| 1745 | - $objReceberTramiteRecusadoDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 1746 | - $objReceberTramiteRecusadoDTO->setNumIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento()); | ||
| 1747 | - $objReceberTramiteRecusadoDTO->setNumIdUnidadeOrigem(null); | ||
| 1748 | - $objReceberTramiteRecusadoDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_TRAMITE_RECUSADO)); | ||
| 1749 | - $objReceberTramiteRecusadoDTO->setStrMotivoRecusa(utf8_decode($tramite->justificativaDaRecusa)); | ||
| 1750 | - $objReceberTramiteRecusadoDTO->setStrNomeUnidadeDestino($objAtributoAndamentoDTO->getStrValor()); | ||
| 1751 | - | ||
| 1752 | - //Faz o tratamento do processo e do trâmite recusado | ||
| 1753 | - $this->receberTramiteRecusadoInterno($objReceberTramiteRecusadoDTO); | 1725 | + //Busca a última atividade de trâmite externo |
| 1726 | + $this->gravarLogDebug("Buscando última atividade de trâmite externo do processo " . $objProcessoEletronicoDTO->getDblIdProcedimento(), 2); | ||
| 1727 | + $objAtividadeDTO = new AtividadeDTO(); | ||
| 1728 | + $objAtividadeDTO->setDblIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento()); | ||
| 1729 | + $objAtividadeDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO)); | ||
| 1730 | + $objAtividadeDTO->setNumMaxRegistrosRetorno(1); | ||
| 1731 | + $objAtividadeDTO->setOrdDthAbertura(InfraDTO::$TIPO_ORDENACAO_DESC); | ||
| 1732 | + $objAtividadeDTO->retNumIdAtividade(); | ||
| 1733 | + $objAtividadeBD = new AtividadeBD($this->getObjInfraIBanco()); | ||
| 1734 | + $objAtividadeDTO = $objAtividadeBD->consultar($objAtividadeDTO); | ||
| 1735 | + | ||
| 1736 | + //Busca a unidade de destino | ||
| 1737 | + $this->gravarLogDebug("Buscando informações sobre a unidade de destino", 2); | ||
| 1738 | + $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); | ||
| 1739 | + $objAtributoAndamentoDTO->setNumIdAtividade($objAtividadeDTO->getNumIdAtividade()); | ||
| 1740 | + $objAtributoAndamentoDTO->setStrNome('UNIDADE_DESTINO'); | ||
| 1741 | + $objAtributoAndamentoDTO->retStrValor(); | ||
| 1742 | + $objAtributoAndamentoBD = new AtributoAndamentoBD($this->getObjInfraIBanco()); | ||
| 1743 | + $objAtributoAndamentoDTO = $objAtributoAndamentoBD->consultar($objAtributoAndamentoDTO); | ||
| 1744 | + | ||
| 1745 | + //Monta o DTO de receber tramite recusado | ||
| 1746 | + $this->gravarLogDebug("Preparando recebimento de trâmite " . $parNumIdentificacaoTramite . " recusado", 2); | ||
| 1747 | + $objReceberTramiteRecusadoDTO = new ReceberTramiteRecusadoDTO(); | ||
| 1748 | + $objReceberTramiteRecusadoDTO->setNumIdTramite($parNumIdentificacaoTramite); | ||
| 1749 | + $objReceberTramiteRecusadoDTO->setNumIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento()); | ||
| 1750 | + $objReceberTramiteRecusadoDTO->setNumIdUnidadeOrigem(null); | ||
| 1751 | + $objReceberTramiteRecusadoDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_TRAMITE_RECUSADO)); | ||
| 1752 | + $objReceberTramiteRecusadoDTO->setStrMotivoRecusa(utf8_decode($tramite->justificativaDaRecusa)); | ||
| 1753 | + $objReceberTramiteRecusadoDTO->setStrNomeUnidadeDestino($objAtributoAndamentoDTO->getStrValor()); | ||
| 1754 | + | ||
| 1755 | + //Faz o tratamento do processo e do trâmite recusado | ||
| 1756 | + $this->gravarLogDebug("Atualizando dados do processo " . $objProcessoEletronicoDTO->getDblIdProcedimento() ." e do trâmite recusado " . $parNumIdentificacaoTramite, 2); | ||
| 1757 | + $this->receberTramiteRecusadoInterno($objReceberTramiteRecusadoDTO); | ||
| 1758 | + | ||
| 1759 | + } catch (Exception $e) { | ||
| 1760 | + $mensagemErro = InfraException::inspecionar($e); | ||
| 1761 | + $this->gravarLogDebug($mensagemErro); | ||
| 1762 | + LogSEI::getInstance()->gravar($mensagemErro); | ||
| 1763 | + throw $e; | ||
| 1764 | + } | ||
| 1754 | } | 1765 | } |
| 1755 | 1766 | ||
| 1756 | - protected function receberTramiteRecusadoInternoControlado(ReceberTramiteRecusadoDTO $objReceberTramiteRecusadoDTO){ | ||
| 1757 | - | 1767 | + protected function receberTramiteRecusadoInternoControlado(ReceberTramiteRecusadoDTO $objReceberTramiteRecusadoDTO) |
| 1768 | + { | ||
| 1758 | //Realiza o desbloqueio do processo | 1769 | //Realiza o desbloqueio do processo |
| 1759 | - $objEntradaDesbloquearProcessoAPI = new EntradaDesbloquearProcessoAPI(); | ||
| 1760 | - $objEntradaDesbloquearProcessoAPI->setIdProcedimento($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); | ||
| 1761 | - | ||
| 1762 | - $objSeiRN = new SeiRN(); | ||
| 1763 | - $objSeiRN->desbloquearProcesso($objEntradaDesbloquearProcessoAPI); | 1770 | + $this->gravarLogDebug("Realizando o desbloqueio do processo", 4); |
| 1771 | + $objProtocoloDTO = new ProtocoloDTO(); | ||
| 1772 | + $objProtocoloDTO->setDblIdProtocolo($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); | ||
| 1773 | + $objProtocoloDTO->setStrStaEstado(ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO); | ||
| 1774 | + $objProtocoloRN = new ProtocoloRN(); | ||
| 1775 | + if($objProtocoloRN->contarRN0667($objProtocoloDTO) != 0) { | ||
| 1776 | + $objEntradaDesbloquearProcessoAPI = new EntradaDesbloquearProcessoAPI(); | ||
| 1777 | + $objEntradaDesbloquearProcessoAPI->setIdProcedimento($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); | ||
| 1778 | + $objSeiRN = new SeiRN(); | ||
| 1779 | + $objSeiRN->desbloquearProcesso($objEntradaDesbloquearProcessoAPI); | ||
| 1780 | + } else { | ||
| 1781 | + $this->gravarLogDebug("Processo " . $objReceberTramiteRecusadoDTO->getNumIdProtocolo() . " já se encontra desbloqueado!", 6); | ||
| 1782 | + } | ||
| 1764 | 1783 | ||
| 1765 | //Adiciona um andamento para o trâmite recusado | 1784 | //Adiciona um andamento para o trâmite recusado |
| 1785 | + $this->gravarLogDebug("Adicionando andamento para registro da recusa do trâmite", 4); | ||
| 1766 | $arrObjAtributoAndamentoDTO = array(); | 1786 | $arrObjAtributoAndamentoDTO = array(); |
| 1767 | - | ||
| 1768 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); | 1787 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); |
| 1769 | $objAtributoAndamentoDTO->setStrNome('MOTIVO'); | 1788 | $objAtributoAndamentoDTO->setStrNome('MOTIVO'); |
| 1770 | $objAtributoAndamentoDTO->setStrValor($objReceberTramiteRecusadoDTO->getStrMotivoRecusa()); | 1789 | $objAtributoAndamentoDTO->setStrValor($objReceberTramiteRecusadoDTO->getStrMotivoRecusa()); |
| 1771 | $objAtributoAndamentoDTO->setStrIdOrigem($objReceberTramiteRecusadoDTO->getNumIdUnidadeOrigem()); | 1790 | $objAtributoAndamentoDTO->setStrIdOrigem($objReceberTramiteRecusadoDTO->getNumIdUnidadeOrigem()); |
| 1772 | $arrObjAtributoAndamentoDTO[] = $objAtributoAndamentoDTO; | 1791 | $arrObjAtributoAndamentoDTO[] = $objAtributoAndamentoDTO; |
| 1773 | 1792 | ||
| 1774 | - | ||
| 1775 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); | 1793 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); |
| 1776 | $objAtributoAndamentoDTO->setStrNome('UNIDADE_DESTINO'); | 1794 | $objAtributoAndamentoDTO->setStrNome('UNIDADE_DESTINO'); |
| 1777 | $objAtributoAndamentoDTO->setStrValor($objReceberTramiteRecusadoDTO->getStrNomeUnidadeDestino()); | 1795 | $objAtributoAndamentoDTO->setStrValor($objReceberTramiteRecusadoDTO->getStrNomeUnidadeDestino()); |
| 1778 | $objAtributoAndamentoDTO->setStrIdOrigem($objReceberTramiteRecusadoDTO->getNumIdUnidadeOrigem()); | 1796 | $objAtributoAndamentoDTO->setStrIdOrigem($objReceberTramiteRecusadoDTO->getNumIdUnidadeOrigem()); |
| 1779 | $arrObjAtributoAndamentoDTO[] = $objAtributoAndamentoDTO; | 1797 | $arrObjAtributoAndamentoDTO[] = $objAtributoAndamentoDTO; |
| 1780 | 1798 | ||
| 1781 | - | ||
| 1782 | $objAtividadeDTO = new AtividadeDTO(); | 1799 | $objAtividadeDTO = new AtividadeDTO(); |
| 1783 | $objAtividadeDTO->setDblIdProtocolo($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); | 1800 | $objAtividadeDTO->setDblIdProtocolo($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); |
| 1784 | $objAtividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); | 1801 | $objAtividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); |
| @@ -1789,21 +1806,18 @@ class ReceberProcedimentoRN extends InfraRN | @@ -1789,21 +1806,18 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 1789 | $objAtividadeRN->gerarInternaRN0727($objAtividadeDTO); | 1806 | $objAtividadeRN->gerarInternaRN0727($objAtividadeDTO); |
| 1790 | 1807 | ||
| 1791 | //Sinaliza na PenProtocolo que o processo obteve recusa | 1808 | //Sinaliza na PenProtocolo que o processo obteve recusa |
| 1809 | + $this->gravarLogDebug("Atualizando protocolo sobre obtenção da ciência de recusa", 4); | ||
| 1792 | $objProtocolo = new PenProtocoloDTO(); | 1810 | $objProtocolo = new PenProtocoloDTO(); |
| 1793 | $objProtocolo->setDblIdProtocolo($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); | 1811 | $objProtocolo->setDblIdProtocolo($objReceberTramiteRecusadoDTO->getNumIdProtocolo()); |
| 1794 | $objProtocolo->setStrSinObteveRecusa('S'); | 1812 | $objProtocolo->setStrSinObteveRecusa('S'); |
| 1795 | - | ||
| 1796 | $objProtocoloBD = new ProtocoloBD($this->getObjInfraIBanco()); | 1813 | $objProtocoloBD = new ProtocoloBD($this->getObjInfraIBanco()); |
| 1797 | $objProtocoloBD->alterar($objProtocolo); | 1814 | $objProtocoloBD->alterar($objProtocolo); |
| 1798 | 1815 | ||
| 1799 | - | 1816 | + $this->gravarLogDebug("Notificando serviços do PEN sobre ciência da recusa do trâmite " . $objReceberTramiteRecusadoDTO->getNumIdTramite(), 4); |
| 1800 | $this->objProcessoEletronicoRN->cienciaRecusa($objReceberTramiteRecusadoDTO->getNumIdTramite()); | 1817 | $this->objProcessoEletronicoRN->cienciaRecusa($objReceberTramiteRecusadoDTO->getNumIdTramite()); |
| 1801 | - | ||
| 1802 | - | ||
| 1803 | } | 1818 | } |
| 1804 | 1819 | ||
| 1805 | 1820 | ||
| 1806 | - | ||
| 1807 | /** | 1821 | /** |
| 1808 | * Método que realiza a validação da extensão dos componentes digitais a serem recebidos | 1822 | * Método que realiza a validação da extensão dos componentes digitais a serem recebidos |
| 1809 | * | 1823 | * |
| @@ -1867,7 +1881,13 @@ class ReceberProcedimentoRN extends InfraRN | @@ -1867,7 +1881,13 @@ class ReceberProcedimentoRN extends InfraRN | ||
| 1867 | throw new InfraException('O sistema não possui permissão de escrita no diretório de armazenamento de arquivos temporários do sistema.'); | 1881 | throw new InfraException('O sistema não possui permissão de escrita no diretório de armazenamento de arquivos temporários do sistema.'); |
| 1868 | 1882 | ||
| 1869 | } | 1883 | } |
| 1884 | + } | ||
| 1870 | 1885 | ||
| 1871 | - | 1886 | + private function gravarLogDebug($strMensagem, $numIdentacao=0) |
| 1887 | + { | ||
| 1888 | + $strDataLog = date("d/m/Y H:i:s"); | ||
| 1889 | + $strLog = sprintf("[%s] [PROCESSAMENTO] %s %s", $strDataLog, str_repeat(" ", $numIdentacao * 4), $strMensagem); | ||
| 1890 | + InfraDebug::getInstance()->gravar($strLog); | ||
| 1872 | } | 1891 | } |
| 1892 | + | ||
| 1873 | } | 1893 | } |
rn/ReceberReciboTramiteRN.php
| @@ -20,14 +20,21 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -20,14 +20,21 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 20 | return BancoSEI::getInstance(); | 20 | return BancoSEI::getInstance(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | - protected function registrarRecebimentoRecibo($numIdProcedimento, $strProtocoloFormatado, $numIdTramite) { | ||
| 24 | - | 23 | + protected function registrarRecebimentoRecibo($numIdProcedimento, $strProtocoloFormatado, $numIdTramite) |
| 24 | + { | ||
| 25 | //REALIZA A CONCLUSÃO DO PROCESSO | 25 | //REALIZA A CONCLUSÃO DO PROCESSO |
| 26 | $objEntradaConcluirProcessoAPI = new EntradaConcluirProcessoAPI(); | 26 | $objEntradaConcluirProcessoAPI = new EntradaConcluirProcessoAPI(); |
| 27 | $objEntradaConcluirProcessoAPI->setIdProcedimento($numIdProcedimento); | 27 | $objEntradaConcluirProcessoAPI->setIdProcedimento($numIdProcedimento); |
| 28 | 28 | ||
| 29 | $objSeiRN = new SeiRN(); | 29 | $objSeiRN = new SeiRN(); |
| 30 | - $objSeiRN->concluirProcesso($objEntradaConcluirProcessoAPI); | 30 | + try { |
| 31 | + $objSeiRN->concluirProcesso($objEntradaConcluirProcessoAPI); | ||
| 32 | + } catch (Exception $e) { | ||
| 33 | + //Registra falha em log de debug mas não gera rollback na transação. | ||
| 34 | + //O rollback da transação poderia deixar a situação do processo inconsistênte já que o Barramento registrou anteriormente que o | ||
| 35 | + //recibo já havia sido obtido. O erro no fechamento não provoca impacto no andamento do processo | ||
| 36 | + InfraDebug::getInstance()->gravar("Processo $strProtocoloFormatado não está aberto na unidade."); | ||
| 37 | + } | ||
| 31 | 38 | ||
| 32 | $arrObjAtributoAndamentoDTO = array(); | 39 | $arrObjAtributoAndamentoDTO = array(); |
| 33 | 40 | ||
| @@ -90,6 +97,7 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -90,6 +97,7 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 90 | } | 97 | } |
| 91 | 98 | ||
| 92 | $objRepositorioDTO = $this->objProcessoEletronicoRN->consultarRepositoriosDeEstruturas($objTramite->destinatario->identificacaoDoRepositorioDeEstruturas); | 99 | $objRepositorioDTO = $this->objProcessoEletronicoRN->consultarRepositoriosDeEstruturas($objTramite->destinatario->identificacaoDoRepositorioDeEstruturas); |
| 100 | + | ||
| 93 | if(!empty($objRepositorioDTO)) { | 101 | if(!empty($objRepositorioDTO)) { |
| 94 | 102 | ||
| 95 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); | 103 | $objAtributoAndamentoDTO = new AtributoAndamentoDTO(); |
| @@ -108,11 +116,11 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -108,11 +116,11 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 108 | 116 | ||
| 109 | $objAtividadeRN = new AtividadeRN(); | 117 | $objAtividadeRN = new AtividadeRN(); |
| 110 | $objAtividadeRN->gerarInternaRN0727($objAtividadeDTO); | 118 | $objAtividadeRN->gerarInternaRN0727($objAtividadeDTO); |
| 111 | - } | ||
| 112 | - | ||
| 113 | - protected function receberReciboDeTramiteConectado($parNumIdTramite) { | ||
| 114 | 119 | ||
| 120 | + } | ||
| 115 | 121 | ||
| 122 | + protected function receberReciboDeTramiteControlado($parNumIdTramite) | ||
| 123 | + { | ||
| 116 | if (!isset($parNumIdTramite)) { | 124 | if (!isset($parNumIdTramite)) { |
| 117 | throw new InfraException('Parâmetro $parNumIdTramite não informado.'); | 125 | throw new InfraException('Parâmetro $parNumIdTramite não informado.'); |
| 118 | } | 126 | } |
| @@ -142,6 +150,7 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -142,6 +150,7 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 142 | 150 | ||
| 143 | if ($objTramiteBD->contar($objTramiteDTO) > 0) { | 151 | if ($objTramiteBD->contar($objTramiteDTO) > 0) { |
| 144 | 152 | ||
| 153 | + | ||
| 145 | $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO); | 154 | $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO); |
| 146 | SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade()); | 155 | SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade()); |
| 147 | 156 | ||
| @@ -151,13 +160,10 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -151,13 +160,10 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 151 | 160 | ||
| 152 | $objReciboTramiteBD = new ReciboTramiteBD(BancoSEI::getInstance()); | 161 | $objReciboTramiteBD = new ReciboTramiteBD(BancoSEI::getInstance()); |
| 153 | if ($objReciboTramiteBD->contar($objReciboTramiteDTOExistente) == 0) { | 162 | if ($objReciboTramiteBD->contar($objReciboTramiteDTOExistente) == 0) { |
| 154 | - | ||
| 155 | //Armazenar dados do recibo de conclusão do trãmite | 163 | //Armazenar dados do recibo de conclusão do trãmite |
| 156 | $objReciboTramiteBD->cadastrar($objReciboTramiteDTO); | 164 | $objReciboTramiteBD->cadastrar($objReciboTramiteDTO); |
| 157 | - | ||
| 158 | if ($objReciboTramite->recibo->hashDoComponenteDigital && is_array($objReciboTramite->recibo->hashDoComponenteDigital)) { | 165 | if ($objReciboTramite->recibo->hashDoComponenteDigital && is_array($objReciboTramite->recibo->hashDoComponenteDigital)) { |
| 159 | foreach ($objReciboTramite->recibo->hashDoComponenteDigital as $strHashComponenteDigital) { | 166 | foreach ($objReciboTramite->recibo->hashDoComponenteDigital as $strHashComponenteDigital) { |
| 160 | - | ||
| 161 | $objReciboTramiteHashDTO = new ReciboTramiteHashDTO(); | 167 | $objReciboTramiteHashDTO = new ReciboTramiteHashDTO(); |
| 162 | $objReciboTramiteHashDTO->setStrNumeroRegistro($objReciboTramite->recibo->NRE); | 168 | $objReciboTramiteHashDTO->setStrNumeroRegistro($objReciboTramite->recibo->NRE); |
| 163 | $objReciboTramiteHashDTO->setNumIdTramite($objReciboTramite->recibo->IDT); | 169 | $objReciboTramiteHashDTO->setNumIdTramite($objReciboTramite->recibo->IDT); |
| @@ -168,7 +174,6 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -168,7 +174,6 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 168 | $objGenericoBD->cadastrar($objReciboTramiteHashDTO); | 174 | $objGenericoBD->cadastrar($objReciboTramiteHashDTO); |
| 169 | } | 175 | } |
| 170 | } | 176 | } |
| 171 | - | ||
| 172 | //ALTERA O ESTADO DO PROCEDIMENTO | 177 | //ALTERA O ESTADO DO PROCEDIMENTO |
| 173 | try { | 178 | try { |
| 174 | 179 | ||
| @@ -198,10 +203,8 @@ class ReceberReciboTramiteRN extends InfraRN | @@ -198,10 +203,8 @@ class ReceberReciboTramiteRN extends InfraRN | ||
| 198 | 203 | ||
| 199 | $this->objProcedimentoAndamentoRN->setOpts($objProcessoEletronicoDTO->getDblIdProcedimento(), $parNumIdTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO)); | 204 | $this->objProcedimentoAndamentoRN->setOpts($objProcessoEletronicoDTO->getDblIdProcedimento(), $parNumIdTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO)); |
| 200 | $this->objProcedimentoAndamentoRN->cadastrar(sprintf('Trâmite do processo %s foi concluído', $objProtocoloDTO->getStrProtocoloFormatado()), 'S'); | 205 | $this->objProcedimentoAndamentoRN->cadastrar(sprintf('Trâmite do processo %s foi concluído', $objProtocoloDTO->getStrProtocoloFormatado()), 'S'); |
| 201 | - | ||
| 202 | //Registra o recbimento do recibo no histórico e realiza a conclusão do processo | 206 | //Registra o recbimento do recibo no histórico e realiza a conclusão do processo |
| 203 | $this->registrarRecebimentoRecibo($objProtocoloDTO->getDblIdProtocolo(), $objProtocoloDTO->getStrProtocoloFormatado(), $parNumIdTramite); | 207 | $this->registrarRecebimentoRecibo($objProtocoloDTO->getDblIdProtocolo(), $objProtocoloDTO->getStrProtocoloFormatado(), $parNumIdTramite); |
| 204 | - | ||
| 205 | $objPenTramiteProcessadoRN = new PenTramiteProcessadoRN(PenTramiteProcessadoRN::STR_TIPO_RECIBO); | 208 | $objPenTramiteProcessadoRN = new PenTramiteProcessadoRN(PenTramiteProcessadoRN::STR_TIPO_RECIBO); |
| 206 | $objPenTramiteProcessadoRN->setRecebido($parNumIdTramite); | 209 | $objPenTramiteProcessadoRN->setRecebido($parNumIdTramite); |
| 207 | 210 |