Commit 644f8b863df778c333e0eb11b0307caea62985a8

Authored by Guilherme Andrade Del Cantoni
2 parents 8bfb76fe f4c68f7e

Correção de problema com o recebimento de processo por duas unidades do mesmo sistema

PENIntegracao.php
@@ -11,10 +11,9 @@ class PENIntegracao extends SeiIntegracao { @@ -11,10 +11,9 @@ class PENIntegracao extends SeiIntegracao {
11 } 11 }
12 12
13 public function getVersao() { 13 public function getVersao() {
14 - return '1.1.6'; 14 + return '1.1.7';
15 } 15 }
16 16
17 -  
18 public function getInstituicao() { 17 public function getInstituicao() {
19 return 'Ministério do Planejamento - MPDG (Projeto Colaborativo no Portal do SPB)'; 18 return 'Ministério do Planejamento - MPDG (Projeto Colaborativo no Portal do SPB)';
20 } 19 }
@@ -460,4 +460,12 @@ Caso o ambiente do ConectaGov PEN utilizado nesta configuração esteja utilizan @@ -460,4 +460,12 @@ Caso o ambiente do ConectaGov PEN utilizado nesta configuração esteja utilizan
460 460
461 ### 2. Trâmites não realizados ou recibos não obtidos 461 ### 2. Trâmites não realizados ou recibos não obtidos
462 462
463 -Verificar se os serviços *gearman* e *supervisord* estão em execução, conforme orientado no manual de instalação, itens 3 e 4.  
464 \ No newline at end of file 463 \ No newline at end of file
  464 +Verificar se os serviços *gearman* e *supervisord* estão em execução, conforme orientado no manual de instalação, itens 3 e 4.
  465 +
  466 +### 3. Erro na inicialização do Gearmand "(Address family not supported by protocol) -> libgearman-server/gearmand.cc:442"
  467 +
  468 +Este problema ocorre quando o servidor não possui suporte ao protocolo IPv6. Por padrão, o Gearman inicia sua comunicação utilizando a porta 4730 e utilizando IPv4 e IPv6. Caso um destes não estejam disponíveis, o serviço não será ativado e um log de erro será gerado com a mensagem "(Address family not supported by protocol) -> libgearman-server/gearmand.cc:442".
  469 +
  470 +Para solucionar o problema, duas ações podem ser feitas:
  471 +- habilitar o suporte à IPv6 no servidor de aplicação onde o Gearman foi instalado
  472 +- configurar o serviço gearmand para utilizar somente IPv4. Para fazer esta configuração, será necessário editar o arquivo de inicialização do Gearmand, normalmente localizado em /etc/sysconfig/gearmand, e adicionar o seguinte parâmetro de inicialização: OPTIONS="--listen=127.0.0.1"
