Commit 6008d3c59bc87ea9a9de992ba40b6c4768a30544
1 parent
e53207ef
Exists in
master
Redmine #3795 - alterações de scripts
Showing
2 changed files
with
20 additions
and
10 deletions
Show diff stats
cit-adm-materiais-api/src/main/resources/scripts-bd/Migracao_ICMBIO/04-Patrimonio.sql
... | ... | @@ -3295,6 +3295,8 @@ COMMIT; -- #FIM :: ZERA OS SALDOS DAS CONTAS COM VALOR NULO >> CONTACONTABILSALD |
3295 | 3295 | |
3296 | 3296 | |
3297 | 3297 | |
3298 | + | |
3299 | + | |
3298 | 3300 | BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPATRIMONIAL |
3299 | 3301 | /* |
3300 | 3302 | ====================================== |
... | ... | @@ -3435,6 +3437,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3435 | 3437 | INNER JOIN ESTRUTURAORGANIZACIONAL EO ON (EO.ID = EP.ESTRUTURAORGANIZACIONAL_ID) |
3436 | 3438 | INNER JOIN BEMPATRIMONIAL B ON (B.ENTRADAITEM_ID = I.ID) |
3437 | 3439 | INNER JOIN MATERIAL M ON (M.ID = B.MATERIAL_ID) |
3440 | + where e.datainativo is null and i.datainativo is null | |
3438 | 3441 | ORDER BY E.ID; |
3439 | 3442 | |
3440 | 3443 | INSERT INTO public.historicobempatrimonial |
... | ... | @@ -3475,6 +3478,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3475 | 3478 | INNER JOIN ENTRADAPATRIMONIOITEM I ON (I.ENTRADA_ID = E.ID) |
3476 | 3479 | INNER JOIN BEMPATRIMONIAL B ON (B.ENTRADAITEM_ID = I.ID) |
3477 | 3480 | WHERE E.DATACONTABIL IS NOT null |
3481 | + and e.datainativo is null and i.datainativo is null | |
3478 | 3482 | ORDER BY E.ID; |
3479 | 3483 | |
3480 | 3484 | select ID FROM PUBLIC.DOMINIO WHERE CHAVE='classeReferencia' AND CODIGO=2 INTO classeId; |
... | ... | @@ -3515,7 +3519,8 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3515 | 3519 | FROM BAIXA B |
3516 | 3520 | INNER JOIN BAIXAPATRIMONIO BP ON (BP.ID = B.ID) |
3517 | 3521 | INNER JOIN BAIXAPATRIMONIOITEM I ON (I.BAIXA_ID = BP.ID) |
3518 | - INNER JOIN BEMPATRIMONIAL BEM ON (BEM.ID = I.BEMPATRIMONIAL_ID); | |
3522 | + INNER JOIN BEMPATRIMONIAL BEM ON (BEM.ID = I.BEMPATRIMONIAL_ID) | |
3523 | + where b.datainativo is null and i.datainativo is null; | |
3519 | 3524 | |
3520 | 3525 | select ID FROM PUBLIC.DOMINIO WHERE CHAVE='classeReferencia' AND CODIGO=3 INTO classeId; |
3521 | 3526 | |
... | ... | @@ -3543,7 +3548,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3543 | 3548 | LOCALTIMESTAMP, |
3544 | 3549 | 0, |
3545 | 3550 | 'Transferência foi realizada em: '||to_char(t.datatransferencia, 'dd/MM/YYYY')||' - Nova Estrutura Organizacional: '||ed.codigo||' - '||ed.nome|| |
3546 | - (CASE WHEN termo.id IS NOT NULL THEN ' - Número do Termo: '||termo.numerotermo ELSE '' END) as descricao, | |
3551 | + ' - Número do Termo: '||t.codigo as descricao, | |
3547 | 3552 | eo.nome as valoranterior, |
3548 | 3553 | ed.nome as valornovo, |
3549 | 3554 | null as numeroprocesso, |
... | ... | @@ -3558,7 +3563,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3558 | 3563 | inner join transferenciaitem i on (i.transferencia_id = t.id) |
3559 | 3564 | inner join estruturaorganizacional ed on (ed.id = t.unidadedestino_id) |
3560 | 3565 | inner join estruturaorganizacional eo on (eo.id = i.unidadeorigem_id) |
3561 | - left join termoresponsabilidade termo on (termo.transferencia_id = t.id AND termo.unidadeorigem_id = i.unidadeorigem_id); | |
3566 | + where t.datainativo is null and i.datainativo is null; | |
3562 | 3567 | |
3563 | 3568 | select ID FROM PUBLIC.DOMINIO WHERE CHAVE='classeReferencia' AND CODIGO=10 INTO classeId; |
3564 | 3569 | |
... | ... | @@ -3598,7 +3603,8 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3598 | 3603 | from definicaodetentor d |
3599 | 3604 | inner join definicaodetentoritem di on (di.definicaodetentor_id = d.id) |
3600 | 3605 | inner join parceiro par on (par.id = d.colaborador_id) |
3601 | - inner join pessoa p on (p.id = par.pessoa_id); | |
3606 | + inner join pessoa p on (p.id = par.pessoa_id) | |
3607 | + where d.datainativo is null and di.datainativo is null; | |
3602 | 3608 | |
3603 | 3609 | select ID FROM PUBLIC.DOMINIO WHERE CHAVE='classeReferencia' AND CODIGO=9 INTO classeId; |
3604 | 3610 | --saida temporaria |
... | ... | @@ -3638,7 +3644,8 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3638 | 3644 | from saidatemporaria s |
3639 | 3645 | inner join saidatemporariaitem si on (si.saidatemporaria_id = s.id) |
3640 | 3646 | inner join bempatrimonial bem on (bem.id = si.bempatrimonial_id) |
3641 | - inner join dominio objetivo on (objetivo.id = s.dominiotipoobjetivo_id); | |
3647 | + inner join dominio objetivo on (objetivo.id = s.dominiotipoobjetivo_id) | |
3648 | + where s.datainativo is null and si.datainativo is null; | |
3642 | 3649 | |
3643 | 3650 | INSERT INTO public.historicobempatrimonial |
3644 | 3651 | ( ID, |
... | ... | @@ -3677,7 +3684,8 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
3677 | 3684 | inner join saidatemporariaitem si on (si.saidatemporaria_id = s.id) |
3678 | 3685 | inner join bempatrimonial bem on (bem.id = si.bempatrimonial_id) |
3679 | 3686 | inner join dominio status on (status.id = bem.dominiostatus_id) |
3680 | - where si.dataretorno is not null; | |
3687 | + where si.dataretorno is not null | |
3688 | + and s.datainativo is null and si.datainativo is null; | |
3681 | 3689 | |
3682 | 3690 | FOR adicao IN SELECT * FROM ADICAOBEMPRINCIPAL loop |
3683 | 3691 | ... | ... |
cit-adm-materiais-api/src/main/resources/scripts-bd/Migracao_MPOG/04-Patrimonio.sql
... | ... | @@ -2252,6 +2252,8 @@ BEGIN; --CRIO AS CONSTRAINTS DE DEPRECIACAOITEM NOVAMENTE |
2252 | 2252 | COMMIT; --CRIO AS CONSTRAINTS DE DEPRECIACAOITEM NOVAMENTE |
2253 | 2253 | |
2254 | 2254 | |
2255 | + | |
2256 | + | |
2255 | 2257 | BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPATRIMONIAL |
2256 | 2258 | /* |
2257 | 2259 | ====================================== |
... | ... | @@ -2259,6 +2261,8 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
2259 | 2261 | ====================================== |
2260 | 2262 | */ |
2261 | 2263 | ALTER TABLE historicobempatrimonial ALTER COLUMN descricao TYPE character varying(400); |
2264 | + ALTER TABLE historicobempatrimonial ALTER COLUMN valoranterior TYPE character varying(400); | |
2265 | + ALTER TABLE historicobempatrimonial ALTER COLUMN valornovo TYPE character varying(400); | |
2262 | 2266 | |
2263 | 2267 | DO $$ |
2264 | 2268 | DECLARE |
... | ... | @@ -2500,7 +2504,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
2500 | 2504 | LOCALTIMESTAMP, |
2501 | 2505 | 0, |
2502 | 2506 | 'Transferência foi realizada em: '||to_char(t.datatransferencia, 'dd/MM/YYYY')||' - Nova Estrutura Organizacional: '||ed.codigo||' - '||ed.nome|| |
2503 | - (CASE WHEN termo.id IS NOT NULL THEN ' - Número do Termo: '||termo.numerotermo ELSE '' END) as descricao, | |
2507 | + ' - Número do Termo: '||t.codigo as descricao, | |
2504 | 2508 | eo.nome as valoranterior, |
2505 | 2509 | ed.nome as valornovo, |
2506 | 2510 | null as numeroprocesso, |
... | ... | @@ -2514,8 +2518,7 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
2514 | 2518 | from transferencia t |
2515 | 2519 | inner join transferenciaitem i on (i.transferencia_id = t.id) |
2516 | 2520 | inner join estruturaorganizacional ed on (ed.id = t.unidadedestino_id) |
2517 | - inner join estruturaorganizacional eo on (eo.id = i.unidadeorigem_id) | |
2518 | - left join termoresponsabilidade termo on (termo.transferencia_id = t.id AND termo.unidadeorigem_id = i.unidadeorigem_id); | |
2521 | + inner join estruturaorganizacional eo on (eo.id = i.unidadeorigem_id); | |
2519 | 2522 | |
2520 | 2523 | select ID FROM PUBLIC.DOMINIO WHERE CHAVE='classeReferencia' AND CODIGO=10 INTO classeId; |
2521 | 2524 | |
... | ... | @@ -2725,7 +2728,6 @@ BEGIN; -- #INI :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPAT |
2725 | 2728 | --Maquina Ju 1,85 min |
2726 | 2729 | COMMIT; -- #FIM :: GERACAO DO HISTORICO DOS BENS PATRIMONIAIS >> HISTORICOBEMPATRIMONIAL |
2727 | 2730 | |
2728 | - | |
2729 | 2731 | --===========================================================================-- |
2730 | 2732 | -- ##FIM :: IMPORTACAO TABELAS DE MOVIMENTO DE MATERIAS PERMANENTES -- |
2731 | 2733 | --===========================================================================-- |
2732 | 2734 | \ No newline at end of file | ... | ... |