From 4c310faa187839ac0d03674cf651b10d8d86b0f1 Mon Sep 17 00:00:00 2001 From: Thiago Farias Date: Tue, 24 Oct 2017 14:24:53 -0200 Subject: [PATCH] Sprint 01 - Release 5: US039, US043, US041, US040 --- pen_map_hipotese_legal_enviado_listar.php | 2 ++ pen_map_hipotese_legal_recebido_listar.php | 2 ++ rn/PENAgendamentoRN.php | 30 ++++++++++++++++++++++++++++++ rn/PenAtualizarSeiRN.php | 23 +++++++++++++++++++++++ rn/ProcessoEletronicoRN.php | 13 +++++++++++++ 5 files changed, 70 insertions(+), 0 deletions(-) diff --git a/pen_map_hipotese_legal_enviado_listar.php b/pen_map_hipotese_legal_enviado_listar.php index 3522cb6..9c93815 100644 --- a/pen_map_hipotese_legal_enviado_listar.php +++ b/pen_map_hipotese_legal_enviado_listar.php @@ -49,6 +49,8 @@ try { $objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO(); $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalEnvioRN(); + $arrParam['hdnInfraItensSelecionados'] = explode(',',$arrParam['hdnInfraItensSelecionados']); + if(is_array($arrParam['hdnInfraItensSelecionados'])) { foreach($arrParam['hdnInfraItensSelecionados'] as $dblIdMap) { diff --git a/pen_map_hipotese_legal_recebido_listar.php b/pen_map_hipotese_legal_recebido_listar.php index 6852a54..279064b 100644 --- a/pen_map_hipotese_legal_recebido_listar.php +++ b/pen_map_hipotese_legal_recebido_listar.php @@ -53,6 +53,8 @@ try { $objPenRelHipoteseLegalDTO = new PenRelHipoteseLegalDTO(); $objPenRelHipoteseLegalRN = new PenRelHipoteseLegalRecebidoRN(); + $arrParam['hdnInfraItensSelecionados'] = explode(',', $arrParam['hdnInfraItensSelecionados']); + if(is_array($arrParam['hdnInfraItensSelecionados'])) { foreach($arrParam['hdnInfraItensSelecionados'] as $dblIdMap) { diff --git a/rn/PENAgendamentoRN.php b/rn/PENAgendamentoRN.php index 06b3e46..01c0794 100644 --- a/rn/PENAgendamentoRN.php +++ b/rn/PENAgendamentoRN.php @@ -264,6 +264,36 @@ class PENAgendamentoRN extends InfraRN { throw new InfraException('Erro ao rodar verificação de status do serviços Gearmand e Supervisord', $e); } } + + /** + * Atualização das hipóteses legais vindas do barramento + * @throws InfraException + */ + public function atualizarHipotesesLegais() { + $objBD = new PenHipoteseLegalBD($this->inicializarObjInfraIBanco()); + $processoEletronicoRN = new ProcessoEletronicoRN(); + $hipotesesPen = $processoEletronicoRN->consultarHipotesesLegais(); + + //Para cada hipótese vinda do PEN será verificado a existencia. + foreach ($hipotesesPen as $hipotese) { + $objDTO = new PenHipoteseLegalDTO(); + $objDTO->setStrNome($hipotese->hipotese->nome); + $objDTO->setNumMaxRegistrosRetorno(1); + $objDTO->retNumIdHipoteseLegal(); + $objConsulta = $objBD->consultar($objDTO); + + //Caso não exista a hipótese irá cadastra-la no sei. + if (empty($objConsulta)) { + $objBD->cadastrar($objDTO); + } + } + + try { + LogSEI::getInstance()->gravar("Hipóteses Legais atualizadas."); + } catch (Exception $e) { + throw new InfraException('Erro no agendamento das Hipóteses Legais', $e); + } + } } // $client = new GearmanClient(); // $client->addServer('localhost', 4730); diff --git a/rn/PenAtualizarSeiRN.php b/rn/PenAtualizarSeiRN.php index 41e13f8..71c1e5a 100644 --- a/rn/PenAtualizarSeiRN.php +++ b/rn/PenAtualizarSeiRN.php @@ -1044,6 +1044,29 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO); $objInfraParametroDTO->setStrValor('1.0.1'); $objInfraParametroBD->alterar($objInfraParametroDTO); + + + //Agendamento + $objDTO = new InfraAgendamentoTarefaDTO(); + + $fnCadastrar = function($strComando, $strDesc) use($objDTO, $objBD, $objRN) { + + $objDTO->unSetTodos(); + $objDTO->setStrComando($strComando); + + if ($objBD->contar($objDTO) == 0) { + + $objDTO->setStrDescricao($strDesc); + $objDTO->setStrStaPeriodicidadeExecucao('D'); + $objDTO->setStrPeriodicidadeComplemento('0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23'); + $objDTO->setStrSinAtivo('S'); + $objDTO->setStrSinSucesso('S'); + + $objBD->cadastrar($objDTO); + } + }; + + $fnCadastrar('PENAgendamentoRN::atualizarHipotesesLegais', 'Verificação se há novas hipóteses legais do barramento.'); } } diff --git a/rn/ProcessoEletronicoRN.php b/rn/ProcessoEletronicoRN.php index 68c083a..2b53a78 100644 --- a/rn/ProcessoEletronicoRN.php +++ b/rn/ProcessoEletronicoRN.php @@ -1437,6 +1437,19 @@ class ProcessoEletronicoRN extends InfraRN { return false; } } + + public function consultarHipotesesLegais() { + try{ + $hipoteses = $this->getObjPenWs()->consultarHipotesesLegais(); + if (empty($hipoteses)) { + return []; + } + return $hipoteses; + + } catch(Exception $e){ + throw new InfraException("Erro durante obtenção da resposta das hipóteses legais", $e); + } + } } -- libgit2 0.21.2