bd/PenMetaBD.php
@@ -8,71 +8,70 @@ require_once dirname(__FILE__) . '/../../../SEI.php'; @@ -8,71 +8,70 @@ require_once dirname(__FILE__) . '/../../../SEI.php';
8 * @author Join Tecnologia 8 * @author Join Tecnologia
9 */ 9 */
10 class PenMetaBD extends InfraMetaBD { 10 class PenMetaBD extends InfraMetaBD {
11 - 11 +
12 const NNULLO = 'NOT NULL'; 12 const NNULLO = 'NOT NULL';
13 const SNULLO = 'NULL'; 13 const SNULLO = 'NULL';
14 14
15 /** 15 /**
16 - * 16 + *
17 * @return string 17 * @return string
18 */ 18 */
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 +
26 switch($strTableDrive) { 25 switch($strTableDrive) {
27 26
28 case 'InfraMySqli': 27 case 'InfraMySqli':
29 $strQuery = sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` SET DEFAULT '%s'", $strNomeTabela, $strNomeColuna, $strValorPadrao); 28 $strQuery = sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` SET DEFAULT '%s'", $strNomeTabela, $strNomeColuna, $strValorPadrao);
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);  
34 - 32 + $strQuery = sprintf("ALTER TABLE [%s] ADD DEFAULT('%s') FOR [%s]", $strNomeTabela, $strValorPadrao, $strNomeColuna);
  33 + break;
  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 }
48 - 47 +
49 /** 48 /**
50 * Verifica se o usuário do drive de conexão possui permissão para criar/ remover 49 * Verifica se o usuário do drive de conexão possui permissão para criar/ remover
51 * estruturas 50 * estruturas
52 - * 51 + *
53 * @return PenMetaBD 52 * @return PenMetaBD
54 */ 53 */
55 public function isDriverPermissao(){ 54 public function isDriverPermissao(){
56 - 55 +
57 $objInfraBanco = $this->getObjInfraIBanco(); 56 $objInfraBanco = $this->getObjInfraIBanco();
58 57
59 if(count($this->obterTabelas('sei_teste'))==0){ 58 if(count($this->obterTabelas('sei_teste'))==0){
60 $objInfraBanco->executarSql('CREATE TABLE sei_teste (id '.$this->tipoNumero().' NULL)'); 59 $objInfraBanco->executarSql('CREATE TABLE sei_teste (id '.$this->tipoNumero().' NULL)');
61 } 60 }
62 - 61 +
63 $objInfraBanco->executarSql('DROP TABLE sei_teste'); 62 $objInfraBanco->executarSql('DROP TABLE sei_teste');
64 - 63 +
65 return $this; 64 return $this;
66 } 65 }
67 - 66 +
68 /** 67 /**
69 * Verifica se o banco do SEI é suportador pelo atualizador 68 * Verifica se o banco do SEI é suportador pelo atualizador
70 - * 69 + *
71 * @throws InfraException 70 * @throws InfraException
72 * @return PenMetaBD 71 * @return PenMetaBD
73 */ 72 */
74 public function isDriverSuportado(){ 73 public function isDriverSuportado(){
75 - 74 +
76 $strTableDrive = get_parent_class($this->getObjInfraIBanco()); 75 $strTableDrive = get_parent_class($this->getObjInfraIBanco());
77 76
78 switch($strTableDrive) { 77 switch($strTableDrive) {
@@ -84,7 +83,7 @@ class PenMetaBD extends InfraMetaBD { @@ -84,7 +83,7 @@ class PenMetaBD extends InfraMetaBD {
84 $version = $version[0]['versao']; 83 $version = $version[0]['versao'];
85 $arrVersion = explode('.', $version); 84 $arrVersion = explode('.', $version);
86 if($arrVersion[0].$arrVersion[1] < 56){ 85 if($arrVersion[0].$arrVersion[1] < 56){
87 - $this->getObjInfraIBanco()->executarSql('@SET STORAGE_ENGINE=InnoDB'); 86 + $this->getObjInfraIBanco()->executarSql('@SET STORAGE_ENGINE=InnoDB');
88 } 87 }
89 case 'InfraSqlServer': 88 case 'InfraSqlServer':
90 case 'InfraOracle': 89 case 'InfraOracle':
@@ -94,38 +93,38 @@ class PenMetaBD extends InfraMetaBD { @@ -94,38 +93,38 @@ class PenMetaBD extends InfraMetaBD {
94 throw new InfraException('BANCO DE DADOS NAO SUPORTADO: ' . $strTableDrive); 93 throw new InfraException('BANCO DE DADOS NAO SUPORTADO: ' . $strTableDrive);
95 94
96 } 95 }
97 - 96 +
98 return $this; 97 return $this;
99 } 98 }
100 - 99 +
101 /** 100 /**
102 * Verifica se a versão sistema é compativel com a versão do módulo PEN 101 * Verifica se a versão sistema é compativel com a versão do módulo PEN
103 - * 102 + *
104 * @throws InfraException 103 * @throws InfraException
105 * @return PenMetaBD 104 * @return PenMetaBD
106 */ 105 */
107 public function isVersaoSuportada($strRegexVersaoSistema, $strVerMinRequirida){ 106 public function isVersaoSuportada($strRegexVersaoSistema, $strVerMinRequirida){
108 - 107 +
109 $numVersaoRequerida = intval(preg_replace('/\D+/', '', $strVerMinRequirida)); 108 $numVersaoRequerida = intval(preg_replace('/\D+/', '', $strVerMinRequirida));
110 $numVersaoSistema = intval(preg_replace('/\D+/', '', $strRegexVersaoSistema)); 109 $numVersaoSistema = intval(preg_replace('/\D+/', '', $strRegexVersaoSistema));
111 - 110 +
112 if($numVersaoRequerida > $numVersaoSistema){ 111 if($numVersaoRequerida > $numVersaoSistema){
113 throw new InfraException('VERSAO DO FRAMEWORK PHP INCOMPATIVEL (VERSAO ATUAL '.$strRegexVersaoSistema.', VERSAO REQUERIDA '.$strVerMinRequirida.')'); 112 throw new InfraException('VERSAO DO FRAMEWORK PHP INCOMPATIVEL (VERSAO ATUAL '.$strRegexVersaoSistema.', VERSAO REQUERIDA '.$strVerMinRequirida.')');
114 } 113 }
115 - 114 +
116 return $this; 115 return $this;
117 } 116 }
118 - 117 +
119 /** 118 /**
120 * Apaga a chave primária da tabela 119 * Apaga a chave primária da tabela
121 - * 120 + *
122 * @throws InfraException 121 * @throws InfraException
123 * @return PenMetaBD 122 * @return PenMetaBD
124 */ 123 */
125 public function removerChavePrimaria($strNomeTabela, $strNomeChave){ 124 public function removerChavePrimaria($strNomeTabela, $strNomeChave){
126 - 125 +
127 if($this->isChaveExiste($strNomeTabela, $strNomeChave)) { 126 if($this->isChaveExiste($strNomeTabela, $strNomeChave)) {
128 - 127 +
129 $strTableDrive = get_parent_class($this->getObjInfraIBanco()); 128 $strTableDrive = get_parent_class($this->getObjInfraIBanco());
130 129
131 switch($strTableDrive) { 130 switch($strTableDrive) {
@@ -139,64 +138,28 @@ class PenMetaBD extends InfraMetaBD { @@ -139,64 +138,28 @@ 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 }
145 return $this; 145 return $this;
146 } 146 }
147 -  
148 - public function isChaveExiste($strNomeTabela = '', $strNomeChave = ''){  
149 -  
150 - $objInfraBanco = $this->getObjInfraIBanco();  
151 - $strTableDrive = get_parent_class($objInfraBanco);  
152 -  
153 - switch($strTableDrive) {  
154 -  
155 - case 'InfraMySqli':  
156 - $strSql = " SELECT COUNT(CONSTRAINT_NAME) AS EXISTE  
157 - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS  
158 - WHERE CONSTRAINT_SCHEMA = '".$objInfraBanco->getBanco()."'  
159 - AND TABLE_NAME = '".$strNomeTabela."'  
160 - AND CONSTRAINT_NAME = '".$strNomeChave."'";  
161 - break;  
162 -  
163 - case 'InfraSqlServer':  
164 -  
165 - $strSql = " SELECT COUNT(CONSTRAINT_NAME) AS EXISTE  
166 - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS  
167 - WHERE CONSTRAINT_CATALOG = '".$objInfraBanco->getBanco()."'  
168 - AND TABLE_NAME = '".$strNomeTabela."'  
169 - AND CONSTRAINT_NAME = '".$strNomeChave."'";  
170 - break;  
171 -  
172 - case 'InfraOracle':  
173 - $strSql = "SELECT 0 AS EXISTE";  
174 - break;  
175 - }  
176 -  
177 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
178 - $arrDados = $objInfraBanco->consultarSql($strSql);  
179 147
180 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false;  
181 - }  
182 -  
183 public function adicionarChaveUnica($strNomeTabela = '', $arrNomeChave = array()){ 148 public function adicionarChaveUnica($strNomeTabela = '', $arrNomeChave = array()){
184 - 149 +
185 $this->getObjInfraIBanco() 150 $this->getObjInfraIBanco()
186 ->executarSql('ALTER TABLE '.$strNomeTabela.' ADD CONSTRAINT UK_'.$strNomeTabela.' UNIQUE('.implode(', ', $arrNomeChave).')'); 151 ->executarSql('ALTER TABLE '.$strNomeTabela.' ADD CONSTRAINT UK_'.$strNomeTabela.' UNIQUE('.implode(', ', $arrNomeChave).')');
187 } 152 }
188 - 153 +
189 public function renomearTabela($strNomeTabelaAtual, $strNomeTabelaNovo){ 154 public function renomearTabela($strNomeTabelaAtual, $strNomeTabelaNovo){
190 - 155 +
191 if($this->isTabelaExiste($strNomeTabelaAtual)) { 156 if($this->isTabelaExiste($strNomeTabelaAtual)) {
192 - 157 +
193 $objInfraBanco = $this->getObjInfraIBanco(); 158 $objInfraBanco = $this->getObjInfraIBanco();
194 -  
195 $strTableDrive = get_parent_class($objInfraBanco); 159 $strTableDrive = get_parent_class($objInfraBanco);
196 $strQuery = ''; 160 $strQuery = '';
197 161
198 switch ($strTableDrive) { 162 switch ($strTableDrive) {
199 -  
200 case 'InfraMySqli': 163 case 'InfraMySqli':
201 $strQuery = sprintf("ALTER TABLE `%s` RENAME TO `%s`", $strNomeTabelaAtual, $strNomeTabelaNovo); 164 $strQuery = sprintf("ALTER TABLE `%s` RENAME TO `%s`", $strNomeTabelaAtual, $strNomeTabelaNovo);
202 break; 165 break;
@@ -208,210 +171,192 @@ class PenMetaBD extends InfraMetaBD { @@ -208,210 +171,192 @@ class PenMetaBD extends InfraMetaBD {
208 $strQuery = sprintf("RENAME TABLE %s TO %s", $strNomeTabelaAtual, $strNomeTabelaNovo); 171 $strQuery = sprintf("RENAME TABLE %s TO %s", $strNomeTabelaAtual, $strNomeTabelaNovo);
209 break; 172 break;
210 } 173 }
211 - 174 +
  175 + $objInfraBanco->executarSql($strQuery);
  176 + }
  177 + }
  178 +
  179 + public function renomearColuna($strNomeTabela, $strNomeColunaAtual, $strNomeColunaNova, $strTipo){
  180 +
  181 + if($this->isColunaExiste($strNomeTabela, $strNomeColunaAtual)) {
  182 +
  183 + $objInfraBanco = $this->getObjInfraIBanco();
  184 + $strTableDrive = get_parent_class($objInfraBanco);
  185 + $strQuery = '';
  186 +
  187 + switch ($strTableDrive) {
  188 +
  189 + case 'InfraMySqli':
  190 + $strQuery = sprintf("ALTER TABLE `%s` CHANGE `%s` `%s` `%s`", $strNomeTabela, $strNomeColunaAtual, $strNomeColunaNova, $strTipo);
  191 + break;
  192 +
  193 + case 'InfraSqlServer':
  194 + $strQuery = sprintf("SP_RENAME '%s'.'%s', '%s', 'COLUMN'", $strNomeTabela, $strNomeColunaAtual, $strNomeColunaNova);
  195 +
  196 + case 'InfraOracle':
  197 + $strQuery = sprintf("ALTER TABLE %s RENAME COLUMN %s TO %s", $strNomeTabela, $strNomeColunaAtual, $strNomeColunaNova);
  198 + break;
  199 + }
  200 +
212 $objInfraBanco->executarSql($strQuery); 201 $objInfraBanco->executarSql($strQuery);
213 } 202 }
214 } 203 }
215 -  
216 - 204 +
217 /** 205 /**
218 * Verifica se uma tabela existe no banco 206 * Verifica se uma tabela existe no banco
219 - * 207 + *
220 * @throws InfraException 208 * @throws InfraException
221 * @return bool 209 * @return bool
222 */ 210 */
223 public function isTabelaExiste($strNomeTabela = ''){ 211 public function isTabelaExiste($strNomeTabela = ''){
224 -  
225 - $objInfraBanco = $this->getObjInfraIBanco();  
226 - $strTableDrive = get_parent_class($objInfraBanco);  
227 -  
228 - switch($strTableDrive) {  
229 212
230 - case 'InfraMySqli':  
231 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
232 - FROM INFORMATION_SCHEMA.TABLES  
233 - WHERE TABLE_SCHEMA = '".$objInfraBanco->getBanco()."'  
234 - AND TABLE_NAME = '".$strNomeTabela."'";  
235 - break;  
236 -  
237 - case 'InfraSqlServer':  
238 -  
239 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
240 - FROM INFORMATION_SCHEMA.TABLES  
241 - WHERE TABLE_CATALOG = '".$objInfraBanco->getBanco()."'  
242 - AND TABLE_NAME = '".$strNomeTabela."'";  
243 - break;  
244 -  
245 - case 'InfraOracle':  
246 - $strSql = "SELECT 0 AS EXISTE";  
247 - break; 213 + return count($this->obterTabelas($strNomeTabela)) != 0;
  214 + }
  215 +
  216 + public function isColunaExiste($strNomeTabela = '', $strNomeColuna = ''){
  217 +
  218 + $arrColunas = $this->obterColunasTabela($strNomeTabela);
  219 + foreach ($arrColunas as $objColuna) {
  220 + if($objColuna['column_name'] == $strNomeColuna){
  221 + return true;
  222 + }
248 } 223 }
249 -  
250 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
251 - $arrDados = $objInfraBanco->consultarSql($strSql);  
252 224
253 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false; 225 + return false;
254 } 226 }
255 -  
256 - public function isColuna($strNomeTabela = '', $strNomeColuna = ''){  
257 -  
258 - $objInfraBanco = $this->getObjInfraIBanco();  
259 - $strTableDrive = get_parent_class($objInfraBanco);  
260 -  
261 - switch($strTableDrive) {  
262 227
263 - case 'InfraMySqli':  
264 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
265 - FROM INFORMATION_SCHEMA.COLUMNS  
266 - WHERE TABLE_SCHEMA = '".$objInfraBanco->getBanco()."'  
267 - AND TABLE_NAME = '".$strNomeTabela."'  
268 - AND COLUMN_NAME = '".$strNomeColuna."'";  
269 - break;  
270 -  
271 - case 'InfraSqlServer':  
272 -  
273 - $strSql = "SELECT COUNT(COLUMN_NAME) AS EXISTE  
274 - FROM INFORMATION_SCHEMA.COLUMNS  
275 - WHERE TABLE_CATALOG = '".$objInfraBanco->getBanco()."'  
276 - AND TABLE_NAME = '".$strNomeTabela."'  
277 - AND COLUMN_NAME = '".$strNomeColuna."'";  
278 - break;  
279 -  
280 - case 'InfraOracle':  
281 - $strSql = "SELECT 0 AS EXISTE";  
282 - break; 228 + public function isChaveExiste($strNomeTabela = '', $strNomeChave = ''){
  229 +
  230 + $arrConstraints = $this->obterConstraints($strNomeTabela);
  231 + foreach ($arrConstraints as $objConstraint) {
  232 + if($objConstraint['constraint_name'] == $strNomeChave){
  233 + return true;
  234 + }
283 } 235 }
284 -  
285 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
286 - $arrDados = $objInfraBanco->consultarSql($strSql);  
287 236
288 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false;  
289 -  
290 - 237 + return false;
291 } 238 }
292 - 239 +
293 /** 240 /**
294 * Cria a estrutura da tabela no padrão ANSI 241 * Cria a estrutura da tabela no padrão ANSI
295 - * 242 + *
296 * @throws InfraException 243 * @throws InfraException
297 * @return PenMetaBD 244 * @return PenMetaBD
298 */ 245 */
299 public function criarTabela($arrSchema = array()){ 246 public function criarTabela($arrSchema = array()){
300 - 247 +
301 $strNomeTabela = $arrSchema['tabela']; 248 $strNomeTabela = $arrSchema['tabela'];
302 -  
303 - 249 +
304 if($this->isTabelaExiste($strNomeTabela)) { 250 if($this->isTabelaExiste($strNomeTabela)) {
305 return $this; 251 return $this;
306 } 252 }
307 - 253 +
308 $objInfraBanco = $this->getObjInfraIBanco(); 254 $objInfraBanco = $this->getObjInfraIBanco();
309 $arrColunas = array(); 255 $arrColunas = array();
310 $arrStrQuery = array(); 256 $arrStrQuery = array();
311 257
312 foreach($arrSchema['cols'] as $strNomeColuna => $arrColunaConfig) { 258 foreach($arrSchema['cols'] as $strNomeColuna => $arrColunaConfig) {
313 - 259 +
314 list($strTipoDado, $strValorPadrao) = $arrColunaConfig; 260 list($strTipoDado, $strValorPadrao) = $arrColunaConfig;
315 - 261 +
316 if($strValorPadrao != self::SNULLO && $strValorPadrao != self::NNULLO) { 262 if($strValorPadrao != self::SNULLO && $strValorPadrao != self::NNULLO) {
317 - 263 +
318 $arrStrQuery[] = $this->adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, true); 264 $arrStrQuery[] = $this->adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, true);
319 $strValorPadrao = self::NNULLO; 265 $strValorPadrao = self::NNULLO;
320 } 266 }
321 267
322 $arrColunas[] = $strNomeColuna.' '.$strTipoDado.' '.$strValorPadrao; 268 $arrColunas[] = $strNomeColuna.' '.$strTipoDado.' '.$strValorPadrao;
323 } 269 }
324 - 270 +
325 $objInfraBanco->executarSql('CREATE TABLE '.$strNomeTabela.' ('.implode(', ', $arrColunas).')'); 271 $objInfraBanco->executarSql('CREATE TABLE '.$strNomeTabela.' ('.implode(', ', $arrColunas).')');
326 - 272 +
327 if(!empty($arrSchema['pk'])) { 273 if(!empty($arrSchema['pk'])) {
328 -  
329 - $this->adicionarChavePrimaria($strNomeTabela, 'pk_'.$strNomeTabela, $arrSchema['pk']);  
330 -  
331 - if(count($arrSchema['pk']) > 1) {  
332 -  
333 - foreach($arrSchema['pk'] as $strPk) {  
334 -  
335 - $objInfraBanco->executarSql('CREATE INDEX idx_'.$strNomeTabela.'_'.$strPk.' ON '.$strNomeTabela.'('.$strPk.')');  
336 - } 274 + $strNomePK = array_key_exists('nome', $arrSchema['pk']) ? $arrSchema['pk']['nome'] : 'pk_' . $strNomeTabela;
  275 + $arrColunas = array_key_exists('cols', $arrSchema['pk']) ? $arrSchema['pk']['cols'] : $arrSchema['pk'];
  276 + $this->adicionarChavePrimaria($strNomeTabela, $strNomePK, $arrColunas);
  277 + if(count($arrColunas) > 1) {
  278 + for ($i=0; $i < count($arrColunas); $i++) {
  279 + $strPk = $arrColunas[$i];
  280 + $strNomeIndex = substr("i" . str_pad($i + 1, 2, "0", STR_PAD_LEFT) . '_' . $strNomeTabela, 0, 30);
  281 + $objInfraBanco->executarSql('CREATE INDEX '.$strNomeIndex.' ON '.$strNomeTabela.'('.$strPk.')');
  282 + }
337 } 283 }
338 } 284 }
339 - 285 +
340 if(array_key_exists('uk', $arrSchema) && !empty($arrSchema['uk'])) { 286 if(array_key_exists('uk', $arrSchema) && !empty($arrSchema['uk'])) {
341 -  
342 $this->adicionarChaveUnica($strNomeTabela, $arrSchema['uk']); 287 $this->adicionarChaveUnica($strNomeTabela, $arrSchema['uk']);
343 } 288 }
344 - 289 +
345 if(!empty($arrSchema['fks'])) { 290 if(!empty($arrSchema['fks'])) {
346 - 291 +
347 foreach($arrSchema['fks'] as $strTabelaOrigem => $array) { 292 foreach($arrSchema['fks'] as $strTabelaOrigem => $array) {
348 -  
349 - $strNomeFK = 'fk_'.$strNomeTabela.'_'.$strTabelaOrigem;  
350 - $arrCamposOrigem = (array)array_shift($array); 293 + $strNomeFK = array_key_exists('nome', $array) ? $array['nome'] : 'fk_'.$strNomeTabela.'_'.$strTabelaOrigem;
  294 + $arrayColumns = array_key_exists('cols', $array) ? $array['cols'] : $array;
  295 + $arrCamposOrigem = (array)array_shift($arrayColumns);
351 $arrCampos = $arrCamposOrigem; 296 $arrCampos = $arrCamposOrigem;
352 297
353 - if(!empty($array)) {  
354 - $arrCampos = (array)array_shift($array); 298 + if(!empty($arrayColumns)) {
  299 + $arrCampos = (array)array_shift($arrayColumns);
355 } 300 }
356 301
357 - $this->adicionarChaveEstrangeira($strNomeFK, $strNomeTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem); 302 + $this->adicionarChaveEstrangeira($strNomeFK, $strNomeTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem);
358 } 303 }
359 } 304 }
360 - 305 +
361 if(!empty($arrStrQuery)) { 306 if(!empty($arrStrQuery)) {
362 -  
363 - foreach($arrStrQuery as $strQuery) { 307 +
  308 + foreach($arrStrQuery as $strQuery) {
364 $objInfraBanco->executarSql($strQuery); 309 $objInfraBanco->executarSql($strQuery);
365 } 310 }
366 } 311 }
367 - 312 +
368 return $this; 313 return $this;
369 } 314 }
370 - 315 +
371 /** 316 /**
372 * Apagar a estrutura da tabela no banco de dados 317 * Apagar a estrutura da tabela no banco de dados
373 - * 318 + *
374 * @throws InfraException 319 * @throws InfraException
375 * @return PenMetaBD 320 * @return PenMetaBD
376 */ 321 */
377 public function removerTabela($strNomeTabela = ''){ 322 public function removerTabela($strNomeTabela = ''){
378 - 323 +
379 $this->getObjInfraIBanco()->executarSql('DROP TABLE '.$strNomeTabela); 324 $this->getObjInfraIBanco()->executarSql('DROP TABLE '.$strNomeTabela);
380 return $this; 325 return $this;
381 } 326 }
382 - 327 +
383 public function adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem) { 328 public function adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem) {
384 - 329 +
385 if(!$this->isChaveExiste($strTabela, $strNomeFK)) { 330 if(!$this->isChaveExiste($strTabela, $strNomeFK)) {
386 parent::adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem); 331 parent::adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem);
387 } 332 }
388 return $this; 333 return $this;
389 } 334 }
390 - 335 +
391 public function adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos) { 336 public function adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos) {
392 - 337 +
393 if(!$this->isChaveExiste($strTabela, $strNomePK)) { 338 if(!$this->isChaveExiste($strTabela, $strNomePK)) {
394 parent::adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos); 339 parent::adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos);
395 } 340 }
396 return $this; 341 return $this;
397 } 342 }
398 - 343 +
399 public function alterarColuna($strTabela, $strColuna, $strTipo, $strNull = '') { 344 public function alterarColuna($strTabela, $strColuna, $strTipo, $strNull = '') {
400 parent::alterarColuna($strTabela, $strColuna, $strTipo, $strNull); 345 parent::alterarColuna($strTabela, $strColuna, $strTipo, $strNull);
401 return $this; 346 return $this;
402 } 347 }
403 - 348 +
404 public function excluirIndice($strTabela, $strIndex) { 349 public function excluirIndice($strTabela, $strIndex) {
405 if($this->isChaveExiste($strTabela, $strFk)) { 350 if($this->isChaveExiste($strTabela, $strFk)) {
406 parent::excluirIndice($strTabela, $strIndex); 351 parent::excluirIndice($strTabela, $strIndex);
407 } 352 }
408 return $this; 353 return $this;
409 } 354 }
410 - 355 +
411 public function excluirChaveEstrangeira($strTabela, $strFk) { 356 public function excluirChaveEstrangeira($strTabela, $strFk) {
412 if($this->isChaveExiste($strTabela, $strFk)) { 357 if($this->isChaveExiste($strTabela, $strFk)) {
413 parent::excluirChaveEstrangeira($strTabela, $strFk); 358 parent::excluirChaveEstrangeira($strTabela, $strFk);
414 } 359 }
415 return $this; 360 return $this;
416 } 361 }
417 -}  
418 \ No newline at end of file 362 \ No newline at end of file
  363 +}
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 }
pen_parametros_configuracao.php
@@ -57,7 +57,7 @@ try { @@ -57,7 +57,7 @@ try {
57 $objPenParametroDTO->retStrNome(); 57 $objPenParametroDTO->retStrNome();
58 58
59 if($objPenParametroRN->contar($objPenParametroDTO) > 0) { 59 if($objPenParametroRN->contar($objPenParametroDTO) > 0) {
60 - $objPenParametroDTO->setStrValor($valor); 60 + $objPenParametroDTO->setStrValor(trim($valor));
61 $objPenParametroRN->alterar($objPenParametroDTO); 61 $objPenParametroRN->alterar($objPenParametroDTO);
62 } 62 }
63 } 63 }
pen_procedimento_expedir.php
@@ -573,10 +573,6 @@ $objPaginaSEI-&gt;montarBarraComandosSuperior($arrComandos); @@ -573,10 +573,6 @@ $objPaginaSEI-&gt;montarBarraComandosSuperior($arrComandos);
573 <img id="imgExcluirProcedimentosApensados" onclick="objLupaProcedimentosApensados.remover();" src="/infra_css/imagens/remover.gif" alt="Remover Processo Apensado" title="Remover Processo Apensado" class="infraImg" tabindex="<?= $objPaginaSEI->getProxTabDados() ?>" /> 573 <img id="imgExcluirProcedimentosApensados" onclick="objLupaProcedimentosApensados.remover();" src="/infra_css/imagens/remover.gif" alt="Remover Processo Apensado" title="Remover Processo Apensado" class="infraImg" tabindex="<?= $objPaginaSEI->getProxTabDados() ?>" />
574 </div> 574 </div>
575 575
576 - <div id="divSinUrgente" class="infraDivCheckbox">  
577 - <input type="checkbox" id="chkSinUrgente" name="chkSinUrgente" class="infraCheckbox" onclick="selecionarUrgencia();" <?= $objPaginaSEI->setCheckbox($boolSinUrgente, true, false) ?> tabindex="<?= $objPaginaSEI->getProxTabDados() ?>" />  
578 - <label id="lblSinUrgente" for="chkSinUrgente" accesskey="" class="infraLabelCheckbox">Urgente</label>  
579 - </div>  
580 576
581 <div id="divMotivosUrgencia" class="infraAreaDados" style="height: 4.5em; display:none"> 577 <div id="divMotivosUrgencia" class="infraAreaDados" style="height: 4.5em; display:none">
582 <label id="lblMotivosUrgencia" for="selMotivosUrgencia" accesskey="" class="infraLabel">Motivo da Urgência:</label> 578 <label id="lblMotivosUrgencia" for="selMotivosUrgencia" accesskey="" class="infraLabel">Motivo da Urgência:</label>
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/PenAtualizarSeiRN.php
@@ -12,8 +12,8 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -12,8 +12,8 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
12 public function __construct() { 12 public function __construct() {
13 parent::__construct(); 13 parent::__construct();
14 } 14 }
15 -  
16 - public function atualizarVersao() { 15 +
  16 + protected function atualizarVersaoConectado() {
17 try { 17 try {
18 $this->inicializar('INICIANDO ATUALIZACAO DO MODULO PEN NO SEI VERSAO ' . SEI_VERSAO); 18 $this->inicializar('INICIANDO ATUALIZACAO DO MODULO PEN NO SEI VERSAO ' . SEI_VERSAO);
19 19
@@ -24,25 +24,31 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -24,25 +24,31 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
24 24
25 $this->finalizar('BANCO DE DADOS NAO SUPORTADO: ' . get_parent_class(BancoSEI::getInstance()), true); 25 $this->finalizar('BANCO DE DADOS NAO SUPORTADO: ' . get_parent_class(BancoSEI::getInstance()), true);
26 } 26 }
27 - 27 +
28 //testando permissoes de criações de tabelas 28 //testando permissoes de criações de tabelas
29 $objInfraMetaBD = new InfraMetaBD($this->objInfraBanco); 29 $objInfraMetaBD = new InfraMetaBD($this->objInfraBanco);
30 - 30 +
31 if (count($objInfraMetaBD->obterTabelas('pen_sei_teste')) == 0) { 31 if (count($objInfraMetaBD->obterTabelas('pen_sei_teste')) == 0) {
32 BancoSEI::getInstance()->executarSql('CREATE TABLE pen_sei_teste (id ' . $objInfraMetaBD->tipoNumero() . ' null)'); 32 BancoSEI::getInstance()->executarSql('CREATE TABLE pen_sei_teste (id ' . $objInfraMetaBD->tipoNumero() . ' null)');
33 } 33 }
34 BancoSEI::getInstance()->executarSql('DROP TABLE pen_sei_teste'); 34 BancoSEI::getInstance()->executarSql('DROP TABLE pen_sei_teste');
35 35
36 - $objInfraParametro = new InfraParametro($this->objInfraBanco);  
37 - 36 + $objInfraParametro = new InfraParametro($this->objInfraBanco);
  37 +
38 // Aplicação de scripts de atualização de forma incremental 38 // Aplicação de scripts de atualização de forma incremental
39 // Ausência de [break;] proposital para realizar a atualização incremental de versões 39 // Ausência de [break;] proposital para realizar a atualização incremental de versões
40 $strVersaoModuloPen = $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO, false) ?: $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO_ANTIGO, false); 40 $strVersaoModuloPen = $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO, false) ?: $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO_ANTIGO, false);
41 - switch ($strVersaoModuloPen) { 41 + switch ($strVersaoModuloPen) {
42 case '': $this->instalarV100(); // Nenhuma versão instalada 42 case '': $this->instalarV100(); // Nenhuma versão instalada
43 case '1.0.0': $this->instalarV101(); 43 case '1.0.0': $this->instalarV101();
44 case '1.0.1': $this->instalarV110(); 44 case '1.0.1': $this->instalarV110();
45 case '1.1.0': $this->instalarV111(); 45 case '1.1.0': $this->instalarV111();
  46 + case '1.1.1': //Não houve atualização no banco de dados
  47 + case '1.1.2': //Não houve atualização no banco de dados
  48 + case '1.1.3': //Não houve atualização no banco de dados
  49 + case '1.1.4': //Não houve atualização no banco de dados
  50 + case '1.1.5': //Não houve atualização no banco de dados
  51 + case '1.1.6': $this->instalarV117();
46 52
47 break; 53 break;
48 default: 54 default:
@@ -76,7 +82,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -76,7 +82,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
76 82
77 return $objDTOCadastrado->getStrNome(); 83 return $objDTOCadastrado->getStrNome();
78 } 84 }
79 - 85 +
80 /** 86 /**
81 * Remove um parâmetro do infra_parametros 87 * Remove um parâmetro do infra_parametros
82 * @return string Nome do parâmetro 88 * @return string Nome do parâmetro
@@ -88,10 +94,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -88,10 +94,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
88 $objBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 94 $objBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
89 return $objBD->excluir($objDTO); 95 return $objBD->excluir($objDTO);
90 } 96 }
91 - 97 +
92 /* Contem atualizações da versao 1.0.0 do modulo */ 98 /* Contem atualizações da versao 1.0.0 do modulo */
93 protected function instalarV100() { 99 protected function instalarV100() {
94 - 100 +
95 $objInfraBanco = $this->objInfraBanco; 101 $objInfraBanco = $this->objInfraBanco;
96 $objMetaBD = $this->objMeta; 102 $objMetaBD = $this->objMeta;
97 103
@@ -101,13 +107,15 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -101,13 +107,15 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
101 'numero_registro' => array($objMetaBD->tipoTextoFixo(16), PenMetaBD::NNULLO), 107 'numero_registro' => array($objMetaBD->tipoTextoFixo(16), PenMetaBD::NNULLO),
102 'id_procedimento' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO) 108 'id_procedimento' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO)
103 ), 109 ),
104 - 'pk' => array('numero_registro'), 110 + 'pk' => array('cols'=>array('numero_registro')),
105 'uk' => array('numero_registro', 'id_procedimento'), 111 'uk' => array('numero_registro', 'id_procedimento'),
106 'fks' => array( 112 'fks' => array(
107 - 'procedimento' => array('id_procedimento', 'id_procedimento') 113 + 'procedimento' => array('nome' => 'fk_md_pen_proc_eletr_procedim',
  114 + 'cols' => array('id_procedimento', 'id_procedimento')),
108 ) 115 )
109 )); 116 ));
110 117
  118 +
