From ae7f0dbc10964886008f05d08478da554504eace Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Del Cantoni Date: Wed, 6 Feb 2019 12:02:13 -0200 Subject: [PATCH] [Fixed #30] Correção de erro Duplicate entry for PRIMARY --- PENIntegracao.php | 2 +- dto/PenHipoteseLegalDTO.php | 15 ++++++++++----- dto/PenRelHipoteseLegalDTO.php | 16 ++++++++++------ dto/PenRelTipoDocMapEnviadoDTO.php | 14 +++++++++----- dto/PenRelTipoDocMapRecebidoDTO.php | 12 ++++++++---- dto/ProcedimentoAndamentoDTO.php | 6 +++++- dto/ReciboTramiteHashDTO.php | 6 +++++- dto/TramitePendenteDTO.php | 23 ++++++++++++----------- rn/PenAtualizarSeiRN.php | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- sip_atualizar_versao_modulo_pen.php | 16 ++++++++++++++++ 10 files changed, 182 insertions(+), 35 deletions(-) diff --git a/PENIntegracao.php b/PENIntegracao.php index 9d81cf6..461ac24 100644 --- a/PENIntegracao.php +++ b/PENIntegracao.php @@ -11,7 +11,7 @@ class PENIntegracao extends SeiIntegracao { } public function getVersao() { - return '1.1.12'; + return '1.1.13'; } public function getInstituicao() { diff --git a/dto/PenHipoteseLegalDTO.php b/dto/PenHipoteseLegalDTO.php index 75f6d09..f4fc92d 100644 --- a/dto/PenHipoteseLegalDTO.php +++ b/dto/PenHipoteseLegalDTO.php @@ -12,14 +12,19 @@ class PenHipoteseLegalDTO extends InfraDTO { public function getStrNomeTabela() { return 'md_pen_hipotese_legal'; } - + + public function getStrNomeSequenciaNativa() + { + return 'md_pen_seq_hipotese_legal'; + } + public function montar() { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal', 'id_hipotese_legal'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Nome', 'nome'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'Identificacao', 'identificacao'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Ativo', 'sin_ativo'); - - $this->configurarPK('IdHipoteseLegal',InfraDTO::$TIPO_PK_SEQUENCIAL); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'Identificacao', 'identificacao'); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Ativo', 'sin_ativo'); + + $this->configurarPK('IdHipoteseLegal',InfraDTO::$TIPO_PK_NATIVA); //$this->configurarExclusaoLogica('Ativo', 'N'); } diff --git a/dto/PenRelHipoteseLegalDTO.php b/dto/PenRelHipoteseLegalDTO.php index 09db089..05b1ad9 100644 --- a/dto/PenRelHipoteseLegalDTO.php +++ b/dto/PenRelHipoteseLegalDTO.php @@ -10,17 +10,21 @@ class PenRelHipoteseLegalDTO extends InfraDTO { public function getStrNomeTabela() { return 'md_pen_rel_hipotese_legal'; } - + + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_rel_hipotese_legal'; + } + public function montar() { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdMap', 'id_mapeamento'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal', 'id_hipotese_legal'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Tipo', 'tipo'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Ativo', 'sin_ativo'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdBarramento', 'id_hipotese_legal_pen'); - - $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'Identificacao', 'identificacao', 'md_pen_hipotese_legal'); - - $this->configurarPK('IdMap',InfraDTO::$TIPO_PK_SEQUENCIAL); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdBarramento', 'id_hipotese_legal_pen'); + + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'Identificacao', 'identificacao', 'md_pen_hipotese_legal'); + + $this->configurarPK('IdMap',InfraDTO::$TIPO_PK_NATIVA); $this->configurarFK('IdBarramento', 'md_pen_hipotese_legal', 'id_hipotese_legal'); //$this->configurarExclusaoLogica('Ativo', 'N'); diff --git a/dto/PenRelTipoDocMapEnviadoDTO.php b/dto/PenRelTipoDocMapEnviadoDTO.php index a9d5619..93eaee5 100644 --- a/dto/PenRelTipoDocMapEnviadoDTO.php +++ b/dto/PenRelTipoDocMapEnviadoDTO.php @@ -8,18 +8,22 @@ class PenRelTipoDocMapEnviadoDTO extends InfraDTO { return "md_pen_rel_doc_map_enviado"; } + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_rel_doc_map_enviado'; + } + public function montar() { - + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdMap', 'id_mapeamento'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'CodigoEspecie', 'codigo_especie'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdSerie', 'id_serie'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Padrao', 'sin_padrao'); - + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeSerie', 'nome', 'serie'); $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeEspecie','nome_especie', 'md_pen_especie_documental'); - - $this->configurarPK('IdMap', InfraDTO::$TIPO_PK_SEQUENCIAL); + + $this->configurarPK('IdMap', InfraDTO::$TIPO_PK_NATIVA); $this->configurarFK('IdSerie', 'serie', 'id_serie'); $this->configurarFK('CodigoEspecie', 'md_pen_especie_documental', 'id_especie'); } -} \ No newline at end of file +} diff --git a/dto/PenRelTipoDocMapRecebidoDTO.php b/dto/PenRelTipoDocMapRecebidoDTO.php index be3c818..17ef322 100644 --- a/dto/PenRelTipoDocMapRecebidoDTO.php +++ b/dto/PenRelTipoDocMapRecebidoDTO.php @@ -8,17 +8,21 @@ class PenRelTipoDocMapRecebidoDTO extends InfraDTO { return 'md_pen_rel_doc_map_recebido'; } + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_rel_doc_map_recebid'; + } + public function montar() { - + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdMap', 'id_mapeamento'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'CodigoEspecie', 'codigo_especie'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdSerie', 'id_serie'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'Padrao', 'sin_padrao'); - + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeSerie', 'nome', 'serie'); $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, 'NomeEspecie','nome_especie', 'md_pen_especie_documental'); - - $this->configurarPK('IdMap', InfraDTO::$TIPO_PK_SEQUENCIAL); + + $this->configurarPK('IdMap', InfraDTO::$TIPO_PK_NATIVA); $this->configurarFK('IdSerie', 'serie', 'id_serie'); $this->configurarFK('CodigoEspecie', 'md_pen_especie_documental', 'id_especie'); } diff --git a/dto/ProcedimentoAndamentoDTO.php b/dto/ProcedimentoAndamentoDTO.php index 306e176..3df2dd1 100644 --- a/dto/ProcedimentoAndamentoDTO.php +++ b/dto/ProcedimentoAndamentoDTO.php @@ -13,6 +13,10 @@ class ProcedimentoAndamentoDTO extends InfraDTO { return 'md_pen_procedimento_andamento'; } + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_procedimento_andam'; + } + public function montar() { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdAndamento', 'id_andamento'); @@ -30,7 +34,7 @@ class ProcedimentoAndamentoDTO extends InfraDTO { $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'IdRepositorioDestino', 'id_repositorio_destino', 'md_pen_tramite'); $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, 'IdEstruturaDestino', 'id_estrutura_destino', 'md_pen_tramite'); - $this->configurarPK('IdAndamento', InfraDTO::$TIPO_PK_SEQUENCIAL); + $this->configurarPK('IdAndamento', InfraDTO::$TIPO_PK_NATIVA); $this->configurarFK('IdTramite', 'md_pen_tramite', 'id_tramite', InfraDTO::$TIPO_FK_OPCIONAL); } diff --git a/dto/ReciboTramiteHashDTO.php b/dto/ReciboTramiteHashDTO.php index 4872dc1..12951eb 100644 --- a/dto/ReciboTramiteHashDTO.php +++ b/dto/ReciboTramiteHashDTO.php @@ -8,6 +8,10 @@ class ReciboTramiteHashDTO extends InfraDTO { return "md_pen_recibo_tramite_hash"; } + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_recibo_tramite_hash'; + } + public function montar() { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_DBL, 'IdTramiteHash', 'id_tramite_hash'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'NumeroRegistro', 'numero_registro'); @@ -15,7 +19,7 @@ class ReciboTramiteHashDTO extends InfraDTO { $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'HashComponenteDigital', 'hash_componente_digital'); $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_STR, 'TipoRecibo', 'tipo_recibo'); - $this->configurarPK('IdTramiteHash', InfraDTO::$TIPO_PK_SEQUENCIAL); + $this->configurarPK('IdTramiteHash', InfraDTO::$TIPO_PK_NATIVA); } } diff --git a/dto/TramitePendenteDTO.php b/dto/TramitePendenteDTO.php index c25c1fc..0565589 100644 --- a/dto/TramitePendenteDTO.php +++ b/dto/TramitePendenteDTO.php @@ -4,17 +4,18 @@ require_once dirname(__FILE__).'/../../../SEI.php'; class TramitePendenteDTO extends InfraDTO { - public function getStrNomeTabela() { - return 'md_pen_tramite_pendente'; + public function getStrNomeTabela() { + return 'md_pen_tramite_pendente'; + } - } + public function getStrNomeSequenciaNativa() { + return 'md_pen_seq_tramite_pendente'; + } - public function montar() { - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdTabela', 'id'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdTramite', 'numero_tramite'); - $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdAtividade', 'id_atividade_expedicao'); - - $this->configurarPK('IdTabela',InfraDTO::$TIPO_PK_SEQUENCIAL); - - } + public function montar() { + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdTabela', 'id'); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdTramite', 'numero_tramite'); + $this->adicionarAtributoTabela(InfraDTO::$PREFIXO_NUM, 'IdAtividade', 'id_atividade_expedicao'); + $this->configurarPK('IdTabela',InfraDTO::$TIPO_PK_NATIVA); + } } diff --git a/rn/PenAtualizarSeiRN.php b/rn/PenAtualizarSeiRN.php index ddc66e4..4ec115f 100644 --- a/rn/PenAtualizarSeiRN.php +++ b/rn/PenAtualizarSeiRN.php @@ -54,6 +54,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { case '1.1.9': $this->instalarV1110(); case '1.1.10': $this->instalarV1111(); case '1.1.11': $this->instalarV1112(); + case '1.1.12': $this->instalarV1113(); break; default: @@ -1204,7 +1205,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { protected function instalarV1112() { $objInfraMetaBD = new InfraMetaBD($this->getObjInfraIBanco()); - //[#22] Correção de erro de consistência no recebimento de processos com concorrência $objInfraMetaBD->adicionarColuna('md_pen_tramite','sta_tipo_tramite', $objInfraMetaBD->tipoTextoFixo(1), 'null'); $objInfraMetaBD->alterarColuna('md_pen_procedimento_andamento','id_procedimento',$objInfraMetaBD->tipoNumeroGrande(),'null'); @@ -1243,4 +1243,109 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { $objInfraParametroBD->alterar($objInfraParametroDTO); } + + /* Contem atualizações da versao 1.1.13 do módulo */ + protected function instalarV1113() + { + //30 - Correção de erros de chave duplicada devido a concorrência de transações + $objInfraSequenciaRN = new InfraSequenciaRN(); + $objInfraSequenciaDTO = new InfraSequenciaDTO(); + + //Sequência: md_pen_seq_procedimento_andam + $rs = BancoSEI::getInstance()->consultarSql('select max(id_andamento) as total from md_pen_procedimento_andamento'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_procedimento_andam', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_procedimento_andamento'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + + //Sequência: md_pen_seq_hipotese_legal + $rs = BancoSEI::getInstance()->consultarSql('select max(id_hipotese_legal) as total from md_pen_hipotese_legal'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_hipotese_legal', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_hipotese_legal'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + + //Sequência: md_pen_seq_rel_hipotese_legal + $rs = BancoSEI::getInstance()->consultarSql('select max(id_mapeamento) as total from md_pen_rel_hipotese_legal'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_rel_hipotese_legal', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_rel_hipotese_legal'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + + //Sequência: md_pen_seq_recibo_tramite_hash + $rs = BancoSEI::getInstance()->consultarSql('select max(id_tramite_hash) as total from md_pen_recibo_tramite_hash'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_recibo_tramite_hash', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_recibo_tramite_hash'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + //Sequência: md_pen_seq_rel_doc_map_enviado + $rs = BancoSEI::getInstance()->consultarSql('select max(id_mapeamento) as total from md_pen_rel_doc_map_enviado'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_rel_doc_map_enviado', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_rel_doc_map_enviado'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + //Sequência: md_pen_seq_rel_doc_map_recebid + $rs = BancoSEI::getInstance()->consultarSql('select max(id_mapeamento) as total from md_pen_rel_doc_map_recebido'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_rel_doc_map_recebid', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_rel_doc_map_recebido'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + + //Sequência: md_pen_seq_tramite_pendente + $rs = BancoSEI::getInstance()->consultarSql('select max(id) as total from md_pen_tramite_pendente'); + $numMaxId = $rs[0]['total']; + if ($numMaxId==null){ + $numMaxId = 0; + } + BancoSEI::getInstance()->criarSequencialNativa('md_pen_seq_tramite_pendente', $numMaxId + 1); + $objInfraSequenciaDTO->setStrNome('md_pen_tramite_pendente'); + $objInfraSequenciaDTO->retStrNome(); + $arrObjInfraSequenciaDTO = $objInfraSequenciaRN->listar($objInfraSequenciaDTO); + $objInfraSequenciaRN->excluir($arrObjInfraSequenciaDTO); + + + //altera o parâmetro da versão de banco + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); + $objInfraParametroDTO = new InfraParametroDTO(); + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO); + $objInfraParametroDTO->setStrValor('1.1.13'); + $objInfraParametroBD->alterar($objInfraParametroDTO); + } + } diff --git a/sip_atualizar_versao_modulo_pen.php b/sip_atualizar_versao_modulo_pen.php index 00a9fb2..5fd8768 100644 --- a/sip_atualizar_versao_modulo_pen.php +++ b/sip_atualizar_versao_modulo_pen.php @@ -94,6 +94,7 @@ class PenAtualizarSipRN extends InfraRN { case '1.1.9': $this->instalarV1110(); case '1.1.10': $this->instalarV1111(); case '1.1.11': $this->instalarV1112(); + case '1.1.12': $this->instalarV1113(); break; default: @@ -1039,6 +1040,21 @@ class PenAtualizarSipRN extends InfraRN { } + /** + * Instala/Atualiza os módulo PEN para versão 1.1.13 + */ + protected function instalarV1113() + { + //Corrigir a versão do módulo no banco de dados + $objInfraParametroDTO = new InfraParametroDTO(); + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO); + $objInfraParametroDTO->retTodos(); + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); + $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO); + $objInfraParametroDTO->setStrValor('1.1.13'); + $objInfraParametroBD->alterar($objInfraParametroDTO); + } + } try { -- libgit2 0.21.2