111 $objMetaBD->criarTabela(array( 119 $objMetaBD->criarTabela(array(
112 'tabela' => 'md_pen_tramite', 120 'tabela' => 'md_pen_tramite',
113 'cols' => array( 121 'cols' => array(
@@ -119,15 +127,17 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -119,15 +127,17 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
119 'id_usuario' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO), 127 'id_usuario' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO),
120 'id_unidade' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO) 128 'id_unidade' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO)
121 ), 129 ),
122 - 'pk' => array('id_tramite'), 130 + 'pk' => array('cols'=>array('id_tramite')),
123 'uk' => array('numero_registro', 'id_tramite'), 131 'uk' => array('numero_registro', 'id_tramite'),
124 'fks' => array( 132 'fks' => array(
125 - 'md_pen_processo_eletronico' => array('numero_registro', 'numero_registro'), 133 + 'md_pen_processo_eletronico' => array('nome'=>'fk_md_pen_tramite_proc_eletr',
  134 + 'cols' => array('numero_registro', 'numero_registro')),
126 'usuario' => array('id_usuario', 'id_usuario'), 135 'usuario' => array('id_usuario', 'id_usuario'),
127 - 'unidade' => array('id_unidade', 'id_unidade') 136 + 'unidade' => array('id_unidade', 'id_unidade'),
128 ) 137 )
129 )); 138 ));
130 139
  140 +
131 $objMetaBD->criarTabela(array( 141 $objMetaBD->criarTabela(array(
132 'tabela' => 'md_pen_especie_documental', 142 'tabela' => 'md_pen_especie_documental',
133 'cols' => array( 143 'cols' => array(
@@ -135,9 +145,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -135,9 +145,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
135 'nome_especie' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO), 145 'nome_especie' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO),
136 'descricao' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO) 146 'descricao' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO)
137 ), 147 ),
138 - 'pk' => array('id_especie') 148 + 'pk' => array('cols'=>array('id_especie')),
139 )); 149 ));
140 150
  151 +
141 $objMetaBD->criarTabela(array( 152 $objMetaBD->criarTabela(array(
142 'tabela' => 'md_pen_tramite_pendente', 153 'tabela' => 'md_pen_tramite_pendente',
143 'cols' => array( 154 'cols' => array(
@@ -145,7 +156,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -145,7 +156,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
145 'numero_tramite' => array($objMetaBD->tipoTextoVariavel(255)), 156 'numero_tramite' => array($objMetaBD->tipoTextoVariavel(255)),
146 'id_atividade_expedicao' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO) 157 'id_atividade_expedicao' => array($objMetaBD->tipoNumero(), PenMetaBD::SNULLO)
147 ), 158 ),
148 - 'pk' => array('id') 159 + 'pk' => array('cols'=>array('id')),
149 )); 160 ));
150 161
151 $objMetaBD->criarTabela(array( 162 $objMetaBD->criarTabela(array(
@@ -156,7 +167,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -156,7 +167,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
156 'dth_recebimento' => array($objMetaBD->tipoDataHora(), PenMetaBD::NNULLO), 167 'dth_recebimento' => array($objMetaBD->tipoDataHora(), PenMetaBD::NNULLO),
157 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO) 168 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO)
158 ), 169 ),
159 - 'pk' => array('numero_registro', 'id_tramite') 170 + 'pk' => array('cols'=>array('numero_registro', 'id_tramite')),
160 )); 171 ));
161 172
162 173
@@ -172,7 +183,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -172,7 +183,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
172 'hash' => array($objMetaBD->tipoTextoFixo(32), PenMetaBD::NNULLO), 183 'hash' => array($objMetaBD->tipoTextoFixo(32), PenMetaBD::NNULLO),
173 'id_tarefa' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO) 184 'id_tarefa' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO)
174 ), 185 ),
175 - 'pk' => array('id_andamento') 186 + 'pk' => array('nome' => 'pk_md_pen_procedim_andamen', 'cols'=>array('id_andamento')),
176 )); 187 ));
177 188
178 $objMetaBD->criarTabela(array( 189 $objMetaBD->criarTabela(array(
@@ -181,20 +192,12 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -181,20 +192,12 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
181 'id_protocolo' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO), 192 'id_protocolo' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO),
182 'sin_obteve_recusa' => array($objMetaBD->tipoTextoFixo(1), 'N') 193 'sin_obteve_recusa' => array($objMetaBD->tipoTextoFixo(1), 'N')
183 ), 194 ),
184 - 'pk' => array('id_protocolo'), 195 + 'pk' => array('cols'=>array('id_protocolo')),
185 'fks' => array( 196 'fks' => array(
186 'protocolo' => array('id_protocolo', 'id_protocolo') 197 'protocolo' => array('id_protocolo', 'id_protocolo')
187 ) 198 )
188 )); 199 ));
189 200
190 - /* $objMetaBD->criarTabela(array(  
191 - 'tabela' => 'md_pen_tramite_recusado',  
192 - 'cols' => array(  
193 - 'numero_registro'=> array($objMetaBD->tipoTextoFixo(16), PenMetaBD::NNULLO),  
194 - 'id_tramite' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO)  
195 - ),  
196 - 'pk' => array('id_tramite')  
197 - )); */  
198 201
199 $objMetaBD->criarTabela(array( 202 $objMetaBD->criarTabela(array(
200 'tabela' => 'md_pen_recibo_tramite', 203 'tabela' => 'md_pen_recibo_tramite',
@@ -205,9 +208,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -205,9 +208,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
205 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO), 208 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO),
206 'cadeia_certificado' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO) 209 'cadeia_certificado' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO)
207 ), 210 ),
208 - 'pk' => array('numero_registro', 'id_tramite'), 211 + 'pk' => array('cols'=>array('numero_registro', 'id_tramite')),
209 'fks' => array( 212 'fks' => array(
210 - 'md_pen_tramite' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')) 213 + 'md_pen_tramite' => array('nome' => 'fk_md_pen_rec_tramite_tramite',
  214 + 'cols' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')))
211 ) 215 )
212 )); 216 ));
213 217
@@ -220,12 +224,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -220,12 +224,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
220 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO), 224 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO),
221 'cadeia_certificado ' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO) 225 'cadeia_certificado ' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO)
222 ), 226 ),
223 - 'pk' => array('numero_registro', 'id_tramite'), 227 + 'pk' => array('nome' => 'pk_md_pen_recibo_tram_envia', 'cols'=>array('numero_registro', 'id_tramite')),
224 'fks' => array( 228 'fks' => array(
225 - 'md_pen_tramite' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')) 229 + 'md_pen_tramite' => array('nome' => 'fk_md_pen_rec_tram_env_tram',
  230 + 'cols' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')))
226 ) 231 )
227 )); 232 ));
228 233
  234 +
229 $objMetaBD->criarTabela(array( 235 $objMetaBD->criarTabela(array(
230 'tabela' => 'md_pen_recibo_tramite_recebido', 236 'tabela' => 'md_pen_recibo_tramite_recebido',
231 'cols' => array( 237 'cols' => array(
@@ -234,12 +240,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -234,12 +240,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
234 'dth_recebimento' => array($objMetaBD->tipoDataHora(), PenMetaBD::NNULLO), 240 'dth_recebimento' => array($objMetaBD->tipoDataHora(), PenMetaBD::NNULLO),
235 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO) 241 'hash_assinatura' => array($objMetaBD->tipoTextoVariavel(345), PenMetaBD::NNULLO)
236 ), 242 ),
237 - 'pk' => array('numero_registro', 'id_tramite', 'hash_assinatura'), 243 + 'pk' => array('nome' => 'pk_md_pen_recibo_tramite_receb', 'cols'=>array('numero_registro', 'id_tramite', 'hash_assinatura')),
238 'fks' => array( 244 'fks' => array(
239 - 'md_pen_tramite' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')) 245 + 'md_pen_tramite' => array('nome' => 'fk_md_pen_recibo_receb_tram',
  246 + 'cols' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')))
240 ) 247 )
241 )); 248 ));
242 249
  250 +
243 $objMetaBD->criarTabela(array( 251 $objMetaBD->criarTabela(array(
244 'tabela' => 'md_pen_rel_processo_apensado', 252 'tabela' => 'md_pen_rel_processo_apensado',
245 'cols' => array( 253 'cols' => array(
@@ -247,9 +255,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -247,9 +255,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
247 'id_procedimento_apensado' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO), 255 'id_procedimento_apensado' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO),
248 'protocolo' => array($objMetaBD->tipoTextoVariavel(50), PenMetaBD::NNULLO) 256 'protocolo' => array($objMetaBD->tipoTextoVariavel(50), PenMetaBD::NNULLO)
249 ), 257 ),
250 - 'pk' => array('numero_registro', 'id_procedimento_apensado'), 258 + 'pk' => array('nome' => 'pk_md_pen_rel_processo_apensad', 'cols'=>array('numero_registro', 'id_procedimento_apensado')),
251 'fks' => array( 259 'fks' => array(
252 - 'md_pen_processo_eletronico' => array('numero_registro', 'numero_registro') 260 + 'md_pen_processo_eletronico' => array('nome' => 'fk_md_pen_proc_eletr_apensado',
  261 + 'cols' => array('numero_registro', 'numero_registro'))
253 ) 262 )
254 )); 263 ));
255 264
@@ -260,10 +269,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -260,10 +269,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
260 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 269 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
261 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'N') 270 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'N')
262 ), 271 ),
263 - 'pk' => array('id_serie'), 272 + 'pk' => array('cols'=>array('id_serie')),
264 'uk' => array('codigo_especie', 'id_serie'), 273 'uk' => array('codigo_especie', 'id_serie'),
265 'fks' => array( 274 'fks' => array(
266 - 'serie' => array('id_serie', 'id_serie') 275 + 'serie' => array('nome' => ' fk_md_pen_rel_serie_especie', 'cols' => array('id_serie', 'id_serie'))
267 ) 276 )
268 )); 277 ));
269 278
@@ -273,22 +282,23 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -273,22 +282,23 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
273 'id_tarefa' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 282 'id_tarefa' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
274 'codigo_operacao' => array($objMetaBD->tipoTextoFixo(2), PenMetaBD::NNULLO) 283 'codigo_operacao' => array($objMetaBD->tipoTextoFixo(2), PenMetaBD::NNULLO)
275 ), 284 ),
276 - 'pk' => array('id_tarefa', 'codigo_operacao'), 285 + 'pk' => array('cols'=>array('id_tarefa', 'codigo_operacao')),
277 'fks' => array( 286 'fks' => array(
278 - 'tarefa' => array('id_tarefa', 'id_tarefa') 287 + 'tarefa' => array('nome' => 'fk_md_pen_rel_operacao_tarefa', 'cols' => array('id_tarefa', 'id_tarefa'))
279 ) 288 )
280 )); 289 ));
281 290
  291 +
282 $objMetaBD->criarTabela(array( 292 $objMetaBD->criarTabela(array(
283 - 'tabela' => 'md_pen_rel_tipo_documento_mapeamento_recebido', 293 + 'tabela' => 'md_pen_rel_tipo_doc_map_rec',
284 'cols' => array( 294 'cols' => array(
285 'codigo_especie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 295 'codigo_especie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
286 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 296 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
287 'sin_padrao' => array($objMetaBD->tipoTextoFixo(2), PenMetaBD::NNULLO) 297 'sin_padrao' => array($objMetaBD->tipoTextoFixo(2), PenMetaBD::NNULLO)
288 ), 298 ),
289 - 'pk' => array('codigo_especie', 'id_serie'), 299 + 'pk' => array('cols'=>array('codigo_especie', 'id_serie')),
290 'fks' => array( 300 'fks' => array(
291 - 'serie' => array('id_serie', 'id_serie') 301 + 'serie' => array('nome' =>'fk_md_pen_rel_tipo_doc_serie', 'cols' => array('id_serie', 'id_serie'))
292 ) 302 )
293 )); 303 ));
294 304
@@ -311,13 +321,13 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -311,13 +321,13 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
311 'ordem' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 321 'ordem' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
312 'sin_enviar' => array($objMetaBD->tipoTextoFixo(1), 'N') 322 'sin_enviar' => array($objMetaBD->tipoTextoFixo(1), 'N')
313 ), 323 ),
314 - 'pk' => array('numero_registro', 'id_procedimento', 'id_documento', 'id_tramite'), 324 + 'pk' => array('cols'=>array('numero_registro', 'id_procedimento', 'id_documento', 'id_tramite')),
315 'fks' => array( 325 'fks' => array(
316 - 'anexo' => array('id_anexo', 'id_anexo'),  
317 - 'documento' => array('id_documento', 'id_documento'),  
318 - 'procedimento' => array('id_procedimento', 'id_procedimento'),  
319 - 'md_pen_processo_eletronico' => array('numero_registro', 'numero_registro'),  
320 - 'md_pen_tramite' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')) 326 + 'anexo' => array('nome' => 'fk_md_pen_comp_dig_anexo', 'cols' => array('id_anexo', 'id_anexo')),
  327 + 'documento' => array('nome' => 'fk_md_pen_comp_dig_documento', 'cols' => array('id_documento', 'id_documento')),
  328 + 'procedimento' => array('nome' => 'fk_md_pen_comp_dig_procediment', 'cols' => array('id_procedimento', 'id_procedimento')),
  329 + 'md_pen_processo_eletronico' => array('nome' => 'fk_md_pen_comp_dig_proc_eletr', 'cols' => array('numero_registro', 'numero_registro')),
  330 + 'md_pen_tramite' => array('nome' => 'fk_md_pen_comp_dig_tramite', 'cols' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')))
321 ) 331 )
322 )); 332 ));
323 333
@@ -327,12 +337,13 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -327,12 +337,13 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
327 'id_unidade' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 337 'id_unidade' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
328 'id_unidade_rh' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO) 338 'id_unidade_rh' => array($objMetaBD->tipoNumeroGrande(), PenMetaBD::NNULLO)
329 ), 339 ),
330 - 'pk' => array('id_unidade'), 340 + 'pk' => array('cols'=>array('id_unidade')),
331 'fks' => array( 341 'fks' => array(
332 'unidade' => array('id_unidade', 'id_unidade') 342 'unidade' => array('id_unidade', 'id_unidade')
333 ) 343 )
334 )); 344 ));
335 345
  346 +
336 //---------------------------------------------------------------------- 347 //----------------------------------------------------------------------
337 // Novas sequências 348 // Novas sequências
338 //---------------------------------------------------------------------- 349 //----------------------------------------------------------------------
@@ -653,7 +664,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -653,7 +664,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
653 664
654 $fnCadastrar('PENAgendamentoRN::seiVerificarServicosBarramento', 'Verificação dos serviços de fila de processamento estão em execução'); 665 $fnCadastrar('PENAgendamentoRN::seiVerificarServicosBarramento', 'Verificação dos serviços de fila de processamento estão em execução');
655 666
656 - 667 +
657 /* ---------- antigo método (instalarV002R003S000US024) ---------- */ 668 /* ---------- antigo método (instalarV002R003S000US024) ---------- */
658 669
659 $objMetaBD->criarTabela(array( 670 $objMetaBD->criarTabela(array(
@@ -664,14 +675,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -664,14 +675,14 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
664 'numero_tentativas' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 675 'numero_tentativas' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
665 'sin_recebimento_concluido' => array($objMetaBD->tipoTextoFixo(1), PenMetaBD::NNULLO) 676 'sin_recebimento_concluido' => array($objMetaBD->tipoTextoFixo(1), PenMetaBD::NNULLO)
666 ), 677 ),
667 - 'pk' => array('id_tramite') 678 + 'pk' => array('cols'=>array('id_tramite')),
668 )); 679 ));
669 680
670 $objInfraParametro = new InfraParametro($objInfraBanco); 681 $objInfraParametro = new InfraParametro($objInfraBanco);
671 $objInfraParametro->setValor('PEN_NUMERO_TENTATIVAS_TRAMITE_RECEBIMENTO', '3'); 682 $objInfraParametro->setValor('PEN_NUMERO_TENTATIVAS_TRAMITE_RECEBIMENTO', '3');
672 -  
673 -  
674 - /* ---------- antigo método (instalarV002R003S000IW001) ---------- */ 683 +
  684 +
  685 + /* ---------- antigo método (instalarV002R003S000IW001) ---------- */
675 686
676 $objDTO = new TarefaDTO(); 687 $objDTO = new TarefaDTO();
677 $objBD = new TarefaBD($objInfraBanco); 688 $objBD = new TarefaBD($objInfraBanco);
@@ -698,11 +709,11 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -698,11 +709,11 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
698 }; 709 };
699 710
700 $fnAlterar('PEN_PROCESSO_RECEBIDO', 'Processo recebido da entidade @ENTIDADE_ORIGEM@ - @REPOSITORIO_ORIGEM@'); 711 $fnAlterar('PEN_PROCESSO_RECEBIDO', 'Processo recebido da entidade @ENTIDADE_ORIGEM@ - @REPOSITORIO_ORIGEM@');
701 - 712 +
702 /* ---------- antigo método (instalarV002R003S001US035) ---------- */ 713 /* ---------- antigo método (instalarV002R003S001US035) ---------- */
703 $objMetaBanco = $this->inicializarObjMetaBanco(); 714 $objMetaBanco = $this->inicializarObjMetaBanco();
704 715
705 - if (!$objMetaBanco->isColuna('md_pen_tramite_processado', 'tipo_tramite_processo')) { 716 + if (!$objMetaBanco->isColunaExiste('md_pen_tramite_processado', 'tipo_tramite_processo')) {
706 $objMetaBanco->adicionarColuna('md_pen_tramite_processado', 'tipo_tramite_processo', 'CHAR(2)', PenMetaBD::NNULLO); 717 $objMetaBanco->adicionarColuna('md_pen_tramite_processado', 'tipo_tramite_processo', 'CHAR(2)', PenMetaBD::NNULLO);
707 $objMetaBanco->adicionarValorPadraoParaColuna('md_pen_tramite_processado', 'tipo_tramite_processo', 'RP'); 718 $objMetaBanco->adicionarValorPadraoParaColuna('md_pen_tramite_processado', 'tipo_tramite_processo', 'RP');
708 } 719 }
@@ -712,7 +723,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -712,7 +723,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
712 $objMetaBanco->removerChavePrimaria('md_pen_tramite_processado', 'pk_md_pen_tramite_processado'); 723 $objMetaBanco->removerChavePrimaria('md_pen_tramite_processado', 'pk_md_pen_tramite_processado');
713 $objMetaBanco->adicionarChavePrimaria('md_pen_tramite_processado', 'pk_md_pen_tramite_processado', array('id_tramite', 'tipo_tramite_processo')); 724 $objMetaBanco->adicionarChavePrimaria('md_pen_tramite_processado', 'pk_md_pen_tramite_processado', array('id_tramite', 'tipo_tramite_processo'));
714 } 725 }
715 - 726 +
716 /* ---------- antigo método (instalarV003R003S003IW001) ---------- */ 727 /* ---------- antigo método (instalarV003R003S003IW001) ---------- */
717 728
718 //---------------------------------------------------------------------- 729 //----------------------------------------------------------------------
@@ -736,11 +747,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -736,11 +747,10 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
736 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 747 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
737 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'S') 748 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'S')
738 ), 749 ),
739 - 'pk' => array('id_mapeamento'),  
740 - //'uk' => array('codigo_especie', 'id_serie'), 750 + 'pk' => array('cols'=>array('id_mapeamento')),
741 'fks' => array( 751 'fks' => array(
742 - 'serie' => array('id_serie', 'id_serie'),  
743 - 'md_pen_especie_documental' => array('id_especie', 'codigo_especie'), 752 + 'serie' => array('nome' => 'fk_md_pen_rel_doc_map_env_seri', 'cols' => array('id_serie', 'id_serie')),
  753 + 'md_pen_especie_documental' => array('nome' => 'fk_md_pen_rel_doc_map_env_espe', 'cols' => array('id_especie', 'codigo_especie')),
744 ) 754 )
745 )); 755 ));
746 756
@@ -752,22 +762,17 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -752,22 +762,17 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
752 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO), 762 'id_serie' => array($objMetaBD->tipoNumero(), PenMetaBD::NNULLO),
753 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'S') 763 'sin_padrao' => array($objMetaBD->tipoTextoFixo(1), 'S')
754 ), 764 ),
755 - 'pk' => array('id_mapeamento'),  
756 - //'uk' => array('codigo_especie', 'id_serie'), 765 + 'pk' => array('cols'=>array('id_mapeamento')),
757 'fks' => array( 766 'fks' => array(
758 - 'serie' => array('id_serie', 'id_serie'),  
759 - 'md_pen_especie_documental' => array('id_especie', 'codigo_especie'), 767 + 'serie' => array('nome' => 'fk_md_pen_rel_doc_map_rec_seri', 'cols' => array('id_serie', 'id_serie')),
  768 + 'md_pen_especie_documental' => array('nome' => 'fk_md_pen_rel_doc_map_rec_espe', 'cols' => array('id_especie', 'codigo_especie')),
760 ) 769 )
761 )); 770 ));
762 771
763 $objBD = new GenericoBD($objInfraBanco); 772 $objBD = new GenericoBD($objInfraBanco);
764 -  
765 if ($objMetaBD->isTabelaExiste('md_pen_rel_tipo_documento_mapeamento_recebido')) { 773 if ($objMetaBD->isTabelaExiste('md_pen_rel_tipo_documento_mapeamento_recebido')) {
766 -  
767 $objDTO = new PenRelTipoDocMapRecebidoDTO(); 774 $objDTO = new PenRelTipoDocMapRecebidoDTO();
768 -  
769 $fnCadastrar = function($numCodigoEspecie, $numIdSerie) use($objDTO, $objBD) { 775 $fnCadastrar = function($numCodigoEspecie, $numIdSerie) use($objDTO, $objBD) {
770 -  
771 $objDTO->unSetTodos(); 776 $objDTO->unSetTodos();
772 $objDTO->setNumCodigoEspecie($numCodigoEspecie); 777 $objDTO->setNumCodigoEspecie($numCodigoEspecie);
773 $objDTO->setNumIdSerie($numIdSerie); 778 $objDTO->setNumIdSerie($numIdSerie);
@@ -782,7 +787,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -782,7 +787,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
782 $arrDados = $objInfraBanco->consultarSql('SELECT DISTINCT codigo_especie, id_serie FROM md_pen_rel_tipo_documento_mapeamento_recebido'); 787 $arrDados = $objInfraBanco->consultarSql('SELECT DISTINCT codigo_especie, id_serie FROM md_pen_rel_tipo_documento_mapeamento_recebido');
783 if (!empty($arrDados)) { 788 if (!empty($arrDados)) {
784 foreach ($arrDados as $arrDocMapRecebido) { 789 foreach ($arrDados as $arrDocMapRecebido) {
785 -  
786 $fnCadastrar($arrDocMapRecebido['codigo_especie'], $arrDocMapRecebido['id_serie']); 790 $fnCadastrar($arrDocMapRecebido['codigo_especie'], $arrDocMapRecebido['id_serie']);
787 } 791 }
788 } 792 }
@@ -790,11 +794,8 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -790,11 +794,8 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
790 $objMetaBD->removerTabela('md_pen_rel_tipo_documento_mapeamento_recebido'); 794 $objMetaBD->removerTabela('md_pen_rel_tipo_documento_mapeamento_recebido');
791 } 795 }
792 796
793 -  
794 if ($objMetaBD->isTabelaExiste('md_pen_rel_serie_especie')) { 797 if ($objMetaBD->isTabelaExiste('md_pen_rel_serie_especie')) {
795 -  
796 $objDTO = new PenRelTipoDocMapEnviadoDTO(); 798 $objDTO = new PenRelTipoDocMapEnviadoDTO();
797 -  
798 $fnCadastrar = function($numCodigoEspecie, $numIdSerie) use($objDTO, $objBD) { 799 $fnCadastrar = function($numCodigoEspecie, $numIdSerie) use($objDTO, $objBD) {
799 800
800 $objDTO->unSetTodos(); 801 $objDTO->unSetTodos();
@@ -802,7 +803,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -802,7 +803,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
802 $objDTO->setNumIdSerie($numIdSerie); 803 $objDTO->setNumIdSerie($numIdSerie);
803 804
804 if ($objBD->contar($objDTO) == 0) { 805 if ($objBD->contar($objDTO) == 0) {
805 -  
806 $objDTO->setStrPadrao('S'); 806 $objDTO->setStrPadrao('S');
807 $objBD->cadastrar($objDTO); 807 $objBD->cadastrar($objDTO);
808 } 808 }
@@ -811,22 +811,26 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -811,22 +811,26 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
811 $arrDados = $objInfraBanco->consultarSql('SELECT DISTINCT codigo_especie, id_serie FROM md_pen_rel_serie_especie'); 811 $arrDados = $objInfraBanco->consultarSql('SELECT DISTINCT codigo_especie, id_serie FROM md_pen_rel_serie_especie');
812 if (!empty($arrDados)) { 812 if (!empty($arrDados)) {
813 foreach ($arrDados as $arrDocMapEnviado) { 813 foreach ($arrDados as $arrDocMapEnviado) {
814 -  
815 $fnCadastrar($arrDocMapEnviado['codigo_especie'], $arrDocMapEnviado['id_serie']); 814 $fnCadastrar($arrDocMapEnviado['codigo_especie'], $arrDocMapEnviado['id_serie']);
816 } 815 }
817 } 816 }
818 817
819 $objMetaBD->removerTabela('md_pen_rel_serie_especie'); 818 $objMetaBD->removerTabela('md_pen_rel_serie_especie');
820 } 819 }
821 -  
822 - 820 +
  821 +
823 /* ---------- antigo método (instalarV004R003S003IW002) ---------- */ 822 /* ---------- antigo método (instalarV004R003S003IW002) ---------- */
824 $strTipo = $this->inicializarObjMetaBanco()->tipoTextoGrande(); 823 $strTipo = $this->inicializarObjMetaBanco()->tipoTextoGrande();
  824 + $objMetaBanco->adicionarColuna('md_pen_recibo_tramite', 'cadeia_certificado_temp', $strTipo, PenMetaBD::SNULLO);
  825 + BancoSEI::getInstance()->executarSql("update md_pen_recibo_tramite set cadeia_certificado_temp = cadeia_certificado");
  826 + $objMetaBanco->excluirColuna('md_pen_recibo_tramite', 'cadeia_certificado');
  827 + $objMetaBanco->renomearColuna('md_pen_recibo_tramite', 'cadeia_certificado_temp', 'cadeia_certificado', $strTipo);
  828 +
  829 + $objMetaBanco->adicionarColuna('md_pen_recibo_tramite_enviado', 'cadeia_certificado_temp', $strTipo, PenMetaBD::SNULLO);
  830 + BancoSEI::getInstance()->executarSql("update md_pen_recibo_tramite_enviado set cadeia_certificado_temp = cadeia_certificado");
  831 + $objMetaBanco->excluirColuna('md_pen_recibo_tramite_enviado', 'cadeia_certificado');
  832 + $objMetaBanco->renomearColuna('md_pen_recibo_tramite_enviado', 'cadeia_certificado_temp', 'cadeia_certificado', $strTipo);
825 833
826 - $this->inicializarObjMetaBanco()  
827 - ->alterarColuna('md_pen_recibo_tramite', 'cadeia_certificado', $strTipo)  
828 - ->alterarColuna('md_pen_recibo_tramite_enviado', 'cadeia_certificado', $strTipo);  
829 -  
830 /* ---------- antigo método (instalarV005R003S005IW018) ---------- */ 834 /* ---------- antigo método (instalarV005R003S005IW018) ---------- */
831 $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); 835 $objBD = new GenericoBD($this->inicializarObjInfraIBanco());
832 $objDTO = new TarefaDTO(); 836 $objDTO = new TarefaDTO();
@@ -857,7 +861,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -857,7 +861,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
857 }; 861 };
858 862
859 $fnCadastrar('O trâmite externo do processo foi abortado manualmente devido a falha no trâmite', 'S', 'S', 'N', 'N', 'S', 'PEN_EXPEDICAO_PROCESSO_ABORTADA'); 863 $fnCadastrar('O trâmite externo do processo foi abortado manualmente devido a falha no trâmite', 'S', 'S', 'N', 'N', 'S', 'PEN_EXPEDICAO_PROCESSO_ABORTADA');
860 - 864 +
861 /* ---------- antigo método (instalarV005R003S005IW023) ---------- */ 865 /* ---------- antigo método (instalarV005R003S005IW023) ---------- */
862 $objBD = new GenericoBD($this->inicializarObjInfraIBanco()); 866 $objBD = new GenericoBD($this->inicializarObjInfraIBanco());
863 867
@@ -883,11 +887,11 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -883,11 +887,11 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
883 $fnAtualizar('PEN_PROCESSO_EXPEDIDO', 'Processo em tramitação externa para @UNIDADE_DESTINO@ - @UNIDADE_DESTINO_HIRARQUIA@ - @REPOSITORIO_DESTINO@'); 887 $fnAtualizar('PEN_PROCESSO_EXPEDIDO', 'Processo em tramitação externa para @UNIDADE_DESTINO@ - @UNIDADE_DESTINO_HIRARQUIA@ - @REPOSITORIO_DESTINO@');
884 $fnAtualizar('PEN_PROCESSO_RECEBIDO', 'Processo recebido da unidade externa @ENTIDADE_ORIGEM@ - @ENTIDADE_ORIGEM_HIRARQUIA@ - @REPOSITORIO_ORIGEM@'); 888 $fnAtualizar('PEN_PROCESSO_RECEBIDO', 'Processo recebido da unidade externa @ENTIDADE_ORIGEM@ - @ENTIDADE_ORIGEM_HIRARQUIA@ - @REPOSITORIO_ORIGEM@');
885 $fnAtualizar('PEN_OPERACAO_EXTERNA', 'Tramitação externa do processo @PROTOCOLO_FORMATADO@ concluída com sucesso. Recebido em @UNIDADE_DESTINO@ - @UNIDADE_DESTINO_HIRARQUIA@ - @REPOSITORIO_DESTINO@'); 889 $fnAtualizar('PEN_OPERACAO_EXTERNA', 'Tramitação externa do processo @PROTOCOLO_FORMATADO@ concluída com sucesso. Recebido em @UNIDADE_DESTINO@ - @UNIDADE_DESTINO_HIRARQUIA@ - @REPOSITORIO_DESTINO@');
886 - 890 +
887 /* ---------- antigo método (instalarV006R004S004WI001) ---------- */ 891 /* ---------- antigo método (instalarV006R004S004WI001) ---------- */
888 $objInfraParametro = new InfraParametro($this->getObjInfraIBanco()); 892 $objInfraParametro = new InfraParametro($this->getObjInfraIBanco());
889 $objInfraParametro->setValor('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO', 50); 893 $objInfraParametro->setValor('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO', 50);
890 - 894 +
891 /* ---------- antigo método (instalarV007R004S005WI002) ---------- */ 895 /* ---------- antigo método (instalarV007R004S005WI002) ---------- */
892 896
893 $objMetaBD->criarTabela(array( 897 $objMetaBD->criarTabela(array(
@@ -899,31 +903,29 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -899,31 +903,29 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
899 'tipo_recibo' => array($objMetaBD->tipoTextoFixo(1), PenMetaBD::NNULLO), 903 'tipo_recibo' => array($objMetaBD->tipoTextoFixo(1), PenMetaBD::NNULLO),
900 'hash_componente_digital ' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO) 904 'hash_componente_digital ' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO)
901 ), 905 ),
902 - 'pk' => array('id_tramite_hash'), 906 + 'pk' => array('cols'=>array('id_tramite_hash')),
903 'fks' => array( 907 'fks' => array(
904 - 'md_pen_tramite' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')) 908 + 'md_pen_tramite' => array('nome' => 'fk_md_pen_rec_tram_hash_tram', 'cols' => array(array('numero_registro', 'id_tramite'), array('numero_registro', 'id_tramite')))
905 ) 909 )
906 )); 910 ));
907 911
908 $objMetaBD->adicionarColuna('md_pen_recibo_tramite_recebido', 'cadeia_certificado', $this->inicializarObjMetaBanco()->tipoTextoGrande(), PenMetaBD::SNULLO); 912 $objMetaBD->adicionarColuna('md_pen_recibo_tramite_recebido', 'cadeia_certificado', $this->inicializarObjMetaBanco()->tipoTextoGrande(), PenMetaBD::SNULLO);
909 913
910 $objInfraSequencia = new InfraSequencia($this->getObjInfraIBanco()); 914 $objInfraSequencia = new InfraSequencia($this->getObjInfraIBanco());
911 -  
912 if (!$objInfraSequencia->verificarSequencia('md_pen_recibo_tramite_hash')) { 915 if (!$objInfraSequencia->verificarSequencia('md_pen_recibo_tramite_hash')) {
913 -  
914 $objInfraSequencia->criarSequencia('md_pen_recibo_tramite_hash', '1', '1', '9999999999'); 916 $objInfraSequencia->criarSequencia('md_pen_recibo_tramite_hash', '1', '1', '9999999999');
915 } 917 }
916 - 918 +
917 $objInfraParametroDTO = new InfraParametroDTO(); 919 $objInfraParametroDTO = new InfraParametroDTO();
918 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO); 920 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
919 $objInfraParametroDTO->setStrValor('1.0.0'); 921 $objInfraParametroDTO->setStrValor('1.0.0');
920 - 922 +
921 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 923 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
922 $objInfraParametroBD->cadastrar($objInfraParametroDTO); 924 $objInfraParametroBD->cadastrar($objInfraParametroDTO);
923 - 925 +
924 $this->logar(' EXECUTADA A INSTALACAO DA VERSAO 0.0.1 DO MODULO PEN NO SEI COM SUCESSO'); 926 $this->logar(' EXECUTADA A INSTALACAO DA VERSAO 0.0.1 DO MODULO PEN NO SEI COM SUCESSO');
925 } 927 }
926 - 928 +
927 /* Contem atualizações da versao 1.0.1 do modulo */ 929 /* Contem atualizações da versao 1.0.1 do modulo */
928 protected function instalarV101() { 930 protected function instalarV101() {
929 /* ---------- antigo método (instalarV008R004S006IW003) ---------- */ 931 /* ---------- antigo método (instalarV008R004S006IW003) ---------- */
@@ -939,7 +941,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -939,7 +941,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
939 $objTarefaDTO->setStrSinPermiteProcessoFechado('S'); 941 $objTarefaDTO->setStrSinPermiteProcessoFechado('S');
940 942
941 $objBD->alterar($objTarefaDTO); 943 $objBD->alterar($objTarefaDTO);
942 - 944 +
943 /* ---------- antigo método (instalarV006R004S001US039) ---------- */ 945 /* ---------- antigo método (instalarV006R004S001US039) ---------- */
944 $objMetaBD = $this->inicializarObjMetaBanco(); 946 $objMetaBD = $this->inicializarObjMetaBanco();
945 $objInfraBanco = $this->inicializarObjInfraIBanco(); 947 $objInfraBanco = $this->inicializarObjInfraIBanco();
@@ -951,9 +953,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -951,9 +953,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
951 'nome' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO), 953 'nome' => array($objMetaBD->tipoTextoVariavel(255), PenMetaBD::NNULLO),
952 'sin_ativo' => array($objMetaBD->tipoTextoFixo(1), 'S'), 954 'sin_ativo' => array($objMetaBD->tipoTextoFixo(1), 'S'),
953 ), 955 ),
954 - 'pk' => array('id_hipotese_legal') 956 + 'pk' => array('cols'=>array('id_hipotese_legal')),
955 )); 957 ));
956 - 958 +
957 $objMetaBD->criarTabela(array( 959 $objMetaBD->criarTabela(array(
958 'tabela' => 'md_pen_rel_hipotese_legal', 960 'tabela' => 'md_pen_rel_hipotese_legal',
959 'cols' => array( 961 'cols' => array(
@@ -963,30 +965,30 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -963,30 +965,30 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
963 'tipo' => array($objMetaBD->tipoTextoFixo(1), 'E'), 965 'tipo' => array($objMetaBD->tipoTextoFixo(1), 'E'),
964 'sin_ativo' => array($objMetaBD->tipoTextoFixo(1), 'S'), 966 'sin_ativo' => array($objMetaBD->tipoTextoFixo(1), 'S'),
965 ), 967 ),
966 - 'pk' => array('id_mapeamento'), 968 + 'pk' => array('cols'=>array('id_mapeamento')),
967 'fks' => array( 969 'fks' => array(
968 - 'hipotese_legal' => array('id_hipotese_legal', 'id_hipotese_legal'),  
969 - 'md_pen_hipotese_legal' => array('id_hipotese_legal', 'id_hipotese_legal_pen') 970 + 'hipotese_legal' => array('nome' => 'fk_md_pen_rel_hipotese_legal', 'cols' => array('id_hipotese_legal', 'id_hipotese_legal')),
  971 + 'md_pen_hipotese_legal' => array('nome' => 'fk_md_pen_rel_hipotese_pen', 'cols' => array('id_hipotese_legal', 'id_hipotese_legal_pen'))
970 ) 972 )
971 )); 973 ));
972 - 974 +
973 $objInfraSequencia = new InfraSequencia($objInfraBanco); 975 $objInfraSequencia = new InfraSequencia($objInfraBanco);
974 -  
975 - if(!$objInfraSequencia->verificarSequencia('md_pen_hipotese_legal')){ 976 +
  977 + if(!$objInfraSequencia->verificarSequencia('md_pen_hipotese_legal')){
976 $objInfraSequencia->criarSequencia('md_pen_hipotese_legal', '1', '1', '9999999999'); 978 $objInfraSequencia->criarSequencia('md_pen_hipotese_legal', '1', '1', '9999999999');
977 } 979 }
978 980
979 - if(!$objInfraSequencia->verificarSequencia('md_pen_rel_hipotese_legal')){ 981 + if(!$objInfraSequencia->verificarSequencia('md_pen_rel_hipotese_legal')){
980 $objInfraSequencia->criarSequencia('md_pen_rel_hipotese_legal', '1', '1', '9999999999'); 982 $objInfraSequencia->criarSequencia('md_pen_rel_hipotese_legal', '1', '1', '9999999999');
981 } 983 }
982 - 984 +
983 $objHipoteseLegalDTO = new HipoteseLegalDTO(); 985 $objHipoteseLegalDTO = new HipoteseLegalDTO();
984 $objHipoteseLegalDTO->setDistinct(true); 986 $objHipoteseLegalDTO->setDistinct(true);
985 $objHipoteseLegalDTO->setStrStaNivelAcesso(1); 987 $objHipoteseLegalDTO->setStrStaNivelAcesso(1);
986 $objHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC); 988 $objHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC);
987 $objHipoteseLegalDTO->retNumIdHipoteseLegal(); 989 $objHipoteseLegalDTO->retNumIdHipoteseLegal();
988 $objHipoteseLegalDTO->retStrNome(); 990 $objHipoteseLegalDTO->retStrNome();
989 - 991 +
990 $objMetaBD = $this->inicializarObjMetaBanco(); 992 $objMetaBD = $this->inicializarObjMetaBanco();
991 993
992 $objMetaBD->criarTabela(array( 994 $objMetaBD->criarTabela(array(
@@ -995,9 +997,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -995,9 +997,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
995 'nome'=> array($objMetaBD->tipoTextoVariavel(100), PenMetaBD::NNULLO), 997 'nome'=> array($objMetaBD->tipoTextoVariavel(100), PenMetaBD::NNULLO),
996 'valor' => array($objMetaBD->tipoTextoGrande(), PenMetaBD::NNULLO) 998 'valor' => array($objMetaBD->tipoTextoGrande(), PenMetaBD::NNULLO)
997 ), 999 ),
998 - 'pk' => array('nome') 1000 + 'pk' => array('cols'=>array('nome')),
999 )); 1001 ));
1000 - 1002 +
1001 //Agendamento 1003 //Agendamento
1002 $objDTO = new InfraAgendamentoTarefaDTO(); 1004 $objDTO = new InfraAgendamentoTarefaDTO();
1003 1005
@@ -1019,29 +1021,25 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1019,29 +1021,25 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1019 }; 1021 };
1020 1022
1021 $fnCadastrar('PENAgendamentoRN::atualizarHipotesesLegais', 'Verificação se há novas hipóteses legais do barramento.'); 1023 $fnCadastrar('PENAgendamentoRN::atualizarHipotesesLegais', 'Verificação se há novas hipóteses legais do barramento.');
1022 - 1024 +
1023 /* altera o parâmetro da versão de banco */ 1025 /* altera o parâmetro da versão de banco */
  1026 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
1024 $objInfraParametroDTO = new InfraParametroDTO(); 1027 $objInfraParametroDTO = new InfraParametroDTO();
1025 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO); 1028 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1026 - $objInfraParametroDTO->setStrValor('1.0.0');  
1027 - $objInfraParametroDTO->retTodos();  
1028 -  
1029 - $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());  
1030 - $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);  
1031 $objInfraParametroDTO->setStrValor('1.0.1'); 1029 $objInfraParametroDTO->setStrValor('1.0.1');
1032 $objInfraParametroBD->alterar($objInfraParametroDTO); 1030 $objInfraParametroBD->alterar($objInfraParametroDTO);
1033 } 1031 }
1034 - 1032 +
1035 /* Contem atualizações da versao 1.1.0 do modulo */ 1033 /* Contem atualizações da versao 1.1.0 do modulo */
1036 protected function instalarV110() { 1034 protected function instalarV110() {
1037 $objMetaBD = $this->objMeta; 1035 $objMetaBD = $this->objMeta;
1038 - 1036 +
1039 //Adiciona a coluna de indentificação nas hipóteses que vem do barramento 1037 //Adiciona a coluna de indentificação nas hipóteses que vem do barramento
1040 $objMetaBD->adicionarColuna('md_pen_hipotese_legal', 'identificacao', $this->inicializarObjMetaBanco()->tipoNumero(), PenMetaBD::SNULLO); 1038 $objMetaBD->adicionarColuna('md_pen_hipotese_legal', 'identificacao', $this->inicializarObjMetaBanco()->tipoNumero(), PenMetaBD::SNULLO);
1041 - 1039 +
1042 //Adiciona a coluna de descricao nos parâmetros 1040 //Adiciona a coluna de descricao nos parâmetros
1043 $objMetaBD->adicionarColuna('md_pen_parametro', 'descricao', $this->inicializarObjMetaBanco()->tipoTextoVariavel(255), PenMetaBD::SNULLO); 1041 $objMetaBD->adicionarColuna('md_pen_parametro', 'descricao', $this->inicializarObjMetaBanco()->tipoTextoVariavel(255), PenMetaBD::SNULLO);
1044 - 1042 +
1045 //Cria os parâmetros do módulo PEN barramento (md_pen_parametro [ nome, valor ]) 1043 //Cria os parâmetros do módulo PEN barramento (md_pen_parametro [ nome, valor ])
1046 $this->criarParametro('PEN_ENDERECO_WEBSERVICE', 'https://pen-api.trafficmanager.net/interoperabilidade/soap/v2/', 'Endereço do Web Service'); 1044 $this->criarParametro('PEN_ENDERECO_WEBSERVICE', 'https://pen-api.trafficmanager.net/interoperabilidade/soap/v2/', 'Endereço do Web Service');
1047 $this->criarParametro('PEN_ENDERECO_WEBSERVICE_PENDENCIAS', 'https://pen-pendencias.trafficmanager.net/', 'Endereço do Web Service de Pendências'); 1045 $this->criarParametro('PEN_ENDERECO_WEBSERVICE_PENDENCIAS', 'https://pen-pendencias.trafficmanager.net/', 'Endereço do Web Service de Pendências');
@@ -1053,7 +1051,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1053,7 +1051,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1053 $this->criarParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO', '50', 'Tamanho Máximo de Documento Expedido'); 1051 $this->criarParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO', '50', 'Tamanho Máximo de Documento Expedido');
1054 $this->criarParametro('PEN_TIPO_PROCESSO_EXTERNO', '100000320', 'Tipo de Processo Externo'); 1052 $this->criarParametro('PEN_TIPO_PROCESSO_EXTERNO', '100000320', 'Tipo de Processo Externo');
1055 $this->criarParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO', '110000001', 'Unidade Geradora de Processo e Documento Recebido'); 1053 $this->criarParametro('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO', '110000001', 'Unidade Geradora de Processo e Documento Recebido');
1056 - 1054 +
1057 //Deleta os parâmetros do infra_parametros 1055 //Deleta os parâmetros do infra_parametros
1058 $this->deletaParametroInfra('PEN_ENDERECO_WEBSERVICE'); 1056 $this->deletaParametroInfra('PEN_ENDERECO_WEBSERVICE');
1059 $this->deletaParametroInfra('PEN_ENDERECO_WEBSERVICE_PENDENCIAS'); 1057 $this->deletaParametroInfra('PEN_ENDERECO_WEBSERVICE_PENDENCIAS');
@@ -1065,7 +1063,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1065,7 +1063,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1065 $this->deletaParametroInfra('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO'); 1063 $this->deletaParametroInfra('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO');
1066 $this->deletaParametroInfra('PEN_TIPO_PROCESSO_EXTERNO', '100000320'); 1064 $this->deletaParametroInfra('PEN_TIPO_PROCESSO_EXTERNO', '100000320');
1067 $this->deletaParametroInfra('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO'); 1065 $this->deletaParametroInfra('PEN_UNIDADE_GERADORA_DOCUMENTO_RECEBIDO');
1068 - 1066 +
1069 //Alterar nomeclatura do recurso 1067 //Alterar nomeclatura do recurso
1070 $objDTO = new PenParametroDTO(); 1068 $objDTO = new PenParametroDTO();
1071 $objDTO->setStrNome('HIPOTESE_LEGAL_PADRAO'); 1069 $objDTO->setStrNome('HIPOTESE_LEGAL_PADRAO');
@@ -1082,32 +1080,71 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1082,32 +1080,71 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1082 $objDTO->setStrDescricao('Hipótese Legal Padrão'); 1080 $objDTO->setStrDescricao('Hipótese Legal Padrão');
1083 $objBD->cadastrar($objDTO); 1081 $objBD->cadastrar($objDTO);
1084 } 1082 }
1085 - 1083 +
1086 /* altera o parâmetro da versão de banco */ 1084 /* altera o parâmetro da versão de banco */
  1085 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
1087 $objInfraParametroDTO = new InfraParametroDTO(); 1086 $objInfraParametroDTO = new InfraParametroDTO();
1088 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO); 1087 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1089 - $objInfraParametroDTO->setStrValor('1.0.1');  
1090 - $objInfraParametroDTO->retTodos();  
1091 - $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());  
1092 - $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);  
1093 $objInfraParametroDTO->setStrValor('1.1.0'); 1088 $objInfraParametroDTO->setStrValor('1.1.0');
1094 $objInfraParametroBD->alterar($objInfraParametroDTO); 1089 $objInfraParametroBD->alterar($objInfraParametroDTO);
  1090 +
1095 } 1091 }
1096 1092
1097 - /* Contem atualizações da versao 1.1.1 do módulo */ 1093 + /* Contem atualizações da versao 1.1.1 do módulo */
1098 protected function instalarV111() { 1094 protected function instalarV111() {
1099 1095
1100 //Ajuste em nome da variável de versão do módulo VERSAO_MODULO_PEN 1096 //Ajuste em nome da variável de versão do módulo VERSAO_MODULO_PEN
1101 BancoSEI::getInstance()->executarSql("update infra_parametro set nome = '" . self::PARAMETRO_VERSAO_MODULO . "' where nome = '" . self::PARAMETRO_VERSAO_MODULO_ANTIGO . "'"); 1097 BancoSEI::getInstance()->executarSql("update infra_parametro set nome = '" . self::PARAMETRO_VERSAO_MODULO . "' where nome = '" . self::PARAMETRO_VERSAO_MODULO_ANTIGO . "'");
1102 1098
1103 /* altera o parâmetro da versão de banco */ 1099 /* altera o parâmetro da versão de banco */
  1100 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
1104 $objInfraParametroDTO = new InfraParametroDTO(); 1101 $objInfraParametroDTO = new InfraParametroDTO();
1105 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO); 1102 $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO);
1106 - $objInfraParametroDTO->retTodos();  
1107 - $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());  
1108 - $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);  
1109 $objInfraParametroDTO->setStrValor('1.1.1'); 1103 $objInfraParametroDTO->setStrValor('1.1.1');
1110 $objInfraParametroBD->alterar($objInfraParametroDTO); 1104 $objInfraParametroBD->alterar($objInfraParametroDTO);
1111 } 1105 }
1112 1106
  1107 + /* Contem atualizações da versao 1.1.7 do módulo */
  1108 + protected function instalarV117() {
  1109 +
  1110 + /* Cadastramento de novas espécies documentais */
  1111 + $objEspecieDocumentalBD = new GenericoBD($this->inicializarObjInfraIBanco());
  1112 + $objEspecieDocumentalDTO = new EspecieDocumentalDTO();
  1113 +
  1114 + $fnCadastrar = function($dblIdEspecie, $strNomeEspecie, $strDescricao) use($objEspecieDocumentalDTO, $objEspecieDocumentalBD) {
  1115 + $objEspecieDocumentalDTO->unSetTodos();
  1116 + $objEspecieDocumentalDTO->setDblIdEspecie($dblIdEspecie);
  1117 + if ($objEspecieDocumentalBD->contar($objEspecieDocumentalDTO) == 0) {
  1118 + $objEspecieDocumentalDTO->setStrNomeEspecie($strNomeEspecie);
  1119 + $objEspecieDocumentalDTO->setStrDescricao($strDescricao);
  1120 + $objEspecieDocumentalBD->cadastrar($objEspecieDocumentalDTO);
  1121 + }
  1122 + };
  1123 +
  1124 + $fnCadastrar(178, 'Alegações', 'Muito comum no Judiciário, tendo previsão no CPC. Podendo ser complementado "Finais", o que representaria o documento "Alegações Finais".');
  1125 + $fnCadastrar(179, 'Anexo', 'Documento ou processo juntado em caráter definitivo a outro processo, para dar continuidade a uma ação administrativa.');
  1126 + $fnCadastrar(180, 'Documento', 'Informação registrada, qualquer que seja o suporte ou formato, que não está reunida e ordenada em processo.');
  1127 + $fnCadastrar(181, 'Apartado', 'Apartado por si só, autos apartados ou partado sigiloso.');
  1128 + $fnCadastrar(182, 'Apresentação', 'Documentos que são apresentações propriamente ditas.');
  1129 + $fnCadastrar(183, 'Diagnóstico', 'Diagnóstico médico, auditoria, etc.');
  1130 + $fnCadastrar(184, 'Exame', 'Exame laboratorial, médico, etc.');
  1131 + $fnCadastrar(185, 'Página', 'Página do Diário Oficial da União.');
  1132 + $fnCadastrar(186, 'Estudo', 'Podendo ser complementado com "Técnico Preliminar da Contratação"; "Técnico".');
  1133 + $fnCadastrar(999, 'Outra', 'Outras espécies documentais não identificadas.');
  1134 +
  1135 + // if($this->isTabelaExiste('md_pen_rel_tipo_documento_mapeamento_recebido')) {
  1136 + // if (BancoSEI::getInstance() instanceof InfraSqlServer) {
  1137 + // BancoSEI::getInstance()->executarSql("sp_rename 'md_pen_rel_tipo_documento_mapeamento_recebido', 'md_pen_rel_tipo_doc_map_rec'");
  1138 + // } else {
  1139 + // BancoSEI::getInstance()->executarSql("ALTER TABLE 'md_pen_rel_tipo_documento_mapeamento_recebido' RENAME TO 'md_pen_rel_tipo_doc_map_rec'");
  1140 + // }
  1141 + // }
  1142 +
  1143 + //altera o parâmetro da versão de banco
  1144 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
  1145 + $objInfraParametroDTO = new InfraParametroDTO();
  1146 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO);
  1147 + $objInfraParametroDTO->setStrValor('1.1.7');
  1148 + $objInfraParametroBD->alterar($objInfraParametroDTO);
  1149 + }
1113 } 1150 }
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
@@ -163,13 +163,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -163,13 +163,10 @@ class ProcessoEletronicoRN extends InfraRN {
163 try { 163 try {
164 164
165 $objConfig = ConfiguracaoSEI::getInstance(); 165 $objConfig = ConfiguracaoSEI::getInstance();
166 -  
167 if($objConfig->isSetValor('SEI', 'LogPenWs')){ 166 if($objConfig->isSetValor('SEI', 'LogPenWs')){
168 -  
169 $this->objPenWs = new LogPenWs($objConfig->getValor('SEI', 'LogPenWs'), $this->strWSDL, $this->options); 167 $this->objPenWs = new LogPenWs($objConfig->getValor('SEI', 'LogPenWs'), $this->strWSDL, $this->options);
170 } 168 }
171 else { 169 else {
172 -  
173 $this->objPenWs = new BeSimple\SoapClient\SoapClient($this->strWSDL, $this->options); 170 $this->objPenWs = new BeSimple\SoapClient\SoapClient($this->strWSDL, $this->options);
174 } 171 }
175 } catch (Exception $e) { 172 } catch (Exception $e) {
@@ -821,8 +818,8 @@ class ProcessoEletronicoRN extends InfraRN { @@ -821,8 +818,8 @@ class ProcessoEletronicoRN extends InfraRN {
821 818
822 //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
823 $objComponenteDigitalDTO->setNumTamanho($objComponenteDigital->tamanhoEmBytes); 820 $objComponenteDigitalDTO->setNumTamanho($objComponenteDigital->tamanhoEmBytes);
824 - $objComponenteDigitalDTO->setNumIdAnexo($objComponenteDigital->idAnexo);  
825 821
  822 + $objComponenteDigitalDTO->setNumIdAnexo($objComponenteDigital->idAnexo);
826 $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO; 823 $arrObjComponenteDigitalDTO[] = $objComponenteDigitalDTO;
827 } 824 }
828 825
rn/ProcessoExpedidoRN.php
@@ -15,9 +15,11 @@ class ProcessoExpedidoRN extends InfraRN { @@ -15,9 +15,11 @@ class ProcessoExpedidoRN extends InfraRN {
15 public function listarProcessoExpedido(ProtocoloDTO &$objProtocoloDTO) { 15 public function listarProcessoExpedido(ProtocoloDTO &$objProtocoloDTO) {
16 16
17 $bolSqlServer = $this->getObjInfraIBanco() instanceof InfraSqlServer; 17 $bolSqlServer = $this->getObjInfraIBanco() instanceof InfraSqlServer;
  18 + $bolOracle = $this->getObjInfraIBanco() instanceof InfraOracle;
18 $numLimit = $objProtocoloDTO->getNumMaxRegistrosRetorno(); 19 $numLimit = $objProtocoloDTO->getNumMaxRegistrosRetorno();
19 $numOffset = $objProtocoloDTO->getNumPaginaAtual() * $objProtocoloDTO->getNumMaxRegistrosRetorno(); 20 $numOffset = $objProtocoloDTO->getNumPaginaAtual() * $objProtocoloDTO->getNumMaxRegistrosRetorno();
20 $strInstrucaoPaginacao = (!$bolSqlServer) ? "LIMIT ".$numOffset.",".$numLimit : "OFFSET $numOffset ROWS FETCH NEXT $numLimit ROWS ONLY"; 21 $strInstrucaoPaginacao = (!$bolSqlServer) ? "LIMIT ".$numOffset.",".$numLimit : "OFFSET $numOffset ROWS FETCH NEXT $numLimit ROWS ONLY";
  22 + $strInstrucaoPaginacao = ($bolOracle) ? "" : $strInstrucaoPaginacao;
21 23
22 $sql = "SELECT 24 $sql = "SELECT
23 p.id_protocolo, 25 p.id_protocolo,
@@ -41,14 +43,20 @@ class ProcessoExpedidoRN extends InfraRN { @@ -41,14 +43,20 @@ class ProcessoExpedidoRN extends InfraRN {
41 ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro) 43 ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro)
42 AND 44 AND
43 NOT EXISTS ( 45 NOT EXISTS (
44 - SELECT at2.* FROM atividade as at2 46 + SELECT at2.* FROM atividade at2
45 WHERE at2.id_protocolo = p.id_protocolo 47 WHERE at2.id_protocolo = p.id_protocolo
46 AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ." 48 AND at2.id_tarefa = ". ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO) ."
47 AND at2.dth_abertura > a.dth_abertura ) 49 AND at2.dth_abertura > a.dth_abertura )
48 GROUP BY 50 GROUP BY
49 p.id_protocolo, p.protocolo_formatado, a.id_unidade , atd.valor , us.id_usuario, us.nome, a.dth_abertura ORDER BY a.dth_abertura DESC ".$strInstrucaoPaginacao; 51 p.id_protocolo, p.protocolo_formatado, a.id_unidade , atd.valor , us.id_usuario, us.nome, a.dth_abertura ORDER BY a.dth_abertura DESC ".$strInstrucaoPaginacao;
50 52
51 - $sqlCount = "SELECT 53 +
  54 + if ($this->getObjInfraIBanco() instanceof InfraOracle){
  55 + $qtd = $numLimit + $numLimit;
  56 + $sql = "select a.* from ($sql) a where rownum >= $numOffset and rownum <= $qtd";
  57 + }
  58 +
  59 + $sqlCount = "SELECT
52 count(*) total 60 count(*) total
53 FROM protocolo p 61 FROM protocolo p
54 INNER JOIN atividade a ON a.id_protocolo = p.id_protocolo 62 INNER JOIN atividade a ON a.id_protocolo = p.id_protocolo
@@ -64,13 +72,12 @@ class ProcessoExpedidoRN extends InfraRN { @@ -64,13 +72,12 @@ class ProcessoExpedidoRN extends InfraRN {
64 ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro) 72 ptra.dth_registro = (SELECT MAX(pt.dth_registro) dth_registro FROM md_pen_tramite pt WHERE pt.numero_registro = pe.numero_registro)
65 AND 73 AND
66 NOT EXISTS ( 74 NOT EXISTS (
67 - SELECT at2.* FROM atividade as at2 75 + SELECT at2.* FROM atividade at2
68 WHERE at2.id_protocolo = p.id_protocolo 76 WHERE at2.id_protocolo = p.id_protocolo
69 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) ."
70 AND at2.dth_abertura > a.dth_abertura ) "; 78 AND at2.dth_abertura > a.dth_abertura ) ";
71 79
72 -  
73 - 80 + //die($sql);
74 $pag = $this->getObjInfraIBanco()->consultarSql($sql); 81 $pag = $this->getObjInfraIBanco()->consultarSql($sql);
75 $count = $this->getObjInfraIBanco()->consultarSql($sqlCount); 82 $count = $this->getObjInfraIBanco()->consultarSql($sqlCount);
76 $total = $count ? $count[0]['total'] : 0; 83 $total = $count ? $count[0]['total'] : 0;
@@ -81,12 +88,12 @@ class ProcessoExpedidoRN extends InfraRN { @@ -81,12 +88,12 @@ class ProcessoExpedidoRN extends InfraRN {
81 $objProtocoloDTO->setNumRegistrosPaginaAtual(count($pag)); 88 $objProtocoloDTO->setNumRegistrosPaginaAtual(count($pag));
82 89
83 foreach ($pag as $res) { 90 foreach ($pag as $res) {
84 - $data = new \DateTime($res['dth_abertura']); 91 + $data = BancoSEI::getInstance()->formatarLeituraDth($res['dth_abertura']);
85 $objProcessoExpedidoDTO = new ProcessoExpedidoDTO(); 92 $objProcessoExpedidoDTO = new ProcessoExpedidoDTO();
86 $objProcessoExpedidoDTO->setDblIdProtocolo($res['id_protocolo']); 93 $objProcessoExpedidoDTO->setDblIdProtocolo($res['id_protocolo']);
87 $objProcessoExpedidoDTO->setStrProtocoloFormatado($res['protocolo_formatado']); 94 $objProcessoExpedidoDTO->setStrProtocoloFormatado($res['protocolo_formatado']);
88 $objProcessoExpedidoDTO->setStrNomeUsuario($res['nome_usuario']); 95 $objProcessoExpedidoDTO->setStrNomeUsuario($res['nome_usuario']);
89 - $objProcessoExpedidoDTO->setDthExpedido($data->format('d/m/Y H:i:s')); 96 + $objProcessoExpedidoDTO->setDthExpedido($data);
90 $objProcessoExpedidoDTO->setStrDestino($res['unidade_destino']); 97 $objProcessoExpedidoDTO->setStrDestino($res['unidade_destino']);
91 98
92 $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,206 +80,193 @@ class ReceberProcedimentoRN extends InfraRN @@ -80,206 +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: Avaliar também processos apensados  
112 - if($this->tramiteRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite)) {  
113 - return ;  
114 - }  
115 - // Validação dos dados do processo recebido  
116 - $objInfraException = new InfraException();  
117 - $this->validarDadosDestinatario($objInfraException, $objMetadadosProcedimento);  
118 - $objInfraException->lancarValidacoes();  
119 -  
120 - #############################INICIA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################  
121 - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);  
122 - $objTramite = $arrObjTramite[0];  
123 -  
124 - //Obtém lista de componentes digitais que precisam ser obtidos  
125 - if(!is_array($objTramite->componenteDigitalPendenteDeRecebimento)){  
126 - $objTramite->componenteDigitalPendenteDeRecebimento = array($objTramite->componenteDigitalPendenteDeRecebimento);  
127 - }  
128 -  
129 - //Faz a validação do tamanho e espécie dos componentes digitais  
130 - $this->validarComponentesDigitais($objProcesso, $parNumIdentificacaoTramite);  
131 83
132 - //Faz a validação da extensão dos componentes digitais a serem recebidos  
133 - $this->validarExtensaoComponentesDigitais($parNumIdentificacaoTramite, $objProcesso);  
134 - //Faz a validação das permissões de leitura e escrita  
135 - $this->verificarPermissoesDiretorios($parNumIdentificacaoTramite);  
136 -  
137 - $arrStrNomeDocumento = $this->listarMetaDadosComponentesDigitais($objProcesso);  
138 -  
139 - //Instancia a RN que faz o recebimento dos componentes digitais  
140 - $receberComponenteDigitalRN = new ReceberComponenteDigitalRN();  
141 -  
142 - //Cria o array que receberá os anexos após os arquivos físicos serem salvos  
143 - $arrAnexosComponentes = array();  
144 -  
145 - //Cria o array com a lista de hash  
146 - $arrayHash = array();  
147 -  
148 - //Percorre os componentes que precisam ser recebidos  
149 - foreach($objTramite->componenteDigitalPendenteDeRecebimento as $key => $componentePendente){  
150 -  
151 - if(!is_null($componentePendente)){  
152 -  
153 - //Adiciona o hash do componente digital ao array  
154 - $arrayHash[] = $componentePendente;  
155 -  
156 - //Obter os dados do componente digital  
157 - $objComponenteDigital = $this->objProcessoEletronicoRN->receberComponenteDigital($parNumIdentificacaoTramite, $componentePendente, $objTramite->protocolo);  
158 - //Copia o componente para a pasta temporária  
159 - $arrAnexosComponentes[$key][$componentePendente] = $receberComponenteDigitalRN->copiarComponenteDigitalPastaTemporaria($objComponenteDigital);  
160 - $arrAnexosComponentes[$key]['recebido'] = false;  
161 -  
162 - //Valida a integridade do hash  
163 - $receberComponenteDigitalRN->validarIntegridadeDoComponenteDigital($arrAnexosComponentes[$key][$componentePendente], $componentePendente, $parNumIdentificacaoTramite);  
164 - }  
165 - }  
166 - if(count($arrAnexosComponentes) > 0){  
167 -  
168 - $receberComponenteDigitalRN->setArrAnexos($arrAnexosComponentes);  
169 - }  
170 - #############################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'));
171 89
172 - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);  
173 - $objTramite = $arrObjTramite[0]; 90 + $objSeiRN = new SeiRN();
174 91
175 - //Verifica se o trâmite está recusado  
176 - if($objTramite->situacaoAtual == ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_RECUSADO) {  
177 - return;  
178 - } 92 + if (!isset($parNumIdentificacaoTramite)) {
  93 + throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.');
  94 + }
179 95
180 - $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);
181 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 + }
182 107
  108 + if (isset($objMetadadosProcedimento)) {
  109 + $strNumeroRegistro = $objMetadadosProcedimento->metadados->NRE;
  110 + $objProcesso = $objMetadadosProcedimento->metadados->processo;
183 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 + }
184 119
185 - // @join_tec US008.08 (#23092)  
186 - $this->objProcedimentoAndamentoRN->setOpts($objProcedimentoDTO->getDblIdProcedimento(), $parNumIdentificacaoTramite, ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_RECEBIDO));  
187 - $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();
188 124
189 - //Verificar se procedimento já existia na base de dados do sistema  
190 - //$dblIdProcedimento = $this->consultarProcedimentoExistente($strNumeroRegistro, $strProtocolo); 125 + #############################INICIA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################
  126 + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);
  127 + $objTramite = $arrObjTramite[0];
191 128
192 - //if(isset($dblIdProcedimento)){  
193 - //TODO: Tratar situação em que o processo (NUP) já existia na base do sistema mas não havia nenhum NRE registrado para ele  
194 - // $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $objMetadadosProcedimento, $objProcesso);  
195 - //}  
196 - //else {  
197 - //TODO: Gerar Procedimento com status BLOQUEADO, aguardando o recebimento dos componentes digitais  
198 - // $objProcedimentoDTO = $this->gerarProcedimento($objMetadadosProcedimento, $objProcesso);  
199 - //} 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 + }
200 134
201 - //TODO: Fazer o envio de cada um dos procedimentos apensados (Processo principal e seus apensados, caso exista)  
202 - //...  
203 - //TODO: Parei aqui!!! Recebimento de processos apensados 135 + $this->validarComponentesDigitais($objProcesso, $parNumIdentificacaoTramite);
  136 + $this->validarExtensaoComponentesDigitais($parNumIdentificacaoTramite, $objProcesso);
  137 + $this->verificarPermissoesDiretorios($parNumIdentificacaoTramite);
204 138
205 - $objProcessoEletronicoDTO = $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso($objProcedimentoDTO->getDblIdProcedimento(),  
206 - $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();
207 145
  146 + //Percorre os componentes que precisam ser recebidos
  147 + foreach($objTramite->componenteDigitalPendenteDeRecebimento as $key => $componentePendente){
208 148
  149 + if(!is_null($componentePendente)){
209 150
210 - //TODO: Passar implementação para outra classe de negócio  
211 - //Verifica se o tramite se encontra na situação correta  
212 - $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);  
213 - if(!isset($arrObjTramite) || count($arrObjTramite) != 1) {  
214 - throw new InfraException("Trâmite não pode ser localizado pelo identificado $parNumIdentificacaoTramite.");  
215 - } 151 + if(!$this->documentoJaRegistrado($strNumeroRegistro, $parNumIdentificacaoTramite, $componentePendente)){
  152 + $arrayHashPendentes[] = $componentePendente;
  153 + }
216 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;
217 158
218 - $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;
219 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 + }
220 170
221 - if($objTramite->situacaoAtual != ProcessoEletronicoRN::$STA_SITUACAO_TRAMITE_COMPONENTES_RECEBIDOS_DESTINATARIO) {  
222 - return;  
223 - } 171 + if(count($arrAnexosComponentes) > 0){
  172 + $receberComponenteDigitalRN->setArrAnexos($arrAnexosComponentes);
  173 + }
  174 + #############################TERMINA O RECEBIMENTO DOS COMPONENTES DIGITAIS US010################################################
224 175
  176 + $arrObjTramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);
  177 + $objTramite = $arrObjTramite[0];
225 178
226 - // throw new InfraException("COMPONENTES DIGITAIS A SEREM ANEXADOS: ".var_export($arrayHash, true));  
227 - 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 + }
228 184
229 - //Obter dados dos componetes digitais  
230 - $objComponenteDigitalDTO = new ComponenteDigitalDTO();  
231 - $objComponenteDigitalDTO->setStrNumeroRegistro($strNumeroRegistro);  
232 - $objComponenteDigitalDTO->setNumIdTramite($parNumIdentificacaoTramite);  
233 - $objComponenteDigitalDTO->setStrHashConteudo($arrayHash, InfraDTO::$OPER_IN);  
234 - $objComponenteDigitalDTO->setOrdNumOrdem(InfraDTO::$TIPO_ORDENACAO_ASC);  
235 - $objComponenteDigitalDTO->retDblIdDocumento();  
236 - $objComponenteDigitalDTO->retNumTicketEnvioComponentes();  
237 - // $objComponenteDigitalDTO->retStrConteudoAssinaturaDocumento();  
238 - $objComponenteDigitalDTO->retStrProtocoloDocumentoFormatado();  
239 - $objComponenteDigitalDTO->retStrHashConteudo();  
240 - $objComponenteDigitalDTO->retStrProtocolo();  
241 - $objComponenteDigitalDTO->retStrNumeroRegistro();  
242 - $objComponenteDigitalDTO->retNumIdTramite();  
243 - $objComponenteDigitalDTO->retStrNome();  
244 - $objComponenteDigitalDTO->retStrStaEstadoProtocolo(); 185 + $this->gravarLogDebug("Persistindo/atualizando dados do processo com NRE " . $strNumeroRegistro, 4);
  186 + $objProcedimentoDTO = $this->registrarProcesso($strNumeroRegistro, $parNumIdentificacaoTramite, $objProcesso, $objMetadadosProcedimento);
245 187
246 - $objComponenteDigitalBD = new ComponenteDigitalBD($this->getObjInfraIBanco());  
247 - $arrObjComponentesDigitaisDTO = $objComponenteDigitalBD->listar($objComponenteDigitalDTO);  
248 188
249 - // 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');
250 192
251 - if ($objComponenteDigitalBD->contar($objComponenteDigitalDTO) > 0) {  
252 193
253 - $objReceberComponenteDigitalRN = $receberComponenteDigitalRN; 194 + $this->gravarLogDebug("Registrando trâmite externo do processo", 4);
  195 + $objProcessoEletronicoDTO = $this->objProcessoEletronicoRN->cadastrarTramiteDeProcesso($objProcedimentoDTO->getDblIdProcedimento(),
  196 + $strNumeroRegistro, $parNumIdentificacaoTramite, null, $objProcesso);
254 197
255 - foreach($arrObjComponentesDigitaisDTO as $objComponenteDigitalDTOEnviado) {  
256 - if($objComponenteDigitalDTOEnviado->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){  
257 - $strHash = $objComponenteDigitalDTOEnviado->getStrHashConteudo();  
258 - $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 + }
259 203
260 - $objReceberComponenteDigitalRN->receberComponenteDigital($objComponenteDigitalDTOEnviado);  
261 204
262 - // @join_tec US008.09 (#23092)  
263 - $this->objProcedimentoAndamentoRN->cadastrar(sprintf('Recebendo %s %s', $strNomeDocumento, $objComponenteDigitalDTOEnviado->getStrProtocoloDocumentoFormatado()), 'S');  
264 - } 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 + }
265 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 + }
266 } 252 }
267 - // @join_tec US008.10 (#23092)  
268 - $this->objProcedimentoAndamentoRN->cadastrar('Todos os componentes digitais foram recebidos', 'S');  
269 -  
270 - }else{  
271 - $this->objProcedimentoAndamentoRN->cadastrar('Nenhum componente digital para receber', 'S');  
272 } 253 }
273 - } 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 + }
274 } 269 }
275 - //$this->fecharProcedimentoEmOutraUnidades($objProcedimentoDTO, $objMetadadosProcedimento);  
276 -  
277 - $objEnviarReciboTramiteRN = new EnviarReciboTramiteRN();  
278 - $objEnviarReciboTramiteRN->enviarReciboTramiteProcesso($parNumIdentificacaoTramite, $arrayHash);  
279 -  
280 - $objPenTramiteProcessadoRN = new PenTramiteProcessadoRN(PenTramiteProcessadoRN::STR_TIPO_PROCESSO);  
281 - $objPenTramiteProcessadoRN->setRecebido($parNumIdentificacaoTramite);  
282 - }  
283 270
284 /** 271 /**
285 * 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
@@ -373,8 +360,6 @@ class ReceberProcedimentoRN extends InfraRN @@ -373,8 +360,6 @@ class ReceberProcedimentoRN extends InfraRN
373 360
374 private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento) 361 private function registrarProcesso($parStrNumeroRegistro, $parNumIdentificacaoTramite, $parObjProcesso, $parObjMetadadosProcedimento)
375 { 362 {
376 -  
377 -  
378 // Validação dos dados do processo recebido 363 // Validação dos dados do processo recebido
379 $objInfraException = new InfraException(); 364 $objInfraException = new InfraException();
380 $this->validarDadosProcesso($objInfraException, $parObjProcesso); 365 $this->validarDadosProcesso($objInfraException, $parObjProcesso);
@@ -389,13 +374,9 @@ class ReceberProcedimentoRN extends InfraRN @@ -389,13 +374,9 @@ class ReceberProcedimentoRN extends InfraRN
389 $dblIdProcedimento = $this->consultarProcedimentoExistente($parStrNumeroRegistro, $parObjProcesso->protocolo); 374 $dblIdProcedimento = $this->consultarProcedimentoExistente($parStrNumeroRegistro, $parObjProcesso->protocolo);
390 375
391 if(isset($dblIdProcedimento)){ 376 if(isset($dblIdProcedimento)){
392 -  
393 - //TODO: Tratar situação em que o processo (NUP) já existia na base do sistema mas não havia nenhum NRE registrado para ele  
394 $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso); 377 $objProcedimentoDTO = $this->atualizarProcedimento($dblIdProcedimento, $parObjMetadadosProcedimento, $parObjProcesso);
395 } 378 }
396 else { 379 else {
397 -  
398 - //TODO: Gerar Procedimento com status BLOQUEADO, aguardando o recebimento dos componentes digitais  
399 $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso); 380 $objProcedimentoDTO = $this->gerarProcedimento($parObjMetadadosProcedimento, $parObjProcesso);
400 } 381 }
401 382
@@ -416,7 +397,8 @@ class ReceberProcedimentoRN extends InfraRN @@ -416,7 +397,8 @@ class ReceberProcedimentoRN extends InfraRN
416 return $objProcedimentoDTO; 397 return $objProcedimentoDTO;
417 } 398 }
418 399
419 - private function tramiteRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite) { 400 + private function tramiteRegistrado($parStrNumeroRegistro, $parNumIdentificacaoTramite)
  401 + {
420 402
421 $objTramiteDTO = new TramiteDTO(); 403 $objTramiteDTO = new TramiteDTO();
422 $objTramiteDTO->setStrNumeroRegistro($parStrNumeroRegistro); 404 $objTramiteDTO->setStrNumeroRegistro($parStrNumeroRegistro);
@@ -426,6 +408,29 @@ class ReceberProcedimentoRN extends InfraRN @@ -426,6 +408,29 @@ class ReceberProcedimentoRN extends InfraRN
426 return $objTramiteBD->contar($objTramiteDTO) > 0; 408 return $objTramiteBD->contar($objTramiteDTO) > 0;
427 } 409 }
428 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 +
429 private function consultarProcedimentoExistente($parStrNumeroRegistro, $parStrProtocolo = null) { 434 private function consultarProcedimentoExistente($parStrNumeroRegistro, $parStrProtocolo = null) {
430 435
431 $dblIdProcedimento = null; 436 $dblIdProcedimento = null;
@@ -445,8 +450,8 @@ class ReceberProcedimentoRN extends InfraRN @@ -445,8 +450,8 @@ class ReceberProcedimentoRN extends InfraRN
445 return $dblIdProcedimento; 450 return $dblIdProcedimento;
446 } 451 }
447 452
448 - private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso){  
449 - 453 + private function atualizarProcedimento($parDblIdProcedimento, $objMetadadosProcedimento, $objProcesso)
  454 + {
450 455
451 if(!isset($parDblIdProcedimento)){ 456 if(!isset($parDblIdProcedimento)){
452 throw new InfraException('Parâmetro $parDblIdProcedimento não informado.'); 457 throw new InfraException('Parâmetro $parDblIdProcedimento não informado.');
@@ -1680,105 +1685,117 @@ class ReceberProcedimentoRN extends InfraRN @@ -1680,105 +1685,117 @@ class ReceberProcedimentoRN extends InfraRN
1680 } 1685 }
1681 1686
1682 1687
1683 - public function receberTramitesRecusados($parNumIdentificacaoTramite) {  
1684 -  
1685 - if (empty($parNumIdentificacaoTramite)) {  
1686 - throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.');  
1687 - }  
1688 -  
1689 - //Busca os dados do trâmite no barramento  
1690 - $tramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);  
1691 -  
1692 - if(!isset($tramite[0])){  
1693 - throw new InfraException("Não foi encontrado no PEN o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa");  
1694 - }  
1695 -  
1696 - $tramite = $tramite[0];  
1697 -  
1698 - $objTramiteDTO = new TramiteDTO();  
1699 - $objTramiteDTO->setNumIdTramite($parNumIdentificacaoTramite);  
1700 - $objTramiteDTO->retNumIdUnidade();  
1701 -  
1702 - $objTramiteBD = new TramiteBD(BancoSEI::getInstance());  
1703 - $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO);  
1704 -  
1705 - if(!isset($objTramiteDTO)){  
1706 - throw new InfraException("Não foi encontrado no sistema o trâmite de número {$parNumIdentificacaoTramite} para realizar a ciência da recusa");  
1707 - }  
1708 -  
1709 - SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade());  
1710 -  
1711 - //Busca os dados do procedimento  
1712 - $objProcessoEletronicoDTO = new ProcessoEletronicoDTO();  
1713 - $objProcessoEletronicoDTO->setStrNumeroRegistro($tramite->NRE);  
1714 - $objProcessoEletronicoDTO->retDblIdProcedimento(); 1688 + public function receberTramitesRecusados($parNumIdentificacaoTramite)
  1689 + {
  1690 + try {
  1691 + if (empty($parNumIdentificacaoTramite)) {
  1692 + throw new InfraException('Parâmetro $parNumIdentificacaoTramite não informado.');
  1693 + }
1715 1694
1716 - $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco());  
1717 - $objProcessoEletronicoDTO = $objProcessoEletronicoBD->consultar($objProcessoEletronicoDTO); 1695 + //Busca os dados do trâmite no barramento
  1696 + $tramite = $this->objProcessoEletronicoRN->consultarTramites($parNumIdentificacaoTramite);
1718 1697
1719 - //Busca a última atividade de trâmite externo  
1720 - $objAtividadeDTO = new AtividadeDTO();  
1721 - $objAtividadeDTO->setDblIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento());  
1722 - $objAtividadeDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_EXPEDIDO));  
1723 - $objAtividadeDTO->setNumMaxRegistrosRetorno(1);  
1724 - $objAtividadeDTO->setOrdDthAbertura(InfraDTO::$TIPO_ORDENACAO_DESC);  
1725 - $objAtividadeDTO->retNumIdAtividade(); 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 + }
1726 1701
1727 - //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  
1728 - $objAtividadeBD = new AtividadeBD($this->getObjInfraIBanco());  
1729 - $objAtividadeDTO = $objAtividadeBD->consultar($objAtividadeDTO); 1702 + $tramite = $tramite[0];
1730 1703
1731 - //Busca a unidade de destino  
1732 - $objAtributoAndamentoDTO = new AtributoAndamentoDTO();  
1733 - $objAtributoAndamentoDTO->setNumIdAtividade($objAtividadeDTO->getNumIdAtividade());  
1734 - $objAtributoAndamentoDTO->setStrNome('UNIDADE_DESTINO');  
1735 - $objAtributoAndamentoDTO->retStrValor(); 1704 + $objTramiteDTO = new TramiteDTO();
  1705 + $objTramiteDTO->setNumIdTramite($parNumIdentificacaoTramite);
  1706 + $objTramiteDTO->retNumIdUnidade();
1736 1707
1737 - $objAtributoAndamentoBD = new AtributoAndamentoBD($this->getObjInfraIBanco());  
1738 - $objAtributoAndamentoDTO = $objAtributoAndamentoBD->consultar($objAtributoAndamentoDTO); 1708 + $objTramiteBD = new TramiteBD(BancoSEI::getInstance());
  1709 + $objTramiteDTO = $objTramiteBD->consultar($objTramiteDTO);
1739 1710
1740 - //Monta o DTO de receber tramite recusado  
1741 - $objReceberTramiteRecusadoDTO = new ReceberTramiteRecusadoDTO();  
1742 - $objReceberTramiteRecusadoDTO->setNumIdTramite($parNumIdentificacaoTramite);  
1743 - $objReceberTramiteRecusadoDTO->setNumIdProtocolo($objProcessoEletronicoDTO->getDblIdProcedimento());  
1744 - $objReceberTramiteRecusadoDTO->setNumIdUnidadeOrigem(null);  
1745 - $objReceberTramiteRecusadoDTO->setNumIdTarefa(ProcessoEletronicoRN::obterIdTarefaModulo(ProcessoEletronicoRN::$TI_PROCESSO_ELETRONICO_PROCESSO_TRAMITE_RECUSADO));  
1746 - $objReceberTramiteRecusadoDTO->setStrMotivoRecusa(utf8_decode($tramite->justificativaDaRecusa));  
1747 - $objReceberTramiteRecusadoDTO->setStrNomeUnidadeDestino($objAtributoAndamentoDTO->getStrValor()); 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 + }
1748 1714
1749 - //Faz o tratamento do processo e do trâmite recusado  
1750 - $this->receberTramiteRecusadoInterno($objReceberTramiteRecusadoDTO); 1715 + SessaoSEI::getInstance(false)->simularLogin('SEI', null, null, $objTramiteDTO->getNumIdUnidade());
1751 1716
  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);
1752 1724
  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 + }
1753 } 1765 }
1754 1766
1755 - protected function receberTramiteRecusadoInternoControlado(ReceberTramiteRecusadoDTO $objReceberTramiteRecusadoDTO){  
1756 -  
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